/* Hallmark · shape: app screen · genre: modern-minimal · theme: Coral (deal 1/3, seed free-open-source-education-platform-9e3c·e0a87411·2026-10-28·r0)
 * nav: left course outline under a slim top bar · signature: a concept term in the text opening its record in the side panel · states: done, current, unseen, review, mastered, empty, selected
 * axes: light/grotesk-sans/warm · posture: restrained · contrast: pass · modes: light+dark · v2.0.0 */
/* Hallmark · pre-emit critique: P4 H4 E4 S4 R4 V4 · weakest: V, the graph labels cross edges where lines pass under text, so labels carry a paper halo */
@import url("./tokens.css");
@import url("./base.css");

:root {
  --bar-h: 56px; --outline-w: 280px; --panel-w: 352px; --measure: 44rem;
  --mastered-fill: var(--color-accent);
}

/* Dark mode: every colour token re-derived, not inverted. */
[data-mode="dark"] {
  color-scheme: dark;
  --color-paper: oklch(18.5% 0.010 40); --color-paper-2: oklch(22% 0.011 40); --color-paper-3: oklch(26% 0.012 40);
  --color-ink: oklch(94% 0.008 60); --color-ink-2: oklch(88% 0.010 55); --color-muted: oklch(71% 0.012 50);
  --color-rule: oklch(30% 0.010 45); --color-rule-2: oklch(40% 0.012 45);
  --color-accent: oklch(76% 0.120 30); --color-accent-ink: oklch(18% 0.010 40); --color-accent-2: oklch(80% 0.110 32); --color-focus: oklch(82% 0.130 35);
  --color-error: oklch(72% 0.150 27); --color-success: oklch(76% 0.120 150);
  --shadow-card: 0 0 0 transparent;
}
[data-mode="dark"] body { font-weight: 350; }

body { min-height: 100dvh; }
.skip { position: absolute; left: var(--space-md); top: -100px; z-index: var(--z-toast); padding: var(--space-xs) var(--space-md); background: var(--color-ink); color: var(--color-paper); border-radius: var(--radius-input); }
.skip:focus-visible { top: var(--space-xs); }

/* Shell */
.app {
  display: grid; max-width: 1600px; margin-inline: auto; min-height: 100dvh;
  grid-template-columns: var(--outline-w) minmax(0, 1fr) var(--panel-w);
  grid-template-rows: var(--bar-h) minmax(0, 1fr);
}
.bar {
  grid-column: 1 / -1; position: sticky; top: 0; z-index: var(--z-sticky-nav);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-md);
  height: var(--bar-h); padding-inline: var(--space-lg);
  background: var(--color-paper); border-bottom: 1px solid var(--color-rule);
}
.brand { font-family: var(--font-display); font-weight: 600; letter-spacing: var(--tracking-display); font-size: var(--text-lg); color: var(--color-ink); text-decoration: none; }
.bar-tools { display: flex; align-items: center; gap: var(--space-sm); }

/* Controls */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-xs);
  min-height: 40px; padding: 0 var(--space-md); border: 1px solid var(--color-rule-2); border-radius: var(--radius-input);
  background: var(--color-paper); color: var(--color-ink); font-weight: 500; font-size: var(--text-sm); line-height: 1; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color var(--dur-micro) var(--ease-out), border-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out);
}
.btn::after { content: ""; position: absolute; inset: -2px; }
.btn:hover { background: var(--color-paper-2); border-color: var(--color-muted); }
.btn:active { transform: translateY(1px); background: var(--color-paper-3); }
.btn:disabled, .btn[aria-disabled="true"] { color: var(--color-muted); border-style: dashed; cursor: not-allowed; background: transparent; }
.btn--primary { background: var(--color-ink); color: var(--color-paper); border-color: var(--color-ink); }
.btn--primary:hover { background: var(--color-ink-2); border-color: var(--color-ink-2); }
.btn--primary:active { background: var(--color-ink); }
.btn--primary[aria-pressed="true"] { background: var(--color-paper); color: var(--color-ink); border-color: var(--color-ink); }
.btn--quiet { border-color: transparent; background: transparent; }
.btn--quiet:hover { background: var(--color-paper-2); border-color: transparent; }
.btn svg { width: 16px; height: 16px; flex: none; }

.seg { display: inline-flex; padding: var(--space-3xs); gap: var(--space-3xs); border: 1px solid var(--color-rule-2); border-radius: var(--radius-input); background: var(--color-paper-2); }
.seg button {
  position: relative; min-height: 34px; padding: 0 var(--space-md); border: 0; border-radius: 4px; background: transparent;
  color: var(--color-muted); font-weight: 500; font-size: var(--text-sm); cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
.seg button::after { content: ""; position: absolute; inset: -5px -1px; }
.seg button:hover { color: var(--color-ink); }
.seg button[aria-selected="true"] { background: var(--color-paper); color: var(--color-ink); box-shadow: 0 0 0 1px var(--color-rule-2); }

/* Outline */
.outline {
  grid-column: 1; grid-row: 2; position: sticky; top: var(--bar-h); align-self: start;
  height: calc(100dvh - var(--bar-h)); overflow-y: auto; padding: var(--space-lg);
  border-right: 1px solid var(--color-rule);
}
.outline > summary { display: none; }
.outline-title { font-family: var(--font-display); font-weight: 600; font-size: var(--text-md); letter-spacing: var(--tracking-display); line-height: 1.25; }
.progress { margin-top: var(--space-md); }
.progress p { font-size: var(--text-sm); color: var(--color-muted); }
progress { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 6px; margin-top: var(--space-xs); border: 0; border-radius: var(--radius-pill); background: var(--color-paper-3); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--color-paper-3); }
progress::-webkit-progress-value { background: var(--color-accent-2); border-radius: var(--radius-pill); }
progress::-moz-progress-bar { background: var(--color-accent-2); border-radius: var(--radius-pill); }
.module { margin-top: var(--space-lg); }
.module h2 { font-size: var(--text-sm); font-weight: 600; letter-spacing: 0; color: var(--color-muted); margin-bottom: var(--space-2xs); max-width: none; line-height: 1.3; }
.module ol { list-style: none; margin: 0; padding: 0; }
.item {
  position: relative; display: flex; align-items: flex-start; gap: var(--space-sm); min-height: 40px; padding: var(--space-xs) var(--space-sm);
  margin-inline: calc(var(--space-sm) * -1); border-radius: var(--radius-input); color: var(--color-ink-2); font-size: var(--text-sm); line-height: 1.35; text-decoration: none;
  transition: background-color var(--dur-micro) var(--ease-out);
}
.item:hover { background: var(--color-paper-2); }
.item .mark { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--color-muted); }
.item[data-state="done"] .mark { color: var(--color-accent-2); }
.item[aria-current="page"] { background: var(--color-paper-2); color: var(--color-ink); font-weight: 600; box-shadow: inset 2px 0 0 var(--color-ink); }
.item[aria-current="page"] .mark { color: var(--color-ink); }
.item small { display: block; font-size: var(--text-xs); font-weight: 400; color: var(--color-muted); }

/* Main column */
.main { grid-column: 2; grid-row: 2; min-width: 0; padding: var(--space-xl) var(--gutter) var(--space-3xl); }
.lesson, .graph-view { max-width: var(--measure); margin-inline: auto; }
.graph-view { max-width: 56rem; }
.lesson h1 { font-size: var(--text-3xl); max-width: 18ch; }
.lesson .lead { margin-top: var(--space-md); color: var(--color-ink-2); }
.lesson > section, .lesson > figure { margin-top: var(--space-xl); }

.video { margin: 0; }
.video [data-slot] { aspect-ratio: 16 / 9; border: 1px solid var(--color-rule); border-radius: var(--radius-card); display: grid; place-items: center; }
.video [data-slot] video { position: absolute; inset: 0; width: 100%; height: 100%; background: var(--color-board); }
.video [data-slot] iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.slot-note { display: grid; gap: var(--space-2xs); justify-items: center; padding: var(--space-lg); text-align: center; color: var(--color-muted); font-size: var(--text-sm); }
.slot-note svg { width: 40px; height: 40px; color: var(--color-ink); }
.slot-note p { max-width: 36ch; }
.slot-note .btn { margin-top: var(--space-xs); }
.video figcaption { margin-top: var(--space-xs); font-size: var(--text-sm); color: var(--color-muted); }

.lesson h2 { font-size: var(--text-xl); max-width: none; line-height: 1.15; }

/* Notion-like toggle blocks */
.steps { display: grid; gap: var(--space-2xs); margin-top: var(--space-md); }
.step { border-radius: var(--radius-card); }
.step > summary {
  position: relative; display: flex; align-items: center; gap: var(--space-sm); min-height: 44px; padding: var(--space-xs) var(--space-sm);
  margin-inline: calc(var(--space-sm) * -1); border-radius: var(--radius-input); cursor: pointer; list-style: none;
  font-family: var(--font-display); font-weight: 600; font-size: var(--text-lg); letter-spacing: var(--tracking-display); line-height: 1.2;
  transition: background-color var(--dur-micro) var(--ease-out);
}
.step > summary::-webkit-details-marker { display: none; }
.step > summary:hover { background: var(--color-paper-2); }
.step > summary::before {
  content: ""; flex: none; width: 7px; height: 7px; margin-inline: var(--space-2xs) var(--space-3xs); border-right: 1.5px solid var(--color-muted); border-bottom: 1.5px solid var(--color-muted);
  transform: rotate(-45deg); transition: transform var(--dur-short) var(--ease-out);
}
.step[open] > summary::before { transform: rotate(45deg); }
.step .n { font-family: var(--font-outlier); font-size: var(--text-sm); font-weight: 400; color: var(--color-muted); font-variant-numeric: tabular-nums; min-width: 1.4ch; }
.step-body { display: grid; gap: var(--space-md); padding: var(--space-2xs) 0 var(--space-lg) var(--space-xl); }

.term {
  padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer;
  text-decoration: underline dotted; text-decoration-thickness: 1.5px; text-underline-offset: 0.2em; text-decoration-color: var(--color-muted);
  border-radius: 2px;
  transition: text-decoration-color var(--dur-micro) var(--ease-out), background-color var(--dur-micro) var(--ease-out);
}
.term:hover { text-decoration-color: var(--color-accent-2); background: color-mix(in oklab, var(--color-accent) 18%, transparent); }
.term[aria-expanded="true"] { text-decoration-style: solid; text-decoration-color: var(--color-accent-2); background: color-mix(in oklab, var(--color-accent) 22%, transparent); }

.formula {
  margin: 0; padding: var(--space-sm) var(--space-md); border-radius: var(--radius-card); background: var(--color-paper-2); border: 1px solid var(--color-rule);
  font-family: var(--font-outlier); font-size: var(--text-md); line-height: 1.6; overflow-x: auto; max-width: 100%; white-space: pre; font-variant-numeric: tabular-nums;
}

.callout {
  display: flex; gap: var(--space-sm); padding: var(--space-md); border-radius: var(--radius-card); background: var(--color-paper-2); border: 1px solid var(--color-rule);
}
.callout svg { width: 20px; height: 20px; flex: none; margin-top: var(--space-3xs); color: var(--color-ink); }
.callout h2, .callout h3 { font-size: var(--text-md); line-height: 1.3; max-width: none; }
.callout p { margin-top: var(--space-2xs); font-size: var(--text-sm); color: var(--color-ink-2); }

/* Sigmoid widget */
.widget { padding: var(--space-md); border: 1px solid var(--color-rule); border-radius: var(--radius-card); display: grid; gap: var(--space-sm); max-width: 28rem; }
.widget svg { width: 100%; height: auto; }
.w-axis { stroke: var(--color-rule-2); stroke-width: 1; }
.w-curve { fill: none; stroke: var(--color-ink); stroke-width: 2; stroke-linejoin: round; }
.w-dot { fill: var(--color-accent); stroke: var(--color-ink); stroke-width: 1.5; }
.widget label { font-size: var(--text-sm); font-weight: 500; display: flex; justify-content: space-between; gap: var(--space-md); }
.widget output { font-family: var(--font-outlier); font-variant-numeric: tabular-nums; font-size: var(--text-sm); color: var(--color-ink-2); }
input[type="range"] { width: 100%; min-height: 44px; margin: 0; accent-color: var(--color-accent-2); cursor: pointer; }

/* Lesson footer */
.lesson-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-md); padding-top: var(--space-lg); border-top: 1px solid var(--color-rule); }
.lesson-foot .pair { display: flex; gap: var(--space-sm); flex-wrap: wrap; }

/* Graph view */
.graph-view h1 { font-size: var(--text-2xl); }
.graph-view .lead { margin-top: var(--space-xs); color: var(--color-ink-2); }
.graph-wrap { margin-top: var(--space-lg); overflow-x: auto; border: 1px solid var(--color-rule); border-radius: var(--radius-card); background: var(--color-paper); }
.graph-wrap svg { min-width: 640px; width: 100%; height: auto; }
.g-edge { stroke: var(--color-rule-2); stroke-width: 1.5; }
.g-node { cursor: pointer; outline: none; }
.g-node:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 4px; border-radius: 50%; }
.g-ring { fill: transparent; stroke: transparent; stroke-width: 2; transition: stroke var(--dur-micro) var(--ease-out); }
.g-node.is-selected .g-ring, .g-node:focus-visible .g-ring { stroke: var(--color-focus); }
.g-node:hover .g-ring { stroke: var(--color-muted); }
.g-dot { stroke-width: 1.5; }
.g-node[data-state="mastered"] .g-dot { fill: var(--mastered-fill); stroke: var(--color-ink); }
.g-node[data-state="review"] .g-dot { fill: var(--color-paper); stroke: var(--color-ink); }
.g-node[data-state="unseen"] .g-dot { fill: var(--color-paper); stroke: var(--color-muted); stroke-dasharray: 3 2.5; }
.g-label { fill: var(--color-ink); font-family: var(--font-display); font-size: 13px; font-weight: 500; text-anchor: middle; paint-order: stroke; stroke: var(--color-paper); stroke-width: 4px; stroke-linejoin: round; }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-md) var(--space-lg); margin: var(--space-md) 0 0; padding: 0; list-style: none; font-size: var(--text-sm); color: var(--color-ink-2); }
.legend li { display: flex; align-items: center; gap: var(--space-xs); }
.legend svg { width: 16px; height: 16px; }
.legend .l-m { fill: var(--mastered-fill); stroke: var(--color-ink); stroke-width: 1.5; }
.legend .l-r { fill: var(--color-paper); stroke: var(--color-ink); stroke-width: 1.5; }
.legend .l-u { fill: var(--color-paper); stroke: var(--color-muted); stroke-width: 1.5; stroke-dasharray: 3 2.5; }
.graph-note { margin-top: var(--space-sm); font-size: var(--text-sm); color: var(--color-muted); }

/* Side panel */
.panel {
  grid-column: 3; grid-row: 2; position: sticky; top: var(--bar-h); align-self: start; height: calc(100dvh - var(--bar-h)); overflow-y: auto;
  padding: var(--space-lg); border-left: 1px solid var(--color-rule); background: var(--color-paper);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); }
.panel-head h2 { font-size: var(--text-md); font-weight: 600; max-width: none; color: var(--color-muted); letter-spacing: 0; }
.panel-empty { margin-top: var(--space-lg); padding: var(--space-lg); border: 1px dashed var(--color-rule-2); border-radius: var(--radius-card); color: var(--color-muted); font-size: var(--text-sm); }
.panel-empty p { max-width: 30ch; }
.record { margin-top: var(--space-lg); display: grid; gap: var(--space-md); }
.record h3 { font-size: var(--text-xl); line-height: 1.1; max-width: none; }
.status { display: inline-flex; align-items: center; gap: var(--space-xs); width: fit-content; padding: var(--space-3xs) var(--space-sm) var(--space-3xs) var(--space-xs); border: 1px solid var(--color-rule-2); border-radius: var(--radius-pill); font-size: var(--text-sm); font-weight: 500; }
.status svg { width: 14px; height: 14px; }
.status .l-m { fill: var(--mastered-fill); stroke: var(--color-ink); stroke-width: 1.5; }
.status .l-r { fill: var(--color-paper); stroke: var(--color-ink); stroke-width: 1.5; }
.status .l-u { fill: var(--color-paper); stroke: var(--color-muted); stroke-width: 1.5; stroke-dasharray: 3 2.5; }
.record dl { margin: 0; display: grid; gap: var(--space-md); }
.record dt { font-size: var(--text-sm); font-weight: 500; color: var(--color-muted); }
.record dd { margin: var(--space-2xs) 0 0; font-size: var(--text-sm); color: var(--color-ink-2); line-height: 1.5; }
.record dd.def { font-size: var(--text-md); color: var(--color-ink); }
.rel { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin: 0; padding: 0; list-style: none; }
.rel button { min-height: 32px; padding: 0 var(--space-sm); border: 1px solid var(--color-rule-2); border-radius: var(--radius-pill); background: var(--color-paper); color: var(--color-ink); font-size: var(--text-sm); cursor: pointer; position: relative; }
.rel button::after { content: ""; position: absolute; inset: -6px -2px; }
.rel button:hover { background: var(--color-paper-2); border-color: var(--color-muted); }

/* Narrow: panel becomes an overlay that appears only with a selection */
@media (max-width: 75rem) {
  .app { grid-template-columns: var(--outline-w) minmax(0, 1fr); }
  .panel {
    position: fixed; top: var(--bar-h); right: 0; bottom: 0; width: min(var(--panel-w), 100%); height: auto; z-index: var(--z-dropdown);
    border-left: 1px solid var(--color-rule-2); box-shadow: var(--shadow-card);
    transform: translateX(100%); visibility: hidden;
    transition: transform var(--dur-short) var(--ease-out), visibility 0s linear var(--dur-short);
  }
  .panel[data-open="true"] { transform: none; visibility: visible; transition-delay: 0s; }
  .main { padding-inline: var(--space-xl); }
}
@media (max-width: 48rem) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--bar-h) auto minmax(0, 1fr); }
  .bar { padding-inline: var(--space-md); }
  .outline { grid-column: 1; grid-row: 2; position: static; height: auto; overflow: visible; padding: 0; border-right: 0; border-bottom: 1px solid var(--color-rule); }
  .outline > summary { display: flex; align-items: center; justify-content: space-between; min-height: 48px; padding: 0 var(--space-md); cursor: pointer; font-weight: 600; list-style: none; }
  .outline > summary::-webkit-details-marker { display: none; }
  .outline > summary::after { content: ""; width: 7px; height: 7px; border-right: 1.5px solid var(--color-muted); border-bottom: 1.5px solid var(--color-muted); transform: rotate(45deg); transition: transform var(--dur-short) var(--ease-out); }
  .outline[open] > summary::after { transform: rotate(-135deg); }
  .outline > .outline-inner { padding: 0 var(--space-md) var(--space-lg); }
  .main { grid-column: 1; grid-row: 3; padding: var(--space-lg) var(--space-md) var(--space-2xl); }
  .panel { top: auto; left: 0; width: 100%; max-height: 70dvh; border-left: 0; border-top: 1px solid var(--color-rule-2); transform: translateY(100%); }
  .panel[data-open="true"] { transform: none; }
  .brand { font-size: var(--text-md); }
  .lesson h1 { font-size: var(--text-2xl); }
  .step > summary { font-size: var(--text-md); }
  .step-body { padding-left: 0; }
}
@media (min-width: 48.01rem) { .outline > .outline-inner { display: block; } }
.brand, .seg button { white-space: nowrap; }
@media (max-width: 30rem) { .mode-label { display: none; } .seg button { padding: 0 var(--space-sm); } }

.episode .lead { margin-top: var(--space-md); color: var(--color-ink-2); }
.episode h1 { font-size: var(--text-3xl); max-width: 22ch; }
.episode .callout { margin-top: var(--space-lg); }
.ep-body { display: grid; gap: var(--space-md); margin-top: var(--space-lg); }
.lesson .video { margin-bottom: var(--space-lg); }
.lesson-foot { margin-top: var(--space-xl); }
