/* ============================================================================ StudyGraph
   A study notebook. Paper surfaces and ink type for setup, Library and Profile; the feed
   is dark ink. One accent: highlighter yellow, used like a highlighter.
   ========================================================================================= */
:root {
  --ink: #141414;
  --ink-2: #3d3a35;
  --ink-3: #6f6a62;
  --paper: #f6f1e7;
  --paper-2: #ede6d8;
  --paper-3: #e3dbc9;
  --line: #d6cdbb;
  --line-2: #bfb4a0;
  --hl: #ffd93d;
  --hl-2: #ffe580;
  --ok: #2f7d4f;
  --bad: #c43d33;
  --dark: #0d0d0e;
  --dark-2: #1b1b1d;
  --dark-line: rgba(255, 255, 255, 0.14);
  --accent: var(--hl);
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --r: 14px;
  --tabbar: 82px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--dark); color: var(--ink); }
body { font-family: var(--sans); font-size: 15px; -webkit-font-smoothing: antialiased; overscroll-behavior: none; overflow: hidden; }
body[data-view="library"], body[data-view="profile"], body[data-view="explore"], body.onboarding { background: var(--paper); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
h1, h2, h3, .serif { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; font-variation-settings: 'opsz' 48; }
mark { background: linear-gradient(transparent 28%, var(--hl) 28%, var(--hl) 88%, transparent 88%); color: inherit; padding: 0 .08em; }
.mono { font-family: var(--mono); }
.muted { color: var(--ink-3); }
.fine { color: var(--ink-3); font-size: 12.5px; line-height: 1.55; margin: 22px 4px 8px; }

/* ---------------------------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 50px; padding: 0 22px; border-radius: 10px;
  border: 1.5px solid var(--ink); background: var(--paper); color: var(--ink); cursor: pointer; font-weight: 600; font-size: 15px;
  transition: transform .1s var(--ease), background .15s, box-shadow .15s; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); color: var(--paper); box-shadow: 3px 3px 0 var(--hl); }
.btn.primary:hover { box-shadow: 4px 4px 0 var(--hl); }
.btn.primary:disabled { background: var(--paper-3); color: var(--ink-3); border-color: var(--paper-3); box-shadow: none; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.vidmoat { background: #fff; }
.vm-logo { width: 22px; height: 22px; border-radius: 6px; background: #fff; object-fit: cover; display: block; }
.link { background: none; border: 0; padding: 0; color: var(--ink); font-weight: 600; cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: var(--hl); text-decoration-thickness: 3px; text-underline-offset: 3px; }

/* ---------------------------------------------------------------------------- onboarding */
.onboard { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--paper); color: var(--ink);
  background-image: radial-gradient(var(--line) .8px, transparent .8px); background-size: 22px 22px; }
.ob-top { position: relative; padding: calc(16px + var(--safe-t)) 64px 6px; display: flex; align-items: center; justify-content: center; min-height: 52px; }
.ob-progress { width: min(520px, 100%); height: 6px; border-radius: 99px; background: var(--paper-3); border: 1px solid var(--line); overflow: hidden; }
.ob-progress i { display: block; height: 100%; width: 33%; background: var(--hl); transition: width .4s var(--ease); }
.ob-back { position: absolute; left: 14px; top: calc(6px + var(--safe-t)); width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--ink); background: var(--paper); cursor: pointer; display: grid; place-items: center; }
.ob-back svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ob-body { flex: 1; overflow-y: auto; padding: 8px 20px 24px; -webkit-overflow-scrolling: touch; }
.ob-body > .step { width: min(560px, 100%); margin: 0 auto; animation: rise .4s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.ob-hero { text-align: center; padding: 10px 0 4px; }
.ob-hero h1 { font-size: clamp(34px, 8.6vw, 46px); line-height: 1.05; margin: 16px 0 12px; font-weight: 600; font-variation-settings: 'opsz' 72; }
.logo-mark { width: 60px; height: 60px; margin: 0 auto; border-radius: 16px; background: url(/icons/icon-192.png) center / cover; box-shadow: 3px 3px 0 var(--hl); }
.lead { color: var(--ink-2); font-size: 16px; line-height: 1.55; margin: 0 0 20px; }
.ob-hero .lead { max-width: 430px; margin: 0 auto 22px; }
.ob-title { font-size: 32px; margin: 12px 0 6px; font-variation-settings: 'opsz' 72; }
.ob-foot { text-align: center; color: var(--ink-3); font-size: 14px; margin-top: 22px; }
.ob-actions { padding: 12px 20px calc(14px + var(--safe-b)); display: flex; justify-content: center; border-top: 1px solid var(--line); background: var(--paper); }
.ob-actions .btn { width: min(560px, 100%); }

.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .02em; text-transform: uppercase; margin: 0 0 8px; }
.ob-who { margin: 0 0 18px; }
.ob-who .segmented { margin: 8px 0 10px; }
.ob-age { max-width: 180px; }
.consent { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.45; color: var(--ink-2); padding: 12px; border-radius: 10px; background: #fff; border: 1.5px solid var(--line-2); margin-top: 8px; }
.consent input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.ob-note { font-size: 13.5px; line-height: 1.45; color: var(--bad); margin: 8px 0 0; }
.level-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; counter-reset: lvl; }
.level-card { counter-increment: lvl; position: relative; display: grid; gap: 6px; text-align: left; padding: 16px 14px 14px; border-radius: var(--r); background: #fff;
  border: 1.5px solid var(--line-2); cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .1s; min-height: 118px; align-content: start; }
.level-card::before { content: counter(lvl, upper-alpha); position: absolute; top: 10px; right: 12px; font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink-3); }
.level-card:active { transform: translateY(1px); }
.level-card .emoji { font-size: 26px; }
.level-card strong { font-size: 15px; font-family: var(--serif); font-weight: 600; }
.level-card small { color: var(--ink-3); font-size: 12.5px; line-height: 1.35; }
.level-card[aria-checked="true"] { border-color: var(--ink); box-shadow: 3px 3px 0 var(--hl); }
.level-card[aria-checked="true"]::before { color: var(--ink); }

.field { display: grid; gap: 8px; margin: 0 0 16px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .02em; text-transform: uppercase; }
.field em { font-style: normal; font-weight: 500; color: var(--ink-3); text-transform: none; letter-spacing: 0; margin-left: 4px; }
.field input { font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 1.5px solid var(--line-2); border-radius: 10px; padding: 14px 15px; outline: none; transition: border-color .15s, box-shadow .15s; }
.field input::placeholder { color: #a39c90; }
.field input:focus { border-color: var(--ink); box-shadow: 3px 3px 0 var(--hl); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; border-radius: 999px; border: 1.5px solid var(--line-2); background: #fff; cursor: pointer; font-weight: 500; font-size: 14px; }
.chip-btn[aria-pressed="true"] { border-color: var(--ink); background: var(--hl); font-weight: 600; }

.program { padding: 16px; border-radius: var(--r); background: #fff; border: 1.5px solid var(--line-2); margin-bottom: 14px; }
.program-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.program-head h3 { margin: 0 0 4px; font-size: 22px; }
.program-head p { margin: 0; font-size: 13px; color: var(--ink-3); line-height: 1.45; }
.unit-list { display: grid; margin-top: 12px; counter-reset: unit; border-top: 1px solid var(--line); }
.unit { counter-increment: unit; display: grid; grid-template-columns: 34px 1fr 24px; gap: 2px 10px; align-items: start; text-align: left; padding: 12px 4px; border: 0;
  border-bottom: 1px solid var(--line); background: none; cursor: pointer; transition: opacity .2s; }
.unit::before { content: counter(unit, decimal-leading-zero); grid-row: span 2; font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--ink-3); padding-top: 3px; }
.unit strong { font-size: 15px; font-weight: 600; }
.unit span { grid-column: 2; font-size: 13px; color: var(--ink-3); line-height: 1.35; }
.unit .tick { grid-column: 3; grid-row: 1 / span 2; align-self: center; width: 22px; height: 22px; border-radius: 5px; border: 1.5px solid var(--ink); background: #fff; }
.unit[aria-pressed="true"] .tick { background: var(--hl) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12l5 5 9-10' fill='none' stroke='%23141414' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 15px no-repeat; }
.unit[aria-pressed="true"] strong { background: linear-gradient(transparent 30%, var(--hl-2) 30%, var(--hl-2) 90%, transparent 90%); }
.unit[aria-pressed="false"] { opacity: .5; }
.researching { display: flex; gap: 14px; align-items: center; }
.researching p { margin: 4px 0 0; font-size: 13px; color: var(--ink-3); }
.sources { font-size: 12.5px; color: var(--ink-3); margin: 12px 0 0; line-height: 1.6; }
.sources a { color: var(--ink); text-decoration-color: var(--hl); text-decoration-thickness: 2px; text-underline-offset: 2px; }
.spinner { width: 22px; height: 22px; flex: none; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--ink); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------------------- app shell */
.app { position: fixed; inset: 0; }
.view { position: absolute; inset: 0 0 calc(var(--tabbar) + var(--safe-b)) 0; }
.view-page { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; background: var(--paper); color: var(--ink);
  background-image: radial-gradient(var(--line) .8px, transparent .8px); background-size: 22px 22px; }
.page { width: min(720px, 100%); margin: 0 auto; padding: 0 16px calc(var(--tabbar) + 24px); }
.page-head { display: flex; align-items: center; justify-content: space-between; }
.refresh-btn { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--ink); background: #fff; color: var(--ink); display: grid; place-items: center; cursor: pointer; transition: transform .4s var(--ease); }
.refresh-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.refresh-btn.spin svg { animation: spin .8s linear infinite; }
.refresh-btn.light { border-color: rgba(255,255,255,.5); background: rgba(0,0,0,.25); color: #fff; width: 34px; height: 34px; justify-self: end; }
.feed-head-spacer { display: flex; justify-content: flex-end; }
.feed-head .refresh-btn { pointer-events: auto; position: relative; z-index: 13; }
@keyframes spin { to { transform: rotate(360deg); } }
.ptr { position: fixed; z-index: 45; left: 50%; top: calc(var(--safe-t) + 8px); transform: translate(-50%, -60px); width: 40px; height: 40px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--ink); box-shadow: 2px 2px 0 var(--hl); display: grid; place-items: center; transition: transform .25s var(--ease), opacity .25s; opacity: 0; }
.ptr.pull { opacity: 1; transform: translate(-50%, var(--pull, 0px)); }
.ptr.go { opacity: 1; transform: translate(-50%, 12px); }
.ptr .spinner { width: 18px; height: 18px; border-width: 2px; border-color: var(--line-2); border-top-color: var(--ink); margin: 0; }
.ptr.go .spinner { animation: spin .8s linear infinite; }
.page-title { font-size: 36px; margin: 8px 2px 16px; font-variation-settings: 'opsz' 72; }

.tabbar { position: fixed; left: 50%; bottom: calc(10px + var(--safe-b)); transform: translateX(-50%); width: min(400px, calc(100% - 24px)); height: 60px; z-index: 30;
  border-radius: 999px; background: var(--paper); color: var(--ink); border: 1.5px solid var(--ink); box-shadow: 4px 4px 0 var(--hl), 0 12px 30px rgba(0, 0, 0, .25); padding: 0 6px; }
body[data-view="feed"] .tabbar { background: rgba(20, 20, 20, .88); color: #fff; border-color: rgba(255, 255, 255, .35); box-shadow: 4px 4px 0 var(--hl); }
body[data-view="feed"] .tabbtn[aria-current="page"] span { color: var(--ink); }
body[data-view="feed"] .tabbtn[aria-current="page"] { color: var(--ink); }
body[data-view="library"] .tabbar, body[data-view="profile"] .tabbar, body[data-view="explore"] .tabbar { background: var(--paper); border-top-color: var(--line-2); color: var(--ink); }
.tabbtn { position: relative; z-index: 1; flex: 1 1 0; max-width: 150px; display: grid; place-items: center; align-content: center; gap: 2px; border: 0; background: none; cursor: pointer; opacity: .55; font-size: 11px; font-weight: 600; color: inherit; transition: opacity .2s; }
.tabbtn svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; transition: transform .25s var(--ease); }
.tabbtn[aria-current="page"] { opacity: 1; }
.tabbtn[aria-current="page"] svg { transform: translateY(-1px) scale(1.08); animation: bop .35s var(--ease); }
.tabbtn[aria-current="page"] span { color: var(--ink); }
@keyframes bop { 0% { transform: scale(.85); } 60% { transform: scale(1.18); } 100% { transform: translateY(-1px) scale(1.08); } }
/* The dock: a floating pill with a highlighter blob that slides under the active tab. */
.tabbar { display: flex; align-items: stretch; }
.tab-blob { position: absolute; z-index: 0; top: 6px; bottom: 6px; width: calc((100% - 12px) / 4); left: 6px; border-radius: 999px; background: var(--hl); transform: translateX(calc(var(--tab, 0) * 100%)); transition: transform .35s var(--ease); box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, .08); }
body[data-view="feed"] .tabbtn[aria-current="page"] span { color: var(--ink); }

/* ---------------------------------------------------------------------------- feed */
.view-feed { background: var(--dark); color: #fff; }
.feed-head { position: absolute; z-index: 12; top: 0; left: 0; right: 0; padding: calc(12px + var(--safe-t)) 16px 24px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  background: linear-gradient(rgba(0, 0, 0, .55), transparent); pointer-events: none; }
.wordmark { display: block; overflow: visible; }
.wordmark text { font-family: var(--serif); font-weight: 600; font-size: 21px; letter-spacing: -.01em; font-variation-settings: 'opsz' 48; }
.wm-fill { fill: #fff; }
/* Tracing lights: two bright dashes run around the letter outlines, one half a lap behind. */
.wm-trace { fill: none; stroke: url(#wm-trace); stroke-width: 2; stroke-linejoin: round; stroke-dasharray: 30 270; stroke-dashoffset: 0; opacity: .95; animation: wm-run 5.5s linear infinite; filter: drop-shadow(0 0 3px rgba(255, 217, 61, .9)); }
.wm-trace-2 { animation-delay: -2.75s; opacity: .6; stroke-width: 1.1; }
@keyframes wm-run { to { stroke-dashoffset: -300; } }
@media (prefers-reduced-motion: reduce) { .wm-trace { animation: none; opacity: 0; } }
.feed-title { font-weight: 600; font-size: 14px; padding-bottom: 3px; border-bottom: 2px solid var(--hl); }
/* clip, not hidden: a hidden container can still be scrolled by the browser to keep a focused button in view, which shifts every slide */
.feed { position: absolute; inset: 0; overflow: hidden; overflow: clip; touch-action: none; outline: none; user-select: none; -webkit-user-select: none; }
.track { position: absolute; inset: 0; will-change: transform; }
.track.animating { transition: transform .42s cubic-bezier(.22, .9, .25, 1); }
.slide { position: absolute; left: 0; right: 0; height: 100%; display: grid; place-items: center; background: var(--dark); }
.stage { position: relative; overflow: hidden; height: 100%; width: min(100%, calc((100dvh - var(--tabbar) - var(--safe-b)) * 9 / 16)); background: #000; }
@media (min-width: 760px) {
  .slide { background: var(--dark); }
  .stage { height: calc(100% - 28px); width: calc((100dvh - var(--tabbar) - var(--safe-b) - 28px) * 9 / 16); border-radius: 18px; border: 1px solid var(--dark-line); }
}
.poster, .player-host, .player-host iframe, .making, .gesture { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.poster { object-fit: cover; filter: brightness(.35) saturate(.9) blur(2px); transform: scale(1.08); }
.poster:not([src]) { display: none; }
.player-host iframe { pointer-events: none; opacity: 0; transition: opacity .3s; background: transparent; }
.slide[data-loaded="true"] .player-host iframe { opacity: 1; }
.gesture { z-index: 3; cursor: pointer; }
/* iOS sound gate: the player's audio can only start after a tap inside its own frame, so until
   the first tap a hole in the gesture layer lets a tap in the middle reach the frame. Swipes at
   the edges still work. */
/* Only a button-sized hole over the sound chip reaches the player (iOS needs a tap inside it); swipes start anywhere else. */
.slide.sound-gate .gesture { clip-path: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, 26% 42%, 74% 42%, 74% 54%, 26% 54%, 26% 42%); }
.slide.sound-gate .player-host iframe { pointer-events: auto; }
.sound-chip { position: absolute; z-index: 9; left: 26%; right: 26%; top: 42%; height: 12%; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 0 12px; text-align: left; font-size: 14px; pointer-events: none; border-radius: 28px; border: 2px dashed rgba(255, 255, 255, .7); background: rgba(13, 13, 14, .35); animation: hint 2.4s var(--ease) infinite; }
.sound-chip i { flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--hl); display: grid; place-items: center; box-shadow: 3px 3px 0 var(--ink); }
.sound-chip i::before { content: '👆'; font-size: 24px; }
.ld-invited { margin: 6px 0 0; font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink); }
.ld-invited b { background: var(--hl); padding: 2px 8px; border-radius: 6px; }
.invite-card .invite-link { display: flex; gap: 8px; align-items: center; margin: 10px 0 12px; }
.invite-card .invite-link code { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 13px; padding: 10px 12px; border-radius: 10px; background: var(--paper-2); border: 1.5px solid var(--line); }
.invite-card .invite-count { font-family: var(--mono); font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.sound-chip span { padding: 8px 14px; border-radius: 6px; background: var(--hl); color: var(--ink); font-size: 13px; font-weight: 600; }
body.sound-gated .swipe-hint { display: none; }

/* making: a paper ticket over the dark stage */
.making { z-index: 2; display: grid; place-items: center; padding: 24px 70px 130px 20px; transition: opacity .3s; }
.slide[data-loaded="true"] .making { opacity: 0; pointer-events: none; }
.making-card { width: 100%; max-width: 330px; display: grid; gap: 12px; padding: 18px 18px 16px; border-radius: 12px; background: var(--paper); color: var(--ink); box-shadow: 4px 4px 0 var(--hl); }
.making-topic { justify-self: start; font-family: var(--mono); font-size: 11.5px; font-weight: 600; letter-spacing: .02em; padding: 4px 8px; border-radius: 5px; background: var(--ink); color: var(--paper); }
.making-hook { font-family: var(--serif); font-size: 24px; font-weight: 600; line-height: 1.15; }
.making-hook:empty { height: 58px; border-radius: 8px; background: linear-gradient(90deg, var(--paper-2), var(--paper-3), var(--paper-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.making-steps { list-style: none; padding: 0; margin: 2px 0 0; display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.making-steps li { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 500; color: var(--ink-3); }
.making-steps i { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--line-2); flex: none; }
.making-steps li.on { color: var(--ink); font-weight: 600; }
.making-steps li.on i { border-color: var(--ink); border-top-color: transparent; animation: spin .8s linear infinite; }
.making-steps li.done i { border-color: var(--ink); background: var(--hl) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12l5 5 9-10' fill='none' stroke='%23141414' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 11px no-repeat; }
.making-note { margin: 0; font-size: 12px; color: var(--ink-3); line-height: 1.45; }
.slide[data-status="failed"] .making-steps, .slide[data-status="failed"] .making-note { display: none; }

.paused-badge { position: absolute; z-index: 4; left: 50%; top: 45%; width: 76px; height: 76px; margin: -38px 0 0 -38px; display: grid; place-items: center; border-radius: 50%;
  background: var(--paper); color: var(--ink); box-shadow: 3px 3px 0 var(--hl); opacity: 0; transform: scale(.8); transition: opacity .15s, transform .15s; pointer-events: none; }
.paused-badge svg { width: 34px; height: 34px; fill: var(--ink); stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; margin-left: 4px; }
.slide[data-paused="true"] .paused-badge { opacity: 1; transform: scale(1); }
.heart-burst { position: absolute; z-index: 5; width: 110px; height: 110px; margin: -55px 0 0 -55px; pointer-events: none; opacity: 0; }
.heart-burst svg { width: 100%; height: 100%; fill: var(--hl); stroke: var(--ink); stroke-width: 1.2; stroke-linejoin: round; }
.heart-burst.go { animation: burst .8s var(--ease) forwards; }
@keyframes burst { 0% { opacity: 0; transform: scale(.3) rotate(-12deg); } 20% { opacity: 1; transform: scale(1.15) rotate(6deg); } 60% { opacity: 1; transform: scale(1) rotate(0); } 100% { opacity: 0; transform: translateY(-60px) scale(.9); } }

/* The rail sits over the stage's right edge; on wide screens the stage is narrower than the slide, so its
   offset is computed from the stage width (the same expression as .stage above). */
.rail { position: absolute; z-index: 6; right: max(10px, calc(50% - (100dvh - var(--tabbar) - var(--safe-b)) * 9 / 32 + 10px)); bottom: 120px; display: grid; gap: 14px; }
@media (min-width: 760px) { .rail { right: calc(50% - (100dvh - var(--tabbar) - var(--safe-b) - 28px) * 9 / 32 + 10px); }
  .quiz { left: calc(50% - (100dvh - var(--tabbar) - var(--safe-b) - 28px) * 9 / 32 + 12px); right: calc(50% - (100dvh - var(--tabbar) - var(--safe-b) - 28px) * 9 / 32 + 70px); } }
.side-brand, .side-foot { display: none; }
.rail-btn { display: grid; justify-items: center; gap: 5px; border: 0; background: none; padding: 0; cursor: pointer; color: #fff; }
.rail-btn .ic { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: rgba(13, 13, 14, .55); border: 1.5px solid rgba(255, 255, 255, .85); transition: transform .12s var(--ease), background .15s; }
.rail-btn:active .ic { transform: scale(.88); }
.rail-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: fill .2s, transform .2s; }
.rail-btn.like[aria-pressed="true"] svg { fill: #ff5a5f; stroke: #ff5a5f; transform: scale(1.1); }
.rail-btn.save[aria-pressed="true"] svg { fill: var(--hl); stroke: var(--hl); }
.rail-btn .count { font-family: var(--mono); font-size: 11px; font-weight: 600; text-shadow: 0 1px 4px #000; }
/* six buttons on a short phone: tighter rail so it stays clear of the top bar */
@media (max-width: 899px) and (max-height: 700px) { .rail { gap: 9px; bottom: 104px; } .rail-btn .ic { width: 40px; height: 40px; } .rail-btn svg { width: 19px; height: 19px; } .rail-btn .count { font-size: 10px; } }
.like[aria-pressed="true"] .ic, .save[aria-pressed="true"] .ic { background: var(--hl); border-color: var(--hl); color: var(--ink); }
.like[aria-pressed="true"] svg { fill: var(--ink); }
.like[aria-pressed="true"] .ic { animation: pop .35s var(--ease); }
@keyframes pop { 50% { transform: scale(1.18); } }

.meta { position: absolute; z-index: 6; left: 0; right: 70px; bottom: 0; padding: 0 14px 18px; pointer-events: none; color: #fff; }
.unit-pill { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; font-family: var(--mono); font-size: 11.5px; font-weight: 600; padding: 5px 9px; border-radius: 5px; background: var(--hl); color: var(--ink); }
.unit-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); flex: none; }
.unit-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pills { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.fmt-badge { flex: none; font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 5px 8px; border-radius: 5px; border: 1.5px solid rgba(255,255,255,.75); color: #fff; }
.fmt-badge:empty { display: none; }
.title { margin: 9px 0 3px; font-size: 19px; font-weight: 600; line-height: 1.22; text-shadow: 0 1px 8px #000; }
.title:empty { display: none; }
.credits { margin: 0; font-size: 11px; color: rgba(255, 255, 255, .6); text-shadow: 0 1px 4px #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { position: absolute; z-index: 7; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255, 255, 255, .18); cursor: pointer; }
.progress::before { content: ''; position: absolute; left: 0; right: 0; bottom: -2px; height: 22px; } /* a finger-sized hit area for the chapters */
.progress .chap { position: absolute; top: -3px; width: 3px; height: 9px; margin-left: -1px; border-radius: 2px; background: rgba(255, 255, 255, .85); box-shadow: 0 0 0 1px rgba(0,0,0,.4); pointer-events: none; }
.progress:hover { height: 5px; }
.bar { height: 100%; background: var(--hl); transform-origin: left; transform: scaleX(0); }

/* quiz: an exam slip */
/* The quiz slip sits over the stage like the rail (same stage-width offsets); on wide screens it moves beside the video. */
.quiz { position: absolute; z-index: 8; left: max(12px, calc(50% - (100dvh - var(--tabbar) - var(--safe-b)) * 9 / 32 + 12px)); right: max(70px, calc(50% - (100dvh - var(--tabbar) - var(--safe-b)) * 9 / 32 + 70px)); bottom: 112px; padding: 14px; border-radius: 12px; background: var(--paper); color: var(--ink); box-shadow: 4px 4px 0 var(--hl); animation: rise .3s var(--ease); }
.quiz-label { margin: 0 0 10px; font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.quiz-options { display: grid; gap: 7px; }
.quiz-opt { display: flex; gap: 10px; align-items: center; padding: 10px 11px; border-radius: 9px; border: 1.5px solid var(--line-2); background: #fff; cursor: pointer; text-align: left; font-weight: 500; font-size: 14.5px; color: var(--ink); }
.quiz-opt b { width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 5px; border: 1.5px solid var(--ink); font-family: var(--mono); font-size: 12px; font-weight: 600; }
.quiz-opt.right { border-color: var(--ok); background: #e7f3eb; font-weight: 600; }
.quiz-opt.right b { background: var(--ok); border-color: var(--ok); color: #fff; }
.quiz-opt.wrong { border-color: var(--bad); background: #f9e6e4; }
.quiz-opt.wrong b { background: var(--bad); border-color: var(--bad); color: #fff; }
.quiz-opt:disabled { cursor: default; }
.quiz-feedback { margin: 10px 0 0; font-size: 13.5px; font-weight: 600; }
.quiz-feedback:empty { display: none; }
.quiz-hint { font-weight: 500; text-transform: none; letter-spacing: 0; }
.quiz-skip { margin-top: 8px; padding: 0; border: 0; background: none; color: var(--ink-3); font: inherit; font-size: 12.5px; text-decoration: underline; cursor: pointer; }
.quiz[data-held="false"] .quiz-hint, .quiz[data-held="false"] .quiz-skip { display: none; }

.pager { position: absolute; z-index: 12; right: 22px; top: 50%; transform: translateY(-50%); display: none; gap: 10px; }
.pager-btn { width: 46px; height: 46px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .85); background: rgba(13, 13, 14, .6); color: #fff; cursor: pointer; display: grid; place-items: center; }
.pager-btn:hover { background: var(--hl); color: var(--ink); border-color: var(--hl); }
.pager-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.pager-btn:disabled { opacity: .3; cursor: default; }
@media (hover: hover) and (pointer: fine) and (min-width: 760px) { .pager { display: grid; } }

.swipe-hint { position: absolute; z-index: 11; left: 0; right: 0; top: calc(64px + var(--safe-t)); display: grid; justify-items: center; pointer-events: none; animation: hint 2.4s var(--ease) infinite; }
.swipe-hint span { padding: 8px 14px; border-radius: 6px; background: var(--hl); color: var(--ink); font-size: 13px; font-weight: 600; }
.swipe-hint span::before { content: '↑  '; }
@keyframes hint { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
.end-slide .stage { display: grid; place-items: center; text-align: center; color: rgba(255, 255, 255, .7); padding: 24px; }
.end-slide .spinner { margin: 0 auto 12px; border-color: var(--dark-line); border-top-color: var(--hl); }

/* ---------------------------------------------------------------------------- library / profile */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; padding: 0; border-radius: 10px; border: 1.5px solid var(--ink); background: #fff; margin-bottom: 16px; overflow: hidden; }
.segmented button { border: 0; background: none; padding: 10px; font-weight: 600; font-size: 14px; color: var(--ink-3); cursor: pointer; border-right: 1.5px solid var(--ink); }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-selected="true"] { background: var(--ink); color: var(--paper); }
.card { padding: 18px; border-radius: var(--r); background: #fff; border: 1.5px solid var(--line-2); margin-bottom: 14px; }
.card h3 { margin: 0 0 8px; font-size: 21px; }
.card p { margin: 0 0 12px; line-height: 1.5; }
.card .btn { margin-top: 6px; }
.course-card { padding: 16px; border-radius: var(--r); background: #fff; border: 1.5px solid var(--line-2); margin-bottom: 14px; }
.course-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.ring { --p: 0; width: 56px; height: 56px; border-radius: 50%; flex: none; display: grid; place-items: center; font-family: var(--mono); font-size: 12.5px; font-weight: 600;
  background: conic-gradient(var(--hl) calc(var(--p) * 1%), var(--paper-3) 0); }
.ring span { width: 44px; height: 44px; border-radius: 50%; background: #fff; display: grid; place-items: center; }
.course-head h3 { margin: 0; font-size: 22px; }
.course-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-3); }
.unit-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(48px, 90px) 32px; gap: 10px; align-items: center; padding: 10px 2px; border-top: 1px solid var(--line); min-width: 0; }
.unit-row .meter { width: 100%; }
.unit-name { min-width: 0; }
.unit-name > span:first-of-type { min-width: 0; overflow-wrap: anywhere; }
.unit-name .tag, .unit-name .due { flex: none; }
.course-card { overflow-x: clip; }
@media (max-width: 400px) { .unit-row { grid-template-columns: minmax(0, 1fr) minmax(40px, 64px) 28px; gap: 8px; } .unit-name .due { display: none; } }
.unit-name { font-weight: 500; font-size: 14px; }
.due { margin-left: 8px; font-family: var(--mono); font-size: 10.5px; font-weight: 600; color: var(--ink); background: var(--hl); padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.meter { height: 7px; border-radius: 999px; background: var(--paper-3); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--hl); border-radius: 999px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }
.pct { font-family: var(--mono); font-size: 12px; color: var(--ink-3); text-align: right; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.vcard { display: grid; gap: 6px; text-align: left; padding: 0 0 10px; border: 1.5px solid var(--line-2); border-radius: 12px; overflow: hidden; background: #fff; cursor: pointer; color: var(--ink); }
.vcard:hover { border-color: var(--ink); box-shadow: 3px 3px 0 var(--hl); }
.vcard img, .vcard .ph { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: var(--paper-2); }
.vcard span { padding: 0 10px; font-family: var(--serif); font-weight: 600; font-size: 14px; line-height: 1.3; }
.vcard small { padding: 0 10px; color: var(--ink-3); font-size: 11.5px; }
.empty { text-align: center; padding: 36px 16px; color: var(--ink-3); grid-column: 1 / -1; }
.empty b { display: block; color: var(--ink); font-family: var(--serif); font-size: 20px; margin-bottom: 6px; }

/* ---------------------------------------------------------------------------- stickers & mascot */
.sticker { display: block; filter: drop-shadow(0 3px 0 rgba(0,0,0,.12)) drop-shadow(0 8px 14px rgba(0,0,0,.14)); }
.hero { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; padding: 18px 18px 14px; border-radius: 18px; margin-bottom: 14px; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line-2); overflow: hidden; }
.hero::before { content: ''; position: absolute; inset: 0; background: radial-gradient(60% 90% at 100% 0%, var(--hl-2) 0%, transparent 60%); opacity: .8; pointer-events: none; }
.hero > * { position: relative; }
.goal { display: grid; justify-items: center; gap: 2px; font-family: var(--mono); font-size: 10.5px; font-weight: 600; color: var(--ink-3); }
.hero { padding-right: 84px; }
.hero .goal { position: absolute; right: 12px; top: 10px; }
.goal-ring { display: block; }
.goal.done span { color: var(--ok); }
.profile-card { position: relative; padding-right: 80px; }
.profile-card .goal { position: absolute; right: 14px; top: 14px; }
.hero .mascot { width: 96px; height: 96px; animation: float 4s ease-in-out infinite; }
.hero h3 { margin: 0; font-size: 24px; }
.hero p { margin: 2px 0 0; color: var(--ink-2); font-size: 13.5px; line-height: 1.4; }
.bubble { position: relative; margin-top: 8px; padding: 9px 12px; border-radius: 12px; background: var(--paper); border: 1.5px solid var(--ink); font-size: 13.5px; line-height: 1.4; font-weight: 500; }
.bubble::before { content: ''; position: absolute; left: -9px; top: 14px; width: 12px; height: 12px; background: var(--paper); border-left: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); transform: rotate(45deg); }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-5px) rotate(2deg); } }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.sbadge { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; font-weight: 600; padding: 5px 9px; border-radius: 999px; background: #fff; border: 1.5px solid var(--ink); transform: rotate(var(--r, -1deg)); box-shadow: 2px 2px 0 var(--hl); }
.sbadge.hot { background: var(--hl); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.tile { position: relative; padding: 12px 10px 10px; border-radius: 14px; background: #fff; border: 1.5px solid var(--line-2); text-align: center; overflow: hidden; }
.tile i { display: block; font-style: normal; font-size: 20px; margin-bottom: 2px; }
.tile b { display: block; font-family: var(--serif); font-size: 24px; line-height: 1.1; }
.tile span { display: block; font-size: 10.5px; color: var(--ink-3); font-weight: 600; letter-spacing: .02em; text-transform: uppercase; margin-top: 2px; }
.tile.hl { background: var(--hl); border-color: var(--ink); }
@media (max-width: 380px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.empty .sticker { width: 110px; height: 110px; margin: 0 auto 10px; }
.course-card { position: relative; }
.course-card .corner { position: absolute; top: -10px; right: 12px; width: 54px; height: 54px; transform: rotate(8deg); }
.profile-card { display: flex; align-items: center; gap: 14px; }
.avatar { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; font-family: var(--serif); font-size: 26px; font-weight: 600; background: var(--ink); color: var(--paper); flex: none; box-shadow: 3px 3px 0 var(--hl); }
.profile-card h3 { margin: 0; font-size: 22px; }
.profile-card p { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 4px; background: var(--hl); color: var(--ink); margin-top: 6px; }
.reassure { display: grid; gap: 6px; margin: 4px 0 14px; padding: 0; list-style: none; font-size: 13.5px; color: var(--ink-2); }
.reassure li::before { content: '✓  '; color: var(--ok); font-weight: 700; }

/* ---------------------------------------------------------------------------- sheet, toast, gate */
.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(13, 13, 14, .55); animation: fade .2s; }
.sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; width: min(560px, 100%); padding: 10px 20px calc(20px + var(--safe-b));
  max-height: calc(100dvh - 24px); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y;
  border-radius: 18px 18px 0 0; background: var(--paper); color: var(--ink); border-top: 3px solid var(--hl); animation: up .3s var(--ease); }
.sheet-grip { width: 40px; height: 4px; border-radius: 99px; background: var(--line-2); margin: 0 auto 14px; }
.sheet-panel h3 { margin: 0 0 12px; font-size: 24px; }
.sheet-panel > .btn { width: 100%; margin-top: 16px; }
.why-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.why-list li { display: flex; gap: 12px; align-items: start; padding: 12px; border-radius: 10px; background: #fff; border: 1.5px solid var(--line-2); font-size: 14px; line-height: 1.45; }
.why-list li span:first-child { font-size: 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

/* Level-up burst: Noti cheering, a sticker and confetti, over whatever is on screen. */
.burst { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; pointer-events: none; }
.burst-card { position: relative; display: grid; justify-items: center; gap: 6px; padding: 22px 26px 18px; border-radius: 22px; background: var(--paper); color: var(--ink); border: 2px solid var(--ink);
  box-shadow: 6px 6px 0 var(--hl); transform: rotate(-3deg); animation: burst-in .55s var(--ease) both; pointer-events: auto; max-width: min(340px, calc(100vw - 40px)); text-align: center; }
.burst-card .mascot { width: 110px; height: 110px; animation: wiggle .6s ease-in-out 2; }
.burst-card b { font-family: var(--serif); font-size: 26px; line-height: 1.1; }
.burst-card span { font-size: 14px; color: var(--ink-2); }
.burst-card .sbadge { margin-top: 6px; }
.burst-card.leaving { animation: burst-out .4s var(--ease) both; }
.burst-actions { display: flex; gap: 8px; margin-top: 10px; }
.btn.small { min-height: 40px; padding: 0 16px; font-size: 14px; }
.btn .btn-ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@keyframes burst-in { 0% { transform: scale(.4) rotate(-12deg); opacity: 0; } 70% { transform: scale(1.06) rotate(-2deg); opacity: 1; } 100% { transform: scale(1) rotate(-3deg); opacity: 1; } }
@keyframes burst-out { to { transform: scale(.6) rotate(6deg); opacity: 0; } }
@keyframes wiggle { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
.confetti { position: absolute; top: 50%; left: 50%; width: 10px; height: 14px; border-radius: 2px; opacity: 0; animation: confetti 1.4s cubic-bezier(.2, .7, .3, 1) forwards; animation-delay: var(--d, 0s); }
@keyframes confetti { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .confetti { display: none; } .burst-card .mascot { animation: none; } }

/* Weekly recap: a postcard-style sticker card. */
.recap { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 18px; border-radius: 18px; margin-bottom: 14px; color: var(--ink);
  background: linear-gradient(135deg, #fff 0%, #fff7cf 100%); border: 1.5px solid var(--ink); box-shadow: 4px 4px 0 var(--hl); overflow: hidden; }
.recap::after { content: 'THIS WEEK'; position: absolute; right: -22px; top: 14px; font-family: var(--mono); font-size: 10px; letter-spacing: .12em; padding: 3px 28px; background: var(--ink); color: var(--paper); transform: rotate(35deg); }
.recap h3 { margin: 0; font-size: 21px; grid-column: 1 / -1; }
.recap .mascot { width: 64px; height: 64px; grid-row: 2 / 4; align-self: center; }
.recap-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.recap-stats span { font-family: var(--mono); font-size: 11.5px; font-weight: 600; padding: 5px 8px; border-radius: 8px; background: #fff; border: 1.5px solid var(--line-2); }
.recap-stats span b { font-family: var(--serif); font-size: 15px; margin-right: 3px; }
.recap p { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--ink-2); }
.recap .btn { grid-column: 1 / -1; justify-self: start; min-height: 38px; font-size: 13.5px; padding: 0 14px; margin-top: 4px; }
.recap.past::after { content: 'LAST WEEK'; }
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(var(--tabbar) + var(--safe-b) + 16px); transform: translate(-50%, 16px); max-width: calc(100vw - 32px);
  background: var(--ink); color: var(--paper); border: 1.5px solid var(--ink); box-shadow: 3px 3px 0 var(--hl); padding: 11px 16px; border-radius: 8px; font-size: 14px; font-weight: 500;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body.onboarding .toast { bottom: calc(96px + var(--safe-b)); }

.sound-gate { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 24px; background: rgba(13, 13, 14, .85); }
.sound-card { text-align: center; display: grid; gap: 16px; padding: 26px 24px; border-radius: 14px; background: var(--paper); color: var(--ink); box-shadow: 5px 5px 0 var(--hl); max-width: 340px; }
.sound-card p { margin: 0; color: var(--ink-2); font-family: var(--serif); font-size: 20px; line-height: 1.25; }

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

/* ---------------------------------------------------------------------------- tune & editing */
.tune h4 { font-family: var(--sans); font-size: 12.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); margin: 18px 0 8px; }
.tune h4:first-child { margin-top: 4px; }
.chip-btn.on { background: var(--hl); border-color: var(--ink); font-weight: 600; padding-right: 6px; }
.chip-x { width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--ink); color: var(--paper); font-size: 15px; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-row input { flex: 1; min-width: 0; font: inherit; font-size: 15px; color: var(--ink); background: #fff; border: 1.5px solid var(--line-2); border-radius: 9px; padding: 9px 12px; outline: none; }
.add-row input:focus { border-color: var(--ink); }
.pref-row { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 14px; font-weight: 600; }
.segmented.small { margin: 0; }
.segmented.small button { padding: 8px 6px; font-size: 13px; }
.unit-row.off { opacity: .45; }
.unit-row label.unit-name { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.unit-on { appearance: none; width: 20px; height: 20px; margin: 0; flex: none; border-radius: 5px; border: 1.5px solid var(--ink); background: #fff; cursor: pointer; }
.unit-on:checked { background: var(--hl) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12l5 5 9-10' fill='none' stroke='%23141414' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 13px no-repeat; }
.tag { font-family: var(--mono); font-size: 10.5px; font-weight: 600; padding: 2px 6px; border-radius: 4px; border: 1px solid var(--ink); }
.unit-row .chip-x { justify-self: end; }
.next-note { margin: 6px 0 0; font-size: 12px; color: var(--hl); font-weight: 600; text-shadow: 0 1px 4px #000; }

/* ---------------------------------------------------------------------------- landing (one screen) */
/* Sized to the real viewport (dvh: mobile toolbars included). Content compacts on short screens;
   if a viewport is shorter still, the page scrolls rather than clipping anything. */
.landing { position: fixed; inset: 0; height: 100dvh; display: flex; flex-direction: column; background: var(--paper); color: var(--ink); overflow-y: auto; overflow-x: hidden;
  background-image: radial-gradient(var(--line) .8px, transparent .8px); background-size: 22px 22px; padding: var(--safe-t) 0 var(--safe-b); -webkit-overflow-scrolling: touch; }
.ld-bar { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 12px 20px 4px; }
.ld-brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--serif); font-weight: 700; font-size: 20px; }
.ld-logo { width: 30px; height: 30px; border-radius: 9px; background: url(/icons/icon-192.png) center / cover; box-shadow: 2px 2px 0 var(--hl); }
.ld-signin { font-weight: 600; color: var(--ink); text-decoration: none; border-bottom: 2px solid var(--hl); padding-bottom: 1px; }
.ld-main { flex: 1 0 auto; display: flex; flex-direction: column; justify-content: center; gap: clamp(8px, 1.6vh, 18px); width: min(900px, 100%); margin: 0 auto; padding: 4px 0; }
.ld-hero { padding: 0 20px; text-align: center; }
.ld-kicker { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 6px; }
.ld-hero h1 { font-size: clamp(24px, 6.4vw, 44px); line-height: 1.04; margin: 0 0 8px; font-weight: 600; font-variation-settings: 'opsz' 96; }
.ld-hero .lead { max-width: 520px; margin: 0 auto; font-size: clamp(13px, 3.6vw, 15.5px); line-height: 1.4; }
.ld-samples { flex: none; display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 6px 20px; scrollbar-width: none; }
.ld-samples::-webkit-scrollbar { display: none; }
.ld-samples > :first-child { margin-left: auto; } .ld-samples > :last-child { margin-right: auto; }
.sample { flex: 0 0 auto; height: clamp(150px, 24vh, 280px); aspect-ratio: 9 / 16; scroll-snap-align: start; position: relative; border-radius: 16px; overflow: hidden; color: #fff; background: var(--dark);
  box-shadow: 0 10px 24px rgba(0,0,0,.2), 3px 3px 0 var(--hl); display: flex; flex-direction: column; padding: 10px 9px; isolation: isolate; animation: rise .5s var(--ease) both; }
.sample::before { content: ''; position: absolute; inset: 0; z-index: -1; background: radial-gradient(120% 80% at 50% 0%, var(--accent) 0%, transparent 60%), linear-gradient(180deg, #2a2a2e, #0d0d0e 70%); opacity: .95; }
.sample::after { content: ''; position: absolute; inset: 0; z-index: -1; background-image: radial-gradient(rgba(255,255,255,.08) .8px, transparent .8px); background-size: 14px 14px; }
.sample .s-chip { align-self: center; font-family: var(--mono); font-size: 7.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 3px 7px; border-radius: 99px; background: var(--accent); color: #0b0b0b; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.sample .s-chip, .sample .s-card, .sample .s-foot, .sample .s-stamp { flex: none; }
.sample .s-hook { flex: 1; min-height: 0; overflow: hidden; display: grid; place-items: center; text-align: center; font-weight: 800; font-size: clamp(11px, 1.7vh, 16px); line-height: 1.1; padding: 4px 2px; text-shadow: 0 3px 14px rgba(0,0,0,.5); }
.sample .s-hook em { font-style: normal; color: var(--accent); }
.sample[data-f="mythbust"] .s-hook, .sample[data-f="rapid"] .s-hook, .sample[data-f="examdrill"] .s-hook { text-transform: uppercase; letter-spacing: .01em; }
.sample[data-f="story"] .s-hook { font-family: var(--serif); font-weight: 600; }
.sample .s-card { border-radius: 8px; padding: 6px 7px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); font-size: 8.5px; line-height: 1.3; }
.sample .s-card b { display: block; font-family: var(--mono); font-size: 7px; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: 2px; }
.sample[data-f="examdrill"] .s-card, .sample[data-f="flashcards"] .s-card { background: #f6f1e7; color: var(--ink); border-color: #d9cfae; }
.sample[data-f="examdrill"] .s-card b, .sample[data-f="flashcards"] .s-card b { color: var(--ink-3); }
.sample .s-stamp { align-self: center; margin: 3px 0; font-weight: 900; font-size: 13px; letter-spacing: .06em; color: #ff5a5f; border: 2px solid #ff5a5f; border-radius: 5px; padding: 1px 6px; transform: rotate(-7deg); text-transform: uppercase; }
.sample .s-foot { margin-top: 5px; display: flex; justify-content: space-between; font-family: var(--mono); font-size: 7.5px; color: rgba(255,255,255,.7); }
.ld-pills { list-style: none; margin: 0; padding: 0 20px; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.ld-pills::-webkit-scrollbar { display: none; }
.ld-pills > :first-child { margin-left: auto; } .ld-pills > :last-child { margin-right: auto; }
.ld-pills li { flex: none; font-size: 12px; font-weight: 600; padding: 6px 11px; border-radius: 99px; background: #fff; border: 1.5px solid var(--line-2); white-space: nowrap; }
.ld-cta { flex: none; padding: 4px 20px 6px; display: grid; gap: 7px; justify-items: center; width: min(560px, 100%); margin: 0 auto; }
.ld-buttons { display: grid; gap: 7px; width: 100%; }
.ld-buttons .btn { width: 100%; }
.ld-go { min-height: 50px; font-size: 16px; }
.ld-go .vm-logo { width: 24px; height: 24px; }
.ld-trust { color: var(--ink-3); font-size: 11.5px; line-height: 1.4; text-align: center; margin: 0; }
.ld-foot { flex: none; font-size: 11px; color: var(--ink-3); text-align: center; padding: 4px 20px 10px; line-height: 1.6; }
.ld-foot img { width: 14px; height: 14px; border-radius: 3px; vertical-align: -3px; margin-right: 4px; }
.ld-foot a { color: var(--ink); font-weight: 600; text-decoration: none; border-bottom: 1.5px solid var(--hl); }
@media (max-height: 740px) { .ld-kicker { display: none; } .ld-hero .lead { font-size: 13px; } .sample { height: 150px; } .sample .s-foot { display: none; } .sample .s-card { font-size: 8px; } }
@media (max-width: 819px) and (max-height: 700px) { .ld-trust { display: none; } .ld-foot { font-size: 10.5px; line-height: 1.4; padding-bottom: 6px; } .ld-cta { gap: 6px; padding-bottom: 4px; } }
@media (max-height: 640px) { .ld-pills { display: none; } .ld-hero .lead { display: none; } .ld-trust { display: none; } }

/* Desktop and tablets in landscape: copy and buttons on the left, a fan of sample cards on the right. */
@media (min-width: 820px) {
  .ld-bar { padding: 18px 40px 0; }
  .ld-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); grid-template-areas: "hero samples" "pills samples" "cta samples"; align-items: center; align-content: center; column-gap: 32px; row-gap: clamp(8px, 2vh, 18px); width: min(1160px, 100%); padding: 0 40px; }
  .ld-hero { grid-area: hero; text-align: left; padding: 0; align-self: end; position: relative; z-index: 2; }
  .ld-hero h1 { font-size: clamp(30px, min(4.6vw, 8vh), 62px); margin-bottom: clamp(6px, 1.5vh, 14px); }
  .ld-hero .lead { margin: 0; font-size: clamp(15px, 1.3vw, 18px); max-width: 540px; }
  .ld-kicker { margin-bottom: 12px; }
  .ld-pills { grid-area: pills; padding: 0; overflow: visible; flex-wrap: wrap; }
  .ld-pills > :first-child, .ld-pills > :last-child { margin: 0; }
  .ld-pills li { font-size: 13px; }
  .ld-cta { grid-area: cta; align-self: start; padding: 0; margin: 0; width: 100%; justify-items: start; }
  .ld-buttons { grid-template-columns: auto auto; justify-content: start; }
  .ld-buttons .btn { width: auto; padding: 0 26px; }
  .ld-trust { text-align: left; max-width: 480px; }
  .ld-samples { grid-area: samples; position: relative; height: min(64vh, 560px); min-height: 220px; overflow: visible; padding: 0; display: block; }
  .ld-samples > :first-child, .ld-samples > :last-child { margin: 0; }
  .sample { position: absolute; top: 50%; left: 50%; height: clamp(190px, 46vh, 400px); animation: none; transform-origin: 50% 110%; box-shadow: 0 24px 50px rgba(0,0,0,.28), 4px 4px 0 var(--hl); padding: 16px 14px; border-radius: 22px; }
  .sample .s-chip { font-size: 9.5px; padding: 5px 9px; }
  .sample .s-hook { font-size: 20px; padding: 10px 4px; }
  .sample .s-card { font-size: 11px; padding: 10px 11px; }
  .sample .s-card b { font-size: 8.5px; }
  .sample .s-stamp { font-size: 20px; }
  .sample .s-foot { font-size: 9.5px; }
  .sample:nth-child(1) { transform: translate(-50%, -50%) translateX(-78%) rotate(-9deg); z-index: 1; }
  .sample:nth-child(2) { transform: translate(-50%, -50%) translateX(-26%) rotate(-3deg); z-index: 3; }
  .sample:nth-child(3) { transform: translate(-50%, -50%) translateX(26%) rotate(3deg); z-index: 2; }
  .sample:nth-child(4) { transform: translate(-50%, -50%) translateX(78%) rotate(9deg); z-index: 1; }
  .sample:nth-child(n+5) { display: none; }
  .sample:hover { z-index: 9; transform: translate(-50%, -54%) scale(1.04); transition: transform .25s var(--ease); }
  .ld-foot { padding: 6px 40px 12px; }
  .ld-kicker, .ld-pills { display: flex; }
  .ld-hero .lead, .ld-trust { display: block; }
}
@media (min-width: 820px) and (max-height: 560px) { .ld-kicker { display: none !important; } .ld-trust { display: none !important; } .ld-hero .lead { font-size: 13.5px; } .sample .s-foot { display: none; } .ld-bar { padding-top: 10px; } }
@media (min-width: 820px) and (max-height: 480px) { .ld-pills { display: none !important; } .ld-hero .lead { display: none !important; } .sample { height: 190px; } .ld-main { row-gap: 8px; } .ld-foot { padding-bottom: 6px; } }
body.landing-on { background: var(--paper); }
.credit-meter { height: 8px; border-radius: 99px; background: var(--paper-3); border: 1px solid var(--line); overflow: hidden; margin: 10px 0 6px; }
.credit-meter i { display: block; height: 100%; background: var(--hl); }
.credit-row { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }
.credit-big { font-family: var(--serif); font-size: 30px; font-weight: 600; margin: 4px 0 2px; }
.credit-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.credit-actions .btn { margin-top: 0; }
.card.warn { border-color: var(--bad); background: #fff7f6; }
.card.warn h3 { color: var(--bad); }
.end-slide .credits-box { max-width: 330px; margin: 0 auto; padding: 18px; border-radius: 12px; background: var(--paper); color: var(--ink); text-align: left; box-shadow: 4px 4px 0 var(--hl); display: grid; gap: 10px; }
.end-slide .credits-box h3 { margin: 0; font-size: 20px; }
.end-slide .credits-box p { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.ld-foot { width: min(760px, 100%); margin: 36px auto 0; padding: 26px 20px calc(30px + var(--safe-b)); border-top: 1.5px solid var(--line-2); text-align: center; }
.ld-built { margin: 0 0 6px; font-family: var(--serif); font-size: 17px; }
.ld-built a, .ld-links a { color: var(--ink); font-weight: 600; text-decoration: none; border-bottom: 2px solid var(--hl); }
.ld-links { margin: 0; font-size: 14px; color: var(--ink-3); }
.ld-foot .fine { max-width: 520px; margin: 16px auto 0; }
body.landing-on { background: var(--paper); }

/* ---------------------------------------------------------------------------- desktop (wide screens)
   The dock becomes a dark sidebar with the brand, the video is a 9:16 column in the middle, and the
   rail and pager sit beside it, outside the picture, like a desktop short-video app. */
@media (min-width: 900px) {
  :root { --tabbar: 0px; --side: 236px; --stage-w: min(540px, calc((100dvh - 32px) * 9 / 16)); }
  .view { left: var(--side); bottom: 0; }
  .tabbar, body[data-view] .tabbar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--side); height: auto; transform: none; border-radius: 0; border: 0; border-right: 1px solid var(--dark-line);
    box-shadow: none; padding: 22px 16px; background: var(--dark-2); color: #fff; display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
  .side-brand { display: block; padding: 6px 10px 22px; }
  .side-brand svg { overflow: visible; width: 190px; height: 34px; }
  .side-brand p { margin: 8px 0 0; font-size: 12.5px; color: rgba(255, 255, 255, .55); }
  .tabbtn { flex: none; max-width: none; display: flex; align-items: center; justify-content: flex-start; gap: 13px; height: 48px; padding: 0 14px; border-radius: 12px; font-size: 15px; opacity: .72; }
  .tabbtn:hover { opacity: 1; }
  .tabbtn svg { width: 22px; height: 22px; }
  .tabbtn[aria-current="page"] svg { transform: none; animation: none; }
  .tabbtn[aria-current="page"], body[data-view="feed"] .tabbtn[aria-current="page"], .tabbtn[aria-current="page"] span, body[data-view="feed"] .tabbtn[aria-current="page"] span { color: var(--ink); opacity: 1; }
  /* In the sidebar the active item carries its own highlight (the sliding blob is a bottom-dock thing). */
  .tab-blob { display: none; }
  .tabbtn { transition: background .2s, opacity .2s; }
  .tabbtn[aria-current="page"] { background: var(--hl); }
  .side-foot { display: block; margin: auto 0 0; padding: 0 10px; font-size: 12px; color: rgba(255, 255, 255, .45); line-height: 1.5; }
  .side-foot a { color: rgba(255, 255, 255, .75); text-decoration-color: var(--hl); text-decoration-thickness: 2px; text-underline-offset: 2px; }

  .view-feed { background: var(--dark) radial-gradient(circle at 100% 0, rgba(255, 217, 61, .14), transparent 48%); }
  .view-feed::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255, 255, 255, .09) 1px, transparent 1.2px); background-size: 26px 26px; pointer-events: none; }
  .slide { background: transparent; }
  .stage { width: var(--stage-w); height: calc(var(--stage-w) * 16 / 9); border-radius: 22px; border: 1px solid rgba(255, 255, 255, .12); box-shadow: 0 30px 80px rgba(0, 0, 0, .55), 0 0 0 6px rgba(255, 255, 255, .03); }
  .feed-head { left: 50%; right: auto; width: var(--stage-w); top: calc(50% - var(--stage-w) * 8 / 9); transform: translateX(-50%); padding: 14px 14px 28px; border-radius: 22px 22px 0 0; }
  .feed-head .wordmark { visibility: hidden; }
  .rail { right: auto; left: calc(50% + var(--stage-w) / 2 + 18px); bottom: calc(50% - var(--stage-w) * 8 / 9); gap: 16px; }
  .rail-btn .ic { width: 50px; height: 50px; background: var(--dark-2); border-color: rgba(255, 255, 255, .25); }
  .rail-btn:hover .ic { border-color: #fff; }
  .pager { right: auto; left: calc(50% + var(--stage-w) / 2 + 20px); top: calc(50% - var(--stage-w) * 8 / 9); transform: none; }
  .pager-btn { background: var(--dark-2); border-color: rgba(255, 255, 255, .25); }
  .meta { right: 14px; }
  .quiz { left: auto; right: calc(50% + var(--stage-w) / 2 + 18px); width: min(320px, calc(50% - var(--stage-w) / 2 - 40px)); bottom: calc(50% - var(--stage-w) * 8 / 9); box-shadow: 6px 6px 0 var(--hl); }
  .quiz-hint::before { content: "· click an answer to continue"; }
  .quiz-hint { font-size: 0; }
  .quiz-hint::before { font-size: 11px; }
  .making { padding: 24px 20px 130px; }
  .swipe-hint { display: none; }
  .ptr { display: none; }
  .page { width: min(760px, 100%); }
  .page-top { padding-top: 24px; }
  .sheet-panel { top: 50%; bottom: auto; transform: translateY(-50%); border-radius: 18px; border: 1.5px solid var(--ink); max-height: min(80vh, 720px); animation: fade .2s; }
  .sheet-grip { display: none; }
}
@media (min-width: 900px) and (max-height: 760px) {
  /* Short, wide windows (laptops with the browser chrome): keep the arrows and the rail apart. */
  .pager { grid-auto-flow: column; }
  .rail { gap: 8px; }
  .rail-btn .ic { width: 44px; height: 44px; }
  .rail-btn .count { font-size: 10px; }
}


/* ============================================================================ library: Saved & History */
.lib-strip { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 14px 16px; border-radius: 16px; margin-bottom: 14px; background: #fff; border: 1.5px solid var(--ink); box-shadow: 4px 4px 0 var(--hl); }
.lib-strip .mascot { width: 64px; height: 64px; animation: float 4s ease-in-out infinite; }
.lib-strip h3 { margin: 0; font-size: 19px; }
.lib-strip p { margin: 2px 0 0; color: var(--ink-3); font-size: 13px; line-height: 1.4; }
@media (max-width: 420px) { .lib-strip { grid-template-columns: auto 1fr; } .lib-strip .btn { grid-column: 1 / -1; justify-self: start; } }
.tiles-grid { grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 12px; }
.ltile-wrap { position: relative; }
.ltile { position: relative; display: block; width: 100%; aspect-ratio: 3 / 4; padding: 0; border: 0; border-radius: 16px; overflow: hidden; background: var(--paper-2); cursor: pointer; color: #fff; text-align: left; isolation: isolate;
  box-shadow: 0 1px 0 rgba(0,0,0,.06); transition: transform .15s var(--ease), box-shadow .15s; }
.ltile:hover, .ltile:focus-visible { transform: translateY(-2px); box-shadow: 4px 4px 0 var(--accent); outline: none; }
.ltile img, .ltile .ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: grid; place-items: center; font-size: 44px; background: linear-gradient(160deg, var(--accent), var(--paper-2)); transition: transform .4s var(--ease); }
.ltile:hover img { transform: scale(1.04); }
.ltile::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.25) 0%, transparent 35%, transparent 45%, rgba(0,0,0,.82) 100%); }
.ltile > span { position: relative; z-index: 1; }
.ltile .lt-top { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; gap: 6px; font-family: var(--mono); font-size: 10.5px; font-weight: 600; }
.ltile .lt-topic { padding: 4px 8px; border-radius: 999px; background: var(--accent); color: var(--ink); max-width: 70%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ltile .lt-dur { padding: 4px 7px; border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; }
.ltile .lt-play { position: absolute; left: 50%; top: 46%; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; background: rgba(255,255,255,.9); display: grid; place-items: center; opacity: 0; transform: scale(.8); transition: opacity .15s, transform .15s; }
.ltile .lt-play svg { width: 18px; height: 18px; fill: var(--ink); margin-left: 2px; }
.ltile:hover .lt-play { opacity: 1; transform: scale(1); }
.ltile .lt-body { position: absolute; left: 12px; right: 12px; bottom: 12px; display: grid; gap: 4px; }
.ltile .lt-body b { font-family: var(--serif); font-weight: 600; font-size: 15px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.ltile .lt-body small { font-size: 11px; color: rgba(255,255,255,.78); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lt-x { position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--ink); background: #fff; color: var(--ink); font-size: 18px; line-height: 1; cursor: pointer; display: grid; place-items: center; box-shadow: 2px 2px 0 var(--ink); z-index: 2; }
.lt-x:hover { background: var(--hl); }
.lib-day { display: flex; align-items: center; gap: 10px; margin: 18px 2px 8px; font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.lib-day::after { content: ''; flex: 1; height: 1.5px; background: var(--line-2); }
.lib-day span { font-weight: 500; }
.hlist { display: grid; gap: 8px; }
.hrow { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; width: 100%; padding: 8px; border-radius: 14px; border: 1.5px solid var(--line-2); background: #fff; cursor: pointer; text-align: left; color: var(--ink); transition: border-color .15s, box-shadow .15s, transform .1s; }
.hrow:hover { border-color: var(--ink); box-shadow: 3px 3px 0 var(--accent); }
.hrow:active { transform: translateY(1px); }
.hrow img, .hrow .ph { width: 56px; height: 72px; border-radius: 10px; object-fit: cover; display: grid; place-items: center; font-size: 24px; background: linear-gradient(160deg, var(--accent), var(--paper-2)); border-left: 4px solid var(--accent); }
.hrow .h-body { display: grid; gap: 3px; min-width: 0; }
.hrow .h-body b { font-family: var(--serif); font-weight: 600; font-size: 15px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hrow .h-body small { color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hrow .h-when { display: grid; justify-items: center; gap: 4px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }
.hrow .h-when svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ============================================================================ moments (cards between lessons) */
.moment-slide { --m1: #ffd93d; --m2: #ffb34d; --m3: #fff3c4; }
.moment-slide[data-theme="mint"] { --m1: #b8f1d2; --m2: #5fd3a6; --m3: #e6fbf0; }
.moment-slide[data-theme="rose"] { --m1: #ffc2cc; --m2: #ff6b8a; --m3: #ffe9ed; }
.moment-slide[data-theme="sky"] { --m1: #bfe3ff; --m2: #5fb0ff; --m3: #e8f4ff; }
.moment-slide[data-theme="grape"] { --m1: #d9c9ff; --m2: #9b7bff; --m3: #efe9ff; }
.m-stage { background: var(--m3); color: var(--ink); display: grid; grid-template-rows: 1fr auto; align-items: center; cursor: pointer; user-select: none; }
.m-bg { position: absolute; inset: 0; overflow: hidden; }
.m-bg i { position: absolute; border-radius: 50%; filter: blur(2px); opacity: .9; animation: m-drift 9s ease-in-out infinite; }
.m-bg i:nth-child(1) { width: 62%; padding-top: 62%; left: -18%; top: -10%; background: var(--m1); }
.m-bg i:nth-child(2) { width: 50%; padding-top: 50%; right: -14%; top: 28%; background: var(--m2); animation-delay: -3s; animation-duration: 11s; }
.m-bg i:nth-child(3) { width: 44%; padding-top: 44%; left: 10%; bottom: -14%; background: var(--m1); animation-delay: -6s; animation-duration: 13s; }
@keyframes m-drift { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(4%, -5%) scale(1.08); } }
.m-card { position: relative; z-index: 1; margin: 0 22px; padding: 26px 22px 22px; border-radius: 22px; background: rgba(255,255,255,.92); border: 2px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); display: grid; justify-items: start; gap: 12px; opacity: 0; transform: translateY(18px) scale(.97); transition: opacity .35s var(--ease), transform .45s var(--ease); }
.moment-slide.on .m-card { opacity: 1; transform: none; }
.m-kicker { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 6px 10px 6px 8px; border-radius: 999px; background: var(--m1); border: 1.5px solid var(--ink); }
.m-kicker .m-emoji { font-size: 15px; }
.m-kicker .m-from { font-weight: 500; letter-spacing: 0; text-transform: none; opacity: .7; }
.m-mascot { position: absolute; right: 14px; top: -42px; width: 88px; height: 88px; animation: float 4s ease-in-out infinite; filter: drop-shadow(0 6px 0 rgba(0,0,0,.12)); }
.m-title { margin: 6px 0 0; font-size: 28px; line-height: 1.08; max-width: 86%; }
.m-title::after { content: ''; display: block; width: 44px; height: 6px; margin-top: 10px; border-radius: 3px; background: var(--m2); transform-origin: left; transform: scaleX(0); transition: transform .5s .3s var(--ease); }
.moment-slide.on .m-title::after { transform: scaleX(1); }
.m-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.m-lines li { position: relative; padding-left: 22px; font-size: 16px; line-height: 1.4; color: var(--ink-2); opacity: 0; transform: translateX(-10px); transition: opacity .4s var(--ease), transform .4s var(--ease); transition-delay: calc(.45s + var(--i) * .55s); }
.m-lines li::before { content: ''; position: absolute; left: 2px; top: .55em; width: 10px; height: 10px; border-radius: 50%; background: var(--m2); border: 1.5px solid var(--ink); }
.moment-slide.on .m-lines li { opacity: 1; transform: none; }
.m-cta { margin-top: 6px; opacity: 0; transform: translateY(8px); transition: opacity .4s var(--ease), transform .4s var(--ease); transition-delay: 2.1s; }
.moment-slide.on .m-cta { opacity: 1; transform: none; }
.m-swipe { position: relative; z-index: 1; display: grid; justify-items: center; gap: 2px; padding: 0 0 128px; font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); opacity: 0; transition: opacity .5s 2.6s; }
.moment-slide.on .m-swipe { opacity: 1; }
.m-swipe svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; animation: m-bob 1.6s ease-in-out infinite; }
@keyframes m-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.m-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.m-confetti i { position: absolute; top: -12px; left: calc(var(--n) * 7% + 2%); width: 8px; height: 14px; border-radius: 2px; background: var(--m2); opacity: 0; transform: rotate(0deg); }
.m-confetti i:nth-child(odd) { background: var(--ink); width: 6px; height: 10px; }
.m-confetti i:nth-child(3n) { background: var(--hl); border-radius: 50%; width: 9px; height: 9px; }
.moment-slide.on .m-confetti i { animation: m-fall 3.2s linear infinite; animation-delay: calc(var(--n) * -.23s); }
@keyframes m-fall { 0% { opacity: 0; transform: translateY(0) rotate(0); } 8% { opacity: 1; } 100% { opacity: .9; transform: translateY(105vh) rotate(540deg); } }
@media (min-width: 900px) { .m-title { font-size: 30px; } .m-card { margin: 0 26px; } }
@media (max-height: 700px) { .m-card { padding: 20px 18px 18px; gap: 9px; } .m-title { font-size: 24px; } .m-lines li { font-size: 14.5px; } .m-mascot { width: 72px; height: 72px; top: -36px; } .m-swipe { padding-bottom: 110px; } }
@media (prefers-reduced-motion: reduce) { .m-bg i, .m-mascot, .m-swipe svg, .moment-slide.on .m-confetti i { animation: none; } .m-lines li, .m-cta, .m-card, .m-swipe { transition-delay: 0s !important; } }


/* ============================================================================ recall cards, exam countdown */
.r-card { gap: 10px; }
.r-unit { margin: 0; font-family: var(--mono); font-size: 12px; color: var(--ink-3); display: flex; gap: 8px; align-items: center; }
.r-count { padding: 2px 7px; border-radius: 999px; background: var(--m1); color: var(--ink); font-weight: 600; font-size: 10.5px; }
.r-q { font-size: 24px; max-width: 100%; }
.r-q::after { display: none; }
.r-options { display: grid; gap: 8px; width: 100%; }
.r-opt { opacity: 0; transform: translateY(6px); transition: opacity .35s var(--ease), transform .35s var(--ease), background .15s, border-color .15s; transition-delay: calc(.4s + var(--i) * .15s); }
.moment-slide.on .r-opt { opacity: 1; transform: none; }
.r-feedback { margin: 2px 0 0; min-height: 1.4em; font-size: 14.5px; line-height: 1.4; color: var(--ink-2); }
.r-feedback[data-state="right"] { color: #15803d; font-weight: 600; }
.r-feedback[data-state="wrong"] { color: var(--ink); }
.r-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; width: 100%; }
.r-skip { margin-left: auto; border: 0; background: none; color: var(--ink-3); font-family: var(--mono); font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.recall-slide .m-cta { display: none; }
.exam-chip { display: inline-flex; align-items: center; gap: 4px; margin-top: 6px; padding: 5px 10px; border-radius: 999px; background: #fff; border: 1.5px solid var(--ink); font-family: var(--mono); font-size: 12px; font-weight: 600; width: max-content; }
.exam-chip.soon { background: var(--hl); }
.hero .exam-chip { margin: 6px 0 2px; }
.fix-strip { border-color: #9b7bff; box-shadow: 4px 4px 0 #9b7bff; }
.field input[type="date"] { font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 1.5px solid var(--line-2); border-radius: 10px; padding: 12px 15px; outline: none; }


/* ============================================================================ start fresh */
.reset-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.danger { color: #b42318; border-color: #b42318; }
.btn.danger:hover { background: #fff1f0; }
.reset-fine { margin: 10px 0 0; }


/* ============================================================================ recall mode chip, playback prefs */
.gaps-chip { position: absolute; z-index: 7; left: 12px; right: 82px; bottom: 112px; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px; border: 1.5px solid rgba(255,255,255,.7); background: rgba(13, 13, 14, .78); color: #fff; font-family: var(--mono); font-size: 11.5px; line-height: 1.3; text-align: left; cursor: pointer; backdrop-filter: blur(6px); }
.gaps-chip i { font-style: normal; font-size: 16px; }
.gaps-chip[data-revealed="true"] { background: var(--hl); color: var(--ink); border-color: var(--ink); }
.gaps-chip[data-revealed="true"] i::before { content: '👁️'; }
.gaps-chip[data-revealed="true"] i { font-size: 0; }
.gaps-chip[data-revealed="true"] i::before { font-size: 16px; }
.pref-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; margin: 6px 0; }
.pref-label { font-weight: 600; font-size: 14px; }
.segmented.small button { padding: 6px 10px; font-size: 12.5px; min-height: 0; }
.pref-hint { margin: -2px 0 10px; font-size: 12.5px; color: var(--ink-3); line-height: 1.4; }
@media (min-width: 900px) { .gaps-chip { right: 12px; } }


/* ============================================================================ community packs */
.packs { display: grid; gap: 10px; margin: 10px 0 6px; }
.pack-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; padding: 12px; border-radius: 14px; border: 1.5px solid var(--line-2); background: #fff; }
.pack-body { display: grid; gap: 3px; min-width: 0; }
.pack-body b { font-family: var(--serif); font-size: 16px; line-height: 1.25; }
.pack-body small { color: var(--ink-3); font-size: 12px; }
.pack-body p { margin: 4px 0 0; font-size: 13px; line-height: 1.4; color: var(--ink-2); }
.pack-card { border-color: #5fb0ff; }
.pack-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }


/* ============================================================================ design system: sticky tops, bounded lists, search */
/* The page title, the tabs and the search box stay on screen while the page scrolls under them. */
.page-top { position: sticky; top: 0; z-index: 8; margin: 0 -16px 14px; padding: calc(12px + var(--safe-t)) 16px 10px; background: var(--paper); box-shadow: 0 10px 14px -12px rgba(20, 20, 20, .35); }
.page-top .page-title { margin: 4px 2px 10px; }
.page-top .segmented { margin-bottom: 0; }
.segmented button { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.segmented .seg-n { font-family: var(--mono); font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); }
.segmented button[aria-selected="true"] .seg-n { background: var(--hl); color: var(--ink); }
.lib-search { position: relative; display: flex; align-items: center; margin-top: 10px; }
.lib-search svg { position: absolute; left: 12px; width: 18px; height: 18px; fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.lib-search input { width: 100%; font: inherit; font-size: 15px; color: var(--ink); background: #fff; border: 1.5px solid var(--line-2); border-radius: 12px; padding: 11px 38px 11px 38px; outline: none; transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; }
.lib-search input:focus { border-color: var(--ink); box-shadow: 3px 3px 0 var(--hl); }
.lib-search input::-webkit-search-cancel-button { display: none; }
.lib-clear { position: absolute; right: 8px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--paper-2); color: var(--ink); font-size: 18px; line-height: 1; cursor: pointer; }
.lib-results { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 0; font-size: 12.5px; }
.lib-res { font: inherit; font-family: var(--mono); font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; border: 1.5px solid var(--line-2); background: #fff; color: var(--ink-2); cursor: pointer; }
.lib-res[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.lib-add { margin-left: auto; }
[data-search].off, .course-card.off, .lib-day.off, .packs-card.off, .search-hide.off { display: none !important; }
/* A bounded list: its own scroll, never an endless page. A hint shows only when there is more below. */
.scroll-box { position: relative; max-height: 340px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; padding-right: 2px; }
.scroll-box.tall { max-height: min(62dvh, 640px); }
.scroll-box::-webkit-scrollbar { width: 6px; }
.scroll-box::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }
.scroll-box.overflows { border-bottom: 1.5px dashed var(--line-2); }
.scroll-box.overflows::after { content: 'scroll for more'; position: sticky; bottom: 0; display: block; width: max-content; margin: 0 auto; padding: 3px 10px; border-radius: 999px 999px 0 0; background: var(--paper-2); font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); pointer-events: none; }
.unit-list.scroll-box { max-height: 380px; }
.unit-filter { width: 100%; margin-top: 12px; font: inherit; font-size: 15px; color: var(--ink); background: #fff; border: 1.5px solid var(--line-2); border-radius: 10px; padding: 10px 14px; outline: none; -webkit-appearance: none; }
.unit-filter:focus { border-color: var(--ink); }
.unit.off { display: none; }
.unit-rows { display: grid; }
.hist-box { display: grid; }
@media (max-height: 700px) { .scroll-box { max-height: 280px; } .scroll-box.tall { max-height: 56dvh; } }


/* ============================================================================ explore (community packs) */
.explore-intro { margin: 0 2px 14px; font-size: 14px; line-height: 1.45; }
.explore-filters { margin-top: 10px; gap: 6px; }
.explore-filters .chip-btn { padding: 6px 10px; font-size: 13px; }
.explore-filters .chip-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.explore-list { display: grid; gap: 12px; }
.xpack { padding: 16px; border-radius: var(--r); background: #fff; border: 1.5px solid var(--line-2); display: grid; gap: 10px; }
.xpack.added { border-color: #5fb0ff; }
.xpack-head { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; }
.xpack-emoji { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 24px; background: var(--accent, var(--hl-2)); border: 1.5px solid var(--ink); }
.xpack-head h3 { margin: 0; font-size: 19px; line-height: 1.2; }
.xpack-head small { display: block; margin-top: 3px; font-size: 12px; color: var(--ink-3); }
.xpack-about { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.xpack details { border-top: 1px solid var(--line); padding-top: 8px; }
.xpack summary { cursor: pointer; font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: 6px; }
.xpack summary::-webkit-details-marker { display: none; }
.xpack summary::before { content: '▸'; transition: transform .15s; }
.xpack details[open] summary::before { transform: rotate(90deg); }
.xpack ol { margin: 8px 0 0; padding-left: 22px; font-size: 14px; line-height: 1.5; }
.xpack-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.xpack-foot .tags { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
.explore-empty { text-align: center; padding: 30px 12px; color: var(--ink-3); }


/* ============================================================================ lesson notes, unit plan */
.notes-btn { width: 100%; margin-top: 12px; }
.notes { display: grid; gap: 12px; }
.notes-kicker { margin: 0; font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.notes-objective { margin: 0; font-size: 15px; line-height: 1.45; padding: 10px 12px; border-radius: 10px; background: var(--hl-2); }
.notes-terms .chip-btn { padding: 5px 10px; font-size: 13px; cursor: default; }
.notes-terms .chip-btn.on { background: var(--hl); border-color: var(--ink); }
.notes-sec { padding: 12px; border-radius: 12px; background: #fff; border: 1.5px solid var(--line-2); }
.notes-sec h4 { margin: 0 0 8px; font-family: var(--sans); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.notes-sec p, .notes-sec li { font-size: 14.5px; line-height: 1.5; margin: 0 0 6px; }
.notes-sec ol { margin: 0; padding-left: 22px; }
.notes-eq code { display: block; font-family: var(--mono); font-size: 15px; padding: 8px 10px; border-radius: 8px; background: var(--paper-2); }
.notes-eq small { color: var(--ink-3); }
.notes-opts li.right { font-weight: 700; background: linear-gradient(transparent 30%, var(--hl-2) 30%, var(--hl-2) 90%, transparent 90%); }
.notes-takeaway { margin: 0; font-family: var(--serif); font-size: 19px; line-height: 1.3; padding: 12px 14px; border-left: 4px solid var(--hl); }
.notes-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.unit-title { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; text-decoration: underline dotted var(--line-2); text-underline-offset: 3px; }
.unit-title:hover { text-decoration-color: var(--ink); }
.plan-list { margin: 10px 0 0; padding-left: 22px; display: grid; gap: 10px; }
.plan-list li { display: grid; gap: 2px; font-size: 14px; line-height: 1.4; }
.plan-list li b { font-family: var(--serif); font-size: 16px; }
.plan-list li small { color: var(--ink-3); }
.plan-list li.done { opacity: .65; }
.plan-list li.done b::after { content: ' ✓'; color: #15803d; }
.plan h4 { margin: 16px 0 6px; font-family: var(--sans); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); }
.plan-gloss { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13.5px; }
.plan-gloss dt { font-weight: 700; } .plan-gloss dd { margin: 0; color: var(--ink-2); }


/* ============================================================================ mini games */
.g-stage { padding-bottom: 92px; }
.g-card { max-height: calc(100% - 24px); overflow-y: auto; overscroll-behavior: contain; gap: 10px; }
.g-title { font-size: 24px; max-width: 100%; }
.g-title::after { display: none; }
.g-intro { margin: -4px 0 2px; font-size: 13.5px; color: var(--ink-3); }
.g-body { width: 100%; display: grid; gap: 10px; }
.g-tile { width: 100%; font: inherit; font-size: 14.5px; line-height: 1.3; text-align: left; padding: 11px 12px; border-radius: 12px; border: 1.5px solid var(--ink); background: #fff; color: var(--ink); cursor: pointer; box-shadow: 2px 2px 0 var(--ink); transition: transform .1s, background .15s, box-shadow .15s; }
.g-tile:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.g-tile.sel { background: var(--m1); box-shadow: 3px 3px 0 var(--ink); }
.g-tile.ok, .g-bin.ok, .g-tf.ok { background: #dcfce7; border-color: #15803d; color: #14532d; box-shadow: 2px 2px 0 #15803d; }
.g-tile.ok:disabled { opacity: .75; cursor: default; }
.g-tile.bad, .g-bin.bad, .g-tf.bad { background: #fee2e2; border-color: #b42318; animation: g-shake .35s; }
@keyframes g-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.g-cols { display: grid; grid-template-columns: 1fr 1.35fr; gap: 8px; }
.g-col { display: grid; gap: 8px; align-content: start; }
.g-tile.l { font-weight: 700; }
.g-tile.r { font-size: 13.5px; }
.g-placed { list-style: none; counter-reset: g; margin: 0; padding: 0; display: grid; gap: 6px; }
.g-placed li { counter-increment: g; display: flex; gap: 8px; align-items: baseline; padding: 8px 10px; border-radius: 10px; background: var(--m3); border: 1.5px solid var(--m2); font-size: 14px; line-height: 1.3; animation: g-in .25s var(--ease); }
.g-placed li::before { content: counter(g); font-family: var(--mono); font-weight: 700; color: var(--ink-3); }
.g-placed li b { font-family: var(--mono); font-size: 12.5px; }
.g-placed li.late { border-style: dashed; }
@keyframes g-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.g-pool { display: grid; gap: 8px; }
.g-chip { min-height: 92px; display: grid; place-items: center; text-align: center; padding: 16px; border-radius: 16px; background: var(--m1); border: 2px solid var(--ink); font-family: var(--serif); font-size: 21px; line-height: 1.2; box-shadow: 4px 4px 0 var(--ink); }
.g-chip.in { animation: g-in .25s var(--ease); }
.g-bins { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.g-bin { display: grid; gap: 4px; justify-items: center; padding: 14px 10px; border-radius: 14px; border: 1.5px solid var(--ink); background: #fff; font: inherit; cursor: pointer; box-shadow: 2px 2px 0 var(--ink); }
.g-bin b { font-size: 15px; } .g-bin span { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.g-timer { height: 6px; border-radius: 3px; background: var(--paper-2); overflow: hidden; }
.g-timer i { display: block; height: 100%; width: 100%; background: var(--m2); transform-origin: left; }
.g-timer.run i { animation: g-time var(--secs, 6s) linear forwards; }
@keyframes g-time { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.g-statement { margin: 4px 0; font-family: var(--serif); font-size: 21px; line-height: 1.3; min-height: 3.9em; }
.g-tfs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.g-tf { padding: 14px; border-radius: 14px; border: 2px solid var(--ink); font: inherit; font-size: 17px; font-weight: 800; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); }
.g-tf.yes { background: #e7f8ee; } .g-tf.no { background: #fdeceb; }
.g-why { margin: 0; min-height: 2.6em; font-size: 14px; line-height: 1.35; color: var(--ink-2); }
.g-why[data-state="right"] { color: #15803d; } .g-why[data-state="wrong"] { color: #b42318; }
.g-sentence { margin: 4px 0; font-family: var(--serif); font-size: 19px; line-height: 1.4; }
.g-blank { display: inline-block; min-width: 3.2em; padding: 0 6px; border-bottom: 3px solid var(--m2); background: var(--m3); border-radius: 4px; text-align: center; font-weight: 700; }
.g-blank.ok { background: #dcfce7; border-color: #15803d; } .g-blank.bad { background: #fee2e2; border-color: #b42318; }
.g-opts { display: grid; gap: 8px; }
.g-dots { display: flex; gap: 6px; justify-content: center; margin-top: 2px; }
.g-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--paper-2); border: 1.5px solid var(--line-2); }
.g-dots i.on { border-color: var(--ink); background: var(--m1); }
.g-dots i.ok { background: #22c55e; border-color: #15803d; } .g-dots i.bad { background: #ef4444; border-color: #b42318; }
.g-result { display: grid; justify-items: center; gap: 6px; text-align: center; padding: 4px 0; }
.g-result .mascot { width: 84px; height: 84px; }
.g-stars { font-size: 34px; color: #f5b301; letter-spacing: 4px; text-shadow: 0 2px 0 rgba(0,0,0,.12); }
.g-stars span { color: var(--paper-2); }
.g-score { margin: 0; font-family: var(--serif); font-size: 30px; font-weight: 700; }
.g-result .muted { margin: 0; font-size: 14px; }
.g-actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; justify-content: center; }
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 10px; }
.game-btn { display: grid; justify-items: start; gap: 2px; padding: 12px; border-radius: 14px; border: 1.5px solid var(--ink); background: #fff; font: inherit; text-align: left; cursor: pointer; box-shadow: 2px 2px 0 var(--hl); color: var(--ink); }
.game-btn:disabled { opacity: .45; cursor: default; box-shadow: none; border-color: var(--line-2); }
.game-btn .game-emoji { font-size: 22px; }
.game-btn b { font-size: 14.5px; } .game-btn small { font-family: var(--mono); font-size: 11px; color: var(--ink-3); }
@media (prefers-reduced-motion: reduce) { .g-tile.bad, .g-bin.bad, .g-tf.bad, .g-placed li, .g-chip.in { animation: none; } }


/* ============================================================================ learning profile */
.learning-card h3 { margin-bottom: 4px; }
.lp-head { margin: 0 0 10px; font-family: var(--serif); font-size: 18px; line-height: 1.3; }
.lp-bars { display: grid; gap: 8px; }
.lp-row { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) 40px; gap: 10px; align-items: center; font-size: 14px; }
.lp-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-name small { color: var(--ink-3); font-size: 11.5px; }
.lp-bar { height: 10px; border-radius: 5px; background: var(--paper-2); overflow: hidden; }
.lp-bar i { display: block; height: 100%; border-radius: 5px; background: var(--line-2); transition: width .5s var(--ease); }
.lp-row.top .lp-bar i { background: var(--hl); box-shadow: inset 0 0 0 1.5px rgba(0,0,0,.15); }
.lp-row.top .lp-name { font-weight: 700; }
.lp-val { font-family: var(--mono); font-size: 12px; color: var(--ink-3); text-align: right; }
.lp-note { margin: 10px 0 8px; }
.lp-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.style-chip[aria-pressed="true"] { background: var(--hl); border-color: var(--ink); }

/* ---- Course profiles (app.js "course profiles"; server/feed/channels.js) ---- */

body.channel-open { overflow: hidden; }
.channel-view { position: fixed; inset: 0; z-index: 60; background: var(--paper); color: var(--ink); display: flex; flex-direction: column; }
.channel-view[hidden] { display: none; }
.ch-top { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px; border-bottom: 1px solid var(--line); background: var(--paper); }
.ch-back, .ch-share-top { border: 0; background: none; width: 40px; height: 40px; border-radius: 50%; font-size: 30px; line-height: 1; color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.ch-share-top svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ch-top-handle { flex: 1; text-align: center; font-family: var(--mono); font-size: 15px; }
.ch-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 0 calc(24px + env(safe-area-inset-bottom, 0px)); }
.ch-loading, .ch-empty { padding: 40px 20px; text-align: center; color: var(--ink-3); }
.ch-head { text-align: center; padding: 22px 16px 14px; max-width: 560px; margin: 0 auto; }
.ch-avatar { width: 88px; height: 88px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 42px; background: var(--accent, var(--hl)); border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); }
.ch-name { font-family: var(--serif); font-size: 24px; line-height: 1.15; margin: 14px 0 2px; }
.ch-handle { margin: 0; font-family: var(--mono); font-size: 14px; color: var(--ink-3); display: flex; justify-content: center; align-items: center; gap: 8px; }
.ch-kicker { margin: 6px 0 0; font-size: 13px; color: var(--ink-2); }
.ch-stats { list-style: none; display: flex; justify-content: center; gap: 26px; margin: 14px 0; padding: 0; font-size: 12.5px; color: var(--ink-3); }
.ch-stats strong { display: block; font-family: var(--serif); font-size: 20px; color: var(--ink); }
.ch-bio { margin: 0 auto 4px; font-size: 14.5px; color: var(--ink-2); max-width: 480px; }
.ch-actions { display: flex; justify-content: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.ch-actions .btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ch-follow-btn { min-width: 132px; }
.ch-syllabus { max-width: 560px; margin: 4px auto 14px; padding: 0 16px; }
.ch-syllabus summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 8px 0; }
.ch-syllabus ol { margin: 0; padding-left: 20px; font-size: 14px; color: var(--ink-2); }
.ch-syllabus li { margin: 6px 0; }
.ch-syllabus li strong { color: var(--ink); display: block; }
.ch-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; max-width: 720px; margin: 0 auto; }
.ch-grid > .ch-empty { grid-column: 1 / -1; }
.ch-tile { position: relative; aspect-ratio: 9 / 16; border: 0; padding: 0; overflow: hidden; background: var(--dark); color: #fff; cursor: pointer; text-align: left; }
.ch-tile img, .ch-tile-blank { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ch-tile-blank { background: linear-gradient(160deg, #2a2a2e, #0d0d0e); }
.ch-tile-meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 6px 6px; display: grid; gap: 2px; background: linear-gradient(transparent, rgba(0, 0, 0, .8)); }
.ch-tile-title { font-size: 11.5px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ch-tile-len { font-family: var(--mono); font-size: 9.5px; opacity: .85; }
.ch-more { display: block; margin: 14px auto 0; }

.xch { margin: 0 0 18px; }
.xch-title { font-family: var(--serif); font-size: 19px; margin: 6px 0 10px; }
.xch-list { display: grid; gap: 8px; }
.ch-card { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: #fff; border: 1.5px solid var(--line-2); border-radius: 14px; cursor: pointer; }
.ch-card:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.ch-card-av { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; background: var(--accent); border: 1.5px solid var(--ink); }
.ch-card-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.ch-card-text strong { font-size: 14.5px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-card-text small { font-family: var(--mono); font-size: 11px; line-height: 1.35; color: var(--ink-3); overflow-wrap: anywhere; }
.ch-card .btn { flex: none; }

.handle-field { display: grid; gap: 6px; margin: 10px 0 14px; }
.handle-row { display: flex; align-items: center; gap: 4px; border: 1.5px solid var(--ink); border-radius: 10px; background: #fff; padding: 0 12px; }
.handle-row span { font-family: var(--mono); font-weight: 600; color: var(--ink-3); }
.handle-input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 12px 0; font-family: var(--mono); font-size: 15px; color: var(--ink); }
.handle-note { font-size: 12.5px; color: var(--ink-3); }
.handle-note[data-ok="true"] { color: var(--ok); }
.handle-note[data-ok="false"] { color: var(--bad); }
.course-handle { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--paper-2); font-size: 13.5px; }
.course-handle p { margin: 0; }
.name-sheet { display: grid; gap: 12px; }
.name-sheet > p { margin: 0; color: var(--ink-2); }

/* A sheet opened from a profile (Change handle) sits above it. */
body.channel-open .sheet { z-index: 70; }
.ch-rename { display: inline-block; margin-top: 12px; border: 0; background: none; padding: 4px 0; font-size: 13.5px; color: var(--ink-2); text-decoration: underline; cursor: pointer; }
.handle-note[data-ok=""] { color: var(--ink-3); }
.similar-note { margin-top: 12px !important; font-weight: 600; }

/* ---- Profile: counts in the header, settings as one list (app.js renderSettingsList) ---- */
.p-counts { display: flex; gap: 18px; margin: 8px 0 4px; }
.p-count { border: 0; background: none; padding: 0; font: inherit; font-size: 13px; color: var(--ink-3); cursor: pointer; display: inline-flex; align-items: baseline; gap: 5px; }
.p-count strong { font-family: var(--serif); font-size: 18px; color: var(--ink); }
.p-count:hover strong, .p-count:focus-visible strong { text-decoration: underline; text-decoration-color: var(--hl); text-decoration-thickness: 3px; }
.settings-list { display: grid; background: #fff; border: 1.5px solid var(--line-2); border-radius: var(--r); overflow: hidden; margin-bottom: 14px; }
.set-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 14px; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; cursor: pointer; color: var(--ink); font: inherit; }
.set-row:first-child { border-top: 0; }
.set-row:active { background: var(--paper-2); }
.set-ic { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; background: var(--paper-2); }
.set-text { flex: 1; min-width: 0; display: grid; gap: 1px; }
.set-text strong { font-size: 15px; }
.set-text small { font-size: 12.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-go { flex: none; font-size: 22px; color: var(--ink-3); }
.card.in-sheet { border: 0; padding: 0; margin: 0; background: none; box-shadow: none; }
.card.in-sheet > h3:first-child { display: none; } /* the sheet title says it */

/* ---- Explore (app.js renderExplore; server/feed/discover.js) ---- */
.x-chips { display: flex; gap: 6px; overflow-x: auto; margin: 10px -16px 0; padding: 0 16px 2px; scrollbar-width: none; }
.x-chips::-webkit-scrollbar { display: none; }
.x-chip { flex: none; border: 1.5px solid var(--line-2); background: #fff; color: var(--ink); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.x-chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.x-suggest { position: absolute; left: 16px; right: 16px; z-index: 20; margin-top: 6px; background: #fff; border: 1.5px solid var(--ink); border-radius: 14px; box-shadow: 4px 4px 0 var(--hl); padding: 6px; max-height: min(60vh, 440px); overflow-y: auto; }
.x-sg-h { margin: 8px 8px 4px; font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.x-sg-row { display: flex; align-items: center; gap: 4px; }
.x-sg-main { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; border: 0; background: none; padding: 9px 8px; border-radius: 10px; text-align: left; font: inherit; font-size: 14.5px; color: var(--ink); cursor: pointer; }
.x-sg-main:hover, .x-sg-main:focus-visible { background: var(--paper-2); }
.x-sg-ic { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--paper-2); font-size: 15px; }
.x-sg-text { display: grid; min-width: 0; }
.x-sg-text span, .x-sg-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x-sg-text small { font-size: 12px; color: var(--ink-3); }
.x-sg-x { flex: none; border: 0; background: none; font-size: 20px; color: var(--ink-3); width: 34px; height: 34px; cursor: pointer; }
.x-sg-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 8px 8px; }
.x-sg-all { font-weight: 600; }
.explore-list > * { min-width: 0; } /* a carousel's content must not widen the page */
.x-sec { margin: 4px 0 18px; min-width: 0; }
.x-h { font-family: var(--serif); font-size: 19px; margin: 6px 0 10px; }
.x-row { display: flex; gap: 10px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 6px; scroll-snap-type: x proximity; scrollbar-width: none; }
.x-row::-webkit-scrollbar { display: none; }
.x-row.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.x-course { flex: none; width: 150px; scroll-snap-align: start; display: grid; justify-items: center; gap: 3px; text-align: center; padding: 14px 10px 12px; background: #fff; border: 1.5px solid var(--line-2); border-radius: 16px; cursor: pointer; }
.x-course-av { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; background: var(--accent); border: 1.5px solid var(--ink); margin-bottom: 4px; }
.x-course strong { font-size: 14px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.x-course small { font-size: 11.5px; color: var(--ink-3); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x-course .x-course-n { font-family: var(--mono); font-size: 10.5px; }
.x-course .x-course-why { color: var(--ink-2); font-weight: 600; }
.x-course .btn { margin-top: 6px; width: 100%; }
.x-pack { flex: none; width: 170px; scroll-snap-align: start; display: grid; gap: 4px; text-align: left; padding: 12px; background: #fff; border: 1.5px solid var(--line-2); border-radius: 14px; cursor: pointer; font: inherit; color: var(--ink); }
.x-pack.added { border-color: #5fb0ff; }
.x-pack-emoji { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 19px; background: var(--accent); border: 1.5px solid var(--ink); }
.x-pack strong { font-size: 14px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.x-pack small { font-size: 11.5px; color: var(--ink-3); }
.x-grid { display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-flow: dense; gap: 3px; margin: 0 -16px; }
.x-tile { position: relative; aspect-ratio: 9 / 16; border: 0; padding: 0; overflow: hidden; background: var(--dark); color: #fff; cursor: pointer; text-align: left; }
.x-tile.big { grid-column: span 2; grid-row: span 2; }
.x-tile img, .x-tile-blank { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.x-tile-blank { display: grid; place-items: center; font-size: 34px; background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--accent) 55%, #000), #0d0d0e 75%); }
.x-tile.big .x-tile-blank { font-size: 64px; }
.x-why { position: absolute; top: 6px; left: 6px; right: 6px; font-size: 10px; font-weight: 600; line-height: 1.2; padding: 3px 6px; border-radius: 6px; background: rgba(13, 13, 14, .62); justify-self: start; max-width: max-content; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x-tile-meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 7px 7px; display: grid; gap: 2px; background: linear-gradient(transparent, rgba(0, 0, 0, .82)); }
.x-tile-title { font-size: 12px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.x-tile.big .x-tile-title { font-size: 16px; }
.x-tile-sub { font-family: var(--mono); font-size: 9.5px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x-more { display: block; margin: 14px auto 0; }
.explore-empty b { display: block; color: var(--ink); font-family: var(--serif); font-size: 20px; margin: 6px 0; }
.explore-empty span { display: block; margin-bottom: 10px; }
.xpack-sheet { display: grid; gap: 8px; }
.xpack-sheet p, .xpack-sheet ol { margin: 0; color: var(--ink-2); }
.xpack-sheet h4 { margin: 6px 0 0; }
.xpack-sheet .xpack-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ch-tile-loc { position: absolute; top: 5px; left: 5px; font-size: 9.5px; font-weight: 600; padding: 2px 6px; border-radius: 6px; background: rgba(13, 13, 14, .65); }
@media (min-width: 720px) { .x-grid { grid-template-columns: repeat(4, 1fr); margin: 0; gap: 6px; } .x-tile { border-radius: 8px; } }

/* The course avatar at the top of a lesson's rail (app.js renderChannelChip). */
.rail-av { position: relative; display: grid; justify-items: center; margin-bottom: 6px; }
.rail-av[hidden] { display: none; }
.av-open { width: 48px; height: 48px; border-radius: 50%; padding: 0; border: 2px solid #fff; background: var(--av, var(--hl)); display: grid; place-items: center; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, .35); }
.av-open:active { transform: scale(.92); }
.av-face { font-size: 24px; line-height: 1; }
.av-plus { position: absolute; bottom: -9px; width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; padding: 0; background: #ff3b5c; color: #fff; font-size: 15px; font-weight: 700; line-height: 1; display: grid; place-items: center; cursor: pointer; }
.av-plus[hidden] { display: none; }
.more-list { margin: 0; }
@media (max-width: 899px) and (max-height: 700px) { .av-open { width: 42px; height: 42px; } .av-face { font-size: 20px; } }

/* Course pictures (app.js face): fill their circle. */
.face-img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.av-open, .ch-avatar, .ch-card-av, .x-course-av, .x-sg-ic { overflow: hidden; }
.av-face { display: grid; place-items: center; width: 100%; height: 100%; }
.ch-owner { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 16px; margin-top: 10px; }
.ch-owner .ch-rename { margin-top: 0; }

/* Daily goal ring in the feed header (app.js renderGoalPill). */
.goal-pill { pointer-events: auto; position: relative; z-index: 13; display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 10px 0 7px; margin-right: 8px; border-radius: 999px; border: 1.5px solid rgba(255, 255, 255, .55); background: rgba(13, 13, 14, .45); color: #fff; font-family: var(--mono); font-size: 12px; font-weight: 700; cursor: pointer; }
.goal-pill[hidden] { display: none; }
.goal-pill svg { width: 20px; height: 20px; transform: rotate(-90deg); }
.gp-track { fill: none; stroke: rgba(255, 255, 255, .25); stroke-width: 3; }
.gp-fill { fill: none; stroke: var(--hl); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; transition: stroke-dashoffset .6s var(--ease); }
.goal-pill.done { border-color: var(--hl); color: var(--hl); }
.feed-head-spacer { align-items: center; }
/* "Up next" near the end of a lesson (app.js showUpNext). */
.up-next { pointer-events: auto; display: flex; align-items: center; gap: 8px; max-width: min(100%, 420px); margin: 0 0 10px; padding: 8px 12px; border-radius: 12px; border: 1.5px solid rgba(255, 255, 255, .7); background: rgba(13, 13, 14, .62); color: #fff; text-align: left; cursor: pointer; animation: upnext-in .35s var(--ease) both; }
.up-next[hidden] { display: none; }
.un-k { flex: none; font-family: var(--mono); font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--hl); }
.un-t { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.un-a { flex: none; font-weight: 700; }
@keyframes upnext-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* Real view counts under the title. */
.proof { margin: 4px 0 0; font-size: 12px; font-weight: 600; text-shadow: 0 1px 4px #000; }
.proof[hidden] { display: none; }
/* Progress after a right answer (app.js showMastery). */
.mastery-pill { display: grid; gap: 5px; margin: 8px 0 0; font-size: 12.5px; color: var(--ink-2); }
.mp-label { font-weight: 600; }
.mp-bar { display: block; height: 7px; border-radius: 99px; background: var(--paper-2); overflow: hidden; }
.mp-bar i { display: block; height: 100%; border-radius: inherit; background: var(--ok); transition: width .9s var(--ease); }
@media (prefers-reduced-motion: reduce) { .up-next { animation: none; } .gp-fill, .mp-bar i { transition: none; } }

/* ---- Ask, comments, exam mode ---- */
.ask .chips { margin: 10px 0; }
.ask-input, .talk-input { width: 100%; box-sizing: border-box; font: inherit; color: var(--ink); background: #fff; border: 1.5px solid var(--line-2); border-radius: 14px; padding: 12px 14px; resize: vertical; }
.ask-actions { display: flex; justify-content: flex-end; margin: 10px 0; }
.ask-out { display: grid; gap: 10px; }
.ask-q { justify-self: end; max-width: 85%; background: var(--hl); color: var(--ink); padding: 10px 14px; border-radius: 16px 16px 4px 16px; font-weight: 600; }
.ask-a { max-width: 92%; background: #fff; border: 1.5px solid var(--line-2); padding: 12px 14px; border-radius: 16px 16px 16px 4px; line-height: 1.45; white-space: pre-wrap; }
.ask-err, .talk-note { color: #b42318; font-size: 13px; margin: 6px 0 0; min-height: 1em; }
.talk-compose { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.talk-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.talk-row { position: relative; background: #fff; border: 1.5px solid var(--line-2); border-radius: 14px; padding: 10px 12px; }
.talk-row p { margin: 4px 0 0; line-height: 1.4; overflow-wrap: anywhere; }
.talk-head { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.talk-act { position: absolute; top: 8px; right: 10px; font: inherit; font-size: 12px; color: var(--ink-2, #666); background: none; border: 0; cursor: pointer; text-decoration: underline; }
.exam-card h3 { margin-bottom: 8px; }
.exam-ready { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.exam-bar { flex: 1; height: 12px; border-radius: 8px; background: var(--line-2); overflow: hidden; }
.exam-bar i { display: block; height: 100%; background: var(--hl); border-right: 2px solid var(--ink); }
.exam-focus { list-style: none; padding: 0; margin: 6px 0 12px; display: grid; gap: 6px; }
.exam-focus li { display: flex; justify-content: space-between; gap: 10px; align-items: center; font-weight: 600; }
.exam-tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; white-space: nowrap; background: #fde2e1; color: #8a1c14; }
.exam-tag.getting-there { background: #fff1c2; color: #6b4e00; }
.exam-tag.ready { background: #d8f5de; color: #14622a; }
.mock-meta { font-size: 13px; color: var(--ink-2, #666); margin: 0 0 6px; }
.mock-q { margin: 0 0 12px; line-height: 1.3; }
.mock-opts { display: grid; gap: 8px; }
.mock-opt { text-align: left; font: inherit; font-weight: 600; padding: 12px 14px; border-radius: 14px; border: 1.5px solid var(--line-2); background: #fff; color: var(--ink); cursor: pointer; }
.mock-opt.ok { background: #d8f5de; border-color: #14622a; }
.mock-opt.bad { background: #fde2e1; border-color: #8a1c14; }
.mock-next { display: grid; gap: 8px; justify-items: start; margin-top: 12px; }
.mock-done { display: grid; gap: 10px; justify-items: center; text-align: center; }
.mock-missed { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; text-align: left; width: 100%; }
.mock-missed li { display: grid; gap: 2px; background: #fff; border: 1.5px solid var(--line-2); border-radius: 12px; padding: 10px 12px; }

/* ---- Comments panel (TikTok-style bottom sheet; the lesson keeps playing above it) ---- */
.tk-root { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.tk-shade { position: absolute; inset: 0; background: rgba(0, 0, 0, 0); transition: background .2s; pointer-events: auto; }
.tk-root.open .tk-shade { background: rgba(0, 0, 0, .25); }
.tk-panel { position: absolute; left: 50%; bottom: 0; width: min(100%, 560px); height: min(72dvh, 680px); transform: translate(-50%, 100%); transition: transform .24s cubic-bezier(.22, .9, .25, 1);
  display: flex; flex-direction: column; background: #fff; color: #161616; border-radius: 16px 16px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .35); pointer-events: auto; overflow: hidden; }
.tk-root.open .tk-panel { transform: translate(-50%, 0); }
.tk-head { position: relative; flex: none; display: grid; place-items: center; padding: 14px 48px 12px; border-bottom: 1px solid #eee; touch-action: none; }
.tk-grab { position: absolute; top: 6px; width: 36px; height: 4px; border-radius: 2px; background: #ddd; }
.tk-count { font-size: 14px; font-weight: 700; }
.tk-close { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; border-radius: 50%; background: none; font-size: 18px; color: #333; cursor: pointer; }
.tk-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 16px 12px; -webkit-overflow-scrolling: touch; }
.tk-thread { padding: 6px 0; }
.tk-row { display: grid; grid-template-columns: 36px 1fr 40px; gap: 10px; align-items: start; padding: 8px 0; }
.tk-row.reply { grid-template-columns: 26px 1fr 40px; padding-left: 46px; }
.tk-av { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 15px; color: #161616; flex: none; }
.tk-row.reply .tk-av { width: 26px; height: 26px; font-size: 12px; }
.tk-av.ai { background: linear-gradient(135deg, #ffd93d, #ff9ecb 55%, #8fc1ff); }
.tk-body { min-width: 0; }
.tk-name { font-size: 13px; color: #8a8a8a; font-weight: 600; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tk-row.ai .tk-name { color: #161616; }
.tk-badge { font-size: 10px; font-weight: 800; letter-spacing: .3px; text-transform: uppercase; padding: 2px 6px; border-radius: 6px; background: #161616; color: #ffd93d; }
.tk-you { font-weight: 500; }
.tk-text { margin: 2px 0 4px; font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; white-space: pre-wrap; }
.tk-row.ai .tk-text { background: #f6f3ff; border-radius: 4px 14px 14px 14px; padding: 8px 10px; }
.tk-meta { display: flex; gap: 14px; font-size: 12px; color: #8a8a8a; align-items: center; }
.tk-link { border: 0; background: none; padding: 0; font: inherit; font-weight: 700; color: #8a8a8a; cursor: pointer; }
.tk-heart { display: grid; justify-items: center; gap: 2px; border: 0; background: none; padding: 4px 0 0; color: #8a8a8a; font-size: 12px; cursor: pointer; }
.tk-heart svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.tk-heart.on { color: #fe2c55; }
.tk-heart.on svg { fill: #fe2c55; stroke: #fe2c55; }
.tk-more { margin: 2px 0 4px 82px; border: 0; background: none; font: inherit; font-size: 12px; font-weight: 700; color: #8a8a8a; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.tk-more::before { content: ''; width: 24px; height: 1px; background: #ccc; }
.tk-typing { display: flex; align-items: center; gap: 3px; color: #8a8a8a; }
.tk-typing i { width: 5px; height: 5px; border-radius: 50%; background: #b9a7ff; animation: tk-dot 1s infinite; }
.tk-typing i:nth-child(2) { animation-delay: .15s; } .tk-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes tk-dot { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
.tk-empty { display: grid; justify-items: center; gap: 6px; text-align: center; color: #8a8a8a; padding: 40px 24px; font-size: 14px; }
.tk-empty b { color: #161616; font-size: 15px; }
.tk-foot { flex: none; border-top: 1px solid #eee; padding: 8px 12px calc(10px + var(--safe-b, 0px)); background: #fff; }
.tk-replying { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: #8a8a8a; padding: 2px 4px 6px; }
.tk-replying button { border: 0; background: none; font-size: 14px; color: #8a8a8a; cursor: pointer; }
.tk-note { margin: 0 4px 6px; font-size: 12px; color: #b42318; min-height: 0; }
.tk-note:empty { display: none; }
.tk-compose { display: flex; gap: 8px; align-items: center; }
.tk-compose .tk-av { width: 32px; height: 32px; font-size: 13px; }
.tk-input { flex: 1; min-width: 0; font: inherit; font-size: 15px; color: #161616; background: #f1f1f2; border: 0; border-radius: 20px; padding: 10px 14px; outline: none; }
.tk-input:focus { box-shadow: 0 0 0 2px #e3e3e6; }
.tk-send { width: 36px; height: 36px; border-radius: 50%; border: 0; display: grid; place-items: center; background: #fe2c55; color: #fff; cursor: pointer; flex: none; }
.tk-send:disabled { background: #e3e3e6; color: #fff; cursor: default; }
.tk-send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.tk-rules { margin: 6px 4px 0; font-size: 11px; color: #a0a0a0; }
