/* Hanura Next learnings portal — same type and palette as hanuranext.com.
 *
 * The reading layout is built for a single screen shared with an editor: a slim
 * topic rail that never collapses above the content, and a panel that stays
 * readable at around 700px so the browser can sit beside VS Code. */

:root {
  /* The palette below has a full dark variant (see the media query), so let the
     browser theme form controls, scrollbars and the like to match. */
  color-scheme: light dark;

  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-sunken: #f1f5f9;
  --dark: #0f172a;
  --text: #374151;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-light: rgba(37, 99, 235, 0.08);
  --border: #e5e7eb;
  --done: #16a34a;
  --done-light: rgba(22, 163, 74, 0.1);
  --warn: #d97706;
  --danger: #dc2626;
  /* Platform accents for code snippets — deliberately different hues so a
     Windows block and a macOS block are never mistaken for each other. */
  --win: #2563eb;
  --win-tint: rgba(37, 99, 235, 0.09);
  --mac: #7c3aed;
  --mac-tint: rgba(124, 58, 237, 0.09);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-lift: 0 2px 4px rgba(15, 23, 42, .06), 0 16px 40px rgba(15, 23, 42, .10);
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --bg-subtle: #131e35;
    --bg-sunken: #0b1222;
    --dark: #f8fafc;
    --text: #cbd5e1;
    --muted: #94a3b8;
    --accent: #60a5fa;
    --accent-dark: #93c5fd;
    --accent-light: rgba(96, 165, 250, 0.12);
    --border: #1e293b;
    --done: #4ade80;
    --done-light: rgba(74, 222, 128, 0.12);
    --warn: #fbbf24;
    --danger: #f87171;
    --win: #60a5fa;
    --win-tint: rgba(96, 165, 250, 0.16);
    --mac: #a78bfa;
    --mac-tint: rgba(167, 139, 250, 0.18);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .35), 0 16px 40px rgba(0, 0, 0, .45);
  }
}

* { box-sizing: border-box; }

/* A class that sets `display` beats the UA stylesheet's rule for [hidden]. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-subtle);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

h1, h2, h3, h4 { color: var(--dark); line-height: 1.25; margin: 0 0 .4em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.dot { opacity: .5; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: .6rem 1.1rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }
.btn-ghost.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--danger); border-color: var(--danger); }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-block { width: 100%; margin-top: .75rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Signed out ──────────────────────────────────────────────────────────── */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--accent-light), transparent 70%),
    var(--bg-subtle);
}
.auth-card {
  width: min(420px, 100%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.25rem;
}
.auth-brand, .topbar-brand { font-weight: 800; letter-spacing: -.02em; color: var(--dark); }
.auth-brand { font-size: 1.35rem; margin-bottom: 1.5rem; }
.auth-brand span, .topbar-brand span { color: var(--accent); }
.auth-form h1 { font-size: 1.5rem; }
.auth-form > .muted { margin: 0 0 .5rem; font-size: .9rem; }
.auth-form label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--dark);
  margin: 1.1rem 0 .35rem;
}
.auth-form input {
  width: 100%;
  font: inherit;
  padding: .65rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}
.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.field-hint { font-size: .78rem; color: var(--muted); margin: .4rem 0 0; }
.captcha-slot { margin-top: 1.1rem; min-height: 78px; }
.form-error { color: var(--danger); font-size: .875rem; margin: 1rem 0 0; }
.form-ok { color: var(--done); font-size: .875rem; margin: 1rem 0 0; }
.auth-foot { font-size: .82rem; text-align: center; margin: 1.25rem 0 0; color: var(--muted); }

/* ── Chrome ──────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: .8rem clamp(.9rem, 3vw, 2.5rem);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-brand { font-size: 1.05rem; text-decoration: none; }
.topbar-nav { display: flex; gap: 1.1rem; flex: 1; }
.topbar-nav a {
  color: var(--muted);
  font-size: .88rem;
  font-weight: 500;
  padding: .25rem 0;
  border-bottom: 2px solid transparent;
  text-decoration: none;
}
.topbar-nav a:hover { color: var(--dark); }
.topbar-nav a.active { color: var(--accent); border-bottom-color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.who { font-size: .84rem; color: var(--muted); }

main { padding: clamp(1.25rem, 3vw, 2.5rem) clamp(.9rem, 3vw, 2.5rem) 3rem; max-width: 1240px; margin: 0 auto; }

.footer {
  padding: 1.1rem clamp(.9rem, 3vw, 2.5rem);
  border-top: 1px solid var(--border);
  font-size: .8rem;
  color: var(--muted);
}

.page-head { margin-bottom: 1.75rem; }
.page-head h1 { font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -.02em; }

/* ── Cards ───────────────────────────────────────────────────────────────── */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 5px solid transparent;
  border-radius: var(--radius);
  padding: 1.3rem 1.3rem 1.4rem;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
a.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lift);
  border-top-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  border-right-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  border-bottom-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  text-decoration: none;
}

/* Every topic read: the card gets the same green marker as the topics did. */
.card-complete { border-left-color: var(--done); }
.card-locked { opacity: .6; cursor: not-allowed; background: var(--bg-subtle); }
.card-locked:hover { transform: none; box-shadow: var(--shadow); }

.card h3 { font-size: 1.1rem; letter-spacing: -.01em; margin-bottom: .3rem; }
.card-sub { font-size: .88rem; color: var(--muted); margin: 0; flex: 1; }
.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem;
  margin-top: .9rem;
  font-size: .76rem;
  color: var(--muted);
}

.badge {
  display: inline-block;
  font-size: .67rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: .16rem .5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--bg-subtle);
}
.badge-draft { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.badge-broken { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.badge-quiz { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: var(--accent-light); }

/* ── Card entry chooser ──────────────────────────────────────────────────── */
/* One level deeper into the same grid: a card opens into 2-3 tiles (deck,
   reader, and — on Set-up only — a download) instead of jumping straight into
   its reader. Reuses .card so it reads as "the same grid, one step in." */

.chooser-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); max-width: 760px; }
.chooser-tile h3 { font-size: 1.02rem; }
.chooser-tile .card-sub { flex: none; }

/* ── Reading a card ──────────────────────────────────────────────────────── */

.reader {
  display: grid;
  /* Half a 1366-1536px laptop is roughly 680-760px, which is the case this is
     built for: the rail narrows but stays a rail, so the green markers keep
     their vertical bar and the panel keeps a sensible measure. */
  grid-template-columns: clamp(168px, 20vw, 250px) minmax(0, 1fr);
  gap: clamp(1rem, 2.5vw, 2rem);
  align-items: start;
}

.rail {
  position: sticky;
  top: 4.2rem;
  max-height: calc(100vh - 5.5rem);
  overflow-y: auto;
  padding-right: .35rem;
}
.rail-back { font-size: .8rem; color: var(--muted); }
.rail-back:hover { color: var(--accent); }
.rail-title {
  font-size: .98rem;
  font-weight: 700;
  color: var(--dark);
  letter-spacing: -.01em;
  margin: .7rem 0 .35rem;
  line-height: 1.35;
}
.rail-count { font-size: .75rem; color: var(--muted); margin-bottom: .8rem; }

.topic-list { list-style: none; margin: 0; padding: 0; }
.topic-link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .7rem;
  /* The visited marker: a green bar to the left of the topic name. */
  border-left: 3px solid var(--border);
  color: var(--text);
  font-size: .875rem;
  line-height: 1.4;
  text-decoration: none;
}
.topic-link:hover { background: var(--bg-subtle); text-decoration: none; }
.topic-link.visited { border-left-color: var(--done); }
.topic-link.current {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}
.topic-link.current:not(.visited) { border-left-color: var(--accent); }
.topic-draft .topic-title { font-style: italic; color: var(--muted); }
.topic-flag {
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--warn);
  flex-shrink: 0;
}

.panel { min-width: 0; }
.intro { margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.topic-head { margin-bottom: 1.4rem; }
.topic-head h1 { font-size: clamp(1.4rem, 2.6vw, 1.8rem); letter-spacing: -.02em; }
.topic-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.slide-link {
  font-size: .76rem;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  background: var(--accent-light);
  border-radius: 999px;
  padding: .12rem .6rem;
}
.slide-link:hover { text-decoration: none; background: var(--accent); color: #fff; }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* Only on a genuinely narrow window — a phone, or a very tight split — does the
   rail give up and become a horizontal strip. */
@media (max-width: 560px) {
  /* The username plus "Sign out" button is the first thing to overflow a
     narrow phone screen — drop the username text, since the person reading
     the page already knows who they are, and keep the button. */
  .topbar { gap: .6rem; }
  .who { display: none; }

  .reader { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .rail {
    position: static;
    max-height: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: .75rem;
  }
  .topic-list {
    display: flex;
    gap: .4rem;
    overflow-x: auto;
    padding-bottom: .35rem;
  }
  .topic-link {
    white-space: nowrap;
    border-left: none;
    border-bottom: 3px solid var(--border);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  }
  .topic-link.visited { border-bottom-color: var(--done); }
  .topic-link.current:not(.visited) { border-bottom-color: var(--accent); }
}

/* ── Quiz ────────────────────────────────────────────────────────────────── */
/* Built mobile-first: this is the one screen students are told to reach from
   their own phone, so code never scrolls — it shrinks and wraps instead — and
   every tap target (option, chip, segment, line) stays comfortably big. */

.quiz-note {
  font-size: .9rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--accent-light);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: .8rem 1rem;
  margin-bottom: 1.1rem;
  max-width: 720px;
}
.quiz-note strong { color: var(--dark); }

/* The single-question stage that fades between questions (and into the
   final report) — advanceQuiz() in app.js toggles quiz-stage-hidden, waits
   for the transition, swaps the content, then removes it again. */
.quiz-stage {
  max-width: 760px;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .2s ease, transform .2s ease;
}
.quiz-stage-hidden { opacity: 0; transform: translateY(6px); }

.quiz-progress { margin-bottom: 1rem; }
.quiz-progress-label {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: .75rem;
  font-size: .88rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: .4rem;
}
.quiz-progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-sunken);
  overflow: hidden;
}
.quiz-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width .2s ease;
}

.quiz-report {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.4rem 1.6rem;
  box-shadow: var(--shadow);
}
.quiz-report h2 { margin-bottom: .3rem; }
.quiz-report-score { font-size: 1.05rem; font-weight: 600; color: var(--dark); margin: 0 0 1.1rem; }
.quiz-report-sections { margin-bottom: 1.3rem; }
.quiz-report-row {
  display: flex;
  justify-content: space-between;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.quiz-report-row:last-child { border-bottom: none; }
.quiz-report-actions { display: flex; flex-wrap: wrap; gap: .6rem; }

.quiz-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .9rem; }

.quiz-question {
  /* A column flex item defaults to min-width: auto, which lets it grow to fit
     an unwrapped descendant and blocks every wrap rule inside it — this is
     what actually has to be zeroed out for the no-scroll code rule to hold. */
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1.25rem;
  box-shadow: var(--shadow);
}
.quiz-question-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .6rem;
  margin-bottom: .75rem;
}
.quiz-question-head > * { min-width: 0; }
.quiz-prompt { margin: 0; font-weight: 600; color: var(--dark); font-size: 1rem; overflow-wrap: anywhere; }
.quiz-badge-correct {
  color: var(--done);
  border-color: color-mix(in srgb, var(--done) 45%, var(--border));
  background: var(--done-light);
}

/* Code in a quiz card: shrink the font and wrap long lines rather than ever
   scrolling, the same rule the Day 1 deck's own tight-code slides follow. */
.quiz-code {
  margin: 0 0 .9rem;
  padding: .7rem .8rem;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: .78rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--dark);
}
.quiz-code code { font-family: inherit; }

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  padding: .55rem .65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: .45rem;
  cursor: pointer;
  font-size: .92rem;
  overflow-wrap: anywhere;
}
.quiz-option:hover { border-color: var(--accent); }
.quiz-option-picked { border-color: var(--accent); background: var(--accent-light); }
/* Right answer: a clearly green block (not the pale tint the blue explanation box uses),
   with dark text so it stays readable in light and dark themes. */
.quiz-option-correct { border-color: var(--done); background: color-mix(in srgb, var(--done) 26%, transparent); box-shadow: inset 0 0 0 1px var(--done); color: var(--dark); }
.quiz-option-wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 16%, transparent); box-shadow: inset 0 0 0 1px var(--danger); color: var(--dark); }
.quiz-option input { margin-top: .2rem; accent-color: var(--accent); flex-shrink: 0; }
.quiz-option span { min-width: 0; }

.quiz-order-answer, .quiz-order-pool {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .7rem;
}
.quiz-seg {
  min-width: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .45rem .65rem;
  font-size: .82rem;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.quiz-seg code { font-family: var(--mono); font-size: .95em; }
.quiz-seg:hover { border-color: var(--accent); }
.quiz-seg-placed { background: var(--accent-light); border-color: var(--accent); }
.quiz-seg-correct { background: color-mix(in srgb, var(--done) 26%, transparent); border-color: var(--done); box-shadow: inset 0 0 0 1px var(--done); color: var(--dark); cursor: default; }
.quiz-order-correct { margin: -.2rem 0 .7rem; }

.quiz-bugcode {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: .9rem;
  background: var(--bg-sunken);
}
.bugline {
  display: block;
  width: 100%;
  font: inherit;
  font-family: var(--mono);
  font-size: .76rem;
  line-height: 1.5;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--dark);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: .35rem .7rem;
  cursor: pointer;
}
.bugline:last-child { border-bottom: none; }
.bugline:hover { background: var(--accent-light); }
.bugline-picked { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.bugline-correct { background: color-mix(in srgb, var(--done) 26%, transparent); box-shadow: inset 4px 0 0 var(--done); color: var(--dark); font-weight: 600; }
.bugline-wrong { background: color-mix(in srgb, var(--danger) 16%, transparent); box-shadow: inset 4px 0 0 var(--danger); color: var(--dark); }
.bugline-static { cursor: default; color: var(--muted); }
.bugline-static:hover { background: transparent; }

.quiz-grading, .quiz-explanation {
  font-size: .84rem;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  margin: .6rem 0 0;
}
.quiz-grading { background: var(--bg-subtle); color: var(--muted); }
.quiz-explanation { background: var(--accent-light); color: var(--text); }

/* Never let a code block force the page to scroll sideways on a phone —
   shrink further rather than overflow. */
@media (max-width: 560px) {
  .quiz-code, .bugline { font-size: .72rem; }
  .quiz-question { padding: .9rem 1rem 1.05rem; }
}

/* ── Prose ───────────────────────────────────────────────────────────────── */

.prose { font-size: 1rem; }
.prose h1 { font-size: 1.35rem; margin-top: 1.9rem; }
.prose h2 { font-size: 1.18rem; margin-top: 1.75rem; }
.prose h3 { font-size: 1.03rem; margin-top: 1.5rem; }
.prose p { margin: 0 0 1rem; }
.prose ul, .prose ol { margin: 0 0 1rem; padding-left: 1.3rem; }
.prose li { margin-bottom: .35rem; }
.prose blockquote {
  margin: 1.25rem 0;
  padding: .85rem 1.1rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose code {
  font-family: var(--mono);
  font-size: .875em;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .1em .35em;
}
.prose table { width: 100%; border-collapse: collapse; margin: 1.25rem 0; font-size: .9rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: .5rem .7rem; text-align: left; }
.prose th { background: var(--bg-subtle); color: var(--dark); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

/* ── Snippets ────────────────────────────────────────────────────────────── */

.snippet {
  margin: 1.3rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}
.snippet-bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .4rem .45rem .4rem .9rem;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-size: .76rem;
}
.snippet-label {
  font-family: var(--mono);
  color: var(--muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.snippet-code {
  margin: 0;
  padding: .95rem 1.05rem;
  overflow-x: auto;
  background: var(--bg-sunken);
  font-family: var(--mono);
  font-size: .85rem;
  line-height: 1.6;
  color: var(--dark);
  tab-size: 2;
}
.snippet-code code { font-family: inherit; }
.snippet-output .snippet-code { opacity: .85; }

/* Platform badge — which machine this command is for. A Windows block and a
   macOS block must be impossible to confuse, so each gets four cues: a coloured
   badge, a thick left edge, a tinted bar, and a tinted code body — in two
   deliberately different hues. */
.snippet-os {
  flex-shrink: 0;
  font: 700 .66rem/1 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #fff;
  padding: .24rem .44rem;
  border-radius: 4px;
}
.snippet-os-windows { border-left: 4px solid var(--win); }
.snippet-os-windows .snippet-bar  { background: var(--win-tint); }
.snippet-os-windows .snippet-os   { background: var(--win); }
.snippet-os-windows .snippet-code { background: color-mix(in srgb, var(--win) 6%, var(--bg-sunken)); }
.snippet-os-macos { border-left: 4px solid var(--mac); }
.snippet-os-macos .snippet-bar  { background: var(--mac-tint); }
.snippet-os-macos .snippet-os   { background: var(--mac); }
.snippet-os-macos .snippet-code { background: color-mix(in srgb, var(--mac) 8%, var(--bg-sunken)); }

.parse-error {
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border));
  background: color-mix(in srgb, var(--danger) 7%, transparent);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin: 1.25rem 0;
}
.parse-error strong { color: var(--danger); display: block; margin-bottom: .5rem; }
.parse-error pre {
  margin: 0 0 .75rem;
  padding: .7rem .85rem;
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: .8rem;
  white-space: pre-wrap;
}
.parse-error p { margin: 0; font-size: .85rem; color: var(--muted); }

/* ── Panels, settings, admin ─────────────────────────────────────────────── */

.panel-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.15rem;
  max-width: 760px;
}
.panel-card.wide { max-width: none; }
.panel-card h2 { font-size: 1.05rem; }
.panel-card > p { margin-top: 0; font-size: .88rem; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.switch-row strong { color: var(--dark); }
.tick {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.tick input { accent-color: var(--done); cursor: pointer; margin: 0; }

.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.inline-form input {
  font: inherit;
  font-size: .875rem;
  padding: .45rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  min-width: 180px;
}
.inline-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

.feedback-form textarea {
  width: 100%;
  font: inherit;
  padding: .7rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  min-height: 8.5rem;
}
.feedback-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.feedback-form .tick { margin: .9rem 0 1.1rem; font-size: .85rem; }

.table-scroll { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.grid th, table.grid td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.grid th { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
table.grid td strong { color: var(--dark); }
.row-disabled { opacity: .55; }
.grants { display: flex; flex-wrap: wrap; gap: .35rem .8rem; min-width: 260px; }
.grant { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; cursor: pointer; white-space: nowrap; }
.grant input { accent-color: var(--accent); cursor: pointer; margin: 0; }
.actions { display: flex; gap: .35rem; white-space: nowrap; }

.analytics { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: .6rem; }
.analytics summary { padding: .65rem .85rem; cursor: pointer; display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
.analytics summary strong { color: var(--dark); }
.analytics[open] summary { border-bottom: 1px solid var(--border); }
.analytics .table-scroll { padding: 0 .85rem .6rem; }

.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty code {
  font-family: var(--mono);
  font-size: .85em;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .1em .4em;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%) translateY(1rem);
  background: var(--dark);
  color: var(--bg);
  padding: .55rem 1.05rem;
  border-radius: 999px;
  font-size: .84rem;
  font-weight: 500;
  box-shadow: var(--shadow-lift);
  opacity: 0;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
