/* Meridian — "The Night Atlas" design system */
:root {
  --ink-0: #070b14;      /* deepest sky */
  --ink-1: #0b1020;
  --ink-2: #121a30;
  --ink-3: #1b2542;      /* raised surfaces */
  --line: #24304f;
  --line-soft: rgba(94, 234, 212, 0.12);
  --star: #e6ecff;
  --text: #c9d3ec;
  --text-dim: #7e8bad;
  --gold: #e8b959;       /* mastery */
  --gold-soft: rgba(232, 185, 89, 0.16);
  --aurora: #5eead4;     /* available / action */
  --aurora-soft: rgba(94, 234, 212, 0.14);
  --locked: #3d4763;
  --danger: #f0768b;
  /* ensemble sigil colors */
  --c-mentor: #e8b959;
  --c-client: #ff9e7d;
  --c-peer: #7dc4ff;
  --c-skeptic: #c39df5;
  --font-display: 'Fraunces', serif;
  --font-body: 'Alegreya Sans', sans-serif;
  --font-mono: 'Spline Sans Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--ink-0);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  overflow-x: hidden;
}
/* atmospheric layers: faint contour rings + starfield grain */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(1200px 800px at 85% -10%, rgba(94, 234, 212, 0.06), transparent 60%),
    radial-gradient(1000px 700px at -10% 110%, rgba(232, 185, 89, 0.05), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='520'%3E%3Cg fill='none' stroke='%235eead4' stroke-opacity='0.05'%3E%3Ccircle cx='390' cy='110' r='70'/%3E%3Ccircle cx='390' cy='110' r='150'/%3E%3Ccircle cx='80' cy='430' r='60' stroke='%23e8b959' stroke-opacity='0.045'/%3E%3Ccircle cx='80' cy='430' r='130' stroke='%23e8b959' stroke-opacity='0.04'/%3E%3C/g%3E%3Cg fill='%23e6ecff' fill-opacity='0.55'%3E%3Ccircle cx='60' cy='80' r='1'/%3E%3Ccircle cx='210' cy='40' r='0.7'/%3E%3Ccircle cx='330' cy='250' r='1.1'/%3E%3Ccircle cx='470' cy='390' r='0.8'/%3E%3Ccircle cx='150' cy='330' r='0.9'/%3E%3Ccircle cx='260' cy='480' r='0.7'/%3E%3Ccircle cx='430' cy='30' r='0.9'/%3E%3C/g%3E%3C/svg%3E");
}
#app { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }

h1, h2, h3, .display { font-family: var(--font-display); font-weight: 550; color: var(--star); }
a { color: var(--aurora); text-decoration: none; }
button { font-family: var(--font-body); cursor: pointer; }

/* ---------- chrome ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 26px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--ink-1) 82%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.wordmark {
  font-family: var(--font-display); font-size: 20px; letter-spacing: 0.22em;
  color: var(--star); text-transform: uppercase; font-weight: 600;
}
.wordmark .dot { color: var(--aurora); }
.topbar .crumb { color: var(--text-dim); font-size: 15px; }
.topbar .spacer { flex: 1; }
.badge {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.08em;
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--text-dim);
}

.btn {
  border: 1px solid var(--line); background: var(--ink-2); color: var(--text);
  padding: 9px 18px; border-radius: 10px; font-size: 15px; font-weight: 500;
  transition: all 0.18s ease;
}
.btn:hover { border-color: var(--aurora); color: var(--aurora); transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(160deg, var(--aurora), #3ec9b2); color: #06251f;
  border-color: transparent; font-weight: 700;
}
.btn.primary:hover { filter: brightness(1.1); color: #06251f; box-shadow: 0 4px 24px rgba(94,234,212,0.35); }
.btn.gold { background: linear-gradient(160deg, var(--gold), #caa044); color: #2a1f06; border-color: transparent; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn.sm { padding: 5px 12px; font-size: 13.5px; border-radius: 8px; }

input[type='text'], textarea {
  width: 100%; background: var(--ink-1); border: 1px solid var(--line); color: var(--star);
  border-radius: 10px; padding: 12px 14px; font-family: var(--font-body); font-size: 16px;
  transition: border-color 0.15s;
}
input:focus, textarea:focus { outline: none; border-color: var(--aurora); }
textarea { resize: vertical; min-height: 110px; }

/* ---------- home ---------- */
.hero { text-align: center; padding: 72px 20px 34px; }
.hero .sigil { margin-bottom: 18px; animation: heroFloat 7s ease-in-out infinite; }
@keyframes heroFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.hero h1 {
  font-size: clamp(44px, 7vw, 84px); letter-spacing: 0.16em; text-transform: uppercase;
  font-weight: 640; line-height: 1;
  background: linear-gradient(180deg, var(--star), #93a5d8);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero .tag {
  margin-top: 16px; font-family: var(--font-display); font-style: italic; font-weight: 400;
  color: var(--text-dim); font-size: clamp(17px, 2.2vw, 22px);
}
.hero .tag em { color: var(--gold); font-style: italic; }
.doors {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px; max-width: 1020px; margin: 44px auto; padding: 0 24px;
}
.door {
  text-align: left; background: linear-gradient(180deg, var(--ink-2), var(--ink-1));
  border: 1px solid var(--line); border-radius: 18px; padding: 26px 24px;
  transition: all 0.22s ease; position: relative; overflow: hidden; color: var(--text);
}
.door::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(400px 200px at 50% -40%, var(--aurora-soft), transparent 70%);
  opacity: 0; transition: opacity 0.25s;
}
.door:hover { transform: translateY(-4px); border-color: var(--aurora); box-shadow: 0 18px 44px rgba(0,0,0,0.5); }
.door:hover::after { opacity: 1; }
.door.gold::after { background: radial-gradient(400px 200px at 50% -40%, var(--gold-soft), transparent 70%); }
.door.gold:hover { border-color: var(--gold); }
.door .k { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.22em; color: var(--text-dim); text-transform: uppercase; }
.door h3 { font-size: 25px; margin: 8px 0 6px; }
.door p { color: var(--text-dim); font-size: 15px; }

.panel {
  background: color-mix(in srgb, var(--ink-1) 92%, transparent);
  border: 1px solid var(--line); border-radius: 16px; padding: 20px;
}
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; margin-top: 10px;
  background: var(--ink-2); transition: border-color 0.15s; cursor: pointer;
}
.list-row:hover { border-color: var(--aurora); }
.list-row .grow { flex: 1; }
.list-row .sub { color: var(--text-dim); font-size: 14px; }

.section-label {
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: 0.24em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 10px;
}

/* ---------- living map ---------- */
.map-layout { display: grid; grid-template-columns: 1fr 330px; gap: 0; flex: 1; min-height: 0; }
.map-canvas { position: relative; overflow: auto; }
.map-canvas svg { display: block; }
.map-side {
  border-left: 1px solid var(--line); padding: 22px; overflow-y: auto;
  background: color-mix(in srgb, var(--ink-1) 88%, transparent);
}
.map-side h2 { font-size: 22px; }
.map-side .greeting { font-style: italic; color: var(--gold); font-family: var(--font-display); font-weight: 400; margin: 8px 0 4px; font-size: 16px; }
.progress-ring { display: flex; align-items: center; gap: 14px; margin: 16px 0; }
.progress-ring .nums .big { font-family: var(--font-display); font-size: 30px; color: var(--star); }
.progress-ring .nums .sub { color: var(--text-dim); font-size: 13.5px; }

.belief {
  border-left: 2px solid var(--aurora); padding: 8px 12px; margin-top: 10px;
  background: var(--ink-2); border-radius: 0 10px 10px 0; font-size: 14.5px;
}
.belief .why { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
.belief-empty { color: var(--text-dim); font-size: 14px; font-style: italic; }

/* map nodes (SVG classes) */
.edge { stroke: var(--line); stroke-width: 1.5; fill: none; }
.edge.lit { stroke: var(--gold); stroke-opacity: 0.55; }
.edge.half { stroke: var(--aurora); stroke-opacity: 0.35; stroke-dasharray: 3 5; }
.node { cursor: pointer; }
.node .halo { opacity: 0; }
.node.available .ring { stroke: var(--aurora); animation: ringPulse 2.6s ease-in-out infinite; }
.node.available .halo { fill: var(--aurora); opacity: 0.1; animation: haloPulse 2.6s ease-in-out infinite; }
.node.mastered .core { fill: var(--gold); }
.node.mastered .ring { stroke: var(--gold); }
.node.mastered .halo { fill: var(--gold); opacity: 0.13; }
.node.locked { cursor: default; }
.node.locked .ring { stroke: var(--locked); stroke-dasharray: 4 6; }
.node.locked .label, .node.locked .icon { opacity: 0.45; }
.node .label {
  fill: var(--text); font-family: var(--font-body); font-size: 13.5px; font-weight: 500;
  text-anchor: middle; paint-order: stroke; stroke: var(--ink-0); stroke-width: 4px; stroke-linejoin: round;
}
.node.mastered .label { fill: #f3ddaa; }
.node.available .label { fill: #d6fff6; }
.node .typechip {
  fill: var(--text-dim); font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.14em;
  text-anchor: middle; text-transform: uppercase;
}
@keyframes ringPulse { 0%,100% { stroke-width: 2; } 50% { stroke-width: 4; } }
@keyframes haloPulse { 0%,100% { opacity: 0.07; transform: scale(1); } 50% { opacity: 0.16; transform: scale(1.12); } }
.node .halo { transform-box: fill-box; transform-origin: center; }
.node:hover .ring { stroke-width: 4; }
.node-pop { animation: nodePop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) both; transform-box: fill-box; transform-origin: center; }
@keyframes nodePop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- stage ---------- */
.stage-layout { display: grid; grid-template-columns: 1fr 300px; flex: 1; min-height: 0; }
.stage-main { display: flex; flex-direction: column; min-height: 0; }
.stage-head {
  padding: 16px 30px; border-bottom: 1px solid var(--line);
  display: flex; align-items: baseline; gap: 16px;
}
.stage-head h2 { font-size: 22px; }
.arc { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.arc .seg {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-dim); padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px;
}
.arc .seg.on { color: #06251f; background: var(--aurora); border-color: var(--aurora); font-weight: 500; }
.arc .seg.past { color: var(--aurora); border-color: var(--aurora); }

.blocks { flex: 1; overflow-y: auto; padding: 28px 30px 130px; scroll-behavior: smooth; }
.block { max-width: 720px; margin: 0 auto 18px; display: flex; gap: 14px; animation: blockIn 0.45s ease both; }
@keyframes blockIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.sigil {
  flex: 0 0 42px; width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; font-family: var(--font-display); font-size: 19px; font-weight: 700;
  color: var(--ink-0); box-shadow: 0 4px 18px rgba(0,0,0,0.4);
}
.block .body { flex: 1; min-width: 0; }
.block .who { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 4px; }
.block .md { background: var(--ink-2); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; padding: 14px 18px; }
.block .md p + p { margin-top: 10px; }
.block .md code { font-family: var(--font-mono); font-size: 14px; background: var(--ink-0); padding: 1px 6px; border-radius: 6px; color: var(--aurora); }
.block .md strong { color: var(--star); }
.block .md ul, .block .md ol { padding-left: 22px; margin: 8px 0; }
.block.ask .md { border-color: var(--aurora); box-shadow: 0 0 0 1px var(--aurora), 0 6px 30px rgba(94,234,212,0.13); }
.block.answer { flex-direction: row-reverse; }
.block.answer .md { background: #12241f; border-color: #1f4a3f; border-radius: 16px 4px 16px 16px; }
.block.answer .who { text-align: right; }
.block.evaluate .md { border-left: 3px solid var(--gold); border-radius: 4px 16px 16px 16px; }
.block.evaluate.incorrect .md { border-left-color: var(--danger); }
.verdict { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; margin-bottom: 6px; }
.verdict.correct { color: var(--aurora); } .verdict.partial { color: var(--gold); }
.verdict.incorrect { color: var(--danger); } .verdict.noted { color: var(--text-dim); }
.advance-note {
  max-width: 720px; margin: 26px auto; text-align: center; color: var(--text-dim);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase;
  display: flex; align-items: center; gap: 14px;
}
.advance-note::before, .advance-note::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.complete-card {
  max-width: 720px; margin: 26px auto; text-align: center; padding: 30px;
  border: 1px solid var(--gold); border-radius: 18px;
  background: radial-gradient(400px 200px at 50% -60%, var(--gold-soft), var(--ink-2));
  animation: blockIn 0.6s ease both;
}
.complete-card h3 { font-size: 26px; color: var(--gold); }
.complete-card .score { font-family: var(--font-mono); font-size: 13px; color: var(--text-dim); margin: 10px 0; }
.complete-card p { max-width: 520px; margin: 8px auto; }

.composer {
  position: sticky; bottom: 0; padding: 16px 30px 22px;
  background: linear-gradient(180deg, transparent, var(--ink-0) 30%);
}
.composer .inner { max-width: 720px; margin: 0 auto; }
.composer .hint { font-family: var(--font-mono); font-size: 11px; color: var(--aurora); letter-spacing: 0.12em; margin-bottom: 8px; text-transform: uppercase; }
.composer .row { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { min-height: 52px; max-height: 220px; }
.mcq { display: flex; flex-direction: column; gap: 8px; }
.mcq button {
  text-align: left; background: var(--ink-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 12px 16px; font-size: 15.5px; transition: all 0.15s;
}
.mcq button:hover { border-color: var(--aurora); color: var(--star); transform: translateX(4px); }
.thinking {
  display: flex; gap: 6px; align-items: center; color: var(--text-dim);
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.14em; padding: 8px 0;
  max-width: 720px; margin: 0 auto;
}
.thinking .orb { width: 8px; height: 8px; border-radius: 50%; background: var(--aurora); animation: orb 1.2s ease-in-out infinite; }
.thinking .orb:nth-child(2) { animation-delay: 0.15s; } .thinking .orb:nth-child(3) { animation-delay: 0.3s; }
@keyframes orb { 0%,100% { opacity: 0.25; transform: scale(0.8); } 50% { opacity: 1; transform: scale(1.15); } }

.stage-side { border-left: 1px solid var(--line); padding: 20px; overflow-y: auto; background: color-mix(in srgb, var(--ink-1) 88%, transparent); }
.cast-card { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 12px; margin-top: 8px; border: 1px solid transparent; transition: all 0.2s; }
.cast-card.speaking { border-color: var(--line); background: var(--ink-2); }
.cast-card .sigil { width: 34px; height: 34px; flex-basis: 34px; font-size: 15px; border-radius: 9px; }
.cast-card .nm { font-weight: 700; color: var(--star); font-size: 14.5px; }
.cast-card .rl { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-dim); }
.evidence-meter { margin-top: 8px; }
.dim-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; }
.dim-row .nm { width: 110px; color: var(--text-dim); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.dim-row .bar { flex: 1; height: 5px; background: var(--ink-3); border-radius: 4px; overflow: hidden; }
.dim-row .fill { height: 100%; background: linear-gradient(90deg, var(--aurora), var(--gold)); border-radius: 4px; transition: width 0.6s ease; }

/* ---------- studio ---------- */
.studio-layout { display: grid; grid-template-columns: 430px 1fr; flex: 1; min-height: 0; }
.studio-left { border-right: 1px solid var(--line); padding: 26px; overflow-y: auto; }
.studio-left h2 { font-size: 26px; margin-bottom: 4px; }
.studio-left .sub { color: var(--text-dim); margin-bottom: 20px; font-size: 15px; }
.q-card { border: 1px solid var(--line); border-left: 3px solid var(--gold); background: var(--ink-2); border-radius: 0 12px 12px 0; padding: 12px 14px; margin-top: 12px; }
.q-card .q { font-weight: 700; color: var(--star); }
.q-card .why { color: var(--text-dim); font-size: 13px; margin: 2px 0 8px; }
.ticker { font-family: var(--font-mono); font-size: 12.5px; margin-top: 14px; }
.ticker div { padding: 3px 0; color: var(--text-dim); animation: blockIn 0.3s ease both; }
.ticker .t-node { color: var(--aurora); }
.ticker .t-cast { color: var(--gold); }
.ticker .t-err { color: var(--danger); }
.studio-map { position: relative; overflow: auto; }
.node-edit { display: flex; gap: 6px; align-items: center; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; margin-top: 7px; background: var(--ink-2); font-size: 14px; }
.node-edit .t { flex: 1; }
.node-edit .type { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--text-dim); }
.node-edit button { background: none; border: none; color: var(--text-dim); font-size: 13px; padding: 2px 6px; border-radius: 6px; }
.node-edit button:hover { color: var(--aurora); background: var(--ink-3); }

/* ---------- coach ---------- */
.coach-wrap { max-width: 900px; margin: 0 auto; padding: 34px 24px; width: 100%; }
.flag-row { border: 1px solid var(--line); border-left: 3px solid var(--danger); border-radius: 0 12px 12px 0; background: var(--ink-2); padding: 14px 18px; margin-top: 12px; }
.flag-row .top { display: flex; gap: 10px; align-items: baseline; }
.flag-row .who { font-weight: 700; color: var(--star); }
.flag-row .what { color: var(--text-dim); font-size: 14px; }
.flag-row .flag { margin-top: 6px; color: var(--danger); font-size: 14.5px; }
.flag-row .m { font-family: var(--font-mono); font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* ---------- coach actions & portfolio ---------- */
.flag-row.reviewed { border-left-color: var(--aurora); opacity: 0.75; }
.coach-actions { display: flex; gap: 8px; margin-top: 10px; }
.review-note {
  margin-top: 8px; padding: 8px 12px; border-radius: 8px; font-size: 13.5px;
  background: var(--aurora-soft); color: var(--aurora); border: 1px solid transparent;
}
.belief.coach { border-left-color: var(--gold); background: var(--gold-soft); }
.coach-tag {
  display: block; font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--gold); margin-bottom: 3px;
}
.nudge {
  margin: 12px 0; padding: 10px 14px; border: 1px dashed var(--gold); border-radius: 12px;
  font-size: 14px; color: var(--text);
}
.nudge a { color: var(--gold); font-weight: 700; }
.folio-wrap { max-width: 780px; margin: 0 auto; padding: 40px 24px 80px; width: 100%; }
.folio-head { text-align: center; margin-bottom: 34px; }
.folio-head h1 { font-size: clamp(34px, 5vw, 52px); }
.folio-sub { color: var(--text-dim); font-family: var(--font-display); font-style: italic; margin-top: 6px; font-size: 17px; }
.folio-stat { margin-top: 14px; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em; color: var(--gold); }
.folio-card {
  border: 1px solid var(--line); border-radius: 16px; background: var(--ink-2);
  padding: 18px 20px; margin-top: 14px;
}
.folio-card.mastered { border-color: color-mix(in srgb, var(--gold) 45%, var(--line)); }
.folio-card-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.folio-card-head h3 { font-size: 21px; flex: 1; }
.folio-score { font-family: var(--font-mono); font-size: 12px; color: var(--gold); }
.folio-summary { margin-top: 12px; color: var(--text); font-size: 15.5px; }
.folio-card .dim-row { max-width: 420px; }
.artifact { margin-top: 14px; border-left: 3px solid var(--aurora); padding: 10px 14px; background: var(--ink-1); border-radius: 0 12px 12px 0; }
.artifact-body { font-size: 14.5px; }
.artifact-body p + p { margin-top: 8px; }

/* ---------- onboarding chat ---------- */
.onboard-wrap { max-width: 680px; margin: 0 auto; padding: 40px 24px 120px; width: 100%; flex: 1; }
.onboard-wrap h2 { font-size: 30px; }
.onboard-wrap .sub { color: var(--text-dim); margin: 6px 0 26px; }

.modal-veil { position: fixed; inset: 0; background: rgba(5, 8, 16, 0.75); backdrop-filter: blur(4px); z-index: 50; display: grid; place-items: center; }
.modal { width: min(480px, 92vw); background: var(--ink-1); border: 1px solid var(--line); border-radius: 18px; padding: 26px; }
.modal h3 { font-size: 22px; margin-bottom: 12px; }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--ink-3); border: 1px solid var(--aurora); color: var(--star);
  padding: 10px 22px; border-radius: 999px; z-index: 60; animation: blockIn 0.3s ease both;
}

@media (max-width: 900px) {
  .map-layout, .stage-layout { grid-template-columns: 1fr; }
  .map-side, .stage-side { border-left: none; border-top: 1px solid var(--line); }
  .studio-layout { grid-template-columns: 1fr; }
  .studio-left { border-right: none; }
}
