/* Design tokens */
:root {
  --bg-0: #05060F;
  --bg-1: #0B1026;
  --cyan: #3EF0FF;
  --violet: #8B5CF6;
  --gold: #F5C76B;
  --green: #4ADE80;
  --warn: #FFB86B;
  --text: #E8ECF8;
  --muted: #9AA3BF;
  --line: rgba(255, 255, 255, 0.09);
  --glass-top: rgba(255, 255, 255, 0.055);
  --glass-bottom: rgba(255, 255, 255, 0.02);
  --radius: 22px;
  --radius-sm: 14px;
  --gap: 24px;
  --font-head: "Space Grotesk", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 800px at 70% -10%, #121a45 0%, transparent 60%),
              linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 55%);
  background-color: var(--bg-0);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

#stars { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -2; pointer-events: none; }

.aurora { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.aurora span {
  position: absolute;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.16;
  animation: float 38s ease-in-out infinite alternate;
}
.aurora span:nth-child(1) { background: var(--violet); top: -18vmax; left: -10vmax; }
.aurora span:nth-child(2) { background: var(--cyan); bottom: -24vmax; right: -12vmax; opacity: 0.1; animation-duration: 46s; }
.aurora span:nth-child(3) { background: #2b3fd6; top: 30%; left: 40%; opacity: 0.1; animation-duration: 54s; }
@keyframes float { to { transform: translate(6vmax, 4vmax) scale(1.08); } }

.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Glass panel with a 1px gradient border */
.glass {
  position: relative;
  background: linear-gradient(180deg, var(--glass-top), var(--glass-bottom));
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 24px 60px rgba(0, 0, 0, 0.35);
}
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(140deg, rgba(62, 240, 255, 0.35), rgba(139, 92, 246, 0.18) 40%, rgba(255, 255, 255, 0.05) 70%, rgba(139, 92, 246, 0.25));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* Navigation */
.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(5, 6, 15, 0.6);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { max-width: 1180px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-family: var(--font-head); font-weight: 700; letter-spacing: 0.22em; font-size: 0.95rem; }
.logo-mark { width: 30px; height: 30px; }
.nav-actions { display: flex; gap: 8px; }

/* Buttons */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 50px;
  padding: 0 24px;
  border-radius: var(--radius-sm);
  border: 0;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.98rem;
  letter-spacing: 0.01em;
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), color 0.2s, border-color 0.2s, background 0.2s;
}
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.btn.small { height: 38px; padding: 0 14px; font-size: 0.85rem; border-radius: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn.primary {
  background: linear-gradient(135deg, rgba(62, 240, 255, 0.16), rgba(139, 92, 246, 0.3));
  box-shadow: 0 10px 34px rgba(139, 92, 246, 0.22);
}
.btn.primary::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(90deg, var(--cyan), var(--violet), var(--gold), var(--cyan));
  background-size: 300% 100%;
  animation: border-flow 6s linear infinite;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
.btn.primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.16) 50%, transparent 70%);
  transform: translateX(-120%);
}
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 14px 40px rgba(139, 92, 246, 0.32); }
.btn.primary:hover::after { transition: transform 0.9s var(--ease); transform: translateX(120%); }
@keyframes border-flow { to { background-position: 300% 0; } }

.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn.ghost:hover:not(:disabled) { color: var(--text); border-color: rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.03); }

/* Layout */
main { max-width: 1180px; margin: 0 auto; padding: 0 16px 64px; }

.hero { text-align: center; padding: 72px 0 36px; }
.eyebrow { margin: 0 0 14px; font-family: var(--font-head); font-size: 0.78rem; letter-spacing: 0.28em; text-transform: uppercase; color: var(--cyan); }
.hero h1 { margin: 0 auto 16px; max-width: 760px; font-family: var(--font-head); font-weight: 600; font-size: clamp(2.2rem, 6vw, 3.8rem); line-height: 1.05; letter-spacing: -0.02em; }
.grad { background: linear-gradient(90deg, var(--cyan), var(--violet)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { margin: 0 auto; max-width: 560px; color: var(--muted); font-size: 1.05rem; }

.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-family: var(--font-head); font-weight: 600; font-size: 1.35rem; letter-spacing: -0.01em; }
.step { font-family: var(--font-head); font-size: 0.8rem; letter-spacing: 0.18em; color: var(--cyan); padding: 4px 10px; border: 1px solid rgba(62, 240, 255, 0.3); border-radius: 999px; }
.muted { color: var(--muted); }

/* Form */
.form-card { max-width: 760px; margin: 0 auto; padding: 32px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.field-row.three { grid-template-columns: repeat(3, 1fr); }
.field { position: relative; }
.field input, .field select {
  width: 100%;
  height: 60px;
  padding: 24px 16px 8px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: 500 1rem var(--font-body);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.field select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239AA3BF' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 38px;
}
.field select option { background: var(--bg-1); color: var(--text); }
.field label {
  position: absolute;
  left: 17px;
  top: 19px;
  color: var(--muted);
  pointer-events: none;
  transition: all 0.18s var(--ease);
}
.field input:focus + label,
.field input:not(:placeholder-shown) + label,
.field.select label {
  top: 9px;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.field input:focus + label, .field select:focus + label { color: var(--cyan); }
.field input:hover, .field select:hover { border-color: rgba(255, 255, 255, 0.16); }
.field input:focus, .field select:focus {
  border-color: rgba(62, 240, 255, 0.6);
  background-color: rgba(62, 240, 255, 0.04);
  box-shadow: 0 0 0 4px rgba(62, 240, 255, 0.1), 0 0 24px rgba(62, 240, 255, 0.12);
}
.field small { display: block; margin: 6px 4px 0; color: var(--muted); font-size: 0.78rem; }
.error { margin: 4px 0 0; color: #ff9b94; font-size: 0.92rem; }
.form-actions { display: flex; gap: 12px; margin-top: 24px; }
.form-actions .primary { flex: 1; }

/* Loading */
.scanning { display: grid; place-items: center; gap: 16px; padding: 72px 0; color: var(--muted); }
.scanning[hidden] { display: none; }
.scan-orb {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #1a2a66, #0b1026 70%);
  box-shadow: 0 0 0 1px rgba(62, 240, 255, 0.4), 0 0 40px rgba(62, 240, 255, 0.35);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.12); box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.6), 0 0 60px rgba(139, 92, 246, 0.45); } }

/* Results */
.results { margin-top: 72px; scroll-margin-top: 80px; }
.results-head p { margin: 0; }
.results-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: var(--gap); align-items: start; }
.tree-col { position: sticky; top: 84px; }
.cards-col { display: grid; gap: var(--gap); }

/* Tree: slender branches fan out of the trunk, leaves along their tips. It grows in, then sways. */
.tree-card { padding: 18px 18px 14px; }
.tree-wrap { position: relative; }
#tree { display: block; width: 100%; max-width: 480px; height: auto; margin: 0 auto; overflow: visible; }
#tree .wood { fill: url(#bark); }
#tree .trunk { fill: url(#trunk-fill); }
#tree .rim { fill: none; stroke: rgba(62, 240, 255, 0.5); stroke-width: 1.4; stroke-linecap: round; }
#tree .rim.left { stroke: rgba(139, 92, 246, 0.45); stroke-width: 1.2; }
#tree .streak { fill: none; stroke: rgba(5, 6, 20, 0.35); stroke-linecap: round; }

/* Individual transform properties: "scale" grows a branch in while "rotate" sways it */
#tree .trunk-g, #tree .br, #tree .follow { transform-box: view-box; }
#tree .trunk-g { transform-origin: 200px 530px; scale: 1 0; }
#tree .br { scale: 0; }
#tree .leaf { transform-box: fill-box; transform-origin: 0% 50%; scale: 0; }
#tree .fx { opacity: 0; }
.play #tree .trunk-g { animation: grow 0.9s var(--ease) forwards 0.1s; }
.play #tree .br { animation: grow 0.9s var(--ease) forwards var(--gd), sway var(--sd) ease-in-out infinite var(--sp); }
.play #tree .follow { animation: sway var(--sd) ease-in-out infinite var(--sp); }
.play #tree .leaf { animation: grow 0.5s var(--ease) forwards var(--ld); }
.play #tree .fx { animation: fade-in 1.4s ease forwards 1.2s; }
.paused #tree * { animation-play-state: paused !important; }
@keyframes grow { to { scale: 1; } }
@keyframes sway { 25% { rotate: var(--a); } 75% { rotate: calc(var(--a) * -1); } }
@keyframes fade-in { to { opacity: 1; } }

#tree .fly { opacity: 0; }
.play #tree .fly { animation: fly var(--fd) ease-in-out infinite alternate var(--fdel); }
@keyframes fly { 0% { opacity: 0.15; translate: 0 0; } 50% { opacity: 0.9; } 100% { opacity: 0.25; translate: var(--fx) var(--fy); } }
#tree .falling { opacity: 0; transform-box: fill-box; transform-origin: center; }
.play #tree .falling { animation: fall var(--fd) linear infinite var(--fdel); }
@keyframes fall {
  0% { opacity: 0; translate: 0 0; rotate: 0deg; }
  10% { opacity: 0.9; }
  85% { opacity: 0.8; }
  100% { opacity: 0; translate: var(--fx) var(--fy); rotate: 400deg; }
}

/* Nodes: glass orbs, gold for master numbers */
#tree .node { opacity: 0; cursor: pointer; outline: none; }
.play #tree .node { animation: fade-in 0.6s var(--ease) forwards; animation-delay: calc(2.2s + var(--i) * 0.09s); }
#tree .node-inner { transform-box: fill-box; transform-origin: center; transition: scale 0.25s var(--ease); }
#tree .node:hover .node-inner, #tree .node.active .node-inner, #tree .node:focus-visible .node-inner { scale: 1.12; }
#tree .node-glow { fill: url(#glow-cyan); }
#tree .orb { fill: url(#orb-cyan); stroke: rgba(62, 240, 255, 0.9); stroke-width: 1.5; }
#tree .halo { fill: none; stroke: rgba(62, 240, 255, 0.35); stroke-width: 1; transform-box: fill-box; transform-origin: center; animation: halo 3.2s ease-in-out infinite; }
@keyframes halo { 50% { scale: 1.08; opacity: 0.5; } }
#tree .node-num { text-anchor: middle; fill: #fff; font: 600 17px var(--font-head); font-variant-numeric: tabular-nums; }
#tree .node.master .node-glow { fill: url(#glow-gold); }
#tree .node.master .orb { fill: url(#orb-gold); stroke: var(--gold); }
#tree .node.master .halo { stroke: rgba(245, 199, 107, 0.45); }
#tree .node.master .node-num { font-size: 14px; fill: #fff3d6; }
#tree .node:focus-visible .orb { stroke-width: 2.6; }

/* Fruits: as many as the Fruits number, popping in after the leaves */
#tree .fruit { display: none; }
#tree .fruit.shown { display: inline; }
#tree .fruit-in { transform-box: fill-box; transform-origin: 50% 0%; scale: 0; }
.play #tree .fruit.shown .fruit-in { animation: grow 0.6s var(--ease) forwards var(--fdl, 2s); }
#tree .fruit-body { fill: url(#fruit-grad); }
#tree .fruit-stem { fill: none; stroke: #4a3f9e; stroke-width: 1; stroke-linecap: round; }
#tree .fruit-shine { fill: rgba(255, 255, 255, 0.75); }
#tree .fruit-glow { fill: url(#fruit-glow); opacity: 0; transition: opacity 0.35s ease; }

/* Interactive tree: hovering a number lights up its part of the tree and dims the rest */
#tree :is(.wood, .trunk, .leaf, .fruit, .streak, .rim) { transition: opacity 0.35s ease; }
#tree.focus :is(.wood, .trunk, .leaf, .fruit, .streak, .rim) { opacity: 0.22; }
#tree.focus-leaves .leaf, #tree.focus-fruits .fruit, #tree.focus-branches .br .wood { opacity: 1; }
#tree.focus-branches .br .wood { fill: url(#bark-lit); }
#tree.focus-trunk .trunk, #tree.focus-bark :is(.trunk, .streak, .rim) { opacity: 1; }
#tree:is(.focus-firstRoot, .focus-secondRoot) .trunk { opacity: 0.5; }
#tree.focus-fruits .fruit-glow { opacity: 1; }
#tree .hl { opacity: 0; transition: opacity 0.35s ease; pointer-events: none; }
#tree .hl-wide { fill: none; stroke: rgba(62, 240, 255, 0.28); stroke-width: 9; stroke-linecap: round; }
#tree .hl-core { fill: none; stroke: #bff9ff; stroke-width: 2.4; stroke-linecap: round; }
#tree .hl-fill { fill: url(#trunk-lit); }
#tree.focus-firstRoot .hl-firstRoot, #tree.focus-secondRoot .hl-secondRoot, #tree.focus-trunk .hl-trunk,
#tree.focus-bark .hl-bark, #tree.focus-leaves .hl-leaves { opacity: 1; }

.hint { margin: 6px 0 0; text-align: center; font-size: 0.8rem; color: var(--muted); }

.tip {
  position: absolute;
  z-index: 5;
  transform: translate(40px, -50%);
  display: grid;
  gap: 2px;
  min-width: 110px;
  padding: 12px 14px;
  background: rgba(11, 16, 38, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(62, 240, 255, 0.25);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  font-size: 0.82rem;
  pointer-events: none;
  text-align: left;
}
.tip[hidden], .toast[hidden] { display: none; }
.tip.left { transform: translate(calc(-100% - 40px), -50%); }
.tip.under { transform: translate(-50%, 36px); }
.tip.above { transform: translate(-50%, calc(-100% - 36px)); }
.tip strong { font-family: var(--font-head); font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--cyan); }
.tip-num { font: 600 1.4rem var(--font-head); }
.tip-num small, .num small { font-size: 0.55em; opacity: 0.75; margin-left: 1px; }
.tip-num.master { color: var(--gold); }

/* Cards */
.card { padding: 26px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; color: var(--cyan); }
.card-head h3 { margin: 0; color: var(--text); font-family: var(--font-head); font-weight: 600; font-size: 1.08rem; }
.note { margin: -8px 0 16px; font-size: 0.88rem; }

.reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.6s var(--ease), transform 0.6s var(--ease); transition-delay: calc(var(--i, 0) * 70ms); }
.reveal.in { opacity: 1; transform: none; }

.num { font-family: var(--font-head); font-weight: 600; font-variant-numeric: tabular-nums; color: #fff; text-shadow: 0 0 18px rgba(62, 240, 255, 0.35); }
.master .num, .num.master { color: var(--gold); text-shadow: 0 0 18px rgba(245, 199, 107, 0.4); }

.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; }
.key-tile {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.025);
  transition: transform 0.25s var(--ease), border-color 0.25s, box-shadow 0.25s;
}
.key-tile:hover { transform: translateY(-2px); border-color: rgba(62, 240, 255, 0.3); box-shadow: 0 10px 30px rgba(62, 240, 255, 0.08); }
.key-tile.master { border-color: rgba(245, 199, 107, 0.35); }

/* Key icons: a small tree drawn faintly, with the key's own part lit in the tile's accent colour */
.key-tile { --accent: var(--cyan); --accent-soft: rgba(62, 240, 255, 0.12); --accent-line: rgba(62, 240, 255, 0.32); }
.key-tile.green { --accent: var(--green); --accent-soft: rgba(74, 222, 128, 0.12); --accent-line: rgba(74, 222, 128, 0.32); }
.key-tile.master { --accent: var(--gold); --accent-soft: rgba(245, 199, 107, 0.14); --accent-line: rgba(245, 199, 107, 0.42); }
.key-icon {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin-bottom: 6px;
  border-radius: 16px;
  background: radial-gradient(circle at 35% 30%, var(--accent-soft), rgba(255, 255, 255, 0.02) 75%);
  border: 1px solid var(--accent-line);
}
.mini-tree { width: 48px; height: 48px; overflow: visible; }
.mini-tree .mt-leaves ellipse { fill: rgba(150, 165, 225, 0.2); }
.mini-tree .mt-branches path, .mini-tree .mt-root { fill: none; stroke: rgba(170, 180, 232, 0.34); stroke-width: 1.7; stroke-linecap: round; }
.mini-tree .mt-trunk { fill: rgba(170, 180, 232, 0.3); }
.mini-tree .mt-bark path { fill: none; stroke: rgba(170, 180, 232, 0.18); stroke-width: 0.9; stroke-linecap: round; stroke-linejoin: round; }
.mini-tree .mt-fruits circle { fill: rgba(170, 180, 232, 0.28); }
.mini-tree .on { filter: drop-shadow(0 0 3px var(--accent)); }
.mini-tree .mt-leaves.on ellipse, .mini-tree .mt-trunk.on, .mini-tree .mt-fruits.on circle { fill: var(--accent); }
.mini-tree .mt-branches.on path { stroke: var(--accent); stroke-width: 2.4; }
.mini-tree .mt-root.on { stroke: var(--accent); stroke-width: 3; }
.mini-tree .mt-bark.on path { stroke: var(--accent); stroke-width: 1.5; }
.key-tile .num { font-size: 2rem; line-height: 1.1; }
.label { font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

.dynamic { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }
.dynamic p { margin: 0; }
.num.big { font-size: 3.4rem; line-height: 1; }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); position: relative; }
.timeline::before { content: ""; position: absolute; top: 24px; left: 12.5%; right: 12.5%; height: 1px; background: linear-gradient(90deg, var(--cyan), var(--violet)); opacity: 0.5; }
.timeline li { display: grid; justify-items: center; gap: 10px; position: relative; }
.orb-num {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #16224f, #0d1533 75%);
  border: 1px solid rgba(139, 92, 246, 0.7);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.35);
  font: 600 1.2rem var(--font-head);
}

.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tool { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 255, 255, 0.02); }
.ring { position: relative; width: 52px; height: 52px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; }
.ring .track { stroke: rgba(255, 255, 255, 0.08); }
.ring .fill { stroke: var(--cyan); stroke-linecap: round; filter: drop-shadow(0 0 4px rgba(62, 240, 255, 0.5)); transition: stroke-dashoffset 0.8s var(--ease); }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font: 600 1.05rem var(--font-head); }
.tool-text { display: grid; gap: 1px; font-size: 0.82rem; }
.tool-label { font-weight: 600; font-size: 0.92rem; }
.tool.zero { border-style: dashed; border-color: rgba(255, 184, 107, 0.35); }
.tool.zero .track { stroke: rgba(255, 184, 107, 0.5); stroke-dasharray: 3 4; }
.tool.zero .fill { display: none; }
.tool.zero .ring span { color: var(--warn); }
.badge { justify-self: start; margin-top: 4px; padding: 2px 8px; border-radius: 999px; font-size: 0.7rem; letter-spacing: 0.04em; color: var(--warn); background: rgba(255, 184, 107, 0.1); border: 1px solid rgba(255, 184, 107, 0.3); }

.years { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { display: grid; gap: 6px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 255, 255, 0.02); }
.stat .num { font-size: 2.4rem; line-height: 1.05; }
.stat .muted { font-size: 0.8rem; }
.stat.featured { background: linear-gradient(140deg, rgba(62, 240, 255, 0.1), rgba(139, 92, 246, 0.14)); border-color: rgba(62, 240, 255, 0.4); box-shadow: 0 0 30px rgba(62, 240, 255, 0.08); }

.footer { max-width: 1180px; margin: 0 auto; padding: 28px 16px 40px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 0.82rem; border-top: 1px solid var(--line); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 30;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(11, 16, 38, 0.92);
  border: 1px solid rgba(62, 240, 255, 0.3);
  font-size: 0.9rem;
}

/* Save button on a reading: the bookmark fills once the person is in My list */
.results-head .save-btn { margin-left: auto; align-self: center; }
.save-btn[aria-pressed="true"] { color: var(--cyan); border-color: rgba(62, 240, 255, 0.45); background: rgba(62, 240, 255, 0.06); }
.save-btn[aria-pressed="true"] .icon { fill: currentColor; }

/* How many people are saved, on the My list button */
.count {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--cyan);
  color: var(--bg-0);
  font: 700 0.72rem var(--font-head);
}
.count[hidden] { display: none; }

/* My list: a drawer sliding in from the right */
body:has(.drawer[open]) { overflow: hidden; }
.drawer {
  width: min(420px, 100%);
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0 0 0 auto;
  padding: 0;
  border: 0;
  border-left: 1px solid rgba(62, 240, 255, 0.2);
  border-radius: var(--radius) 0 0 var(--radius);
  background: linear-gradient(180deg, rgba(16, 22, 52, 0.98), rgba(7, 9, 22, 0.98));
  color: var(--text);
  box-shadow: -30px 0 80px rgba(0, 0, 0, 0.5);
}
.drawer[open] { animation: drawer-in 0.35s var(--ease); }
.drawer::backdrop { background: rgba(3, 4, 12, 0.62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: backdrop-in 0.3s ease; }
@keyframes drawer-in { from { translate: 100% 0; } }
@keyframes backdrop-in { from { opacity: 0; } }
.drawer-inner { display: flex; flex-direction: column; gap: 16px; height: 100%; padding: 22px 18px 18px; }
.drawer-head { display: flex; align-items: center; gap: 10px; color: var(--cyan); }
.drawer-head h2 { margin: 0; color: var(--text); font: 600 1.2rem var(--font-head); }
.drawer-head .muted { font-size: 0.85rem; }
.drawer-head .icon-btn { margin-left: auto; }
.drawer-note { margin: 0; font-size: 0.78rem; text-align: center; }

.people { flex: 1; min-height: 0; display: grid; align-content: start; gap: 8px; margin: 0; padding: 2px; list-style: none; overflow-y: auto; }
.person { display: flex; align-items: center; gap: 4px; padding-right: 8px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 255, 255, 0.025); transition: border-color 0.2s, background 0.2s; }
.person:hover { border-color: rgba(62, 240, 255, 0.3); background: rgba(62, 240, 255, 0.04); }
.person.current { border-color: rgba(62, 240, 255, 0.5); background: rgba(62, 240, 255, 0.06); }
.person-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 12px; border: 0; border-radius: 16px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.initials {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #16224f, #0d1533 75%);
  border: 1px solid rgba(62, 240, 255, 0.6);
  box-shadow: 0 0 14px rgba(62, 240, 255, 0.18);
  font: 600 0.9rem var(--font-head);
  letter-spacing: 0.04em;
}
.person-text { display: grid; min-width: 0; }
.person-name { overflow: hidden; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.person-date { color: var(--muted); font-size: 0.82rem; }
.person.undo { justify-content: space-between; padding: 14px 10px 14px 16px; border-style: dashed; color: var(--muted); font-size: 0.88rem; }
.no-match { padding: 12px 4px; font-size: 0.9rem; }

.icon-btn { display: grid; place-items: center; flex: none; width: 38px; height: 38px; padding: 0; border: 1px solid transparent; border-radius: 12px; background: none; color: var(--muted); cursor: pointer; transition: color 0.2s, background 0.2s, border-color 0.2s; }
.icon-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); border-color: var(--line); }
.icon-btn.danger:hover { color: #ff9b94; background: rgba(255, 155, 148, 0.06); border-color: rgba(255, 155, 148, 0.3); }
.link-btn { padding: 4px 6px; border: 0; border-radius: 8px; background: none; color: var(--cyan); font: 600 0.88rem var(--font-head); cursor: pointer; }
:is(.person-open, .icon-btn, .link-btn):focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.people:empty { display: none; }
.list-empty { --accent: var(--green); --accent-soft: rgba(74, 222, 128, 0.12); --accent-line: rgba(74, 222, 128, 0.32); flex: 1; display: grid; justify-items: center; align-content: center; gap: 4px; padding: 36px 12px 80px; text-align: center; }
.list-empty[hidden] { display: none; }
.list-empty p { margin: 0; }
.list-empty .key-icon { margin-bottom: 12px; }

/* Meanings: every number opens its meaning in a side panel */
[data-m] { cursor: pointer; }
[data-m]:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.tool, .stat { transition: border-color 0.2s, background 0.2s; }
.tool:hover, .stat:hover { border-color: rgba(62, 240, 255, 0.3); background: rgba(62, 240, 255, 0.04); }
.timeline li[data-m] { border-radius: 12px; }
.orb-num { transition: box-shadow 0.2s; }
.timeline li:hover .orb-num { box-shadow: 0 0 26px rgba(139, 92, 246, 0.7); }
#life-dynamic { border-radius: 10px; transition: text-shadow 0.2s; }
#life-dynamic:hover { text-shadow: 0 0 30px rgba(62, 240, 255, 0.7); }

.meaning .drawer-head { align-items: flex-start; }
.m-place { margin: 10px 0 0; font: 600 0.76rem var(--font-head); letter-spacing: 0.2em; text-transform: uppercase; color: var(--cyan); }
.m-body { flex: 1; min-height: 0; display: grid; align-content: start; gap: 16px; overflow-y: auto; padding: 2px 4px 2px 2px; }
.m-body p { margin: 0; line-height: 1.6; }
.m-hero { display: flex; align-items: center; gap: 18px; padding: 18px 20px; border: 1px solid rgba(62, 240, 255, 0.3); border-radius: 18px; background: linear-gradient(140deg, rgba(62, 240, 255, 0.08), rgba(139, 92, 246, 0.13)); }
.m-hero.master { border-color: rgba(245, 199, 107, 0.45); background: linear-gradient(140deg, rgba(245, 199, 107, 0.1), rgba(139, 92, 246, 0.1)); }
.m-hero.master .num { color: var(--gold); text-shadow: 0 0 18px rgba(245, 199, 107, 0.4); }
.m-hero.zero { border-style: dashed; border-color: rgba(255, 184, 107, 0.45); background: rgba(255, 184, 107, 0.05); }
.m-hero.zero .num { color: var(--warn); text-shadow: none; }
.m-hero h2 { margin: 0; font: 600 1.35rem var(--font-head); }
.m-body .m-words { margin-top: 4px; color: var(--muted); font-size: 0.85rem; }
.m-about { color: var(--muted); font-size: 0.88rem; }
.m-line { padding-left: 14px; border-left: 2px solid var(--cyan); color: #fff; font: 500 1.06rem/1.55 var(--font-head); }
.m-hero.master ~ .m-line { border-left-color: var(--gold); }
.m-more summary { width: fit-content; list-style: none; color: var(--cyan); font: 600 0.9rem var(--font-head); cursor: pointer; }
.m-more summary::-webkit-details-marker { display: none; }
.m-more summary::after { content: " +"; }
.m-more[open] summary::after { content: " −"; }
.m-more summary:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 4px; }
.m-more > p { margin: 12px 0 16px; }
.m-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.m-cols h3 { margin: 0 0 6px; font: 600 0.72rem var(--font-head); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.m-cols ul { margin: 0; padding-left: 18px; font-size: 0.9rem; line-height: 1.6; }
.m-nav { display: flex; gap: 8px; }
.m-nav .btn[hidden] { display: none; }
#m-next { margin-left: auto; }
.m-ask { align-self: flex-start; color: var(--cyan); border-color: rgba(62, 240, 255, 0.35); }
.m-ask[hidden] { display: none; }

/* Calendar: second page (#calendar) with the numbers of each year */
#calendar-btn[aria-pressed="true"] { color: var(--cyan); border-color: rgba(62, 240, 255, 0.45); background: rgba(62, 240, 255, 0.06); }
.calendar-view[hidden], .calendar-view [hidden], main[hidden] { display: none !important; }
.cal-hero { padding: 56px 0 30px; }
.cal-profile { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 24px; padding: 18px 22px; }
.cal-who { display: flex; align-items: center; gap: 14px; min-width: 0; }
.cal-who-text { display: grid; min-width: 0; }
.cal-who-text strong { overflow: hidden; font: 600 1.08rem var(--font-head); white-space: nowrap; text-overflow: ellipsis; }
.cal-who-text .muted { font-size: 0.85rem; }
.cal-pick { flex: 0 1 340px; margin-left: auto; }
.cal-empty { display: grid; justify-items: center; gap: 6px; max-width: 560px; margin: 0 auto; padding: 40px 24px; text-align: center; }
.cal-empty p { margin: 0; }
.cal-empty .chat-mark { width: 46px; height: 46px; margin-bottom: 8px; }
.cal-empty .btn { margin-top: 14px; }
.cal-body { display: grid; gap: 24px; }

.cal-focus-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.cal-year { font: 600 2.6rem/1 var(--font-head); letter-spacing: -0.02em; }
.cal-when { padding: 3px 10px; border: 1px solid rgba(62, 240, 255, 0.35); border-radius: 999px; color: var(--cyan); font: 600 0.78rem var(--font-head); letter-spacing: 0.04em; }
.cal-when.now { background: var(--cyan); border-color: var(--cyan); color: var(--bg-0); }
.cal-step { margin-left: auto; font-size: 0.88rem; }
.cal-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cal-stats .stat { align-content: start; }
.cal-title { color: #fff; font: 600 0.98rem var(--font-head); }
.cal-line { margin: 4px 0 0; font-size: 0.92rem; line-height: 1.55; }
.cal-sub { color: var(--muted); font: 500 0.95rem var(--font-head); }
.cal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.cal-actions .btn { color: var(--cyan); border-color: rgba(62, 240, 255, 0.35); }
.cal-ask { display: none; }
.can-ask .cal-ask { display: inline-flex; }

/* Years / Months / Days switch */
.cal-tabs { display: flex; justify-self: center; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 16px; background: rgba(11, 16, 38, 0.85); }
.cal-tab { min-width: 96px; height: 38px; padding: 0 16px; border: 1px solid transparent; border-radius: 12px; background: none; color: var(--muted); font: 600 0.9rem var(--font-head); cursor: pointer; transition: color 0.2s, background 0.2s, border-color 0.2s; }
.cal-tab:hover { color: var(--text); }
.cal-tab:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.cal-tab[aria-selected="true"] { border-color: rgba(62, 240, 255, 0.45); background: linear-gradient(135deg, rgba(62, 240, 255, 0.14), rgba(139, 92, 246, 0.24)); color: var(--text); }

.cal-cycle-head { flex-wrap: wrap; }
.cal-cycle-head #cal-range { font-size: 0.9rem; }
.cal-arrows { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.icon-btn:disabled { opacity: 0.3; cursor: default; background: none; border-color: transparent; }
.cal-grid { display: grid; gap: 10px; }
.cal-grid-year { grid-template-columns: repeat(9, 1fr); }
.cal-grid-month { grid-template-columns: repeat(6, 1fr); }
.cal-grid-day { grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-tile {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 12px 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s var(--ease);
}
.cal-tile:hover { transform: translateY(-2px); border-color: rgba(62, 240, 255, 0.3); }
.cal-tile:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.cal-tile.selected { border-color: rgba(62, 240, 255, 0.6); background: linear-gradient(140deg, rgba(62, 240, 255, 0.1), rgba(139, 92, 246, 0.16)); box-shadow: 0 0 24px rgba(62, 240, 255, 0.1); }
.cal-tile.master { border-color: rgba(245, 199, 107, 0.35); }
.cal-tile.master.selected { border-color: rgba(245, 199, 107, 0.7); }
.cal-tile .num { font-size: 2rem; line-height: 1.1; }
.cal-tile-year { display: flex; align-items: center; gap: 5px; color: var(--muted); font: 600 0.8rem var(--font-head); letter-spacing: 0.04em; }
.cal-tile-year b { padding: 1px 6px; border-radius: 999px; background: var(--cyan); color: var(--bg-0); font-size: 0.6rem; letter-spacing: 0.06em; text-transform: uppercase; }
.cal-tile-sub { display: grid; justify-items: center; color: var(--muted); font-size: 0.72rem; line-height: 1.45; }
.cal-tile-sub b { color: var(--text); font-weight: 600; }

/* Day squares of the month */
.cal-wd { padding-bottom: 2px; color: var(--muted); font: 600 0.72rem var(--font-head); letter-spacing: 0.08em; text-align: center; text-transform: uppercase; }
.cal-day {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-height: 74px;
  padding: 18px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.cal-day:hover { border-color: rgba(62, 240, 255, 0.3); }
.cal-day:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.cal-day.selected { border-color: rgba(62, 240, 255, 0.6); background: linear-gradient(140deg, rgba(62, 240, 255, 0.1), rgba(139, 92, 246, 0.16)); }
.cal-day.master { border-color: rgba(245, 199, 107, 0.35); }
.cal-day.master.selected { border-color: rgba(245, 199, 107, 0.7); }
.cal-day .num { font-size: 1.45rem; line-height: 1.1; }
.cal-day-date { position: absolute; top: 5px; left: 7px; color: var(--muted); font: 600 0.72rem var(--font-head); }
.cal-day.now .cal-day-date { padding: 0 5px; border-radius: 999px; background: var(--cyan); color: var(--bg-0); left: 4px; }
.cal-day-sub { color: var(--muted); font-size: 0.66rem; white-space: nowrap; }

/* AI chat: a round button in the bottom right corner that opens into a conversation */
.has-chat { padding-bottom: 92px; }   /* room so the button never hides the end of the page */
.has-chat .toast { bottom: 96px; }
.chat {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 25;
}
.chat[hidden], .chat-panel[hidden], .chat.open .chat-fab { display: none; }
.chat-fab {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45), 0 0 24px rgba(62, 240, 255, 0.28);
  color: var(--bg-0);
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s;
}
.chat-fab .icon { width: 26px; height: 26px; stroke-width: 2; }
.chat-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5), 0 0 32px rgba(62, 240, 255, 0.42); }
.chat-fab:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.chat-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin: 0 12px;
  padding: 5px 5px 5px 14px;
  border: 1px solid rgba(62, 240, 255, 0.28);
  border-radius: 18px;
  background: rgba(11, 16, 38, 0.9);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.chat-bar:focus-within { border-color: rgba(62, 240, 255, 0.55); box-shadow: 0 0 20px rgba(62, 240, 255, 0.14); }
.chat-bar textarea, .chat-bar input {
  flex: 1;
  min-width: 0;
  max-height: 132px;
  padding: 10px 0;
  border: 0;
  outline: 0;
  resize: none;
  background: none;
  color: var(--text);
  font: 400 0.98rem/1.45 var(--font-body);
}
.chat-bar textarea::placeholder, .chat-bar input::placeholder { color: var(--muted); }
.chat-send {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  color: var(--bg-0);
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.2s, color 0.2s;
}
.chat-send .icon { stroke-width: 2.3; }
.chat-send:hover { transform: translateY(-1px); }
.chat-send:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.chat.busy .chat-send { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.chat.busy .chat-send .icon { fill: currentColor; }

.chat-panel {
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100vw - 40px));
  height: min(620px, calc(100vh - 40px));
  height: min(620px, calc(var(--chat-room, 100dvh) - 40px));   /* --chat-room: what a phone keyboard leaves visible, see chat.js */
  background: linear-gradient(180deg, rgba(16, 22, 52, 0.97), rgba(7, 9, 22, 0.97));
  animation: chat-in 0.3s var(--ease);
}
@keyframes chat-in { from { opacity: 0; translate: 0 14px; } }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 10px 12px 16px; border-bottom: 1px solid var(--line); }
.chat-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(62, 240, 255, 0.55);
  background: radial-gradient(circle at 50% 40%, #16224f, #0d1533 75%);
  box-shadow: 0 0 14px rgba(62, 240, 255, 0.2);
  color: var(--cyan);
}
.chat-title { display: grid; margin-right: auto; line-height: 1.3; }
.chat-title strong { font: 600 0.98rem var(--font-head); }
.chat-title .muted { font-size: 0.8rem; }
.chat-log { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; padding: 16px; overflow-y: auto; overscroll-behavior: contain; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; font-size: 0.94rem; line-height: 1.6; overflow-wrap: anywhere; }
.msg p, .msg ul, .msg ol { margin: 0 0 8px; }
.msg > :last-child { margin-bottom: 0; }
.msg ul, .msg ol { padding-left: 20px; }
.msg li + li { margin-top: 2px; }
.msg strong { color: #fff; font-weight: 600; }
.msg .chat-h { color: #fff; font: 600 0.98rem var(--font-head); }
.msg .cut { color: var(--muted); font-size: 0.82rem; }
.msg.user { align-self: flex-end; border: 1px solid rgba(62, 240, 255, 0.25); border-bottom-right-radius: 6px; background: linear-gradient(135deg, rgba(62, 240, 255, 0.13), rgba(139, 92, 246, 0.24)); white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; border: 1px solid var(--line); border-bottom-left-radius: 6px; background: rgba(255, 255, 255, 0.035); }
.msg.error { align-self: flex-start; border: 1px dashed rgba(255, 184, 107, 0.45); background: rgba(255, 184, 107, 0.05); color: var(--warn); }
.msg.error .link-btn { margin: 4px 0 0 -6px; }
.dots { display: inline-flex; gap: 5px; padding: 7px 2px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); opacity: 0.35; animation: dot 1.2s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 40% { opacity: 1; translate: 0 -3px; } }
.chat-hello { display: grid; gap: 14px; margin-top: auto; color: var(--muted); font-size: 0.92rem; }
.chat-hello p { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 13px; border: 1px solid rgba(62, 240, 255, 0.28); border-radius: 999px; background: rgba(62, 240, 255, 0.05); color: var(--text); font: 500 0.85rem var(--font-body); text-align: left; cursor: pointer; transition: border-color 0.2s, background 0.2s; }
.chip:hover { border-color: rgba(62, 240, 255, 0.6); background: rgba(62, 240, 255, 0.1); }
.chip:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.chat-note { margin: 0; padding: 8px 16px 12px; color: var(--muted); font-size: 0.74rem; text-align: center; }
/* Private for now: the panel only asks for the access code */
/* Free questions used up (.spent): the conversation stays, the offer shows under it */
.chat.locked:not(.spent) .chat-panel, .chat.spent:not(.has-talk) .chat-panel { height: auto; }
.chat.locked:not(.spent) .chat-log, .chat.spent:not(.has-talk) .chat-log,
.chat.locked #chat-form, .chat.locked #chat-reset, .chat.locked .chat-note, .chat:not(.locked) .chat-lock { display: none; }
.chat.spent .chat-lock { order: 1; border-top: 1px solid var(--line); }
.chat.free.show-lock .chat-lock { display: grid; border-bottom: 1px solid var(--line); }   /* "Go unlimited" */
.chat-spent { display: none; color: var(--text); }
.chat.spent .chat-spent { display: block; }
.chat.spent #chat-lock-text { display: none; }
.chat-free { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2px 6px; margin: 8px 16px 0; color: var(--cyan); font-size: 0.8rem; }
.chat-free[hidden] { display: none; }
/* The access code box is for the owner only: it shows after opening the site as /#code (chat.js) */
body:not(.owner-door) .code-door { display: none !important; }
.pay-box .btn[hidden] { display: none; }
.chat-free .link-btn { padding: 2px 4px; font-size: 0.8rem; }
.chat-lock { display: grid; gap: 12px; padding: 16px; color: var(--muted); font-size: 0.92rem; }
.chat-lock p { margin: 0; }
.chat-lock .chat-bar { margin: 0; }
.chat-lock-error { color: var(--warn); font-size: 0.85rem; }

/* Full report: the button at the bottom of the tree, and the third page (#report) */
.report-cta { display: none; }
.has-report .report-cta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  margin-top: var(--gap);
  padding: 28px 30px;
  background: linear-gradient(120deg, rgba(62, 240, 255, 0.07), rgba(139, 92, 246, 0.12) 55%, rgba(245, 199, 107, 0.08));
}
.report-cta-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid rgba(245, 199, 107, 0.55);
  background: radial-gradient(circle at 50% 40%, #3a2c10, #21180a 75%);
  box-shadow: 0 0 26px rgba(245, 199, 107, 0.22);
  color: var(--gold);
}
.report-cta-mark .icon { width: 28px; height: 28px; }
.report-cta-text .eyebrow { margin-bottom: 6px; color: var(--gold); }
.report-cta-text h3 { margin: 0 0 6px; font: 600 1.35rem/1.25 var(--font-head); letter-spacing: -0.01em; }
.report-cta-text p:last-child { margin: 0; max-width: 620px; font-size: 0.95rem; }

.report-view [hidden] { display: none !important; }
.rp-hero { padding: 56px 0 28px; }
.rp-hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
.rp-bar {
  position: sticky;
  top: 70px;
  z-index: 12;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: var(--gap);
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(16, 22, 52, 0.94), rgba(11, 16, 38, 0.94));
}
.rp-progress { display: grid; gap: 6px; flex: 1 1 260px; min-width: 0; }
.rp-status { color: var(--muted); font-size: 0.88rem; }
.rp-status .link-btn { padding: 0 4px; font-size: 0.88rem; }
.rp-meter { display: block; height: 4px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, 0.07); }
.rp-meter span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--violet), var(--gold)); transition: width 0.6s var(--ease); }
.rp-progress.live .rp-status { color: var(--text); }
.rp-actions { display: flex; gap: 8px; }
#rp-rewrite.confirm { color: var(--warn); border-color: rgba(255, 184, 107, 0.5); }

.rp-note { display: grid; justify-items: center; gap: 8px; max-width: 620px; margin: 0 auto var(--gap); padding: 40px 26px; text-align: center; }
.rp-note p { margin: 0; }
.rp-note .chat-mark { width: 46px; height: 46px; margin-bottom: 6px; }
.rp-note > .btn { margin-top: 14px; }
.rp-oops { color: var(--warn); }
.rp-lock .chat-bar { width: min(100%, 360px); margin: 10px 0 0; }

/* Payments (pay.js): the buy box in the report lock and the chat lock, the manage link, the confirmation toast */
.pay-box { display: grid; justify-items: center; gap: 8px; width: min(100%, 420px); margin: 14px 0 4px; }
.pay-box .btn { width: 100%; justify-content: center; }
.pay-box .btn:disabled { opacity: 0.6; cursor: wait; }
.pay-note { font-size: 0.82rem; }
.pay-or { margin-top: 10px !important; font-size: 0.85rem; }
.chat-lock .pay-box { justify-items: stretch; width: 100%; margin: 0; text-align: center; }
.chat-manage { align-self: flex-end; margin: 6px 12px 0; font-size: 0.82rem; }
.pay-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 80;
  max-width: min(92vw, 460px);
  padding: 14px 18px;
  transform: translateX(-50%);
  color: var(--text);
  font-size: 0.95rem;
  text-align: center;
}
.rp-kept { display: grid; gap: 8px; width: min(100%, 420px); margin: 12px 0 0; padding: 0; list-style: none; text-align: left; }

.rp-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--gap); align-items: start; }
.rp-toc { position: sticky; top: 150px; padding: 18px 12px 14px; }
.rp-toc-title { margin: 0 10px 8px; color: var(--muted); font: 600 0.72rem var(--font-head); letter-spacing: 0.16em; text-transform: uppercase; }
.rp-toc ol { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.rp-toc button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font: 500 0.88rem/1.35 var(--font-body);
  text-align: left;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.rp-toc button:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.rp-toc button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }
.rp-dot { flex: none; width: 9px; height: 9px; border: 1.5px solid rgba(255, 255, 255, 0.3); border-radius: 50%; }
.rp-toc [data-state="done"] { color: var(--text); }
.rp-toc [data-state="done"] .rp-dot { border-color: var(--cyan); background: var(--cyan); box-shadow: 0 0 8px rgba(62, 240, 255, 0.5); }
.rp-toc [data-state="writing"] .rp-dot { border-color: var(--cyan); animation: rp-pulse 1.2s ease-in-out infinite; }
.rp-toc [data-state="waiting"] .rp-dot { border-style: dashed; border-color: rgba(62, 240, 255, 0.5); }
.rp-toc [data-state="error"] .rp-dot, .rp-toc [data-state="missing"] .rp-dot { border-color: var(--warn); }
@keyframes rp-pulse { 50% { background: var(--cyan); box-shadow: 0 0 10px rgba(62, 240, 255, 0.6); } }

.rp-sections { display: grid; gap: var(--gap); min-width: 0; }
.rp-section { padding: 34px 40px 30px; scroll-margin-top: 150px; }
.rp-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.rp-head h2 { margin: 0; font: 600 clamp(1.3rem, 2.6vw, 1.7rem)/1.25 var(--font-head); letter-spacing: -0.01em; }
.rp-body { max-width: 72ch; font-size: 1.02rem; line-height: 1.78; overflow-wrap: break-word; }
.rp-body > :first-child { margin-top: 0; }
.rp-body p { margin: 0 0 14px; }
.rp-body h3 { margin: 38px 0 12px; color: #fff; font: 600 1.22rem/1.35 var(--font-head); }
.rp-body h4 { margin: 26px 0 8px; color: var(--cyan); font: 600 0.82rem var(--font-head); letter-spacing: 0.1em; text-transform: uppercase; }
.rp-body strong { color: #fff; font-weight: 600; }
.rp-body ul, .rp-body ol { margin: 0 0 14px; padding-left: 22px; }
.rp-body li + li { margin-top: 6px; }
.rp-section[data-state="writing"] .rp-body > :last-child::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 1.05em;
  margin-left: 3px;
  vertical-align: -2px;
  border-radius: 2px;
  background: var(--cyan);
  animation: rp-caret 1s steps(2) infinite;
}
@keyframes rp-caret { 50% { opacity: 0; } }

/* The cards: in your life, fulfilled, contrary, strengths and pitfalls side by side, nuances, key */
.rp-card { margin: 20px 0; padding: 16px 20px 4px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 255, 255, 0.025); }
.rp-card ul { padding-left: 18px; }
.rp-card-title { margin: 0 0 6px !important; font: 600 0.72rem var(--font-head); letter-spacing: 0.16em; text-transform: uppercase; }
.rp-fulfilled { border-color: rgba(74, 222, 128, 0.32); background: linear-gradient(160deg, rgba(74, 222, 128, 0.07), rgba(74, 222, 128, 0.015)); }
.rp-fulfilled .rp-card-title { color: var(--green); }
.rp-contrary { border-color: rgba(255, 184, 107, 0.32); background: linear-gradient(160deg, rgba(255, 184, 107, 0.07), rgba(255, 184, 107, 0.015)); }
.rp-contrary .rp-card-title { color: var(--warn); }
.rp-strengths { border-color: rgba(62, 240, 255, 0.26); }
.rp-strengths .rp-card-title { color: var(--cyan); }
.rp-pitfalls { border-color: rgba(255, 155, 148, 0.28); }
.rp-pitfalls .rp-card-title { color: #ff9b94; }
.rp-life { border-color: rgba(139, 92, 246, 0.38); background: linear-gradient(160deg, rgba(139, 92, 246, 0.09), rgba(139, 92, 246, 0.015)); }
.rp-life .rp-card-title { color: #b69cff; }
.rp-nuances { border-style: dashed; border-color: rgba(147, 197, 253, 0.38); background: rgba(147, 197, 253, 0.03); }
.rp-nuances .rp-card-title { color: #93c5fd; }
.rp-key { border-color: rgba(245, 199, 107, 0.45); background: linear-gradient(160deg, rgba(245, 199, 107, 0.1), rgba(245, 199, 107, 0.02)); box-shadow: 0 0 30px rgba(245, 199, 107, 0.06); }
.rp-key .rp-card-title { color: var(--gold); }
.rp-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 20px 0; }
.rp-pair .rp-card { margin: 0; font-size: 0.95rem; line-height: 1.65; }

.rp-wait { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.92rem; }
.rp-skeleton { display: grid; gap: 10px; margin-top: 16px; }
.rp-skeleton i { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.04)); background-size: 200% 100%; animation: rp-shine 1.6s linear infinite; }
.rp-skeleton i:nth-child(2) { width: 92%; }
.rp-skeleton i:nth-child(3) { width: 96%; }
.rp-skeleton i:nth-child(4) { width: 60%; }
@keyframes rp-shine { to { background-position: -200% 0; } }
.rp-error { padding: 14px 16px; border: 1px dashed rgba(255, 184, 107, 0.45); border-radius: 14px; background: rgba(255, 184, 107, 0.05); color: var(--warn); }
.rp-error p { margin: 0 0 4px; }
.rp-error .link-btn { margin-left: -6px; }
.rp-foot { max-width: 620px; margin: 28px auto 0; font-size: 0.85rem; text-align: center; }

/* Responsive */
@media (max-width: 960px) {
  .results-grid { grid-template-columns: 1fr; }
  .tree-col { position: static; }
  .rp-layout { grid-template-columns: minmax(0, 1fr); }   /* minmax: a long row of contents chips must not widen the page */
  .rp-toc { position: static; min-width: 0; }
  .rp-toc ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rp-section { scroll-margin-top: 140px; }
  .cal-grid-year { grid-template-columns: repeat(3, 1fr); }
  .cal-grid-month { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 600px) {
  .nav-actions { gap: 6px; }
  .nav-actions .btn span { display: none; }
  .nav-actions .btn.small { padding: 0 10px; }
  .nav-actions .count { position: absolute; top: 3px; right: 3px; min-width: 15px; height: 15px; padding: 0 4px; font-size: 0.6rem; }
  .drawer { width: 100%; border-left: 0; border-radius: 0; }
  .hero { padding: 48px 0 28px; }
  .form-card { padding: 22px 18px; }
  .field-row, .field-row.three { grid-template-columns: 1fr; }
  .card { padding: 20px 18px; }
  .years { grid-template-columns: 1fr; }
  .timeline .wide-only { display: none; }
  .cal-hero { padding: 40px 0 22px; }
  .cal-profile { padding: 16px; }
  .cal-pick { flex: 1 1 100%; margin-left: 0; }
  .cal-stats { grid-template-columns: 1fr; }
  .cal-step { width: 100%; margin-left: 0; }
  .cal-year { font-size: 2.2rem; }
  .cal-grid-month { grid-template-columns: repeat(3, 1fr); }
  .cal-grid-day { gap: 4px; }
  .cal-day { min-height: 56px; padding: 16px 2px 6px; border-radius: 10px; }
  .cal-day .num { font-size: 1.2rem; }
  .cal-day-sub { display: none; }
  .cal-day-date { top: 3px; left: 5px; font-size: 0.66rem; }
  .cal-tab { min-width: 0; flex: 1; }
  .cal-tabs { justify-self: stretch; }
  .has-chat { padding-bottom: 80px; }
  .chat { right: calc(14px + env(safe-area-inset-right)); bottom: calc(14px + env(safe-area-inset-bottom)); }
  .chat.open { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); }
  .chat-bar textarea, .chat-bar input { font-size: 16px; }   /* below 16px, iPhones zoom the page when the box is tapped */
  .chat-panel { width: 100%; height: calc(var(--chat-room, 100dvh) - 20px - env(safe-area-inset-bottom)); }
  .chat-log { padding: 14px 12px; }
  .msg { max-width: 94%; }
  .has-report .report-cta { grid-template-columns: 1fr; justify-items: start; gap: 16px; padding: 22px 18px; }
  .report-cta .btn { width: 100%; }
  .rp-hero { padding: 40px 0 22px; }
  .rp-bar { position: static; padding: 8px; }   /* a phone screen is too small to keep it on top while reading */
  .rp-bar .btn span { display: none; }
  .rp-bar .btn.small { padding: 0 10px; }
  .rp-bar #rp-rewrite.confirm span { display: inline; }
  .rp-progress { order: 3; flex-basis: 100%; }
  .rp-actions { margin-left: auto; }
  /* Contents: one row of chips to swipe through */
  .rp-toc { padding: 8px; }
  .rp-toc-title { display: none; }
  .rp-toc ol { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
  .rp-toc li { flex: none; }
  .rp-toc button { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; }
  .rp-section { padding: 24px 18px 20px; scroll-margin-top: 76px; }
  .rp-body { font-size: 1rem; line-height: 1.72; }
  .rp-pair { grid-template-columns: 1fr; }
  .rp-card { padding: 14px 16px 2px; }
}

/* Small phones: five nav buttons next to the logo */
@media (max-width: 420px) {
  .nav-actions { gap: 4px; }
  .nav-actions .btn.small { padding: 0 8px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  *, *::before, *::after { animation-delay: 0s !important; }
  #tree .fly, #tree .falling { display: none; }
}

/* Print / PDF: light, ink-friendly */
@media print {
  body { background: #fff; color: #111; }
  #stars, .aurora, .nav, .hero, .form-card, .scanning, .footer, .hint, .toast, .drawer, .save-btn, .chat, .report-cta, .rp-bar, .rp-toc { display: none !important; }
  .rp-layout { display: block; }
  .rp-body, .rp-body strong, .rp-body h3 { color: #111; }
  .has-chat { padding-bottom: 0; }
  .results { margin: 0; }
  .glass { background: #fff; box-shadow: none; backdrop-filter: none; border: 1px solid #ddd; break-inside: avoid; }
  .glass::before { display: none; }
  .results-grid { grid-template-columns: 1fr; }
  .tree-col { position: static; }
  .tree-card { background: #0B1026; }
  .reveal { opacity: 1; transform: none; }
  .num, .master .num { color: #111; text-shadow: none; }
  .muted, .label { color: #555; }
  .card-head, .card-head h3 { color: #111; }
  .key-tile, .tool, .stat { border-color: #ddd; background: #fff; }
  #tree .trunk-g, #tree .br, #tree .leaf, #tree .fruit-in { scale: 1 !important; rotate: 0deg !important; }
  #tree .node, #tree .fx { opacity: 1; }
  #tree .fly, #tree .falling { display: none; }
}
