/* Gradient — visual language shared with the Ai_Engineering app (AETheme.swift):
   dark-first navy canvas with an engineering grid and aurora glow, glass surfaces,
   rounded system type, mono eyebrows, and five accents: signal, azure, violet, coral, amber. */

:root {
  /* Accents (AEColor) */
  --signal: #61fac4;
  --azure: #4fc2ff;
  --violet: #9c7aff;
  --coral: #ff736b;
  --amber: #ffb84a;
  /* Readable accent text (bright in dark mode) */
  --t-signal: #61fac4;
  --t-azure: #4fc2ff;
  --t-violet: #9c7aff;
  --t-coral: #ff736b;
  --t-amber: #ffb84a;

  /* Neutrals (dark) */
  --canvas: #05060d;
  --canvas-raised: #090c16;
  --surface: #0e121d;
  --surface-elevated: #131826;
  --glass: rgba(19, 24, 38, 0.62);
  --glass-strong: rgba(19, 24, 38, 0.86);
  --text-1: #f2f7ff;
  --text-2: #a2afc7;
  --text-3: #6b7993;
  --text-4: #48536a;
  --stroke: rgba(255, 255, 255, 0.105);
  --stroke-strong: rgba(255, 255, 255, 0.19);
  --stroke-hi: rgba(255, 255, 255, 0.18);
  --divider: rgba(255, 255, 255, 0.075);
  --subtle-fill: rgba(255, 255, 255, 0.055);
  --input-fill: rgba(0, 0, 0, 0.22);
  --rail-fill: rgba(0, 0, 0, 0.10);
  --shadow: rgba(0, 0, 0, 0.52);
  --grid-line: rgba(255, 255, 255, 0.035);
  --grid-major: rgba(255, 255, 255, 0.065);
  --on-signal: #03140e;
  --code-bg: rgba(0, 0, 0, 0.30);
  --code-ink: #dfe7f5;
  --hl-keyword: #b59cff;
  --hl-string: #7ee8b8;
  --hl-number: #ffb84a;
  --hl-comment: #6b7993;
  --hl-builtin: #4fc2ff;
  --hl-def: #ff9b8f;
  --marker: rgba(255, 184, 74, 0.16);
  --marker-strong: #ffb84a;

  --grad-signal: linear-gradient(135deg, #61fac4, #4fc2ff);
  --grad-spectral: linear-gradient(90deg, #61fac4, #4fc2ff, #9c7aff);
  --grad-active: linear-gradient(90deg, #f0742c, #f5933f);

  --font-ui: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-pill: 999px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --sidebar-w: 248px;
  --topbar-h: 0px;

  /* Aliases kept for inline styles in scripts */
  --ink: var(--text-1);
  --ink-2: var(--text-2);
  --ink-3: var(--text-3);
  --ink-4: var(--text-4);
  --paper-sunk: var(--subtle-fill);
  --rule-strong: var(--stroke-strong);
  --font-read: var(--font-ui);
  --signal-soft: rgba(97, 250, 196, 0.10);
  --signal-line: rgba(97, 250, 196, 0.38);
  --redpen: var(--t-coral);
  --redpen-soft: rgba(255, 115, 107, 0.10);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --t-signal: #006e4f;
  --t-azure: #0063ab;
  --t-violet: #573bb8;
  --t-coral: #b82626;
  --t-amber: #8a4f00;
  --canvas: #f4f7fc;
  --canvas-raised: #ffffff;
  --surface: #fbfcff;
  --surface-elevated: #ffffff;
  --glass: rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.92);
  --text-1: #0e121d;
  --text-2: #4f5c74;
  --text-3: #79859a;
  --text-4: #a7b0bf;
  --stroke: rgba(20, 31, 54, 0.105);
  --stroke-strong: rgba(20, 31, 54, 0.19);
  --stroke-hi: rgba(75, 0, 130, 0.11);
  --divider: rgba(20, 31, 54, 0.10);
  --subtle-fill: rgba(20, 31, 54, 0.055);
  --input-fill: rgba(255, 255, 255, 0.88);
  --rail-fill: rgba(255, 255, 255, 0.36);
  --shadow: rgba(75, 0, 130, 0.13);
  --grid-line: rgba(75, 0, 130, 0.035);
  --grid-major: rgba(75, 0, 130, 0.06);
  --code-bg: rgba(20, 31, 54, 0.05);
  --code-ink: #1b2233;
  --hl-keyword: #6a3fc4;
  --hl-string: #00744f;
  --hl-number: #9a5a00;
  --hl-comment: #8590a3;
  --hl-builtin: #0063ab;
  --hl-def: #b0352b;
  --marker: rgba(255, 184, 74, 0.24);
  --marker-strong: #b36b00;
  --signal-soft: rgba(0, 150, 105, 0.09);
  --signal-line: rgba(0, 130, 95, 0.35);
  --redpen-soft: rgba(184, 38, 38, 0.07);
  color-scheme: light;
}

/* Phase / category accents: set --acc and --acc-text on any element */
.acc-signal { --acc: var(--signal); --acc-text: var(--t-signal); }
.acc-azure { --acc: var(--azure); --acc-text: var(--t-azure); }
.acc-violet { --acc: var(--violet); --acc-text: var(--t-violet); }
.acc-coral { --acc: var(--coral); --acc-text: var(--t-coral); }
.acc-amber { --acc: var(--amber); --acc-text: var(--t-amber); }

/* ── Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--text-1);
  font: 400 15px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* Frontier background: aurora glow + engineering grid (AEFrontierBackground) */
body::before, body::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; }
body::before {
  background:
    radial-gradient(60vw 60vw at 92% -12%, rgba(156, 122, 255, 0.16), rgba(156, 122, 255, 0.05) 40%, transparent 70%),
    radial-gradient(52vw 52vw at -8% 108%, rgba(79, 194, 255, 0.13), rgba(79, 194, 255, 0.04) 40%, transparent 70%);
}
body::after {
  background-image:
    linear-gradient(var(--grid-major) 0.75px, transparent 0.75px),
    linear-gradient(90deg, var(--grid-major) 0.75px, transparent 0.75px),
    linear-gradient(var(--grid-line) 0.5px, transparent 0.5px),
    linear-gradient(90deg, var(--grid-line) 0.5px, transparent 0.5px);
  background-size: 128px 128px, 128px 128px, 32px 32px, 32px 32px;
  -webkit-mask-image: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.9) 35%, rgba(0, 0, 0, 0.9) 65%, transparent);
  mask-image: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.9) 35%, rgba(0, 0, 0, 0.9) 65%, transparent);
}
:root[data-theme="light"] body::before {
  background:
    radial-gradient(60vw 60vw at 92% -12%, rgba(156, 122, 255, 0.12), transparent 65%),
    radial-gradient(52vw 52vw at -8% 108%, rgba(79, 194, 255, 0.12), transparent 65%);
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--t-azure); outline-offset: 2px; border-radius: 6px; }
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* Mono uppercase eyebrow, colored by accent */
.eyebrow {
  font: 700 12px/1.3 var(--font-mono);
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--acc-text, var(--t-signal));
  display: inline-flex; align-items: center; gap: 8px;
}
.eyebrow.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.eyebrow.quiet { color: var(--text-3); }

/* Glass surface (aeGlassSurface) */
.glass {
  background:
    linear-gradient(var(--glass), var(--glass)) padding-box,
    linear-gradient(135deg, var(--stroke-hi), var(--stroke)) border-box;
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  backdrop-filter: blur(18px) saturate(1.3);
}

/* ── Buttons & chips ──────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px;
  border: 1px solid var(--stroke-strong); border-radius: var(--r-pill);
  background: var(--subtle-fill); color: var(--text-1);
  font-weight: 600; font-size: 14.5px; white-space: nowrap; text-decoration: none;
  transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), transform 100ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
.btn:hover { background: rgba(255, 255, 255, 0.09); border-color: var(--stroke-hi); }
:root[data-theme="light"] .btn:hover { background: rgba(20, 31, 54, 0.08); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn.primary {
  background: var(--grad-signal); border-color: transparent; color: var(--on-signal);
  box-shadow: 0 0 0 1px rgba(97, 250, 196, 0.25), 0 6px 22px rgba(97, 250, 196, 0.18);
}
.btn.primary:hover { filter: brightness(1.06); box-shadow: 0 0 0 1px rgba(97, 250, 196, 0.35), 0 8px 28px rgba(97, 250, 196, 0.26); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.quiet:hover { background: var(--subtle-fill); color: var(--text-1); }
.btn.small { height: 32px; padding: 0 13px; font-size: 13px; }
.btn.large { height: 48px; padding: 0 24px; font-size: 16px; }
.btn kbd { font-family: var(--font-mono); font-size: 11px; opacity: 0.7; }
.linkish { background: none; border: 0; padding: 0; color: var(--t-signal); font-weight: 600; text-decoration: none; }
.linkish:hover { text-decoration: underline; text-underline-offset: 3px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  border-radius: var(--r-pill); background: var(--subtle-fill); border: 1px solid var(--stroke);
  color: var(--text-2); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--grad-signal); color: var(--on-signal); font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.icon-btn {
  width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--stroke); background: var(--subtle-fill); border-radius: 50%; color: var(--text-2);
}
.icon-btn:hover { color: var(--text-1); border-color: var(--stroke-strong); }
.icon-btn svg { width: 18px; height: 18px; }

/* ── App shell: sidebar + content ─────────────────────────── */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 20;
  display: flex; flex-direction: column; gap: 22px;
  padding: 22px 14px 16px;
  background: color-mix(in srgb, var(--canvas-raised) 82%, transparent);
  border-right: 1px solid var(--divider);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; text-decoration: none; }
.brand .tile {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: radial-gradient(circle at 30% 25%, rgba(156, 122, 255, 0.55), rgba(79, 194, 255, 0.18) 55%, rgba(5, 6, 13, 0.9));
  border: 1px solid var(--stroke-strong); color: #fff;
  box-shadow: 0 0 18px rgba(156, 122, 255, 0.22);
}
.brand .tile svg { width: 22px; height: 22px; }
.brand .name { font: 700 14.5px/1.1 var(--font-mono); letter-spacing: 0.06em; color: var(--text-1); }
.brand .tag { font: 600 9.5px/1.4 var(--font-mono); letter-spacing: 0.16em; color: var(--text-3); margin-top: 3px; }
.nav { display: grid; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  height: 46px; padding: 0 14px; border-radius: 12px;
  text-decoration: none; color: var(--text-1); font-weight: 600; font-size: 16px;
  transition: background-color 140ms var(--ease-out);
}
.nav a svg { width: 20px; height: 20px; flex: none; }
.nav a:hover { background: var(--subtle-fill); }
.nav a[aria-current="page"] { background: var(--grad-active); color: #fff; box-shadow: 0 6px 20px rgba(240, 116, 44, 0.28); }
.nav a .badge { margin-left: auto; }
.nav a[aria-current="page"] .badge { background: rgba(255, 255, 255, 0.92); color: #a2430d; }
.sidebar .spacer { flex: 1; }
.path-card { padding: 14px; display: grid; gap: 12px; border-radius: 18px; }
.path-card .who { display: flex; align-items: center; gap: 10px; }
.path-card .avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--grad-signal); color: var(--on-signal); font: 800 12px var(--font-ui); }
.path-card .who .t { font-weight: 700; font-size: 14px; line-height: 1.25; }
.path-card .who .s { color: var(--text-3); font-size: 12.5px; }
.path-card .streak { margin-left: auto; display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 14px; color: var(--t-amber); }
.path-card .streak svg { width: 16px; height: 16px; }
.path-card .loss-box { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; padding: 10px 12px; border-radius: 12px; background: var(--rail-fill); border: 1px solid var(--stroke); text-decoration: none; }
.path-card .loss-box .k { font: 700 10.5px var(--font-mono); letter-spacing: 0.14em; color: var(--t-signal); }
.path-card .loss-box .v { font: 700 18px var(--font-mono); color: var(--text-1); font-variant-numeric: tabular-nums; }
.path-card .loss-box .n { grid-column: 1 / -1; color: var(--text-3); font-size: 12px; }
.meter { height: 6px; border-radius: 3px; background: var(--subtle-fill); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--signal), #4fe0d8); box-shadow: 0 0 10px rgba(97, 250, 196, 0.45); }
.path-card .today-line { color: var(--text-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.sidebar-foot .ver { font: 600 10px var(--font-mono); letter-spacing: 0.14em; color: var(--text-4); }
.content { min-width: 0; position: relative; }

/* ── Page frame ───────────────────────────────────────────── */
.page { max-width: 1180px; margin: 0 auto; padding: 44px 40px 96px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; flex-wrap: wrap; }
.page-head h1 { margin-top: 10px; font-size: 46px; line-height: 1.06; letter-spacing: -0.8px; }
.page-head .sub { margin-top: 10px; color: var(--text-2); font-size: 18px; max-width: 62ch; }
.metric-pills { display: flex; gap: 10px; flex-wrap: wrap; }
.metric-pill { display: flex; align-items: center; gap: 10px; padding: 10px 16px 10px 12px; border-radius: 18px; }
.metric-pill svg { width: 18px; height: 18px; flex: none; }
.metric-pill .v { font-weight: 800; font-size: 18px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric-pill .l { color: var(--text-3); font-size: 12.5px; }
.loading { padding: 80px 24px; text-align: center; color: var(--text-3); }
.section-title { margin: 44px 0 16px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-title h2 { font-size: 24px; letter-spacing: -0.35px; }

/* ── Today ────────────────────────────────────────────────── */
.hero-card { margin-top: 34px; padding: 34px 36px 30px; display: grid; gap: 26px; position: relative; overflow: hidden; }
.hero-card::before { content: ""; position: absolute; inset: 0; background: radial-gradient(80% 120% at 0% 0%, color-mix(in srgb, var(--acc, var(--signal)) 9%, transparent), transparent 60%); pointer-events: none; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr); gap: 32px; align-items: center; position: relative; }
.hero-card h2 { margin-top: 14px; font-size: 34px; line-height: 1.12; letter-spacing: -0.8px; }
.hero-card .kicker { margin-top: 12px; color: var(--t-violet); font-weight: 700; font-size: 17px; }
.hero-card .summary { margin-top: 8px; color: var(--text-2); font-size: 17px; line-height: 1.55; max-width: 56ch; }
.hero-card ul.objectives { margin: 18px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; max-width: 58ch; }
.hero-card ul.objectives li { display: grid; grid-template-columns: 18px 1fr; gap: 10px; color: var(--text-2); font-size: 15px; }
.hero-card ul.objectives li::before { content: ""; width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 8px rgba(97, 250, 196, 0.6); }
.hero-card .actions { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.viz-frame { position: relative; padding: 14px 16px 12px; border-radius: var(--r-md); background: var(--rail-fill); border: 1px solid var(--stroke); }
.viz-frame::before, .viz-frame::after { content: ""; position: absolute; width: 16px; height: 16px; border: 1.5px solid var(--stroke-strong); }
.viz-frame::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.viz-frame::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }
.viz-frame .cap { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.viz-frame .cap .v { font: 700 22px var(--font-mono); font-variant-numeric: tabular-nums; }
.viz-frame .note { margin-top: 6px; font-size: 12px; color: var(--text-3); line-height: 1.45; }
.loss-chart { display: block; width: 100%; height: 130px; }
.loss-chart .grid { stroke: var(--grid-major); }
.loss-chart .curve { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; filter: drop-shadow(0 0 6px rgba(97, 250, 196, 0.45)); }
.loss-chart .dot { fill: var(--signal); filter: drop-shadow(0 0 6px rgba(97, 250, 196, 0.8)); }
.loss-chart text { font: 10px var(--font-mono); fill: var(--text-3); }

.path-progress { position: relative; display: grid; gap: 10px; }
.path-progress .row { display: flex; justify-content: space-between; align-items: baseline; }
.path-progress .pct { font: 800 22px var(--font-mono); color: var(--t-signal); font-variant-numeric: tabular-nums; }
.track-dots { position: relative; height: 14px; }
.track-dots .rail { position: absolute; left: 0; right: 0; top: 6px; height: 2px; background: var(--stroke-strong); border-radius: 1px; }
.track-dots .fill { position: absolute; left: 0; top: 6px; height: 2px; background: var(--grad-spectral); border-radius: 1px; box-shadow: 0 0 8px rgba(97, 250, 196, 0.5); }
.track-dots i { position: absolute; top: 2px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--canvas); border: 1.5px solid var(--text-3); }
.track-dots i.done { background: var(--signal); border-color: var(--signal); box-shadow: 0 0 8px rgba(97, 250, 196, 0.7); }
.path-progress .foot { display: flex; justify-content: space-between; color: var(--text-3); font-size: 14px; }
.stat-chips { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; position: relative; }
.stat-chip { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; background: color-mix(in srgb, var(--acc, var(--signal)) 7%, var(--rail-fill)); border: 1px solid var(--stroke); text-decoration: none; }
.stat-chip svg { width: 18px; height: 18px; color: var(--acc-text); flex: none; }
.stat-chip .l { color: var(--text-2); font-weight: 600; }
.stat-chip .v { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }

.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.course-card {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 12px; padding: 24px; text-decoration: none;
  transition: transform 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}
.course-card::before { content: ""; position: absolute; inset: 0; background: linear-gradient(160deg, color-mix(in srgb, var(--acc) 10%, transparent), transparent 55%); pointer-events: none; }
.course-card:hover { transform: translateY(-2px); box-shadow: 0 18px 40px var(--shadow); }
.course-card > * { position: relative; }
.course-card .top { display: flex; justify-content: space-between; align-items: flex-start; }
.icon-tile { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--acc) 16%, transparent); border: 1px solid color-mix(in srgb, var(--acc) 34%, transparent); color: var(--acc-text); }
.icon-tile svg { width: 24px; height: 24px; }
.level { font: 700 11px var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.level::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--acc); }
.course-card h3 { font-size: 22px; line-height: 1.2; letter-spacing: -0.35px; }
.course-card p { color: var(--text-2); font-size: 15px; line-height: 1.5; }
.course-card .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.course-card .foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--divider); display: flex; align-items: center; gap: 18px; color: var(--text-3); font-size: 14px; }
.course-card .foot .arrow { margin-left: auto; color: var(--acc-text); font-size: 18px; }
.course-card .bar { height: 4px; border-radius: 2px; background: var(--subtle-fill); overflow: hidden; }
.course-card .bar span { display: block; height: 100%; background: var(--acc); }
.course-card.current { box-shadow: 0 0 0 1px color-mix(in srgb, var(--acc) 55%, transparent), 0 0 30px color-mix(in srgb, var(--acc) 14%, transparent); }
.queue { display: grid; gap: 10px; }
.queue-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 18px; border-radius: var(--r-md); text-decoration: none; transition: border-color 140ms var(--ease-out); }
.queue-row:hover { border-color: var(--stroke-strong); }
.queue-row .t { font-weight: 700; font-size: 16px; }
.queue-row .s { color: var(--text-3); font-size: 14px; }
.queue-row .n { font: 700 11px var(--font-mono); letter-spacing: 0.12em; color: var(--acc-text); }
.today-cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.side-card { padding: 22px; display: grid; gap: 12px; }
.side-card h3 { font-size: 18px; }
.side-card .count { font: 800 34px var(--font-mono); letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.side-card .muted { font-size: 14px; }

/* ── Map ──────────────────────────────────────────────────── */
.map-page { display: grid; grid-template-rows: auto 1fr; height: 100vh; }
.map-head { display: flex; align-items: flex-end; gap: 20px 32px; flex-wrap: wrap; padding: 28px 32px 18px; border-bottom: 1px solid var(--divider); }
.map-head h1 { margin-top: 8px; font-size: 34px; letter-spacing: -0.8px; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--text-2); padding-bottom: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.map-body { position: relative; display: grid; grid-template-columns: 1fr auto; min-height: 0; }
.map-canvas { position: relative; overflow: auto; min-height: 0; }
.map-inner { position: relative; }
.map-edges { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.map-edges path { fill: none; stroke: var(--text-3); stroke-width: 1; opacity: 0.35; }
.map-edges path.hot { stroke: var(--signal); stroke-width: 1.75; opacity: 1; filter: drop-shadow(0 0 4px rgba(97, 250, 196, 0.55)); }
.map-edges path.hot-up { stroke: var(--azure); stroke-width: 1.75; opacity: 1; filter: drop-shadow(0 0 4px rgba(79, 194, 255, 0.5)); }
.phase-band { position: absolute; top: 0; bottom: 0; border-right: 1px dashed var(--divider); }
.phase-band header { position: sticky; top: 0; padding: 16px 18px 12px; z-index: 2; background: linear-gradient(180deg, var(--canvas) 70%, transparent); }
.phase-band header .n { font: 700 11px var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--acc-text); }
.phase-band header .t { font-weight: 800; font-size: 17px; letter-spacing: -0.2px; margin-top: 2px; }
.phase-band header .c { font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.track-label { position: absolute; font: 700 10.5px var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); }
.node {
  position: absolute; width: 168px; min-height: 44px;
  display: flex; align-items: center; gap: 9px;
  padding: 7px 11px; border-radius: 12px;
  border: 1px solid var(--stroke-strong); background: var(--glass-strong);
  font-size: 12.5px; font-weight: 600; line-height: 1.3; text-align: left; color: var(--text-2);
  transition: border-color 140ms var(--ease-out), background-color 140ms var(--ease-out), box-shadow 140ms var(--ease-out);
}
.node:hover { border-color: var(--text-3); color: var(--text-1); }
.node .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--text-4); }
.node.locked { color: var(--text-3); border-style: dashed; border-color: var(--stroke-strong); background: color-mix(in srgb, var(--glass) 70%, transparent); }
.node.available { color: var(--text-1); border-color: rgba(97, 250, 196, 0.45); }
.node.available .dot { border-color: var(--signal); }
.node.learning { color: var(--text-1); border-color: rgba(79, 194, 255, 0.5); }
.node.learning .dot { border-color: var(--azure); background: linear-gradient(90deg, var(--azure) 50%, transparent 50%); }
.node.known { color: var(--text-1); background: color-mix(in srgb, var(--signal) 10%, var(--glass-strong)); border-color: rgba(97, 250, 196, 0.45); }
.node.known .dot { background: var(--signal); border-color: var(--signal); box-shadow: 0 0 8px rgba(97, 250, 196, 0.7); }
.node.tested .dot { background: repeating-linear-gradient(45deg, var(--signal) 0 2px, transparent 2px 4px); }
.node.selected { box-shadow: 0 0 0 2px var(--azure), 0 0 22px rgba(79, 194, 255, 0.3); }
.node.next { box-shadow: 0 0 0 2px var(--amber), 0 0 22px rgba(255, 184, 74, 0.28); }
.drawer {
  width: 380px; border-left: 1px solid var(--divider); background: color-mix(in srgb, var(--canvas-raised) 90%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  overflow-y: auto; padding: 24px; display: grid; gap: 16px; align-content: start;
}
.drawer h2 { font-size: 26px; line-height: 1.15; letter-spacing: -0.35px; }
.drawer .summary { font-size: 16px; color: var(--text-2); line-height: 1.5; }
.drawer .rel h3 { font: 700 11px var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.drawer .rel ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.drawer .rel button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; padding: 7px 10px; border-radius: 10px; color: var(--text-2); font-weight: 600; }
.drawer .rel button:hover { background: var(--subtle-fill); border-color: var(--stroke); color: var(--text-1); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: 700; background: var(--subtle-fill); border: 1px solid var(--stroke); color: var(--text-2); width: fit-content; }
.status-pill.known { background: var(--signal-soft); border-color: rgba(97, 250, 196, 0.35); color: var(--t-signal); }
.drawer .actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Placement ────────────────────────────────────────────── */
.narrow { max-width: 760px; margin: 0 auto; padding: 56px 32px 96px; }
.narrow > h1 { margin-top: 10px; font-size: 40px; line-height: 1.1; letter-spacing: -0.8px; }
.lede { margin-top: 14px; font-size: 18px; line-height: 1.55; color: var(--text-2); }
.ratings { margin-top: 32px; display: grid; gap: 10px; }
.rating-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 16px 18px; border-radius: var(--r-md); }
.rating-row .l { font-weight: 700; font-size: 16px; }
.rating-row .h { font-size: 13.5px; color: var(--text-3); }
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--r-pill); background: var(--rail-fill); border: 1px solid var(--stroke); }
.seg button { border: 0; background: transparent; padding: 0 12px; height: 32px; border-radius: var(--r-pill); font-size: 13px; font-weight: 600; color: var(--text-2); }
.seg button:hover { color: var(--text-1); background: var(--subtle-fill); }
.seg button[aria-pressed="true"] { background: var(--grad-signal); color: var(--on-signal); }
.progress-line { height: 6px; background: var(--subtle-fill); border-radius: 3px; overflow: hidden; margin-bottom: 28px; }
.progress-line span { display: block; height: 100%; background: var(--grad-spectral); transition: width 240ms var(--ease-out); box-shadow: 0 0 10px rgba(97, 250, 196, 0.5); }
.question { display: grid; gap: 18px; }
.question .qmeta { display: flex; justify-content: space-between; color: var(--text-3); font: 600 12px var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; }
.question .qtext { font-size: 22px; font-weight: 700; line-height: 1.35; letter-spacing: -0.2px; }
.question .qtext code, .option code { font-family: var(--font-mono); font-size: 0.86em; background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 6px; }
.options { display: grid; gap: 10px; }
.option {
  display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start;
  text-align: left; padding: 14px 16px; border-radius: var(--r-md);
  border: 1px solid var(--stroke-strong); background: var(--glass);
  font-size: 15.5px; line-height: 1.45;
  transition: border-color 140ms var(--ease-out), background-color 140ms var(--ease-out);
}
.option:hover:not(:disabled) { border-color: var(--t-azure); }
.option .k { font: 700 12px var(--font-mono); color: var(--text-2); width: 26px; height: 26px; border: 1px solid var(--stroke-strong); border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; }
.option.right { border-color: var(--signal); background: var(--signal-soft); }
.option.right .k { background: var(--signal); color: var(--on-signal); border-color: var(--signal); }
.option.wrong { border-color: var(--coral); background: var(--redpen-soft); }
.option.wrong .k { background: var(--coral); color: #210403; border-color: var(--coral); }
.option:disabled { cursor: default; }
.results-grid { margin-top: 28px; display: grid; gap: 12px; padding: 20px; }
.result-row { display: grid; grid-template-columns: 200px 1fr 70px; gap: 14px; align-items: center; font-size: 14px; font-weight: 600; }
.result-row .bar { height: 8px; border-radius: 4px; background: var(--subtle-fill); overflow: hidden; }
.result-row .bar span { display: block; height: 100%; background: var(--grad-signal); }

/* ── Lesson ───────────────────────────────────────────────── */
.lesson-shell { display: grid; grid-template-columns: minmax(0, 1fr) 400px; min-height: 100vh; }
.lesson-shell.tutor-closed { grid-template-columns: minmax(0, 1fr) 0; }
.lesson-main { min-width: 0; }
.lesson-head { max-width: 800px; margin: 0 auto; padding: 40px 36px 0; }
.crumbs { display: flex; gap: 8px; flex-wrap: wrap; font: 700 12px var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.crumbs a { text-decoration: none; color: var(--acc-text, var(--t-azure)); }
.crumbs a:hover { text-decoration: underline; text-underline-offset: 3px; }
.lesson-head h1 { margin-top: 12px; font-size: 42px; line-height: 1.08; letter-spacing: -0.8px; }
.lesson-head .meta { margin-top: 12px; display: flex; gap: 10px; color: var(--text-3); font-size: 14px; flex-wrap: wrap; align-items: center; }
.stages { margin-top: 26px; display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--r-pill); background: var(--rail-fill); border: 1px solid var(--stroke); }
.stage-tab {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 16px 0 8px; border-radius: var(--r-pill);
  border: 0; background: transparent; color: var(--text-2); font-weight: 700; font-size: 14px;
}
.stage-tab:hover { color: var(--text-1); }
.stage-tab .num { font: 700 11px var(--font-mono); width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--stroke-strong); display: inline-flex; align-items: center; justify-content: center; }
.stage-tab[aria-selected="true"] { background: var(--surface-elevated); color: var(--text-1); box-shadow: 0 0 0 1px var(--stroke-strong); }
.stage-tab.done .num { background: var(--signal); border-color: var(--signal); color: var(--on-signal); }
.lesson-body { max-width: 800px; margin: 0 auto; padding: 30px 36px 120px; }
.lesson-foot { margin-top: 44px; padding-top: 22px; border-top: 1px solid var(--divider); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.why { padding: 20px 22px; margin-bottom: 26px; border-radius: var(--r-md); position: relative; overflow: hidden; }
.why::before { content: ""; position: absolute; inset: 0; background: linear-gradient(120deg, rgba(97, 250, 196, 0.09), transparent 60%); pointer-events: none; }
.why > * { position: relative; }
.why .eyebrow { margin-bottom: 8px; }
.why .prose p { font-size: 16.5px; color: var(--text-1); }
.objective-list { margin: 0 0 30px; padding: 0; list-style: none; display: grid; gap: 8px; color: var(--text-2); font-size: 15.5px; }
.objective-list li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; }
.objective-list li::before { content: "→"; color: var(--t-signal); font-weight: 700; }

/* Reading prose */
.prose { font-size: 17px; line-height: 1.68; color: var(--text-1); }
.prose > * + * { margin-top: 1em; }
.prose h2 { font-size: 24px; line-height: 1.25; letter-spacing: -0.35px; margin-top: 1.9em; }
.prose h3 { font-size: 18px; margin-top: 1.5em; }
.prose h2 + *, .prose h3 + * { margin-top: 0.6em; }
.prose p, .prose li { color: color-mix(in srgb, var(--text-1) 88%, var(--text-2)); }
.prose strong { color: var(--text-1); font-weight: 700; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 0.4em; }
.prose li::marker { color: var(--t-signal); }
.prose code { font-family: var(--font-mono); font-size: 0.84em; background: var(--code-bg); border: 1px solid var(--divider); padding: 0.1em 0.38em; border-radius: 6px; }
.prose a { color: var(--t-azure); text-underline-offset: 3px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14.5px; border-radius: 12px; overflow: hidden; }
.prose th, .prose td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--divider); vertical-align: top; }
.prose th { font: 700 11.5px var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); border-bottom-color: var(--stroke-strong); }
.prose blockquote { --tint: var(--azure); margin: 1.3em 0; padding: 14px 18px; border-radius: 14px; background: color-mix(in srgb, var(--tint) 6%, var(--glass)); border: 1px solid color-mix(in srgb, var(--tint) 28%, transparent); font-size: 16px; }
.prose blockquote.callout-tip, .prose blockquote.callout-note { --tint: var(--signal); }
.prose blockquote.callout-marketers { --tint: var(--amber); }
.prose blockquote.callout-watch { --tint: var(--coral); }
.prose blockquote strong:first-child { color: color-mix(in srgb, var(--tint) 70%, var(--text-1)); }
.prose blockquote > * + * { margin-top: 0.6em; }
.prose pre { margin: 1.1em 0; }
.section { margin-top: 34px; }
.section:first-child { margin-top: 0; }

/* Code */
pre.code {
  margin: 0; padding: 14px 18px; overflow-x: auto;
  background: var(--code-bg); color: var(--code-ink);
  border-radius: 14px; border: 1px solid var(--stroke);
  font: 500 13.5px/1.65 var(--font-mono); tab-size: 4;
}
.tok-k { color: var(--hl-keyword); }
.tok-s { color: var(--hl-string); }
.tok-n { color: var(--hl-number); }
.tok-c { color: var(--hl-comment); font-style: italic; }
.tok-b { color: var(--hl-builtin); }
.tok-d { color: var(--hl-def); }

.cell { border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--stroke-strong); background: var(--surface); }
.cell .cell-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px 8px 16px; border-bottom: 1px solid var(--divider); background: var(--glass); }
.cell .cell-bar .lbl { font: 700 11px var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.cell .cell-bar .btns { display: flex; gap: 6px; }
.cell .output { border-top: 1px solid var(--divider); background: var(--rail-fill); }

.editor { position: relative; font: 500 13.5px/1.65 var(--font-mono); tab-size: 4; background: var(--code-bg); }
.editor .gutter { position: absolute; left: 0; top: 0; bottom: 0; width: 44px; padding: 14px 10px 14px 0; text-align: right; color: var(--text-4); font-variant-numeric: tabular-nums; user-select: none; border-right: 1px solid var(--divider); overflow: hidden; }
.editor .gutter div.err { color: var(--t-coral); font-weight: 700; }
.editor .scroller { position: relative; margin-left: 44px; overflow-x: auto; }
.editor pre, .editor textarea { margin: 0; padding: 14px 16px; border: 0; min-height: 100%; font: inherit; white-space: pre; word-wrap: normal; overflow-wrap: normal; letter-spacing: normal; }
.editor pre { pointer-events: none; color: var(--code-ink); }
.editor textarea { position: absolute; inset: 0; width: 100%; height: 100%; resize: none; overflow: hidden; background: transparent; color: transparent; caret-color: var(--signal); outline: none; }
.editor textarea::selection { background: rgba(79, 194, 255, 0.28); color: transparent; }
.editor:focus-within { box-shadow: inset 0 0 0 1px rgba(79, 194, 255, 0.45); }

.out { font: 500 13px/1.6 var(--font-mono); padding: 12px 16px; white-space: pre-wrap; word-break: break-word; max-height: 340px; overflow: auto; color: var(--text-1); }
.out:empty { display: none; }
.out .err { color: var(--t-coral); }
.out .note { color: var(--text-3); font-family: var(--font-ui); font-size: 12.5px; }
.out:has(.plot) { max-height: none; }
.out .plot { display: block; max-width: 100%; height: auto; margin: 10px 0 4px; border-radius: var(--r-sm); border: 1px solid var(--divider); }

/* Math: TeX source shows in mono until KaTeX loads, then KaTeX's own markup replaces it. */
.math:not([data-done]), .math-display:not([data-done]) { font-family: var(--font-mono); font-size: 0.92em; color: var(--text-2); }
.math-display { margin: 14px 0; padding: 10px 4px; overflow-x: auto; overflow-y: hidden; text-align: center; }
.katex { font-size: 1.06em; color: inherit; }
.katex-display { margin: 0; }
.out-label { font: 700 10.5px var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); padding: 10px 16px 0; }

/* Example and check blocks */
.example { padding: 22px; display: grid; gap: 14px; border-radius: var(--r-lg); }
.example > header .eyebrow { margin-bottom: 6px; }
.example > header h3 { font-size: 19px; letter-spacing: -0.2px; }
.example .after { border-top: 1px dashed var(--stroke-strong); padding-top: 14px; }
.check { padding: 22px; display: grid; gap: 14px; border-radius: var(--r-lg); }
.check .q { font-weight: 700; font-size: 16.5px; }
.check .explain, .quiz-feedback { font-size: 15px; color: var(--text-2); padding: 12px 14px; border-radius: 12px; background: var(--rail-fill); border: 1px solid var(--stroke); }
.widget-frame { border-radius: var(--r-lg); overflow: hidden; }
.widget-frame > header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--divider); }
.widget-frame > header .t { font-weight: 700; font-size: 14.5px; }
.widget-frame > header .k { font: 700 10.5px var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--t-violet); }
.caption { margin-top: 10px; font-size: 14px; color: var(--text-3); line-height: 1.5; }

/* Practice */
.exercise { display: grid; gap: 18px; }
.exercise .task { padding: 18px 20px; border-radius: var(--r-md); }
.exercise .toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.exercise .toolbar .spacer { flex: 1; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checks li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; font-size: 14.5px; line-height: 1.45; }
.checks li .m { width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; margin-top: 1px; }
.checks li.ok .m { background: var(--signal); color: var(--on-signal); }
.checks li.no .m { background: var(--coral); color: #210403; }
.checks li code { font-family: var(--font-mono); font-size: 12.5px; background: var(--code-bg); padding: 0 5px; border-radius: 5px; }
.hint { padding: 14px 16px; border-radius: 14px; border: 1px dashed var(--stroke-strong); font-size: 15px; background: var(--rail-fill); }
.hint .n { font: 700 10.5px var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--t-amber); margin-bottom: 6px; }
.hint pre { margin-top: 6px; }
.banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 16px 18px; border-radius: var(--r-md); border: 1px solid rgba(97, 250, 196, 0.38); background: var(--signal-soft); }
.banner .t { font-weight: 800; color: var(--t-signal); }
.banner.warn { border-color: rgba(255, 115, 107, 0.4); background: var(--redpen-soft); }
.banner.warn .t { color: var(--t-coral); }
details.solution summary { cursor: pointer; color: var(--text-3); font-size: 14px; font-weight: 600; }
details.solution[open] summary { margin-bottom: 10px; }

/* Quiz */
.quiz { display: grid; gap: 22px; }
.quiz-progress { display: flex; gap: 6px; }
.quiz-progress i { flex: 1; height: 6px; border-radius: 3px; background: var(--subtle-fill); }
.quiz-progress i.right { background: var(--signal); box-shadow: 0 0 8px rgba(97, 250, 196, 0.5); }
.quiz-progress i.partial { background: var(--amber); }
.quiz-progress i.wrong { background: var(--coral); }
.quiz-progress i.current { background: var(--text-3); }
.quiz textarea.answer, .quiz input.answer {
  width: 100%; border: 1px solid var(--stroke-strong); border-radius: 14px; background: var(--input-fill);
  padding: 12px 14px; font: 15px/1.5 var(--font-ui); resize: vertical;
}
.quiz textarea.answer.code, .quiz input.answer.code { font-family: var(--font-mono); font-size: 13.5px; }
.quiz textarea.answer:focus, .quiz input.answer:focus { outline: none; border-color: var(--t-azure); }
.score-card { display: grid; gap: 14px; padding: 28px; border-radius: var(--r-lg); }
.score-card .big { font: 800 52px var(--font-mono); letter-spacing: -2px; font-variant-numeric: tabular-nums; }
.score-card.pass .big { background: var(--grad-signal); -webkit-background-clip: text; background-clip: text; color: transparent; }
.score-card p { color: var(--text-2); font-size: 16px; }
.verdict { font-weight: 800; }
.verdict.correct { color: var(--t-signal); }
.verdict.partial { color: var(--t-amber); }
.verdict.incorrect { color: var(--t-coral); }
.panel { padding: 22px; border-radius: var(--r-lg); }
.panel h2 { font-size: 15px; font-weight: 700; color: var(--text-1); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.panel h2 .muted { font-weight: 500; font-size: 13px; }

/* Tutor */
.tutor {
  position: sticky; top: 0; height: 100vh;
  border-left: 1px solid var(--divider); background: color-mix(in srgb, var(--canvas-raised) 88%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  display: grid; grid-template-rows: auto 1fr auto; min-width: 0; overflow: hidden;
}
.tutor-closed .tutor { visibility: hidden; }
.tutor > header { display: flex; align-items: center; gap: 12px; padding: 18px 18px 14px; border-bottom: 1px solid var(--divider); }
.tutor .avatar-tile { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; flex: none; background: radial-gradient(circle at 30% 25%, rgba(156, 122, 255, 0.6), rgba(79, 194, 255, 0.25) 60%, transparent); border: 1px solid rgba(156, 122, 255, 0.45); color: #fff; }
.tutor .avatar-tile svg { width: 22px; height: 22px; }
.tutor > header .t { font: 700 12px var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--t-violet); }
.tutor > header .s { font-size: 14px; color: var(--text-2); font-weight: 600; }
.tutor > header .icon-btn { margin-left: auto; }
.tutor .log { overflow-y: auto; padding: 18px; display: grid; gap: 14px; align-content: start; }
.tutor .msg { font-size: 14.5px; line-height: 1.6; }
.tutor .msg.user { justify-self: end; max-width: 88%; background: rgba(79, 194, 255, 0.12); border: 1px solid rgba(79, 194, 255, 0.28); padding: 9px 14px; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; }
.tutor .msg.assistant { padding: 14px 16px; border-radius: 16px; background: var(--glass); border: 1px solid var(--stroke); }
.tutor .msg.assistant > * + * { margin-top: 0.6em; }
.tutor .msg.assistant pre.code { font-size: 12.5px; padding: 10px 12px; }
.tutor .msg.assistant code { font-family: var(--font-mono); font-size: 12.5px; background: var(--code-bg); padding: 0 5px; border-radius: 5px; }
.tutor .msg.assistant ul, .tutor .msg.assistant ol { padding-left: 1.2em; margin: 0; }
.tutor .msg.thinking { color: var(--text-3); font-size: 13.5px; }
.tutor .empty { color: var(--text-2); font-size: 14.5px; line-height: 1.55; padding: 16px; border-radius: 16px; background: var(--glass); border: 1px solid var(--stroke); }
.tutor .suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tutor .suggest button { border: 1px solid rgba(156, 122, 255, 0.4); background: transparent; border-radius: var(--r-pill); padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--text-1); }
.tutor .suggest button:hover { background: rgba(156, 122, 255, 0.12); }
.tutor form { border-top: 1px solid var(--divider); padding: 12px; display: grid; gap: 8px; }
.tutor .ask { display: flex; gap: 10px; align-items: flex-end; }
.tutor textarea { flex: 1; min-height: 52px; max-height: 180px; resize: none; border: 1px solid var(--stroke-strong); border-radius: 18px; background: var(--input-fill); padding: 13px 16px; font-size: 14.5px; line-height: 1.45; }
.tutor textarea:focus { outline: none; border-color: var(--t-azure); }
.tutor .send { width: 46px; height: 46px; border-radius: 50%; border: 0; flex: none; display: grid; place-items: center; background: var(--grad-signal); color: var(--on-signal); box-shadow: 0 4px 16px rgba(97, 250, 196, 0.25); }
.tutor .send:disabled { opacity: 0.4; }
.tutor .send svg { width: 20px; height: 20px; }
.tutor form .row { font-size: 12px; color: var(--text-3); padding-left: 4px; }
.tutor-toggle { position: fixed; right: 22px; bottom: 22px; z-index: 15; }
.tutor-toggle svg { width: 17px; height: 17px; }

/* Review */
.review-wrap { max-width: 680px; margin: 0 auto; padding: 56px 32px 96px; }
.flash { margin-top: 24px; min-height: 280px; display: grid; grid-template-rows: 1fr auto; overflow: hidden; border-radius: var(--r-lg); }
.flash .face { padding: 36px 32px; display: grid; gap: 18px; align-content: center; }
.flash .face .from { font: 700 11px var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--t-azure); }
.flash .front { font-size: 24px; font-weight: 700; line-height: 1.35; letter-spacing: -0.2px; }
.flash .back { border-top: 1px dashed var(--stroke-strong); padding-top: 18px; font-size: 18px; line-height: 1.55; color: var(--text-2); }
.flash .back code, .flash .front code { font-family: var(--font-mono); font-size: 0.82em; background: var(--code-bg); padding: 0.1em 0.38em; border-radius: 6px; }
.flash footer { border-top: 1px solid var(--divider); padding: 14px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.flash footer.single { grid-template-columns: 1fr; }
.flash footer .btn { height: 52px; flex-direction: column; gap: 0; line-height: 1.15; border-radius: 16px; }
.flash footer .btn small { font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.flash footer .btn.primary small { color: inherit; opacity: 0.75; }

/* Dialog */
dialog { border: 1px solid var(--stroke-strong); border-radius: var(--r-lg); background: var(--surface-elevated); color: var(--text-1); padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 30px 80px var(--shadow); }
dialog::backdrop { background: rgba(2, 3, 8, 0.6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog .d-head { padding: 22px 24px 0; display: flex; justify-content: space-between; align-items: center; }
dialog .d-head h2 { font-size: 22px; letter-spacing: -0.35px; }
dialog .d-body { padding: 18px 24px 24px; display: grid; gap: 16px; }
.setting { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; padding-bottom: 16px; border-bottom: 1px solid var(--divider); }
.setting:last-child { border-bottom: 0; padding-bottom: 0; }
.setting .l { font-weight: 700; }
.setting .h { font-size: 13.5px; color: var(--text-3); }
.switch { appearance: none; width: 44px; height: 26px; border-radius: 13px; background: var(--stroke-strong); position: relative; cursor: pointer; transition: background 150ms var(--ease-out); margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 150ms var(--ease-out); }
.switch:checked { background: var(--grad-signal); }
.switch:checked::after { transform: translateX(18px); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: var(--surface-elevated); border: 1px solid var(--stroke-strong); color: var(--text-1); padding: 12px 18px; border-radius: var(--r-pill); font-size: 14px; font-weight: 600; box-shadow: 0 12px 30px var(--shadow); animation: toast-in 180ms var(--ease-out); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } }

/* ── Widgets ──────────────────────────────────────────────── */
.widget-body { min-width: 0; }
.stepper { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
.stepper .src { background: var(--code-bg); border-right: 1px solid var(--divider); padding: 12px 0; font: 500 13px/1.75 var(--font-mono); overflow-x: auto; }
.stepper .src .ln { display: grid; grid-template-columns: 40px 1fr; padding-right: 12px; white-space: pre; position: relative; }
.stepper .src .ln .no { color: var(--text-4); text-align: right; padding-right: 12px; user-select: none; font-variant-numeric: tabular-nums; }
.stepper .src .ln.next { background: var(--marker); }
.stepper .src .ln.next .no { color: var(--t-amber); }
.stepper .src .ln.prev { background: rgba(97, 250, 196, 0.06); }
.stepper .state { padding: 14px 16px; display: grid; gap: 14px; align-content: start; font-size: 13.5px; min-height: 220px; }
.stepper .state h4 { font: 700 10.5px var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.vars { display: grid; gap: 5px; }
.var { display: grid; grid-template-columns: minmax(74px, auto) 1fr; gap: 10px; align-items: baseline; padding: 6px 10px; border-radius: 10px; background: var(--rail-fill); border: 1px solid var(--stroke); font: 500 12.5px var(--font-mono); }
.var .n { color: var(--text-1); font-weight: 700; }
.var .v { color: var(--text-2); word-break: break-all; }
.var .ty { color: var(--text-4); font-size: 11px; margin-left: 6px; }
.var.changed { border-color: rgba(97, 250, 196, 0.45); background: var(--signal-soft); }
.frame { padding: 8px 10px; border-radius: 12px; border: 1px solid color-mix(in srgb, var(--violet) 30%, transparent); background: color-mix(in srgb, var(--violet) 5%, transparent); display: grid; gap: 5px; }
.frame .fn { font: 600 12px var(--font-mono); color: var(--t-violet); }
.stepper .printed { background: var(--code-bg); border-radius: 10px; padding: 8px 10px; font: 500 12.5px/1.5 var(--font-mono); white-space: pre-wrap; min-height: 32px; border: 1px solid var(--divider); }
.stepper footer { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--divider); }
.stepper footer input[type="range"] { flex: 1; accent-color: var(--signal); }
.stepper footer .pos { font: 600 12px var(--font-mono); color: var(--text-3); min-width: 76px; text-align: right; font-variant-numeric: tabular-nums; }
.stepper .note { font-size: 13px; color: var(--text-2); padding: 8px 10px; border-radius: 10px; background: var(--rail-fill); border: 1px solid var(--stroke); }

.indexviz { padding: 20px 18px; display: grid; gap: 16px; }
.indexviz .boxes { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 4px; }
.indexviz .box { flex: none; min-width: 42px; text-align: center; display: grid; gap: 4px; }
.indexviz .box .pos, .indexviz .box .neg { font: 600 11px var(--font-mono); color: var(--text-3); }
.indexviz .box .cell-v { font: 500 14px var(--font-mono); padding: 9px 7px; border: 1px solid var(--stroke-strong); border-radius: 10px; background: var(--rail-fill); white-space: pre; color: var(--text-1); }
.indexviz .box.in .cell-v { background: var(--marker); border-color: var(--amber); box-shadow: 0 0 12px rgba(255, 184, 74, 0.25); }
.indexviz .controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.indexviz label { display: grid; gap: 5px; font: 700 10.5px var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.indexviz input[type="number"] { height: 36px; border: 1px solid var(--stroke-strong); border-radius: 10px; background: var(--input-fill); padding: 0 10px; font-family: var(--font-mono); }
.indexviz .expr, .indexviz .codeline { font: 500 14px var(--font-mono); padding: 11px 14px; background: var(--code-bg); border-radius: 10px; border: 1px solid var(--divider); }

.terminal { background: #04060b; color: #d8e1ee; font: 500 13px/1.6 var(--font-mono); }
.terminal .screen { height: 320px; overflow-y: auto; padding: 14px 16px; white-space: pre-wrap; word-break: break-word; }
.terminal .screen .cmd { color: #ffffff; }
.terminal .screen .prompt { color: #61fac4; }
.terminal .screen .err { color: #ff8c84; }
.terminal .screen .dim { color: #6b7993; }
.terminal .input-line { display: flex; gap: 8px; padding: 0 16px 14px; align-items: baseline; }
.terminal .input-line input { flex: 1; background: transparent; border: 0; outline: none; color: #fff; font: inherit; caret-color: #61fac4; }
.terminal-tasks { padding: 14px 16px; display: grid; gap: 7px; border-top: 1px solid var(--divider); }
.terminal-tasks .task { display: grid; grid-template-columns: 22px 1fr; gap: 8px; font-size: 14px; color: var(--text-3); }
.terminal-tasks .task.current { color: var(--text-1); font-weight: 700; }
.terminal-tasks .task.done { color: var(--text-2); }
.terminal-tasks .task .m { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--text-4); margin-top: 1px; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; }
.terminal-tasks .task.done .m { background: var(--signal); border-color: var(--signal); color: var(--on-signal); }
.terminal-tasks .task.current .m { border-color: var(--signal); box-shadow: 0 0 8px rgba(97, 250, 196, 0.5); }
.terminal-tasks .hintline { font-size: 13px; color: var(--text-3); padding-left: 30px; }

.httpw .req { padding: 16px; display: grid; gap: 12px; border-bottom: 1px solid var(--divider); }
.httpw .presets { display: flex; flex-wrap: wrap; gap: 8px; }
.httpw .presets button { border: 1px solid var(--stroke-strong); background: var(--subtle-fill); border-radius: var(--r-pill); padding: 5px 12px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.httpw .presets button[aria-pressed="true"] { background: var(--grad-signal); color: var(--on-signal); border-color: transparent; }
.httpw .line { display: grid; grid-template-columns: 104px 1fr auto; gap: 8px; }
.httpw select, .httpw input, .httpw textarea { border: 1px solid var(--stroke-strong); border-radius: 10px; background: var(--input-fill); padding: 0 10px; height: 40px; font: 500 13px var(--font-mono); min-width: 0; }
.httpw textarea { height: 90px; padding: 10px; resize: vertical; }
.httpw .sub { font: 700 10.5px var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.httpw .res { display: grid; grid-template-columns: 1fr 1fr; min-height: 170px; }
.httpw .res > div { padding: 14px 16px; min-width: 0; }
.httpw .res > div + div { border-left: 1px solid var(--divider); }
.httpw .raw { font: 500 12px/1.6 var(--font-mono); white-space: pre-wrap; word-break: break-word; color: var(--text-2); max-height: 300px; overflow: auto; margin: 0; }
.httpw .status { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.httpw .status .code { font: 800 24px var(--font-mono); }
.httpw .status.ok .code { color: var(--t-signal); }
.httpw .status.bad .code { color: var(--t-coral); }
.httpw .status .meaning { font-size: 13.5px; color: var(--text-2); font-weight: 600; }

.jsonw { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr); }
.jsonw .tree { padding: 14px 8px 14px 14px; font: 500 13px/1.75 var(--font-mono); max-height: 380px; overflow: auto; border-right: 1px solid var(--divider); }
.jsonw .row { display: flex; gap: 6px; align-items: baseline; cursor: pointer; border-radius: 6px; padding: 0 6px; white-space: nowrap; }
.jsonw .row:hover { background: var(--subtle-fill); }
.jsonw .row.sel { background: var(--marker); }
.jsonw .tw { width: 12px; color: var(--text-3); flex: none; }
.jsonw .key { color: var(--hl-def); }
.jsonw .str { color: var(--hl-string); }
.jsonw .num { color: var(--hl-number); }
.jsonw .lit { color: var(--hl-keyword); }
.jsonw .sum { color: var(--text-4); }
.jsonw .side { padding: 16px; display: grid; gap: 10px; align-content: start; }
.jsonw .side .expr { font: 500 13px var(--font-mono); background: var(--code-bg); padding: 11px 13px; border-radius: 10px; word-break: break-all; border: 1px solid var(--divider); color: var(--t-signal); }
.jsonw .side .val { font: 500 12.5px var(--font-mono); white-space: pre-wrap; color: var(--text-2); max-height: 210px; overflow: auto; }

.arrayw { padding: 18px; display: grid; gap: 16px; }
.arrayw .toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.arrayw .eq { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.arrayw .op { font: 700 20px var(--font-mono); color: var(--text-3); }
.arrayw .grid { display: grid; gap: 4px; }
.arrayw .grid .c { min-width: 46px; height: 36px; display: flex; align-items: center; justify-content: center; font: 500 13px var(--font-mono); border: 1px solid var(--stroke-strong); border-radius: 8px; background: var(--rail-fill); font-variant-numeric: tabular-nums; }
.arrayw .grid .c.ghost { border-style: dashed; color: var(--text-4); background: transparent; }
.arrayw .grid .c.hot { background: var(--marker); border-color: var(--amber); }
.arrayw .grid .c.res { background: var(--signal-soft); border-color: rgba(97, 250, 196, 0.4); }
.arrayw .shape { font: 600 11px var(--font-mono); color: var(--text-3); margin-top: 6px; text-align: center; }
.arrayw .codeline { font: 500 13px var(--font-mono); background: var(--code-bg); padding: 10px 14px; border-radius: 10px; border: 1px solid var(--divider); white-space: pre; overflow-x: auto; }

.tokensw { padding: 16px; display: grid; gap: 14px; }
.tokensw textarea { width: 100%; min-height: 80px; border: 1px solid var(--stroke-strong); border-radius: 12px; background: var(--input-fill); padding: 10px 12px; font: 15px/1.5 var(--font-ui); resize: vertical; }
.tokensw .chips { display: flex; flex-wrap: wrap; gap: 3px; font: 500 13px/2 var(--font-mono); }
.tokensw .chip { all: unset; padding: 0 3px; border-radius: 5px; white-space: pre; }
.tokensw .chip:nth-child(4n+1) { background: rgba(97, 250, 196, 0.18); }
.tokensw .chip:nth-child(4n+2) { background: rgba(255, 184, 74, 0.22); }
.tokensw .chip:nth-child(4n+3) { background: rgba(156, 122, 255, 0.22); }
.tokensw .chip:nth-child(4n+4) { background: rgba(79, 194, 255, 0.2); }
.tokensw .stats { display: flex; gap: 24px; flex-wrap: wrap; font-size: 13px; color: var(--text-3); }
.tokensw .stats b { font: 800 20px var(--font-mono); color: var(--text-1); display: block; font-variant-numeric: tabular-nums; }

.msgw { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.msgw .build { padding: 16px; display: grid; gap: 12px; border-right: 1px solid var(--divider); align-content: start; }
.msgw label { display: grid; gap: 5px; font: 700 10.5px var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); }
.msgw textarea, .msgw input, .msgw select { border: 1px solid var(--stroke-strong); border-radius: 10px; background: var(--input-fill); padding: 8px 10px; font: 14px/1.45 var(--font-ui); resize: vertical; min-width: 0; text-transform: none; letter-spacing: normal; }
.msgw input[type="number"] { font-family: var(--font-mono); height: 36px; width: 120px; }
.msgw .turn { display: grid; gap: 4px; }
.msgw .turn .role { font: 600 11px var(--font-mono); color: var(--t-violet); }
.msgw .views { display: grid; grid-template-rows: auto 1fr; min-width: 0; }
.msgw .tabs { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--divider); }
.msgw .tabs button { border: 0; background: transparent; padding: 6px 12px; font-size: 13px; font-weight: 700; color: var(--text-3); border-radius: var(--r-pill); }
.msgw .tabs button[aria-selected="true"] { color: var(--text-1); background: var(--subtle-fill); box-shadow: 0 0 0 1px var(--stroke-strong); }
.msgw .view { padding: 14px 16px; font: 500 12px/1.6 var(--font-mono); white-space: pre-wrap; word-break: break-word; overflow: auto; max-height: 400px; }

/* ── Login ────────────────────────────────────────────────── */
.login-page { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(400px, 100%); padding: 32px; display: grid; gap: 18px; }
.login-card h1 { font-size: 32px; letter-spacing: -0.8px; }
.login-card p { color: var(--text-2); font-size: 15px; }
.login-card input { height: 48px; border: 1px solid var(--stroke-strong); border-radius: 14px; background: var(--input-fill); padding: 0 16px; font-size: 16px; width: 100%; }
.login-card input:focus { outline: none; border-color: var(--t-azure); }
.login-card .err { color: var(--t-coral); font-size: 13.5px; min-height: 18px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1180px) {
  .lesson-shell, .lesson-shell.tutor-closed { grid-template-columns: minmax(0, 1fr); }
  .tutor { position: fixed; right: 0; top: 0; bottom: 0; width: min(420px, 100vw); z-index: 30; height: auto; box-shadow: -20px 0 60px var(--shadow); }
  .tutor-closed .tutor { display: none; }
  .today-cols { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --topbar-h: 60px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; height: var(--topbar-h); flex-direction: row; align-items: center; gap: 10px; padding: 0 12px; border-right: 0; border-bottom: 1px solid var(--divider); }
  .sidebar .brand .meta, .sidebar .spacer, .sidebar .path-card, .sidebar-foot .ver { display: none; }
  .brand { padding: 0; }
  .brand .tile { width: 36px; height: 36px; }
  .nav { display: flex; gap: 2px; flex: 1; }
  .nav a { height: 38px; padding: 0 10px; font-size: 14px; gap: 6px; }
  .nav a svg { width: 17px; height: 17px; }
  .sidebar-foot { padding: 0; }
  .map-page { height: calc(100vh - var(--topbar-h)); }
  .tutor { top: var(--topbar-h); }
  .hero-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .nav a span.label { display: none; }
  .page, .narrow, .review-wrap { padding-left: 16px; padding-right: 16px; }
  .page { padding-top: 28px; }
  .page-head h1 { font-size: 34px; }
  .hero-card { padding: 22px 18px; }
  .hero-card h2 { font-size: 28px; }
  .stat-chips { grid-template-columns: 1fr; }
  .lesson-head, .lesson-body { padding-left: 16px; padding-right: 16px; }
  .lesson-head h1 { font-size: 32px; }
  .stepper, .jsonw, .httpw .res, .msgw { grid-template-columns: minmax(0, 1fr); }
  .stepper .src { border-right: 0; border-bottom: 1px solid var(--divider); }
  .jsonw .tree, .msgw .build { border-right: 0; border-bottom: 1px solid var(--divider); }
  .httpw .res > div + div { border-left: 0; border-top: 1px solid var(--divider); }
  .rating-row { grid-template-columns: 1fr; }
  .seg { width: 100%; }
  .seg button { flex: 1; padding: 0 4px; font-size: 12px; }
  .drawer { position: fixed; inset: auto 0 0 0; width: auto; max-height: 72vh; border-left: 0; border-top: 1px solid var(--stroke-strong); z-index: 25; border-radius: 24px 24px 0 0; }
  .result-row { grid-template-columns: 120px 1fr 56px; }
  .map-head { padding: 18px 16px 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}

/* ── Baby AI ──────────────────────────────────────────────── */
.baby-layout { margin-top: 30px; display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start; }
.baby-main { display: grid; gap: 18px; min-width: 0; }
.baby-side { display: grid; gap: 16px; position: sticky; top: 20px; }
.baby-stage { padding: 28px 30px; display: grid; gap: 16px; position: relative; overflow: hidden; }
.baby-stage::before { content: ""; position: absolute; inset: 0; background: radial-gradient(70% 90% at 0% 0%, color-mix(in srgb, var(--acc) 10%, transparent), transparent 60%); pointer-events: none; }
.baby-stage > * { position: relative; }
.baby-stage h2 { font-size: 30px; letter-spacing: -0.6px; }
.baby-prose { font-size: 16.5px; }
.baby-try { color: var(--text-2); font-size: 15px; }
.baby-try strong { color: var(--t-amber); }
.pipeline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 16px; border-radius: var(--r-md); background: var(--rail-fill); border: 1px solid var(--stroke); }
.pipe-block { position: relative; padding: 9px 14px; border-radius: 12px; border: 1px solid var(--stroke-strong); background: var(--glass-strong); font-weight: 700; font-size: 14px; }
.pipe-block.new { border-color: var(--amber); box-shadow: 0 0 0 1px rgba(255, 184, 74, 0.35), 0 0 18px rgba(255, 184, 74, 0.18); }
.pipe-block em { position: absolute; top: -9px; right: 8px; font: 700 9.5px var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; font-style: normal; padding: 1px 6px; border-radius: 6px; background: var(--amber); color: #2b1600; }
.pipe-arrow { color: var(--text-3); font-weight: 700; }
.look-inside { border-radius: var(--r-md); border: 1px solid var(--stroke); background: var(--rail-fill); }
.look-inside summary { cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 14px 16px; font-weight: 700; color: var(--t-azure); list-style: none; }
.look-inside summary::-webkit-details-marker { display: none; }
.look-inside summary svg { width: 18px; height: 18px; }
.look-inside .src-body { padding: 0 16px 16px; display: grid; gap: 12px; }
.baby-links { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.baby-links .chip { text-decoration: none; }
.baby-links .chip:hover { color: var(--text-1); border-color: var(--stroke-strong); }
.baby-panel { padding: 22px 24px; display: grid; gap: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn-row { display: flex; gap: 8px; }
.chart-box .loss-chart { height: 150px; }
.train-status { font-size: 14.5px; color: var(--text-2); }
.train-status strong { color: var(--text-1); font-family: var(--font-mono); }
.write-controls { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 14px; }
.write-controls label { display: grid; gap: 6px; font: 700 10.5px var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.write-controls input[type="range"] { accent-color: var(--violet); margin-top: 10px; }
.baby-input { height: 44px; border: 1px solid var(--stroke-strong); border-radius: 12px; background: var(--input-fill); padding: 0 14px; font-size: 15px; width: 100%; }
.baby-input:focus, .baby-text:focus { outline: none; border-color: var(--t-azure); }
.baby-text { width: 100%; border: 1px solid var(--stroke-strong); border-radius: 12px; background: var(--input-fill); padding: 10px 12px; font: 14px/1.5 var(--font-ui); resize: vertical; }
.baby-output { min-height: 120px; padding: 16px 18px; border-radius: var(--r-md); background: var(--code-bg); border: 1px solid var(--stroke); font: 500 15px/1.75 var(--font-mono); white-space: pre-wrap; word-break: break-word; }
.baby-output .prompt-part { color: var(--t-azure); }
.baby-output .ch { all: unset; cursor: pointer; border-radius: 3px; white-space: pre-wrap; }
.baby-output .ch:hover { background: var(--subtle-fill); }
.baby-output .ch.sel { background: var(--marker); box-shadow: 0 0 0 1px var(--amber); }
.inspector { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.inspector:empty { display: none; }
.insp-col { display: grid; gap: 10px; align-content: start; }
.probs { display: grid; gap: 6px; }
.prob { display: grid; grid-template-columns: 28px 1fr 58px; gap: 10px; align-items: center; font-size: 13px; }
.prob .c { text-align: center; font-weight: 700; padding: 2px 0; border-radius: 6px; background: var(--subtle-fill); }
.prob .bar { height: 8px; border-radius: 4px; background: var(--subtle-fill); overflow: hidden; }
.prob .bar span { display: block; height: 100%; background: var(--violet); border-radius: 4px; }
.prob.chosen .bar span { background: var(--grad-signal); }
.prob.chosen .c { background: var(--signal); color: var(--on-signal); }
.prob .p { color: var(--text-2); text-align: right; font-variant-numeric: tabular-nums; }
.att-row { display: flex; flex-wrap: wrap; gap: 2px; padding: 10px; border-radius: 12px; background: var(--code-bg); border: 1px solid var(--stroke); }
.att-ch { min-width: 16px; text-align: center; padding: 3px 2px; border-radius: 4px; font-size: 13px; color: var(--text-1); white-space: pre; }
.small-seg button { height: 28px; font-size: 12px; }
.count-grid { display: grid; gap: 3px; overflow-x: auto; font-size: 12px; }
.count-grid .hd { text-align: center; color: var(--text-3); font-weight: 700; padding: 4px 0; }
.count-grid .cell { text-align: center; padding: 5px 2px; border-radius: 5px; color: var(--text-1); font-variant-numeric: tabular-nums; }
.baby-card { padding: 18px 20px; display: grid; gap: 12px; border-radius: 20px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.timeline li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 12px; color: var(--text-3); }
.timeline li .dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 700 11px var(--font-mono); border: 1.5px solid var(--stroke-strong); color: var(--text-3); }
.timeline li .l { font-weight: 700; }
.timeline li .a { font-size: 12.5px; }
.timeline li.done { color: var(--text-2); }
.timeline li.done .dot { background: var(--signal); border-color: var(--signal); color: var(--on-signal); }
.timeline li.now { color: var(--text-1); background: color-mix(in srgb, var(--acc) 10%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--acc) 40%, transparent); }
.timeline li.now .dot { border-color: var(--acc); color: var(--acc-text); box-shadow: 0 0 10px color-mix(in srgb, var(--acc) 50%, transparent); }
.timeline li.open .dot { border-color: var(--acc); color: var(--acc-text); }
.timeline .linkish { font-size: 15px; }
.baby-card.grow p { color: var(--text-2); font-size: 14px; }
.baby-card.grow.ready { box-shadow: 0 0 0 1px rgba(97, 250, 196, 0.35), 0 0 24px rgba(97, 250, 196, 0.08); }
.baby-card .checks li.no .m { background: transparent; border: 1.5px solid var(--stroke-strong); }
.data-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip.toggle { cursor: pointer; }
.chip.toggle[aria-pressed="true"] { background: var(--grad-signal); color: var(--on-signal); border-color: transparent; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--text-3); }
.kv strong { color: var(--text-1); }
.baby-birth { margin-top: 30px; padding: 30px; }
.birth-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 30px; align-items: start; }
.growth-preview { display: grid; gap: 8px; }
.gp { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px; background: var(--rail-fill); border: 1px solid var(--stroke); }
.gp .n { font: 700 12px var(--font-mono); color: var(--acc-text); }
.gp .l { font-weight: 700; }
.gp .a { font-size: 13px; color: var(--text-3); }
@media (max-width: 1180px) {
  .baby-layout, .birth-grid { grid-template-columns: minmax(0, 1fr); }
  .baby-side { position: static; }
}
@media (max-width: 680px) {
  .write-controls { grid-template-columns: 1fr; }
  .baby-stage { padding: 22px 18px; }
}
.loss-chart .curve-2 { fill: none; stroke: var(--violet); stroke-width: 1.75; stroke-dasharray: 5 4; stroke-linejoin: round; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-3); }
.chart-legend i { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--signal); vertical-align: middle; margin-right: 6px; }
.chart-legend i.test { border-top: 2px dashed var(--violet); }

/* ── Math widgets ─────────────────────────────────────────── */
.c-signal { --c: var(--t-signal); }
.c-azure { --c: var(--t-azure); }
.c-violet { --c: var(--t-violet); }
.c-amber { --c: var(--t-amber); }
.c-coral { --c: var(--t-coral); }
.mathw { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 300px); gap: 18px; padding: 18px; align-items: start; }
.mathw.wide { grid-template-columns: minmax(0, 1.35fr) minmax(250px, 300px); }
.mathw.softmaxw { grid-template-columns: minmax(0, 1fr); }
.mstage { min-width: 0; }
.plane { width: 100%; height: auto; display: block; border-radius: var(--r-md); background: var(--rail-fill); border: 1px solid var(--divider); user-select: none; -webkit-user-select: none; }
.plane .gl { stroke: var(--grid-major); stroke-width: 1; }
.plane .axis { stroke: var(--stroke-strong); stroke-width: 1.4; }
.plane .tick { fill: var(--text-3); font: 500 13px var(--font-mono); }
.plane .vec line { stroke: var(--c, var(--text-2)); stroke-width: 3; stroke-linecap: round; }
.plane .vec.thick line { stroke-width: 6; opacity: 0.45; }
.plane .vec.faint line { opacity: 0.5; stroke-dasharray: 5 4; }
.plane .vec .head { fill: var(--c, var(--text-2)); }
.plane .vlabel { fill: var(--c, var(--text-1)); font: 700 16px var(--font-mono); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; }
.plane .vec .vlabel { stroke-width: 4px; }
.plane .handle { fill: var(--surface-elevated); stroke-width: 2.5; }
.plane .handle.h-signal { stroke: var(--t-signal); }
.plane .handle.h-azure { stroke: var(--t-azure); }
.plane .handle.h-amber { stroke: var(--t-amber); }
.plane .handle:hover { stroke-width: 4; }
.plane .guide { stroke: var(--text-3); stroke-width: 1.3; stroke-dasharray: 4 4; }
.plane .arc { fill: none; stroke: var(--t-amber); stroke-width: 2; }
.plane .tgrid { stroke: var(--t-azure); stroke-opacity: 0.22; stroke-width: 1; }
.plane .tgrid.axis { stroke-opacity: 0.55; stroke-width: 1.6; }
.plane .unitsq { fill: var(--t-amber); fill-opacity: 0.16; stroke: var(--t-amber); stroke-opacity: 0.6; stroke-width: 1.5; }
.plane .eigline { stroke: var(--t-violet); stroke-width: 2; stroke-dasharray: 8 5; opacity: 0.85; }
.plane .curve { fill: none; stroke: var(--c); stroke-width: 2.6; stroke-linejoin: round; }
.plane .tangent { stroke: var(--t-violet); stroke-width: 2; }
.plane .tangent.faint { opacity: 0.35; stroke-dasharray: 5 4; }
.plane .secant { stroke: var(--t-coral); stroke-width: 2; }
.plane .dot { fill: var(--t-amber); fill-opacity: 0.55; }
.plane .dot.now { fill: var(--t-amber); fill-opacity: 1; stroke: var(--surface); stroke-width: 2; }
.plane .trail { fill: none; stroke: var(--t-amber); stroke-width: 1.6; stroke-opacity: 0.7; }
.plane .contour { fill: none; stroke: var(--t-signal); stroke-opacity: 0.35; stroke-width: 1.2; }
.plane .legend { fill: var(--c); font: 600 14px var(--font-ui); }
.plane .band1 { fill: var(--t-amber); fill-opacity: 0.2; }
.plane .band2 { fill: var(--t-amber); fill-opacity: 0.09; }
.plane .bar { fill: var(--c); fill-opacity: 0.35; }
.plane .area { fill: var(--c); fill-opacity: 0.16; stroke: var(--c); stroke-width: 2.2; }
.plane .mark { stroke: var(--c); stroke-width: 2.5; stroke-dasharray: 3 3; }
.mpanel { display: grid; gap: 14px; min-width: 0; }
.mcontrols { display: grid; gap: 10px; }
.mrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mrow > .sl, .mslider .sl { font: 700 10.5px var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); }
.mslider { display: grid; grid-template-columns: minmax(70px, auto) 1fr 64px; align-items: center; gap: 10px; }
.mslider input[type="range"] { width: 100%; accent-color: var(--t-signal); }
.mslider .sv { font: 600 12.5px var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; color: var(--text-1); }
.readout { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; padding: 12px 14px; border-radius: var(--r-sm); background: var(--subtle-fill); border: 1px solid var(--divider); font-size: 12.5px; }
.readout dt { color: var(--text-3); }
.readout dd { margin: 0; font: 600 12.5px var(--font-mono); color: var(--c, var(--text-1)); font-variant-numeric: tabular-nums; word-break: break-word; }
.mathw .codeline { margin: 0; font: 500 12px/1.55 var(--font-mono); background: var(--code-bg); color: var(--code-ink); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--divider); white-space: pre; overflow-x: auto; }
.mhint { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--text-3); }
.mside { display: grid; gap: 10px; }
.matrix-in { display: grid; grid-template-columns: repeat(2, 64px); gap: 6px; padding: 6px 10px; border-left: 2px solid var(--stroke-strong); border-right: 2px solid var(--stroke-strong); border-radius: 6px; }
.matrix-in input { width: 64px; padding: 6px 8px; font: 600 13px var(--font-mono); text-align: center; background: var(--input-fill); color: var(--text-1); border: 1px solid var(--stroke); border-radius: 8px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.prows { display: grid; gap: 8px; }
.prow { display: grid; grid-template-columns: auto minmax(220px, 1.1fr) minmax(120px, 1fr) 56px; gap: 12px; align-items: center; }
.prow input[type="radio"] { accent-color: var(--t-coral); margin: 0; }
.prow .mslider { grid-template-columns: 70px 1fr 40px; }
.ptrack { height: 14px; border-radius: var(--r-pill); background: var(--subtle-fill); overflow: hidden; }
.pbar { height: 100%; border-radius: var(--r-pill); background: var(--t-azure); opacity: 0.75; transition: width 0.18s var(--ease-out); }
.pbar.top { background: var(--t-signal); opacity: 1; }
.pbar.target { box-shadow: inset 0 0 0 2px var(--t-coral); }
.ppct { font: 600 12.5px var(--font-mono); text-align: right; font-variant-numeric: tabular-nums; }
.softmaxw .mpanel.full { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 900px) {
  .mathw, .mathw.wide { grid-template-columns: minmax(0, 1fr); }
  .prow { grid-template-columns: auto minmax(0, 1fr) 52px; }
  .prow .ptrack { grid-column: 2 / 3; }
}
@media (prefers-reduced-motion: reduce) { .pbar { transition: none; } }
