/* ─────────────────────────────────────────────────────────────────────────
   Sennoric Learn — styled on the Sennoric paper shell (sennoric.com/assets/paper.css).

   Warm paper, near-black ink, a deep-forest counter panel and the logo
   marigold used sparingly. Like the Sennoric site, the paper ground is
   deliberate in both system themes, so there is no dark variant.

   The one memorable element is the spiral: the Sennoric mark doubles as the
   progress meter, drawn in as you finish lessons. Everything around it stays
   quiet: rules instead of cards, ink buttons, no gradients.

   Type roles:
     --disp  Archivo 600/700/800  headlines, course and lesson names
     --sans  IBM Plex Sans        body copy and UI
     --mono  IBM Plex Mono        counts, code, widget readouts
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --paper:    #f3f0e6;  /* page ground */
  --paper-2:  #eae5d6;  /* inset surface */
  --paper-3:  #fbf9f3;  /* input wells, quiz options */
  --ink:      #17140d;  /* 16.2:1 on paper */
  --ink-2:    #5a5445;  /*  6.6:1 on paper */
  --rule:     #d8d1bd;
  --rule-2:   #c4bca4;
  --forest:   #12301c;  /* counter panel */
  --green:    #1a5c35;  /*  7.0:1 on paper: links, correct, progress */
  --marigold: #E8B534;  /*  7.6:1 on forest: the logo mark */
  --brick:    #9c3324;  /*  6.3:1 on paper: wrong answers */

  --disp: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --gut: 40px;
  --nav-h: 66px;

  /* Names the lesson widgets read. They map onto the paper palette so the
     canvases and chips pick up the theme without touching widget code. */
  --surface-1: var(--paper-3);
  --page: var(--paper);
  --muted: var(--ink-2);
  --grid: var(--rule);
  --baseline: var(--rule-2);
  --border: var(--rule);
  --good: var(--green);
  --good-text: var(--green);
  --bad: var(--brick);
  --accent: var(--ink);  /* widget buttons fill with this */

  /* Chart series for widget canvases, deepened to hold up on paper. */
  --series-1: #2f62a8;
  --series-2: #1f8a62;
  --series-3: #c98a0b;
  --series-4: #1a5c35;
  --series-5: #5a4a9e;
  --series-6: #b5402f;
  --series-7: #b85479;
  --series-8: #c4612a;
  --series-9: #1f7f8f;
  --series-10: #4b4fa8;
  --series-11: #2a7a70;
  --series-12: #5f7d1a;
  --series-13: #7a4aa6;
  --series-14: #8f5a12;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--sans); font-size: 16px; line-height: 1.55;
  background: var(--paper); color: var(--ink);
  min-height: 100vh; display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased; overflow-x: clip;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
::selection { background: rgba(26, 92, 53, .18); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; border-radius: 2px; }
h1, h2, h3 { font-family: var(--disp); font-weight: 700; letter-spacing: -.02em; line-height: 1.08; }
button { font: inherit; color: inherit; }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 200;
  background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 4px;
}
.skip:focus { top: 12px; text-decoration: none; }

/* ── Nav ──────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 18px;
  height: var(--nav-h); padding: 0 var(--gut);
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.brand {
  font-family: var(--disp); font-weight: 700; font-size: 20px; letter-spacing: -.01em;
  color: var(--ink); display: flex; align-items: center; gap: 8px;
}
.brand:hover { text-decoration: none; }
.brand img { height: 22px; width: auto; display: block; transition: transform .5s var(--ease); }
.brand:hover img { transform: rotate(90deg); }
.by { font-size: 14.5px; color: var(--ink-2); }
.by:hover { color: var(--ink); text-decoration: none; }
.by.on { color: var(--ink); position: relative; }
.by.on::after { content: ''; position: absolute; left: 0; right: 0; bottom: -8px; height: 2px; background: var(--marigold); border-radius: 1px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 20px; }
.tally { font-size: 13.5px; color: var(--ink-2); white-space: nowrap; }
.tally b { font-family: var(--mono); font-weight: 500; color: var(--ink); margin-right: 4px; }
/* Optional sign-in (saves progress to the visitor's Sennoric account) */
.acct { position: relative; }
.acct-btn { font: 500 13.5px var(--sans, inherit); color: var(--ink); background: transparent; border: 1px solid var(--rule, #c4bca4); border-radius: 999px; padding: 6px 14px; cursor: pointer; white-space: nowrap; }
.acct-btn:hover { border-color: var(--ink); }
.acct-btn.signed { color: var(--green, #1a5c35); border-color: var(--green, #1a5c35); }
.acct-btn:focus-visible, .acct-menu .oauth:focus-visible { outline: 2px solid var(--marigold); outline-offset: 2px; }
.acct-menu { position: absolute; right: 0; top: calc(100% + 10px); width: 280px; z-index: 30; background: var(--paper, #f3f0e6); color: var(--ink); border: 1px solid var(--ink); border-radius: 10px; padding: 16px; box-shadow: 0 18px 40px -22px rgba(23, 20, 13, .55); }
.acct-menu[hidden] { display: none; }
.acct-menu p { margin: 0 0 12px; font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.acct-menu p b { color: var(--ink); word-break: break-all; }
.acct-menu .fine { font-size: 12.5px; margin: 10px 0 0; }
.acct-menu .oauth { display: block; width: 100%; box-sizing: border-box; text-align: center; font: 500 14px var(--sans, inherit); color: var(--ink); background: transparent; border: 1px solid var(--ink); border-radius: 8px; padding: 9px 12px; margin-top: 8px; cursor: pointer; text-decoration: none; }
.acct-menu .oauth:hover { background: var(--ink); color: var(--paper, #f3f0e6); text-decoration: none; }
@media (max-width: 720px) { .acct-btn { padding: 5px 10px; font-size: 12.5px; } .acct-menu { position: fixed; left: 16px; right: 16px; top: 64px; width: auto; } }

.tally.off b { color: var(--ink-2); }

/* ── Footer ───────────────────────────────────────────────────────────── */
.footer { margin-top: auto; border-top: 1px solid var(--rule); padding: 48px 0 40px; }
.foot-inner { max-width: 1120px; margin: 0 auto; padding: 0 var(--gut); display: grid; grid-template-columns: auto 1fr auto; gap: 12px 32px; align-items: baseline; }
.foot-brand { font-family: var(--disp); font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.foot-brand img { height: 18px; }
.footer p { color: var(--ink-2); font-size: 14px; }
.foot-links { display: flex; gap: 22px; }
.foot-links a { color: var(--ink); }
.foot-links a:hover { color: var(--green); }

#app { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 var(--gut) 88px; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-block; cursor: pointer;
  padding: 13px 24px; border-radius: 4px; border: 1px solid transparent;
  font-family: var(--sans); font-size: 15px; font-weight: 600; line-height: 1.2;
  background: var(--ink); color: var(--paper);
  transition: background .15s, border-color .15s, transform .2s var(--ease), box-shadow .2s var(--ease);
}
.btn:hover { background: var(--forest); transform: translateY(-1px); box-shadow: 0 10px 22px -14px rgba(18, 48, 28, .7); text-decoration: none; }
.btn:active { transform: none; transition-duration: .05s; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule-2); }
.btn.ghost:hover { background: var(--paper-2); border-color: var(--ink-2); box-shadow: none; }
.btn.small { padding: 8px 14px; font-size: 13.5px; }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: default; transform: none; box-shadow: none; }
.btn:disabled:hover { background: var(--ink); }
.btn.ghost:disabled:hover { background: transparent; border-color: var(--rule-2); }

/* ── Spiral meter ─────────────────────────────────────────────────────── */
/* The Sennoric mark, drawn with pathLength=1 so stroke-dashoffset is the
   share of lessons left to do. */
.spiral { display: block; overflow: visible; }
.spiral path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.spiral .track { stroke: var(--rule); }
.spiral .fill { stroke: var(--green); stroke-dasharray: 1 1; transition: stroke-dashoffset .9s var(--ease); }
.spiral .fill[data-zero] { visibility: hidden; }

/* ── Home: hero ───────────────────────────────────────────────────────── */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: 56px; align-items: center; padding: 72px 0 80px;
}
.hero > * { min-width: 0; }
.hero h1 { font-size: clamp(44px, 6vw, 84px); font-weight: 800; letter-spacing: -.038em; line-height: .96; max-width: 11ch; }
.hero-body { margin-top: 26px; font-size: 18px; line-height: 1.6; color: var(--ink-2); max-width: 30em; }
.hero-body strong { color: var(--ink); font-weight: 600; }
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 32px; }
.cta-row .btn { max-width: 100%; }
.cta-sub { display: block; margin-top: 4px; font-weight: 400; font-size: 13px; opacity: .8; }

.counter {
  background: var(--forest); color: #dfe6d9; border-radius: 8px;
  padding: 36px 36px 30px; display: grid; gap: 22px; justify-items: center;
}
.counter .spiral { width: min(100%, 300px); height: auto; }
.counter .spiral .track { stroke: rgba(243, 240, 230, .12); }
.counter .spiral .fill { stroke: var(--marigold); }
.counter-cap { text-align: center; }
.counter-cap b { display: block; font-family: var(--disp); font-weight: 700; font-size: 26px; letter-spacing: -.02em; color: #f3f0e6; }
.counter-cap span { font-size: 14px; color: #b9c6b4; }

/* ── Home: course ledger ──────────────────────────────────────────────── */
.band { border-top: 1px solid var(--rule); padding-top: 56px; }
.band-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px 32px; flex-wrap: wrap; margin-bottom: 8px; }
.band-head h2 { font-size: clamp(28px, 3.2vw, 38px); }
.band-head p { color: var(--ink-2); margin-top: 8px; max-width: 30em; }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.search { width: 280px; max-width: 100%; }
.seg { display: flex; border: 1px solid var(--rule-2); border-radius: 4px; overflow: hidden; }
.seg button {
  cursor: pointer; border: 0; background: none; color: var(--ink-2);
  font-size: 13.5px; font-weight: 500; padding: 9px 13px;
}
.seg button + button { border-left: 1px solid var(--rule); }
.seg button:hover { background: var(--paper-2); color: var(--ink); }
.seg button.on { background: var(--ink); color: var(--paper); }

.level-group { margin-top: 44px; }
.level-group > h3 {
  font-family: var(--sans); font-size: 14px; font-weight: 600; letter-spacing: 0;
  color: var(--ink-2); padding-bottom: 12px; border-bottom: 1px solid var(--rule-2);
}
.level-group > h3 span { font-weight: 400; margin-left: 6px; }
.course-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 9ch 9ch 150px;
  gap: 24px; align-items: center; padding: 22px 12px 22px 0;
  border-bottom: 1px solid var(--rule); color: var(--ink);
  transition: background .2s;
}
.course-row:hover { text-decoration: none; background: color-mix(in srgb, var(--paper-2) 70%, transparent); }
.course-row h4 { font-family: var(--disp); font-weight: 700; font-size: 21px; letter-spacing: -.015em; line-height: 1.2; }
.course-row .tagline { color: var(--ink-2); font-size: 14.5px; margin-top: 4px; max-width: 52ch; }
.course-row .num { font-family: var(--mono); font-size: 14px; white-space: nowrap; }
.course-row .num small { display: block; font-family: var(--sans); font-size: 12.5px; color: var(--ink-2); }
.course-state { display: flex; align-items: center; gap: 12px; justify-content: flex-end; }
.course-state .spiral { width: 30px; height: 30px; flex: none; }
.course-state .go { font-size: 14.5px; font-weight: 500; color: var(--green); white-space: nowrap; }
.course-row:hover .go { text-decoration: underline; text-underline-offset: 3px; }
.empty { color: var(--ink-2); padding: 40px 0; border-bottom: 1px solid var(--rule); }

/* ── Course page ──────────────────────────────────────────────────────── */
.crumb { display: inline-block; margin-top: 40px; font-size: 14.5px; color: var(--ink-2); }
.crumb:hover { color: var(--ink); }
.course-headrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 40px; align-items: end; padding: 28px 0 44px; }
.course-headrow h1 { font-size: clamp(38px, 5vw, 60px); max-width: 16ch; }
.course-desc { margin-top: 20px; font-size: 17px; line-height: 1.62; color: var(--ink-2); max-width: 32em; }
.facts { display: flex; gap: 28px; margin-top: 24px; flex-wrap: wrap; }
.facts div { font-size: 13px; color: var(--ink-2); }
.facts b { display: block; font-family: var(--mono); font-weight: 500; font-size: 16px; color: var(--ink); }
.course-meter { display: grid; justify-items: center; gap: 8px; }
.course-meter .spiral { width: 120px; height: 120px; }
.course-meter span { font-size: 13.5px; color: var(--ink-2); }

.lesson-list { list-style: none; border-top: 1px solid var(--rule-2); }
.lesson-row {
  display: grid; grid-template-columns: 3ch minmax(0, 1fr) auto; gap: 20px; align-items: baseline;
  padding: 20px 12px 20px 0; border-bottom: 1px solid var(--rule); color: var(--ink);
  transition: background .2s;
}
.lesson-row:hover { text-decoration: none; background: color-mix(in srgb, var(--paper-2) 70%, transparent); }
.lesson-num { font-family: var(--mono); font-size: 14px; color: var(--ink-2); text-align: right; }
.lesson-row h3 { font-size: 19px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.lesson-row .meta { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 4px; font-size: 13.5px; color: var(--ink-2); }
.lesson-go { font-size: 14.5px; font-weight: 500; color: var(--green); white-space: nowrap; }
.lesson-row.done .lesson-num { color: var(--green); }
.lesson-row.done .lesson-go { color: var(--ink-2); font-weight: 400; }
.lesson-row:hover .lesson-go { text-decoration: underline; text-underline-offset: 3px; }

/* ── Lesson player ────────────────────────────────────────────────────── */
.player { max-width: 760px; margin: 0 auto; }
.player-top {
  position: sticky; top: var(--nav-h); z-index: 50;
  display: flex; align-items: center; gap: 18px; padding: 14px 0;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.exit-btn { font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.exit-btn:hover { color: var(--ink); }
.player-title { flex: 1; min-width: 0; font-size: 14px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-count { font-family: var(--mono); font-size: 13px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* A hairline of marigold, the same reading meter the Sennoric homepage uses. */
.pbar { height: 2px; background: var(--rule); position: relative; }
.pbar > div { position: absolute; inset: 0 auto 0 0; background: var(--marigold); transition: width .35s var(--ease); }
.player .pbar { position: sticky; top: calc(var(--nav-h) + 51px); z-index: 50; }

.stage { min-height: 320px; padding-top: 44px; }
.step { margin-bottom: 28px; }
.step-card h2 { font-size: clamp(28px, 3.4vw, 38px); margin-bottom: 18px; max-width: 20ch; }
.step-card p, .step-card li { font-size: 17px; line-height: 1.68; max-width: 34em; }
.step-card p { margin-bottom: 14px; }
.step-card > :last-child { margin-bottom: 0; }
.step-card ul, .step-card ol { margin: 0 0 14px 22px; }
.step-card li { margin-bottom: 6px; padding-left: 4px; }
.step-card strong { font-weight: 600; }
.step-card em { font-style: italic; }
.step-card code, .tutor-a code {
  font-family: var(--mono); font-size: .86em;
  background: var(--paper-2); border: 1px solid var(--rule); padding: 1px 5px; border-radius: 3px;
}
.step-card pre {
  font-family: var(--mono); font-size: 13.5px; line-height: 1.75;
  background: var(--forest); color: #dfe6d9;
  border-radius: 8px; padding: 20px 24px; margin: 18px 0; overflow-x: auto;
}
.step-card pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; }
.callout {
  border-left: 3px solid var(--green); background: var(--paper-2);
  border-radius: 0 4px 4px 0; padding: 14px 18px; margin: 18px 0; font-size: 16px;
}
.callout p { font-size: inherit; }

/* step transitions: answer the reader pressing Next or Back */
@keyframes enterR { from { opacity: 0; transform: translateX(32px); } to { opacity: 1; transform: none; } }
@keyframes enterL { from { opacity: 0; transform: translateX(-32px); } to { opacity: 1; transform: none; } }
@keyframes leaveL { to { opacity: 0; transform: translateX(-32px); } }
@keyframes leaveR { to { opacity: 0; transform: translateX(32px); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.enter-right { animation: enterR .25s var(--ease) both; }
.enter-left  { animation: enterL .25s var(--ease) both; }
.leave-left  { animation: leaveL .2s ease both; }
.leave-right { animation: leaveR .2s ease both; }

.step-nav { display: flex; justify-content: space-between; gap: 12px; padding-top: 24px; border-top: 1px solid var(--rule); }

/* quiz */
.quiz-q { font-family: var(--disp); font-weight: 600; font-size: clamp(22px, 2.6vw, 28px); letter-spacing: -.015em; line-height: 1.25; margin-bottom: 22px; max-width: 26em; }
.quiz-opts { display: grid; gap: 10px; }
.quiz-opt {
  text-align: left; cursor: pointer; font-size: 16px; line-height: 1.45;
  background: var(--paper-3); color: var(--ink);
  border: 1px solid var(--rule-2); border-radius: 4px; padding: 14px 18px;
  transition: border-color .15s, background .15s;
}
.quiz-opt:hover:not(:disabled) { border-color: var(--ink); }
.quiz-opt:disabled { cursor: default; color: var(--ink-2); }
.quiz-opt.correct { border-color: var(--green); background: rgba(26, 92, 53, .08); color: var(--ink); box-shadow: inset 3px 0 0 var(--green); }
.quiz-opt.wrong { border-color: var(--brick); background: rgba(156, 51, 36, .07); color: var(--ink); box-shadow: inset 3px 0 0 var(--brick); }
.quiz-why {
  margin-top: 18px; padding: 16px 20px; border-radius: 0 4px 4px 0;
  background: var(--paper-2); font-size: 15.5px; line-height: 1.6;
  animation: rise .3s var(--ease) both;
}
.quiz-why.ok { border-left: 3px solid var(--green); }
.quiz-why.no { border-left: 3px solid var(--brick); }
.quiz-why b { display: block; margin-bottom: 4px; font-weight: 600; }
.quiz-why.ok b { color: var(--green); }
.quiz-why.no b { color: var(--brick); }
.quiz-opt.pop { animation: pop .35s ease; }
@keyframes pop { 40% { transform: scale(1.015); } }
.shake { animation: shake .4s ease; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
.fill-row { display: flex; gap: 10px; }
.fill-row .w-input { flex: 1; min-width: 0; }

/* ── Widgets ──────────────────────────────────────────────────────────── */
.widget {
  margin-top: 22px; padding: 22px; border-radius: 6px;
  background: var(--paper-2); border: 1px solid var(--rule);
}
.widget canvas { width: 100%; height: auto; display: block; border-radius: 4px; background: var(--paper-3); }
.w-row { display: flex; align-items: center; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
.w-row label { font-size: 14px; font-weight: 500; color: var(--ink-2); min-width: 130px; }
.w-row input[type=range] { flex: 1; accent-color: var(--green); min-width: 120px; }
.w-row .val { font-family: var(--mono); font-size: 14px; min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; }
.w-out {
  font-family: var(--mono); font-size: 14px; line-height: 1.6;
  padding: 12px 14px; border-radius: 4px; margin-top: 12px;
  background: var(--paper-3); border: 1px solid var(--rule); font-variant-numeric: tabular-nums;
}
.w-note { font-size: 14px; color: var(--ink-2); margin-top: 10px; }
.w-input {
  width: 100%; font: inherit; font-size: 15px; padding: 11px 14px;
  border: 1px solid var(--rule-2); border-radius: 4px;
  background: var(--paper-3); color: var(--ink);
}
.w-input::placeholder { color: #857d6b; }
.w-input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(26, 92, 53, .14); }
.w-input.ok { border-color: var(--green); background: rgba(26, 92, 53, .07); }
.w-input.no { border-color: var(--brick); background: rgba(156, 51, 36, .06); }
.widget select.w-input { appearance: auto; }
.token-chip {
  display: inline-block; padding: 3px 8px; margin: 3px 2px; border-radius: 3px;
  font-family: var(--mono); font-size: 14px; border: 1px solid var(--rule-2); white-space: pre;
}
.attn-token {
  display: inline-block; padding: 6px 10px; margin: 3px; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--rule-2); font-weight: 500; background: var(--paper-3); user-select: none;
}
.attn-token.sel { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

.flip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.flip-card {
  cursor: pointer; user-select: none; min-height: 96px; padding: 14px;
  border: 1px solid var(--rule-2); border-radius: 4px; background: var(--paper-3);
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-weight: 600; line-height: 1.35; transition: border-color .15s, background .15s;
}
.flip-card:hover { border-color: var(--ink); }
.flip-card.flipped { background: var(--forest); color: #e9eee5; border-color: var(--forest); font-weight: 400; font-size: 15px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.pick-chip {
  cursor: pointer; padding: 9px 14px; border-radius: 4px; font-size: 15px;
  border: 1px solid var(--rule-2); background: var(--paper-3); color: var(--ink);
  transition: border-color .15s, background .15s, opacity .15s;
}
.pick-chip:hover:not(:disabled) { border-color: var(--ink); }
.pick-chip.sel { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.pick-chip.matched, .pick-chip.placed { border-color: var(--green); background: rgba(26, 92, 53, .08); cursor: default; }
.pick-chip.wrong-flash { border-color: var(--brick); background: rgba(156, 51, 36, .08); }
.match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.match-col { display: grid; gap: 8px; align-content: start; }
.bucket-row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; }
.bucket { flex: 1; min-width: 160px; min-height: 72px; padding: 10px; border-radius: 4px; border: 1px dashed var(--rule-2); background: var(--paper-3); }
.bucket.target { cursor: pointer; }
.bucket.target:hover { border-color: var(--ink); }
.bucket h4 { margin: 0 0 8px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); text-align: center; }
.bucket .pick-chip { display: block; width: 100%; text-align: left; margin-bottom: 6px; }
.order-slots { display: grid; gap: 8px; margin: 12px 0; }
.order-slot {
  min-height: 44px; border-radius: 4px; border: 1px dashed var(--rule-2);
  display: flex; align-items: center; padding: 0 14px; font-size: 15px; color: var(--ink-2);
}
.order-slot.filled { border-style: solid; color: var(--ink); background: var(--paper-3); }
.order-slot.correct { border-color: var(--green); background: rgba(26, 92, 53, .08); color: var(--ink); }
.order-slot.incorrect { border-color: var(--brick); background: rgba(156, 51, 36, .07); color: var(--ink); }

/* ── AI tutor ─────────────────────────────────────────────────────────── */
.tutor-row { margin-top: 18px; }
.tutor-btn {
  cursor: pointer; background: none; border: 0; padding: 4px 0;
  font-size: 14.5px; font-weight: 500; color: var(--green);
}
.tutor-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
.tutor-panel {
  margin-top: 12px; padding: 18px 20px; border-radius: 6px;
  background: var(--paper-3); border: 1px solid var(--rule-2);
  font-size: 15px; animation: rise .25s var(--ease) both;
}
.tutor-quicks { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tutor-input { resize: vertical; min-height: 44px; flex: 1; }
.tutor-thread { display: grid; gap: 10px; margin-top: 10px; }
.tutor-msg { padding: 12px 14px; border-radius: 4px; }
.tutor-q { background: var(--paper-2); font-weight: 600; font-size: 14.5px; }
.tutor-a { border-left: 3px solid var(--green); border-radius: 0 4px 4px 0; padding-left: 16px; }
.tutor-a p { margin-bottom: 8px; }
.tutor-a p:last-child { margin-bottom: 0; }
.tutor-error { color: var(--brick); font-size: 14px; margin-top: 6px; }
.tutor-setup p { margin-bottom: 10px; }
.tutor-provider { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 9px 12px; border: 1px solid var(--rule-2); border-radius: 4px; }
.tutor-provider:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.tutor-provider input { accent-color: var(--green); }
.tutor-provider em { color: var(--ink-2); font-size: 13.5px; font-style: normal; }

/* ── Lesson complete ──────────────────────────────────────────────────── */
.complete-card {
  background: var(--forest); color: #dfe6d9; border-radius: 8px;
  padding: 48px 40px; display: grid; justify-items: start; gap: 6px;
}
.complete-card .spiral { width: 92px; height: 92px; margin-bottom: 18px; }
.complete-card .spiral .track { stroke: rgba(243, 240, 230, .12); }
.complete-card .spiral .fill { stroke: var(--marigold); }
.complete-card h2 { font-size: clamp(32px, 4vw, 44px); color: #f3f0e6; }
.complete-card p { color: #b9c6b4; font-size: 16px; max-width: 32em; }
.score { font-family: var(--mono); font-size: 15px; color: var(--marigold); margin-top: 6px; }
.complete-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.complete-card .btn { background: var(--marigold); color: var(--forest); }
.complete-card .btn:hover { background: #f0c552; box-shadow: none; }
.complete-card .btn.ghost { background: transparent; color: #f3f0e6; border-color: rgba(243, 240, 230, .32); }
.complete-card .btn.ghost:hover { background: rgba(243, 240, 230, .08); border-color: rgba(243, 240, 230, .6); }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 150; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 1px; opacity: 0; animation: fall 2s ease-in forwards; }
@keyframes fall { 0% { opacity: 1; transform: translate(0, 0) rotate(0); } 100% { opacity: 0; transform: translate(var(--dx), 105vh) rotate(var(--rot)); } }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1000px) {
  :root { --gut: 28px; }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 40px; padding: 48px 0 64px; }
  .counter { grid-template-columns: 120px minmax(0, 1fr); justify-items: start; align-items: center; padding: 24px; }
  .counter .spiral { width: 120px; }
  .counter-cap { text-align: left; }
  .course-row { grid-template-columns: minmax(0, 1fr) 8ch 8ch 130px; gap: 16px; }
}
@media (max-width: 700px) {
  :root { --gut: 16px; --nav-h: 58px; }
  .by { display: none; }
  .topbar-right { gap: 14px; }
  .tally .word, #lvl-badge { display: none; }
  .hero h1 { font-size: clamp(42px, 13vw, 60px); }
  .hero-body { font-size: 16.5px; }
  .search { width: 100%; }
  .course-row { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; padding: 18px 0; }
  .course-row .num { display: none; }
  .course-row .tagline { font-size: 14px; }
  .course-state .go { display: none; }
  .course-headrow { grid-template-columns: minmax(0, 1fr); gap: 24px; padding-bottom: 32px; }
  .course-meter { justify-items: start; grid-auto-flow: column; align-items: center; gap: 14px; }
  .course-meter .spiral { width: 56px; height: 56px; }
  .lesson-row { grid-template-columns: 2.5ch minmax(0, 1fr); gap: 14px; }
  .lesson-go { display: none; }
  .player-title { display: none; }
  .player-top { justify-content: space-between; }
  .player .pbar { top: calc(var(--nav-h) + 51px); }
  .stage { padding-top: 32px; }
  .step-card p, .step-card li { font-size: 16.5px; }
  .widget { padding: 16px; margin-left: -4px; margin-right: -4px; }
  .match-cols { grid-template-columns: 1fr; gap: 14px; }
  .complete-card { padding: 36px 24px; }
  .foot-inner { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .confetti { display: none; }
}
