/* Lumen: chalk on slate. One accent ("lit" gold) marks what you've mastered; sky blue marks what you can touch. */

@font-face { font-family: "Atkinson"; src: url("../fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("../fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("../fonts/atkinson-hyperlegible-latin-400-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  --slate: #1f2b38;
  --slate-2: #273646;
  --slate-3: #33465a;
  --chalk: #eef1ea;
  --chalk-dim: #a9b6c2;
  --chalk-faint: #6f8193;
  --lit: #f4cf6a;
  --sky: #7cc4e8;
  --right: #8fd19e;
  --wrong: #ec9a86;
  --line: rgba(238, 241, 234, 0.12);
  --display: "KaTeX_Main", "Latin Modern Roman", "Cambria", serif;
  --text: "Atkinson", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius-s: 6px;
  --radius-m: 14px;
  --gap: 1rem;
  --bar-h: 64px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --slate: #f2f4f6; --slate-2: #ffffff; --slate-3: #dfe5eb;
    --chalk: #1f2b38; --chalk-dim: #4c5d6e; --chalk-faint: #7d8c9b;
    --lit: #b8860b; --sky: #1f6f99; --right: #2f7d45; --wrong: #b4442d;
    --line: rgba(31, 43, 56, 0.14); color-scheme: light;
  }
}
:root[data-theme="light"] {
  --slate: #f2f4f6; --slate-2: #ffffff; --slate-3: #dfe5eb;
  --chalk: #1f2b38; --chalk-dim: #4c5d6e; --chalk-faint: #7d8c9b;
  --lit: #b8860b; --sky: #1f6f99; --right: #2f7d45; --wrong: #b4442d;
  --line: rgba(31, 43, 56, 0.14); color-scheme: light;
}

* { box-sizing: border-box; }
html { font-size: 17px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--slate); color: var(--chalk);
  font-family: var(--text); line-height: 1.55; font-feature-settings: "kern";
}
a { color: var(--sky); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- shell ---------- */
#app { max-width: 720px; margin: 0 auto; padding: 1.25rem 1.1rem calc(var(--bar-h) + 2rem); }
#app.wide { max-width: none; padding: 0 0 var(--bar-h); }

.tabbar {
  position: fixed; inset: auto 0 0 0; height: var(--bar-h); display: flex; justify-content: center;
  background: color-mix(in srgb, var(--slate) 92%, transparent); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); z-index: 20; padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 0 1 140px; display: grid; place-items: center; align-content: center; gap: 2px;
  color: var(--chalk-faint); text-decoration: none; font-size: 0.78rem;
}
.tabbar a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.tabbar a[aria-current="page"] { color: var(--chalk); }
.tabbar a[aria-current="page"] svg { stroke: var(--lit); }

/* ---------- type ---------- */
h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.2; margin: 0 0 0.5rem; letter-spacing: 0; }
h1 { font-size: 2.05rem; }
h2 { font-size: 1.5rem; margin-top: 1.75rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 0.8rem; }
.dim { color: var(--chalk-dim); }
.faint { color: var(--chalk-faint); font-size: 0.88rem; }
.prose { max-width: 62ch; }

/* ---------- top line on Today ---------- */
.topline { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: 1.5rem; }
.topline .stats { display: flex; gap: 1.1rem; color: var(--chalk-dim); font-size: 0.92rem; white-space: nowrap; }
.topline .stats b { color: var(--chalk); font-weight: 700; }
.streak b { color: var(--lit) !important; }

/* ---------- surfaces ---------- */
.panel { background: var(--slate-2); border-radius: var(--radius-m); padding: 1.1rem 1.15rem; margin-bottom: var(--gap); }
.panel.quiet { background: transparent; border: 1px solid var(--line); }
.next-up { padding: 1.4rem 1.3rem; }
.next-up h2 { margin-top: 0.15rem; font-size: 1.75rem; }
.strand-name { color: var(--chalk-faint); font-size: 0.85rem; }

.row { display: flex; align-items: center; gap: 0.75rem; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 0.6rem; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list a, .list button.item {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; width: 100%;
  padding: 0.8rem 0.1rem; color: var(--chalk); text-decoration: none; background: none; border: 0; text-align: left; cursor: pointer;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; min-height: 46px;
  padding: 0.6rem 1.15rem; border-radius: 999px; border: 1px solid var(--line); background: transparent;
  cursor: pointer; text-decoration: none; color: var(--chalk); font-weight: 700;
}
.btn.primary { background: var(--chalk); color: var(--slate); border-color: var(--chalk); }
.btn.lit { background: var(--lit); color: #1f2b38; border-color: var(--lit); }
.btn.small { min-height: 36px; padding: 0.35rem 0.85rem; font-size: 0.9rem; font-weight: 400; }
.btn.link { border: 0; color: var(--sky); padding-inline: 0.2rem; font-weight: 400; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }

/* ---------- progress ---------- */
.meter { height: 6px; background: var(--slate-3); border-radius: 3px; overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--lit); border-radius: 3px; transition: width 400ms ease; }
.steps-dots { display: flex; gap: 6px; margin: 0.25rem 0 1.25rem; }
.steps-dots span { flex: 1; height: 4px; border-radius: 2px; background: var(--slate-3); }
.steps-dots span.on { background: var(--chalk); }

/* ---------- lesson & problems ---------- */
.lesson-head { margin-bottom: 0.25rem; }
.problem { font-size: 1.12rem; margin: 0.5rem 0 1rem; }
.problem .katex-display { margin: 0.6rem 0; }
.choices { display: grid; gap: 0.55rem; margin-bottom: 0.5rem; }
.choice {
  text-align: left; padding: 0.8rem 1rem; border-radius: var(--radius-s); border: 1px solid var(--line);
  background: var(--slate-2); cursor: pointer; min-height: 48px;
}
.choice[aria-pressed="true"] { border-color: var(--sky); box-shadow: inset 0 0 0 1px var(--sky); }

.answer-box { display: grid; gap: 0.45rem; }
.answer-box input {
  width: 100%; padding: 0.8rem 0.95rem; border-radius: var(--radius-s); border: 1px solid var(--slate-3);
  background: var(--slate-2); font-size: 1.1rem; min-height: 52px;
}
.answer-box input:focus { border-color: var(--sky); outline: none; box-shadow: 0 0 0 1px var(--sky); }
.preview { min-height: 1.8rem; color: var(--chalk-dim); font-size: 1.05rem; }
.keypad { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0.35rem; margin-top: 0.15rem; }
.keypad button {
  min-height: 42px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--slate-2); cursor: pointer;
}

.feedback { border-left: 3px solid var(--line); padding: 0.4rem 0 0.4rem 0.9rem; margin: 1rem 0; }
.feedback.right { border-color: var(--right); }
.feedback.wrong { border-color: var(--wrong); }
.feedback .verdict { font-weight: 700; margin-bottom: 0.2rem; }
.feedback.right .verdict { color: var(--right); }
.feedback.wrong .verdict { color: var(--wrong); }

.solution { list-style: none; padding: 0; margin: 0.75rem 0 0; counter-reset: step; }
.solution li { display: grid; grid-template-columns: 1.6rem 1fr; gap: 0.2rem 0.6rem; padding: 0.55rem 0; border-top: 1px solid var(--line); }
.solution li::before { counter-increment: step; content: counter(step); color: var(--chalk-faint); font-size: 0.85rem; padding-top: 0.25rem; }
.solution .why { grid-column: 2; color: var(--chalk-dim); font-size: 0.92rem; }
.solution .math { overflow-x: auto; }
.solution li.hidden-step .math { filter: blur(6px); user-select: none; }

.hint { background: color-mix(in srgb, var(--sky) 10%, transparent); border-radius: var(--radius-s); padding: 0.6rem 0.85rem; margin: 0.5rem 0; }

.story { font-family: var(--display); font-size: 1.15rem; line-height: 1.5; }
.code-tie { border-left: 3px solid var(--sky); padding-left: 0.9rem; }
.code-tie code, code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.9em; background: var(--slate-3); padding: 0.05em 0.35em; border-radius: 4px; }

/* ---------- visuals ---------- */
.visual { margin: 0.75rem 0 1rem; }
.visual > svg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.visual .control { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.4rem; font-size: 0.92rem; color: var(--chalk-dim); }
.visual input[type="range"] { flex: 1; accent-color: var(--lit); min-height: 32px; }
.visual .caption { color: var(--chalk-dim); font-size: 0.9rem; margin-top: 0.3rem; }
svg .axis { stroke: var(--chalk-faint); stroke-width: 1; fill: none; }
svg .grid { stroke: var(--line); stroke-width: 1; }
svg .curve { fill: none; stroke: var(--chalk); stroke-width: 2.4; }
svg .curve.c1 { stroke: var(--sky); }
svg .curve.c2 { stroke: var(--lit); }
svg .curve.dashed { stroke: var(--chalk-faint); stroke-dasharray: 5 5; stroke-width: 1.6; }
svg .accent { stroke: var(--lit); fill: none; stroke-width: 2.2; }
svg .accent-fill { fill: var(--lit); fill-opacity: 0.22; stroke: var(--lit); stroke-width: 1; }
svg .sky-fill { fill: var(--sky); fill-opacity: 0.18; stroke: var(--sky); stroke-width: 1; }
svg .dot { fill: var(--lit); }
svg .hole { fill: var(--slate); stroke: var(--chalk); stroke-width: 2; }
svg text { fill: var(--chalk-dim); font-family: var(--text); font-size: 13px; }
svg text.big { fill: var(--chalk); font-size: 18px; font-family: var(--display); }
svg .box { fill: var(--slate-2); stroke: var(--chalk-faint); stroke-width: 1; }

/* ---------- constellation map ---------- */
.map-wrap { position: relative; height: calc(100dvh - var(--bar-h)); overflow: hidden; touch-action: none; }
.map-canvas > svg { width: 100%; height: 100%; display: block; cursor: grab; }
.map-canvas > svg.dragging { cursor: grabbing; }
.map-head { position: absolute; top: 0; left: 0; right: 0; padding: 1rem 1.1rem; pointer-events: none;
  background: linear-gradient(var(--slate), transparent); }
.map-head > * { pointer-events: auto; }
.map-head h1 { font-size: 1.6rem; }
.map-head .btn { white-space: nowrap; }
.map-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: 0.85rem; color: var(--chalk-dim); }
.map-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 0.35rem; vertical-align: -1px; }
.edge { stroke: var(--chalk); stroke-opacity: 0.09; stroke-width: 1; fill: none; }
.edge.on-path { stroke-opacity: 0.22; }
.edge.lit { stroke: var(--lit); stroke-opacity: 0.35; }
.star { cursor: pointer; outline: none; }
.star:focus-visible circle.core { stroke: var(--sky); stroke-width: 3; }
.star circle.core { fill: var(--chalk-faint); }
.star.m1 circle.core { fill: var(--chalk-dim); }
.star.m2 circle.core, .star.m3 circle.core, .star.m4 circle.core { fill: var(--lit); }
.star circle.halo { fill: var(--lit); opacity: 0; }
.star.m3 circle.halo { opacity: 0.18; }
.star.m4 circle.halo { opacity: 0.32; }
.star.frontier circle.ring { fill: none; stroke: var(--sky); stroke-width: 1.5; animation: pulse 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.star.due circle.ring { fill: none; stroke: var(--wrong); stroke-width: 1.3; stroke-dasharray: 2 3; }
.star text { fill: var(--chalk-dim); font-size: 11px; pointer-events: none; }
.star.m2 text, .star.m3 text, .star.m4 text, .star.frontier text { fill: var(--chalk); }
.strand-label { fill: var(--chalk-faint); font-family: var(--display); font-size: 15px; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 0.9; } 50% { transform: scale(1.35); opacity: 0.35; } }

.sheet {
  position: fixed; left: 0; right: 0; bottom: var(--bar-h); max-height: 70dvh; overflow-y: auto; z-index: 15;
  background: var(--slate-2); border-radius: var(--radius-m) var(--radius-m) 0 0; padding: 1.1rem 1.15rem 1.4rem;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35); max-width: 720px; margin: 0 auto;
}

/* ---------- tutor drawer ---------- */
.lesson-head .row.between { align-items: center; }
.lesson-head .btn.small { flex: 0 0 auto; }
.drawer {
  position: fixed; inset: auto 0 0 0; height: min(78dvh, 640px); background: var(--slate-2); z-index: 30;
  border-radius: var(--radius-m) var(--radius-m) 0 0; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto;
  box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.45); transform: translateY(105%); visibility: hidden;
  transition: transform 260ms ease, visibility 0s linear 260ms;
}
.drawer.open { transform: none; visibility: visible; transition: transform 260ms ease; }
.drawer header { display: flex; justify-content: space-between; align-items: center; padding: 0.85rem 1.1rem; border-bottom: 1px solid var(--line); }
.drawer .msgs { flex: 1; overflow-y: auto; padding: 0.9rem 1.1rem; }
.drawer .msg { margin-bottom: 0.9rem; max-width: 62ch; }
.drawer .msg.user { color: var(--chalk-dim); border-left: 2px solid var(--slate-3); padding-left: 0.7rem; }
.drawer .quick { display: flex; gap: 0.4rem; overflow-x: auto; padding: 0 1.1rem 0.5rem; scrollbar-width: none; }
.drawer .quick .btn { flex: 0 0 auto; white-space: nowrap; }
.drawer form { display: flex; gap: 0.5rem; padding: 0.6rem 1.1rem calc(0.8rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.drawer form input { flex: 1; padding: 0.7rem 0.85rem; border-radius: 999px; border: 1px solid var(--slate-3); background: var(--slate); }
.provider-tag { font-size: 0.8rem; color: var(--chalk-faint); }

/* ---------- toasts ---------- */
.toasts { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 40; display: grid; gap: 0.5rem; width: min(92vw, 420px); }
.toast { background: var(--chalk); color: var(--slate); padding: 0.7rem 1rem; border-radius: var(--radius-s); font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.toast.lit { background: var(--lit); color: #1f2b38; }

/* ---------- forms ---------- */
label.field { display: grid; gap: 0.3rem; margin-bottom: 0.9rem; }
label.field span { color: var(--chalk-dim); font-size: 0.92rem; }
input[type="text"], input[type="password"], input[type="url"], select, textarea {
  padding: 0.7rem 0.85rem; border-radius: var(--radius-s); border: 1px solid var(--slate-3); background: var(--slate); width: 100%;
}
.segmented { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.4rem; }
.segmented button { padding: 0.65rem; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--slate); cursor: pointer; }
.segmented button[aria-pressed="true"] { border-color: var(--lit); color: var(--lit); }
.notice { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0.75rem 0.9rem; color: var(--chalk-dim); font-size: 0.93rem; }
.error-text { color: var(--wrong); }

.empty { text-align: center; padding: 3rem 1rem; color: var(--chalk-dim); }
.spinner { width: 22px; height: 22px; border: 2px solid var(--slate-3); border-top-color: var(--chalk); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 2rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 900px) {
  #app { padding-top: 2.5rem; }
  h1 { font-size: 2.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
