/* Learn Plus — a calm study desk: warm paper, ink text, one ink-blue accent. */

:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem; --space-5: 1.25rem;
  --space-6: 1.5rem; --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem; --space-16: 4rem;

  --font-display: 'Fraunces', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --font-read: 'Source Serif 4', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --font-body: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --color-bg: #f6f3ec;
  --color-surface: #fdfcf8;
  --color-surface-2: #f0ece3;
  --color-surface-3: #e8e3d8;
  --color-border: #ddd6c8;
  --color-divider: #e9e3d8;
  --color-text: #1f2533;
  --color-text-muted: #5b6272;
  --color-text-faint: #9a9ca3; /* decoration only (the concept map's lines): too light to read as text */
  --color-placeholder: #6b6e76; /* hints in empty fields: 4.5:1 or more on the field */
  --color-text-inverse: #fbfaf6;
  --color-primary: #24467f;
  --color-primary-hover: #1a3666;
  --color-primary-active: #142a50;
  --color-primary-highlight: #e2e8f3;
  --color-error: #a63d2a;
  --color-error-highlight: #f6e3dc;
  --color-success: #3a7448;
  --color-success-highlight: #dfeddf;

  --st-fragile: #9d4128; --st-fragile-bg: #f7e4dc; /* as text on its badge: 4.5:1 or more */
  --st-learning: #865a12; --st-learning-bg: #f6ead1;
  --st-mastered: #3a7448; --st-mastered-bg: #e0eddf;
  --st-secure: #24467f; --st-secure-bg: #e2e8f3;
  --st-planned: #a19c91;

  --radius-sm: 0.375rem; --radius-md: 0.625rem; --radius-lg: 0.875rem; --radius-xl: 1.25rem; --radius-full: 9999px;
  --shadow-sm: 0 1px 2px oklch(0.3 0.02 80 / 0.06);
  --shadow-md: 0 6px 18px oklch(0.3 0.02 80 / 0.08);
  --shadow-lg: 0 18px 40px oklch(0.3 0.02 80 / 0.12);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-interactive: 180ms var(--ease);
  --header-h: 3.75rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #15171c; --color-surface: #1c1f25; --color-surface-2: #23272f; --color-surface-3: #2b3039;
    --color-border: #343a45; --color-divider: #2a2f38;
    --color-text: #e8e5de; --color-text-muted: #a9adb7; --color-text-faint: #6f7480; --color-placeholder: #8b909c; --color-text-inverse: #15171c;
    --color-primary: #93b2e8; --color-primary-hover: #adc5ef; --color-primary-active: #c4d6f4; --color-primary-highlight: #263247;
    --color-error: #e58a72; --color-error-highlight: #3d2620; --color-success: #8cc79a; --color-success-highlight: #213326;
    --st-fragile: #e58a72; --st-fragile-bg: #3d2620; --st-learning: #e2b764; --st-learning-bg: #3a3020;
    --st-mastered: #8cc79a; --st-mastered-bg: #213326; --st-secure: #93b2e8; --st-secure-bg: #263247; --st-planned: #6f7480;
    --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.3); --shadow-md: 0 6px 18px oklch(0 0 0 / 0.35); --shadow-lg: 0 18px 40px oklch(0 0 0 / 0.45);
    color-scheme: dark;
  }
}

/* base */
[hidden] { display: none !important; }
.icon { width: 1.15em; height: 1.15em; flex: none; }
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: none; text-size-adjust: none; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; scroll-padding-top: calc(var(--header-h) + var(--space-4)); }
body { min-height: 100dvh; line-height: 1.55; font-family: var(--font-body); font-size: var(--text-base); color: var(--color-text);
  background: var(--color-bg); }
img, svg, canvas, iframe { display: block; max-width: 100%; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
h1, h2, h3 { text-wrap: balance; line-height: 1.2; }
p, li { text-wrap: pretty; }
a { color: var(--color-primary); text-underline-offset: 0.18em; }
a:hover { color: var(--color-primary-hover); }
::selection { background: color-mix(in oklab, var(--color-primary) 22%, transparent); }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; border-radius: var(--radius-sm); }
h1[tabindex='-1']:focus-visible { outline: none; } /* focus put there so a new page is announced: nothing to operate */
a, button, [role='button'], input, textarea, select { transition: color var(--transition-interactive), background var(--transition-interactive),
  border-color var(--transition-interactive), box-shadow var(--transition-interactive), opacity var(--transition-interactive); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: var(--space-4); top: -4rem; z-index: 100; background: var(--color-primary); color: var(--color-text-inverse);
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-md); }
.skip:focus { top: var(--space-2); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important; scroll-behavior: auto !important; } }

/* shell */
.app-header { position: sticky; top: 0; z-index: 20; height: var(--header-h); display: flex; align-items: center; gap: var(--space-4);
  padding: 0 clamp(var(--space-4), 3vw, var(--space-8)); background: color-mix(in oklab, var(--color-bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--color-divider); }
.wordmark { font-family: var(--font-display); font-weight: 650; font-size: 1.3rem; letter-spacing: -0.01em; color: var(--color-text);
  text-decoration: none; display: flex; align-items: baseline; gap: 0.1em; white-space: nowrap; }
.wordmark span { color: var(--color-primary); }
.nav { display: flex; gap: var(--space-1); margin-left: auto; }
.nav a { font-size: var(--text-sm); font-weight: 550; color: var(--color-text-muted); text-decoration: none; padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md); min-height: 40px; display: inline-flex; align-items: center; gap: var(--space-2); }
.nav a:hover { color: var(--color-text); background: var(--color-surface-2); }
.nav a[aria-current='page'] { color: var(--color-text); background: var(--color-surface-3); }
.nav .count { font-size: var(--text-xs); background: var(--color-primary); color: var(--color-text-inverse); border-radius: var(--radius-full);
  min-width: 1.4rem; height: 1.4rem; display: inline-grid; place-items: center; padding: 0 0.35rem; font-variant-numeric: tabular-nums; }
.account { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.account .who { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-header .nav { margin-left: auto; }
.app-header:not(:has(.nav:not([hidden]))) .account { margin-left: auto; }
@media (max-width: 1000px) { .account .who { display: none; } }
@media (max-width: 720px) { .nav a { padding: var(--space-2); } .nav .nav-admin { display: none; } }
/* On a phone the wordmark and three links already fill the row, so the header's Sign out goes (Settings has one). */
@media (max-width: 480px) { .app-header { gap: var(--space-2); } .account { display: none; } .nav { gap: 0; } .nav a { padding: var(--space-2) 0.4rem; } }
@media (max-width: 360px) { .app-header { gap: 0.25rem; } .wordmark { font-size: 1rem; } .nav a { padding: var(--space-2) 0.2rem; } }

main { width: 100%; max-width: 1180px; margin: 0 auto; padding: clamp(var(--space-5), 3vw, var(--space-10)) clamp(var(--space-4), 3vw, var(--space-8)) var(--space-16); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3) var(--space-6); margin-bottom: var(--space-6); }
.page-title { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.015em; }
.page-sub { color: var(--color-text-muted); font-size: var(--text-sm); margin-top: var(--space-1); }
.section-title { font-size: var(--text-lg); font-weight: 650; letter-spacing: -0.01em; margin-bottom: var(--space-3); }
.eyebrow { font-size: var(--text-xs); font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-muted); }
.muted { color: var(--color-text-muted); }
.wrap-anywhere { overflow-wrap: anywhere; }
.small { font-size: var(--text-sm); }
.tiny { font-size: var(--text-xs); }
.num { font-variant-numeric: tabular-nums; }
.stack > * + * { margin-top: var(--space-4); }
.stack-sm > * + * { margin-top: var(--space-2); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.grid-2 { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }
.grid-3 { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }

/* cards and controls */
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: clamp(var(--space-4), 2.5vw, var(--space-6));
  box-shadow: var(--shadow-sm); min-width: 0; }
.card.quiet { background: transparent; box-shadow: none; border-style: dashed; }
.card.feature { border-color: color-mix(in oklab, var(--color-primary) 35%, var(--color-border)); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 44px; padding: 0 var(--space-5);
  border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: 600; text-decoration: none; border: 1px solid transparent; white-space: nowrap; }
.btn svg { width: 1.1em; height: 1.1em; flex: none; }
.btn-primary { background: var(--color-primary); color: var(--color-text-inverse); }
.btn-primary:hover { background: var(--color-primary-hover); color: var(--color-text-inverse); }
.btn-primary:active { background: var(--color-primary-active); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { border-color: var(--color-text-muted); color: var(--color-text); }
.btn-ghost { color: var(--color-text-muted); padding: 0 var(--space-3); }
.btn-ghost:hover { color: var(--color-text); background: var(--color-surface-2); }
.btn-danger { color: var(--color-error); border-color: color-mix(in oklab, var(--color-error) 40%, var(--color-border)); background: transparent; }
.btn-danger:hover { background: var(--color-error-highlight); }
.btn[disabled], .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
/* On a very narrow phone a long label (Settings' Import button) wraps instead of reaching into the card's padding. */
@media (max-width: 360px) { .card .btn { white-space: normal; text-align: center; } }
.btn:has(input:focus-visible) { outline: 2px solid var(--color-primary); outline-offset: 3px; }
.btn-lg { min-height: 52px; padding: 0 var(--space-6); font-size: var(--text-base); }
.btn-block { width: 100%; }
.link-btn { color: var(--color-primary); font-weight: 600; font-size: var(--text-sm); text-decoration: underline; text-underline-offset: 0.2em; min-height: 44px;
  white-space: nowrap; }
.link-btn:hover { color: var(--color-primary-hover); }

label.field, .field { display: grid; gap: var(--space-2); }
.field > span:first-child { font-size: var(--text-sm); font-weight: 600; }
.field .hint { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 400; }
.input, .textarea, .select { width: 100%; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  padding: 0.7rem 0.85rem; font-size: var(--text-base); line-height: 1.5; min-height: 44px; }
.textarea { resize: vertical; min-height: 6.5rem; font-family: var(--font-read); }
.input:hover, .textarea:hover, .select:hover { border-color: color-mix(in oklab, var(--color-text-muted) 60%, var(--color-border)); }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-highlight); }
.input::placeholder, .textarea::placeholder { color: var(--color-placeholder); }

.badge { display: inline-flex; align-items: center; gap: 0.35em; font-size: var(--text-xs); font-weight: 650; padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full); background: var(--color-surface-2); color: var(--color-text-muted); white-space: nowrap; }
.badge.primary { background: var(--color-primary-highlight); color: var(--color-primary); }
.badge.fragile { background: var(--st-fragile-bg); color: var(--st-fragile); }
.badge.learning { background: var(--st-learning-bg); color: var(--st-learning); }
.badge.mastered { background: var(--st-mastered-bg); color: var(--st-mastered); }
.badge.secure { background: var(--st-secure-bg); color: var(--st-secure); }
.badge.planned { background: transparent; border: 1px dashed var(--st-planned); color: var(--color-text-muted); }

.notice { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  background: var(--color-surface-2); font-size: var(--text-sm); }
.notice svg { flex: none; width: 1.15rem; height: 1.15rem; margin-top: 0.15rem; color: var(--color-primary); }
.notice.warn { background: var(--st-learning-bg); }
.notice.warn svg { color: var(--st-learning); }
.notice.error { background: var(--color-error-highlight); }
.notice.error svg { color: var(--color-error); }

/* confidence */
.confidence { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-1); background: var(--color-surface-2);
  padding: var(--space-1); border-radius: var(--radius-md); }
.confidence button { min-height: 40px; border-radius: calc(var(--radius-md) - 3px); font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted);
  padding: 0 var(--space-1); }
.confidence button:hover { color: var(--color-text); background: var(--color-surface); }
.confidence button[aria-pressed='true'] { background: var(--color-surface); color: var(--color-primary); box-shadow: var(--shadow-sm);
  outline: 1px solid color-mix(in oklab, var(--color-primary) 45%, transparent); }

/* answer box */
.answer { display: grid; gap: var(--space-3); }
.answer .actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.answer .kbd-hint { font-size: var(--text-xs); color: var(--color-text-muted); }
kbd { font-family: var(--font-body); font-size: 0.85em; border: 1px solid var(--color-border); border-bottom-width: 2px; border-radius: 4px; padding: 0 0.3em; }

/* reading text (tutor, questions) */
.prose { font-family: var(--font-read); font-size: var(--text-base); line-height: 1.68; }
.prose > * + * { margin-top: 0.8em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 0.25em; }
.prose strong { font-weight: 650; }
.prose code { font-size: 0.9em; background: var(--color-surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
.prose pre { background: var(--color-surface-2); padding: var(--space-3); border-radius: var(--radius-md); overflow-x: auto; }
.prose table { border-collapse: collapse; width: 100%; font-family: var(--font-body); font-size: var(--text-sm); display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--color-border); padding: 0.4em 0.6em; text-align: left; }
.prose blockquote { border-left: 3px solid var(--color-border); padding-left: var(--space-3); color: var(--color-text-muted); }
.math-display { display: block; overflow-x: auto; overflow-y: hidden; padding: 0.25em 0; text-align: center; }
.katex { font-size: 1.06em; }

/* lesson */
.lesson { display: grid; gap: var(--space-6); grid-template-columns: minmax(0, 1fr); }
.lesson-side { order: -1; min-width: 0; }
.lesson-side summary::-webkit-details-marker { display: none; }
@media (min-width: 1040px) { .lesson { grid-template-columns: minmax(0, 1fr) 21rem; align-items: start; }
  .lesson-side { order: 2; position: sticky; top: calc(var(--header-h) + var(--space-5)); max-height: calc(100dvh - var(--header-h) - var(--space-10)); overflow-y: auto; } }
.stepper { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); list-style: none; font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted); }
.stepper li { display: flex; align-items: center; gap: var(--space-2); }
.stepper li + li::before { content: ''; width: 1rem; height: 1px; background: var(--color-border); }
.stepper .dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; border: 1.5px solid currentColor; }
.stepper .done { color: var(--color-success); }
.stepper .done .dot { background: currentColor; }
.stepper .now { color: var(--color-primary); }
.stepper .now .dot { background: currentColor; box-shadow: 0 0 0 3px var(--color-primary-highlight); }

.convo { display: grid; gap: var(--space-5); }
.lesson-action { margin-top: var(--space-5); }
.lesson-action:empty { display: none; }
.msg { animation: rise 260ms var(--ease) both; min-width: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-tutor { padding-left: var(--space-4); border-left: 2px solid var(--color-divider); }
.msg-note { color: var(--color-text-muted); font-size: var(--text-sm); display: flex; gap: var(--space-2); align-items: flex-start; }
.msg-note svg { flex: none; width: 1rem; height: 1rem; margin-top: 0.25rem; }
.msg-note .prose { font-family: var(--font-body); font-size: var(--text-sm); line-height: 1.55; }
.msg-learner { justify-self: end; max-width: min(36rem, 92%); background: var(--color-surface-2); border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
  padding: var(--space-3) var(--space-4); overflow-wrap: anywhere; }
.msg-learner .meta { display: block; font-family: var(--font-body); font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-1); }
.msg-question { background: var(--color-surface); border: 1px solid var(--color-border); border-left: 3px solid var(--color-primary);
  border-radius: var(--radius-md); padding: var(--space-4) var(--space-5); }
.msg-question .head { display: flex; gap: var(--space-2); align-items: center; margin-bottom: var(--space-2); }
.feedback { border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); padding: var(--space-4) var(--space-5); }
.feedback.pass { border-color: color-mix(in oklab, var(--color-success) 40%, var(--color-border)); }
.feedback.miss { border-color: color-mix(in oklab, var(--st-fragile) 40%, var(--color-border)); }
.feedback .verdict { display: flex; align-items: center; gap: var(--space-2); font-weight: 650; font-size: var(--text-sm); margin-bottom: var(--space-3); }
.feedback .verdict svg { width: 1.2rem; height: 1.2rem; }
.feedback.pass .verdict { color: var(--color-success); }
.feedback.miss .verdict { color: var(--st-fragile); }
.points { list-style: none; display: grid; gap: var(--space-2); margin: var(--space-3) 0; font-size: var(--text-sm); }
.points li { display: flex; gap: var(--space-2); align-items: flex-start; }
.points svg { flex: none; width: 1.05rem; height: 1.05rem; margin-top: 0.2rem; }
.points .hit svg { color: var(--color-success); }
.points .miss { color: var(--color-text-muted); }
.points .miss svg { color: var(--st-fragile); }
details.more { margin-top: var(--space-3); font-size: var(--text-sm); }
details.more summary { cursor: pointer; color: var(--color-primary); font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }
details.more[open] summary { margin-bottom: var(--space-2); }
.callout { margin-top: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--st-fragile-bg); font-size: var(--text-sm); }

.composer { position: sticky; bottom: 0; z-index: 5; margin-top: var(--space-6); padding: var(--space-4) 0 max(var(--space-4), env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--color-bg) 22%); }
.composer .card { box-shadow: var(--shadow-md); }
.composer-row { display: flex; gap: var(--space-2); align-items: flex-end; }
.composer-row .textarea { min-height: 48px; height: 48px; max-height: 12rem; resize: none; font-family: var(--font-body); }
.tools { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }

.thinking { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--color-text-muted); font-size: var(--text-sm); }
.thinking i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite both; }
.thinking i:nth-child(2) { animation-delay: 0.15s; } .thinking i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }
.streaming::after { content: '▍'; color: var(--color-primary); animation: blink 1s infinite; margin-left: 2px; }

.side-card h3 { font-size: var(--text-sm); font-weight: 650; margin-bottom: var(--space-3); }
.map-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--space-2)); padding: var(--space-2); }
.map-wrap svg { width: 100%; height: auto; max-width: none; margin: 0 auto; }
.concept-map { font-family: var(--font-body); }
.cm-node rect { fill: var(--color-surface); stroke: var(--color-border); stroke-width: 1.5; }
.cm-node text { font-size: 12.5px; fill: var(--color-text); font-weight: 550; }
.cm-edge { fill: none; stroke: var(--color-text-faint); stroke-width: 1.4; }
.cm-arrowhead { fill: var(--color-text-faint); }
.cm-planned rect, .cm-later rect, .cm-upcoming rect { stroke-dasharray: 5 4; fill: transparent; stroke: var(--st-planned); }
.cm-planned text, .cm-later text { fill: var(--color-text-muted); }
.cm-current rect { fill: var(--color-primary-highlight); stroke: var(--color-primary); stroke-width: 2.5; stroke-dasharray: none; }
.cm-taught rect { fill: var(--st-mastered-bg); stroke: var(--st-mastered); }
.cm-tested-out rect { fill: var(--st-mastered-bg); stroke: var(--st-mastered); stroke-dasharray: 3 3; }
.cm-learning rect { fill: var(--st-learning-bg); stroke: var(--st-learning); }
.cm-fragile rect { fill: var(--st-fragile-bg); stroke: var(--st-fragile); }
.cm-mastered rect { fill: var(--st-mastered-bg); stroke: var(--st-mastered); }
.cm-secure rect { fill: var(--st-secure-bg); stroke: var(--st-secure); }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-3); font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-3); list-style: none; }
.legend li { display: flex; align-items: center; gap: var(--space-1); }
.legend i { width: 0.8rem; height: 0.8rem; border-radius: 3px; border: 1.5px solid; }
.legend .now { background: var(--color-primary-highlight); border-color: var(--color-primary); }
.legend .ok { background: var(--st-mastered-bg); border-color: var(--st-mastered); }
.legend .todo { border-style: dashed; border-color: var(--st-planned); }
.legend .secure { background: var(--st-secure-bg); border-color: var(--st-secure); }
.legend .mastered { background: var(--st-mastered-bg); border-color: var(--st-mastered); }
.legend .learning { background: var(--st-learning-bg); border-color: var(--st-learning); }
.legend .fragile { background: var(--st-fragile-bg); border-color: var(--st-fragile); }
.outline { list-style: none; display: grid; gap: var(--space-2); font-size: var(--text-sm); }
.outline li { display: grid; grid-template-columns: auto 1fr; gap: var(--space-2); align-items: start; }
.outline .mark { width: 0.65rem; height: 0.65rem; border-radius: 50%; margin-top: 0.4rem; border: 1.5px solid var(--st-planned); }
.outline .current .mark { background: var(--color-primary); border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-highlight); }
.outline .taught .mark, .outline .tested-out .mark, .outline .mastered .mark, .outline .learning .mark, .outline .secure .mark { background: var(--st-mastered); border-color: var(--st-mastered); }
.outline .fragile .mark { background: var(--st-fragile); border-color: var(--st-fragile); }
.outline .later { color: var(--color-text-muted); }

.progress { height: 6px; background: var(--color-surface-3); border-radius: var(--radius-full); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--color-primary); border-radius: inherit; transition: width 400ms var(--ease); }

/* home */
.hero-due { display: grid; gap: var(--space-5); grid-template-columns: minmax(0, 1fr); align-items: center; }
@media (min-width: 720px) { .hero-due { grid-template-columns: auto minmax(0, 1fr) auto; } }
.big-num { font-family: var(--font-display); font-size: clamp(2.6rem, 2rem + 2vw, 3.4rem); font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; color: var(--color-primary); }
.big-num .icon { width: 2.4rem; height: 2.4rem; }
.days { display: flex; gap: 4px; align-items: center; }
.days i { width: 12px; height: 12px; border-radius: 3px; background: var(--color-surface-3); }
.days i.on { background: var(--st-mastered); }
.mbar { display: flex; height: 8px; border-radius: var(--radius-full); overflow: hidden; background: var(--color-surface-3); }
.mbar i { display: block; height: 100%; }
.mbar .fragile { background: var(--st-fragile); } .mbar .learning { background: var(--st-learning); } .mbar .mastered { background: var(--st-mastered); }
.mbar .secure { background: var(--st-secure); } .mbar .planned { background: repeating-linear-gradient(90deg, var(--st-planned) 0 3px, transparent 3px 6px); opacity: 0.6; }
.topic-card { display: grid; gap: var(--space-3); text-decoration: none; color: inherit; }
.topic-card:hover { border-color: var(--color-text-muted); }
.topic-card h3 { font-size: var(--text-base); font-weight: 650; }
.kv { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); font-size: var(--text-xs); color: var(--color-text-muted); }
.stat { display: grid; gap: var(--space-1); }
.stat b { font-size: var(--text-lg); font-weight: 650; font-variant-numeric: tabular-nums; }

/* sign in */
.signin { display: grid; gap: var(--space-10) var(--space-12); align-items: start; max-width: 62rem; margin: clamp(var(--space-4), 5vh, var(--space-12)) auto 0;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }
.signin h1 { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.02em; max-width: 18ch; }
.signin .lede { font-family: var(--font-read); font-size: var(--text-lg); line-height: 1.5; color: var(--color-text-muted); max-width: 36ch; margin-top: var(--space-4); }
.signin .pitch { list-style: none; margin-top: var(--space-6); }
@media (max-width: 720px) { .signin .pitch { display: none; } .signin { gap: var(--space-6); } }
.auth-tabs { display: flex; gap: var(--space-1); margin-bottom: var(--space-5); border-bottom: 1px solid var(--color-divider); }
.auth-tabs a { padding: 0 var(--space-4); min-height: 44px; display: inline-flex; align-items: center; font-weight: 600; font-size: var(--text-sm);
  color: var(--color-text-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.auth-tabs a:hover { color: var(--color-text); }
.auth-tabs a[aria-current='page'] { color: var(--color-text); border-color: var(--color-primary); }

/* welcome */
.welcome { max-width: 52rem; margin: clamp(var(--space-4), 6vh, var(--space-16)) auto 0; }
.welcome h1 { font-family: var(--font-display); font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.02em; max-width: 22ch; }
.welcome .lede { font-family: var(--font-read); font-size: var(--text-lg); line-height: 1.5; color: var(--color-text-muted); max-width: 40ch; margin-top: var(--space-4); }
.steps3 { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); margin: var(--space-10) 0; counter-reset: s; list-style: none; }
.steps3 li { counter-increment: s; border-top: 2px solid var(--color-text); padding-top: var(--space-3); }
.steps3 li::before { content: counter(s); font-family: var(--font-display); font-weight: 600; font-size: var(--text-lg); color: var(--color-primary); display: block; margin-bottom: var(--space-1); }
.steps3 b { display: block; font-weight: 650; margin-bottom: var(--space-1); }
.steps3 p { font-size: var(--text-sm); color: var(--color-text-muted); }

/* settings */
input[type='range'] { width: 100%; accent-color: var(--color-primary); min-height: 32px; }

/* lists */
.list { list-style: none; display: grid; }
.list > li { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); align-items: center; justify-content: space-between;
  padding: var(--space-3) 0; border-top: 1px solid var(--color-divider); }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1 1 16rem; min-width: 0; }
.list .title { font-weight: 600; }
.list .sub { font-size: var(--text-sm); color: var(--color-text-muted); overflow-wrap: anywhere; }

/* explorable */
.explorable { border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); overflow: hidden; }
.explorable .head { padding: var(--space-4) var(--space-5) 0; }
.explorable .body { padding: var(--space-4) var(--space-5) var(--space-5); display: grid; gap: var(--space-3); }
.frame-wrap { position: relative; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--color-divider); background: #fbfaf7; }
.frame-wrap iframe { width: 100%; border: 0; height: 440px; background: #fbfaf7; }
.frame-veil { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in oklab, var(--color-surface) 85%, transparent); }
.check-line { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--color-text-muted); }
.check-line svg { width: 1rem; height: 1rem; }
.check-line.ok svg { color: var(--color-success); }
.check-line.bad svg { color: var(--st-learning); }

/* feedback toast */
.toasts { position: fixed; z-index: 50; left: 50%; bottom: var(--space-6); transform: translateX(-50%); display: grid; gap: var(--space-2); width: min(34rem, calc(100% - 2rem)); }
.toast { background: var(--color-text); color: var(--color-text-inverse); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  font-size: var(--text-sm); display: flex; gap: var(--space-3); align-items: flex-start; animation: rise 220ms var(--ease) both; }
.toast a { color: inherit; font-weight: 650; }
.toast button { margin-left: auto; color: inherit; opacity: 0.7; min-width: 28px; min-height: 28px; }

.skeleton { background: linear-gradient(90deg, var(--color-surface-2), var(--color-surface-3), var(--color-surface-2)); background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear; border-radius: var(--radius-md); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty { text-align: center; padding: var(--space-10) var(--space-4); color: var(--color-text-muted); }
.empty h3 { color: var(--color-text); font-size: var(--text-base); margin-bottom: var(--space-2); }

/* confirmation dialog */
dialog.ask { border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); color: var(--color-text);
  padding: var(--space-6); max-width: min(28rem, calc(100vw - 2rem)); box-shadow: var(--shadow-lg); margin: auto; }
dialog.ask p { margin: 0 0 var(--space-5); line-height: 1.5; }
dialog.ask::backdrop { background: oklch(0.2 0.02 260 / 0.45); }

/* allowance meter: how much of the tutor is left, in words. Each state has its own icon and wording, not only a colour. */
.meter { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; padding: 0 var(--space-3); border: 1px solid var(--color-border);
  border-radius: var(--radius-full); text-decoration: none; color: var(--color-text-muted); font-size: var(--text-xs); font-weight: 650; white-space: nowrap; }
.meter:hover { border-color: var(--color-primary); color: var(--color-text); }
.meter .icon { width: 1.25rem; height: 1.25rem; }
.meter .ring { width: 1.5rem; height: 1.5rem; flex: none; }
.ring .track { fill: none; stroke: var(--color-surface-3); stroke-width: 3.5; }
.ring .fill { fill: none; stroke: var(--color-primary); stroke-width: 3.5; stroke-linecap: round; }
.ring .fill.low { stroke: var(--st-learning); }
.meter[data-state='low'] { color: var(--st-learning); border-color: color-mix(in oklab, var(--st-learning) 45%, var(--color-border)); }
.meter[data-state='empty'] { color: var(--st-fragile); border-color: color-mix(in oklab, var(--st-fragile) 45%, var(--color-border)); }
.meter[data-state='unverified'], .meter[data-state='paused'] { border-style: dashed; }
.meter-short { display: none; }
.meter-strip { display: none; }
@media (max-width: 1000px) { .app-header .meter-long { display: none; } .app-header .meter-short { display: inline; } }
.app-header .meter { margin-left: var(--space-2); }
.app-header:not(:has(.nav:not([hidden]))) .meter { display: none; }
@media (max-width: 720px) {
  .app-header .meter { display: none; }
  .under-header .meter-strip { display: flex; width: 100%; justify-content: center; border-radius: 0; border-width: 0 0 1px; background: var(--color-surface-2);
    min-height: 44px; font-size: var(--text-sm); }
  .under-header .meter-strip .meter-short { display: none; }
  .under-header .meter-strip .meter-long { display: inline; }
}
.banner-in { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); padding: var(--space-3) clamp(var(--space-4), 3vw, var(--space-8));
  background: var(--color-primary-highlight); border-bottom: 1px solid var(--color-divider); font-size: var(--text-sm); }
.banner-in > p { flex: 1 1 18rem; }
.banner-in .icon { color: var(--color-primary); width: 1.3rem; height: 1.3rem; }

/* plan & usage */
.meter-bar { height: 8px; border-radius: var(--radius-full); background: color-mix(in oklab, var(--color-primary) 14%, var(--color-surface-3)); overflow: hidden; }
.meter-bar > i { display: block; height: 100%; background: var(--color-primary); border-radius: inherit; transition: width 400ms var(--ease); }
.meter-bar.near > i { background: var(--st-learning); }
.meter-bar.full > i { background: var(--st-fragile); }
.parts { list-style: none; display: grid; gap: var(--space-4); }
.parts li { display: grid; gap: var(--space-1); }
.rules { list-style: none; display: grid; gap: var(--space-3); font-size: var(--text-sm); }
.rules li { padding-left: var(--space-4); border-left: 2px solid var(--color-divider); }
.notice.success { background: var(--color-success-highlight); }
.notice.success svg { color: var(--color-success); }
.narrow-page { max-width: 30rem; margin: clamp(var(--space-4), 6vh, var(--space-12)) auto 0; }
.welcome-note { margin-top: var(--space-6); max-width: 40rem; }
.toast-action { color: inherit; font-weight: 650; text-decoration: underline; min-height: 28px; }

/* a review the learner marks themselves */
fieldset.points-check { border: 0; display: grid; gap: var(--space-1); margin: var(--space-3) 0; min-width: 0; }
.check { display: flex; gap: var(--space-3); align-items: flex-start; min-height: 44px; padding: var(--space-2) 0; cursor: pointer; font-size: var(--text-sm); }
.check input { width: 1.3rem; height: 1.3rem; margin-top: 0.1rem; accent-color: var(--color-primary); flex: none; }
.self-idea { font-family: var(--font-read); line-height: 1.6; }

/* business dashboard */
.kpis { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); margin-bottom: var(--space-6); }
.stat-tile { display: grid; gap: var(--space-1); align-content: start; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
  padding: var(--space-4); min-width: 0; }
.stat-tile b { font-size: var(--text-xl); font-weight: 600; line-height: 1.1; overflow-wrap: anywhere; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 4px; background: var(--color-surface-2); border-radius: var(--radius-md); }
.segmented button { min-height: 44px; padding: 0 var(--space-4); border-radius: calc(var(--radius-md) - 2px); font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted); }
.segmented button:hover { color: var(--color-text); }
.segmented button[aria-pressed='true'] { background: var(--color-surface); color: var(--color-primary); font-weight: 700; box-shadow: var(--shadow-sm); }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
table.data th { text-align: left; font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 650; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-divider); }
table.data td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-divider); vertical-align: top; overflow-wrap: anywhere; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  table.data thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  table.data, table.data tbody, table.data tr, table.data td { display: block; }
  table.data tr { padding: var(--space-2) 0; border-bottom: 1px solid var(--color-border); }
  table.data td { display: flex; justify-content: space-between; gap: var(--space-4); border: 0; padding: var(--space-1) 0; text-align: right; }
  table.data td::before { content: attr(data-label); color: var(--color-text-muted); font-weight: 600; text-align: left; flex: none; }
  table.data td a { display: inline-flex; align-items: center; min-height: 44px; }
}
.chart-card { display: grid; gap: var(--space-2); margin: 0; min-width: 0; position: relative; }
.chart-card figcaption { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); align-items: baseline; }
.chart { width: 100%; height: auto; overflow: visible; }
.chart .col { fill: var(--color-primary); }
.chart .axis { stroke: var(--color-border); stroke-width: 1; }
.chart .axis-text { fill: var(--color-text-muted); font-size: 15px; font-family: var(--font-body); }
.chart-tip { position: absolute; top: 1.6rem; right: 0; pointer-events: none; font-size: var(--text-xs); background: var(--color-text); color: var(--color-text-inverse); padding: 0.2rem 0.5rem; border-radius: var(--radius-sm); }
.chart-tip.off { visibility: hidden; }
.hbars { list-style: none; display: grid; gap: var(--space-3); }
.hbars li { display: grid; grid-template-columns: minmax(8rem, 15rem) minmax(0, 1fr) auto; gap: var(--space-1) var(--space-3); align-items: center; font-size: var(--text-sm); }
.hbar-track { display: block; height: 10px; background: color-mix(in oklab, var(--color-primary) 12%, transparent); border-radius: 0 4px 4px 0; }
.hbar-track > i { display: block; height: 100%; background: var(--color-primary); border-radius: 0 4px 4px 0; }
@media (max-width: 560px) { .hbars li { grid-template-columns: minmax(0, 1fr) auto; } .hbar-track { grid-column: 1 / -1; } }

/* an icon in the middle of a sentence stays in the line (a bare svg is a block) */
p > .icon, b > .icon { display: inline-block; vertical-align: -0.2em; }
.status-area:empty { display: none; }
.status-area > * + * { margin-top: var(--space-3); }
