/* Praxis Spelling. Tokens follow the homepage (index.php): maroon + gold,
   navy ink, Outfit for headings, DM Sans for text. */
:root {
  --maroon: #6A0D18;
  --maroon-2: #8a1321;
  --maroon-deep: #3f0d14;
  --grad: linear-gradient(135deg, #8a1321 0%, #6A0D18 55%, #3f0d14 100%);
  --gold: #FFC107;
  --gold-2: #ffcd38;
  --ink: #1a1f35;
  --ink-2: #2d3548;
  --muted: #6b7280;
  --line: #ece7e4;
  --line-2: #ddd5d1;
  --bg: #f7f4f2;
  --card: #ffffff;
  --tint: #f8eef0;
  --tint-2: #f1dde1;
  --ok: #15803d;
  --ok-bg: #ecfdf3;
  --ok-line: #b7ebc9;
  --no: #b42318;
  --no-bg: #fef3f2;
  --no-line: #fbd0cc;
  --mid: #b45309;
  --font-display: 'Outfit', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(26, 31, 53, .05), 0 2px 8px rgba(26, 31, 53, .05);
  --shadow: 0 12px 32px rgba(26, 31, 53, .08);
  --shadow-lg: 0 30px 90px rgba(26, 31, 53, .22);
  --ring: 0 0 0 4px rgba(106, 13, 24, .14);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; color: var(--ink); }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.i { display: inline-block; flex-shrink: 0; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes pulse-dot { 0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .45); } 60% { box-shadow: 0 0 0 7px rgba(22, 163, 74, 0); } }

/* ── Top bar (matches the white site header) ─────────────────────────── */
.bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  height: 68px; padding: 0 clamp(16px, 3vw, 32px);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(26, 31, 53, .04);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--ink); white-space: nowrap; }
.brand img { width: 36px; height: 36px; object-fit: contain; }
.bar-tag {
  font-size: .78rem; font-weight: 700; letter-spacing: .02em;
  color: var(--maroon); background: var(--tint); border: 1px solid var(--tint-2);
  padding: 4px 11px; border-radius: 999px; white-space: nowrap;
}
.bar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.bar-right form { margin: 0; }
.bar-link { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .9rem; text-decoration: none; color: var(--ink-2); }
.bar-link:hover { color: var(--maroon); }
.bar-tabs { display: flex; gap: 4px; margin-left: 18px; }
.bar-tabs a {
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
  padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: .9rem; color: var(--muted);
  transition: background .2s, color .2s;
}
.bar-tabs a:hover { color: var(--ink); background: #f3efed; }
.bar-tabs a.on { color: var(--maroon); background: var(--tint); }
.who { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: .92rem; }
.who-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 700; font-size: .93rem; line-height: 1; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), background .2s, color .2s, border-color .2s;
}
.btn:focus-visible, .icon-btn:focus-visible, .seg-btn:focus-visible, .choice:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .6; cursor: default; transform: none !important; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .84rem; border-radius: 9px; }
.btn-lg { min-height: 52px; padding: 0 24px; font-size: 1rem; border-radius: 12px; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 10px 24px rgba(106, 13, 24, .26); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(106, 13, 24, .34); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #0f1324; transform: translateY(-1px); }
.btn-gold { background: var(--gold); color: var(--ink); box-shadow: 0 8px 20px rgba(255, 193, 7, .28); }
.btn-gold:hover { background: var(--gold-2); transform: translateY(-1px); }
.btn-soft { background: #fff; color: var(--ink); border-color: var(--line-2); }
.btn-soft:hover { border-color: var(--maroon); color: var(--maroon); background: #fffafa; }
.btn-quiet { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-quiet:hover { background: #f3efed; }
.btn-glass { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .28); }
.btn-glass:hover { background: rgba(255, 255, 255, .2); }
.btn-ghost-danger { background: transparent; color: var(--no); border-color: var(--no-line); }
.btn-ghost-danger:hover { background: var(--no-bg); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2); cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}
.icon-btn:hover { border-color: var(--maroon); color: var(--maroon); }
.icon-btn.danger:hover { border-color: var(--no); color: var(--no); background: var(--no-bg); }
.icon-btn.playing, .btn.playing { background: var(--maroon); border-color: var(--maroon); color: #fff; }

/* ── Inputs ──────────────────────────────────────────────────────────── */
.field-label { display: block; font-weight: 700; font-size: .84rem; color: var(--ink-2); margin: 0 0 6px; }
.field-label .opt { font-weight: 500; color: var(--muted); }
.input {
  width: 100%; padding: 11px 14px; border-radius: 10px; border: 1.5px solid var(--line-2);
  background: #fff; font-size: 1rem; transition: border-color .2s, box-shadow .2s;
}
.input:focus { outline: none; border-color: var(--maroon); box-shadow: var(--ring); }
.input::placeholder { color: #a3a3ad; }
textarea.input { resize: vertical; line-height: 1.5; }
.input.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .88rem; }
.input-lg { min-height: 52px; font-size: 1.05rem; }
.input-xl { min-height: 58px; font-size: 1.3rem; font-weight: 700; letter-spacing: .02em; text-align: center; }
.input.is-ok { border-color: var(--ok); background: var(--ok-bg); }
.input.is-no { border-color: var(--no); background: var(--no-bg); }

/* ── Small pieces ────────────────────────────────────────────────────── */
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .76rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--maroon);
}
.eyebrow.light { color: rgba(255, 255, 255, .78); }
.eyebrow.live { color: #15803d; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #c4c4cc; display: inline-block; flex-shrink: 0; }
.dot.on { background: #16a34a; animation: pulse-dot 1.8s infinite; }
.avatar {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--tint); color: var(--maroon); font-weight: 800; font-size: .8rem; flex-shrink: 0; letter-spacing: .02em;
}
.avatar.sm { width: 28px; height: 28px; font-size: .7rem; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; background: #f3efed; color: var(--ink-2); border: 1px solid var(--line);
}
.chip .or, .or { font-weight: 500; color: var(--muted); font-size: .9em; }
.auto { font-weight: 600; opacity: .8; border-bottom: 1px dotted currentColor; cursor: help; }
.chip.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.chip.warn { background: #fff7e6; color: #92400e; border-color: #fde3a7; }
.chip.live { background: #ecfdf3; color: #15803d; border-color: var(--ok-line); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.acc { font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.acc.good { color: var(--ok); background: var(--ok-bg); }
.acc.mid { color: var(--mid); background: #fff7e6; }
.acc.low { color: var(--no); background: var(--no-bg); }
.acc.none { color: var(--muted); background: transparent; font-weight: 500; padding-left: 0; }
.meter { display: block; height: 6px; border-radius: 999px; background: #efe9e7; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--ok); transition: width .6s var(--ease); }
.meter.mid > span { background: #f59e0b; }
.meter.low > span { background: #e5484d; }
.alert {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px;
  font-weight: 600; font-size: .92rem; margin: 0 0 16px; animation: rise .35s var(--ease);
}
.alert-error { background: var(--no-bg); color: var(--no); border: 1px solid var(--no-line); }
.alert-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok-line); }
.empty-inline { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 22px 14px; color: var(--muted); font-size: .92rem; border: 1.5px dashed var(--line-2); border-radius: 12px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: .92rem;
  box-shadow: var(--shadow-lg); animation: rise .3s var(--ease); max-width: calc(100% - 32px);
}
.toast.error { background: var(--no); }

/* Sentence with a blank */
.sentence { font-size: 1.15rem; line-height: 1.75; color: var(--ink); }
.sentence.big { font-size: clamp(1.25rem, 2.2vw, 1.6rem); font-family: var(--font-display); font-weight: 600; line-height: 1.55; }
.sentence.sm { font-size: .98rem; line-height: 1.6; }
.blank {
  display: inline-block; vertical-align: -0.15em; width: 5.2em; height: 1.15em; margin: 0 .2em;
  border-radius: 7px; background: var(--tint); border-bottom: 3px solid var(--maroon);
}
.sentence.sm .blank { width: 3.6em; height: 1em; border-bottom-width: 2px; }
.blank.filled { width: auto; height: auto; padding: 0 .4em; background: var(--ok-bg); border-bottom-color: var(--ok); color: var(--ok); font-weight: 700; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: clamp(18px, 2.4vw, 26px);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head.wrap { flex-wrap: wrap; }
.card-head form { margin: 0; }
.card-title { font-size: 1.3rem; font-weight: 800; margin-top: 2px; }
.card-title.xl { font-size: clamp(1.6rem, 3vw, 2.1rem); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Entry: an exercise-book page with a letter-tile board ──────────── */
.view-student-entry, .view-admin-entry { background: #fbf8f2; }
.desk {
  position: relative; overflow: hidden;
  min-height: calc(100vh - 68px);
  padding: clamp(28px, 5vw, 64px) clamp(16px, 4vw, 40px) 56px clamp(40px, 8vw, 120px);
  background-image: repeating-linear-gradient(to bottom, transparent 0 35px, rgba(56, 89, 160, .09) 35px 36px);
  background-position: 0 18px;
}
/* the margin line of a school exercise book, in Praxis maroon */
.desk::before { content: ''; position: absolute; top: 0; bottom: 0; left: clamp(22px, 5.5vw, 84px); width: 2px; background: rgba(106, 13, 24, .28); box-shadow: 5px 0 0 rgba(106, 13, 24, .1); }
.desk-inner { position: relative; max-width: 1160px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: clamp(28px, 5vw, 64px); align-items: center; }
.desk-copy { animation: rise .5s var(--ease); }
.title { font-size: clamp(2.4rem, 5.4vw, 4.1rem); font-weight: 900; line-height: 1.08; letter-spacing: -.02em; margin: .55em 0 18px; }
/* teacher's insertion mark: a caret under the gap and a handwritten letter above */
.ins { position: relative; display: inline-block; width: .05em; height: .72em; vertical-align: baseline; }
.ins::after {
  content: '^'; position: absolute; left: 50%; top: 100%; margin-top: -.12em;
  font-family: 'Caveat', cursive; font-weight: 700; font-size: .62em; color: #c0262d; line-height: 1;
  opacity: 0; transform: translateX(-50%); animation: ink .35s .5s var(--ease) forwards;
}
.ins-mark {
  position: absolute; left: 50%; bottom: 64%;
  font-family: 'Caveat', cursive; font-weight: 700; font-size: .78em; color: #c0262d; line-height: 1;
  opacity: 0; transform: translateX(-50%) rotate(-6deg); animation: ink .45s .85s var(--ease) forwards;
}
@keyframes ink { from { opacity: 0; transform: translateX(-50%) scale(.6) rotate(-6deg); } to { opacity: 1; transform: translateX(-50%) scale(1) rotate(-6deg); } }
.squiggle {
  color: var(--maroon); padding-bottom: .08em;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 12' preserveAspectRatio='none'%3E%3Cpath d='M2 8 C 20 2, 30 11, 48 6 S 80 3, 96 7 S 112 9, 118 4' fill='none' stroke='%23FFC107' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E") bottom left / 100% .32em no-repeat;
}
.lead { color: var(--ink-2); font-size: clamp(1rem, 1.4vw, 1.12rem); line-height: 1.65; margin-bottom: 26px; max-width: 520px; }
.join-form { margin: 0; }
.join-card { max-width: 520px; padding: 18px; border-radius: 18px; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); }
.join-row { display: flex; gap: 10px; }
.join-row .input { flex: 1; min-width: 0; }
.facts { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: .9rem; font-weight: 600; }
.facts li { display: inline-flex; align-items: center; gap: 7px; }
.facts .i { color: var(--maroon); }
.facts b { color: var(--ink); }
.facts li.is-live { color: #15803d; }

/* Letter-tile board */
.board {
  position: relative; background: #fff; border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 24px 60px rgba(26, 31, 53, .1); padding: clamp(20px, 3vw, 30px);
  rotate: .6deg; animation: rise .6s .1s var(--ease) both;
}
.board::before { content: ''; position: absolute; top: -12px; left: 50%; width: 92px; height: 24px; transform: translateX(-50%) rotate(-2deg); background: rgba(255, 193, 7, .45); border-radius: 3px; }
.board-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.board-count { font-weight: 700; font-size: .85rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.rack { padding: 14px 12px 20px; border-radius: 14px; background: linear-gradient(180deg, #8a1321, #5a0b14); box-shadow: inset 0 -7px 0 rgba(0, 0, 0, .22), 0 10px 22px rgba(106, 13, 24, .25); }
.tiles { container-type: inline-size; display: grid; grid-template-columns: repeat(var(--n, 10), minmax(0, 1fr)); gap: 5px; max-width: calc(var(--n, 10) * 54px); margin: 0 auto; }
.tile {
  position: relative; aspect-ratio: 1; display: grid; place-items: center; border-radius: 14%;
  background: linear-gradient(180deg, #fffaf0, #f3e4c6); color: var(--ink);
  box-shadow: 0 3px 0 #cdb582, 0 5px 10px rgba(0, 0, 0, .2);
  font-family: var(--font-display); font-weight: 800; font-size: min(1.55rem, calc(100cqi / var(--n, 10) * .52)); line-height: 1;
}
.tile sub { position: absolute; right: 9%; bottom: 7%; font-size: .42em; font-weight: 700; opacity: .65; }
@container (max-width: 420px) { .tile sub { display: none; } }
.tile.bad { background: linear-gradient(180deg, #fff1f0, #fbd5d2); color: #b42318; box-shadow: 0 3px 0 #e69a94, 0 5px 10px rgba(0, 0, 0, .2); animation: wobble .5s var(--ease); }
.tile.fix { background: linear-gradient(180deg, #effcf3, #c9efd6); color: #15803d; box-shadow: 0 3px 0 #8fcfa6, 0 5px 10px rgba(0, 0, 0, .2); animation: flip-in .55s var(--ease); }
@keyframes wobble { 0%, 100% { transform: none; } 25% { transform: rotate(-7deg); } 60% { transform: rotate(5deg); } }
@keyframes flip-in { from { transform: rotateX(90deg); } to { transform: none; } }
.board-status { display: inline-flex; align-items: center; gap: 7px; margin: 18px 0 10px; padding: 5px 12px; border-radius: 999px; font-weight: 800; font-size: .82rem; letter-spacing: .02em; }
.board-status.bad { background: var(--no-bg); color: var(--no); }
.board-status.good { background: var(--ok-bg); color: var(--ok); }
.board-status .word { font-weight: 700; opacity: .85; }
.board-tip { min-height: 4.4em; }
.board-tip-label { display: block; font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.board-tip p { font-family: 'Caveat', cursive; font-weight: 700; font-size: clamp(1.35rem, 2vw, 1.6rem); line-height: 1.2; color: var(--maroon); transition: opacity .3s; }
.board-tip p.ask { color: var(--muted); }
.board-dots { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.board-dots button { width: 9px; height: 9px; padding: 0; border: 0; border-radius: 999px; background: #e3dcd8; cursor: pointer; transition: width .3s var(--ease), background .3s; }
.board-dots button[aria-current="true"] { width: 26px; background: var(--maroon); }
.board-dots button:focus-visible { outline: none; box-shadow: var(--ring); }

/* How it works */
.steps { position: relative; list-style: none; max-width: 1160px; margin: clamp(40px, 6vw, 72px) auto 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.step { position: relative; padding: 22px 22px 24px; border-radius: 18px; background: rgba(255, 255, 255, .86); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.step-n { position: absolute; top: 12px; right: 18px; font-family: 'Caveat', cursive; font-size: 1.7rem; font-weight: 700; color: rgba(106, 13, 24, .35); }
.step-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--tint); color: var(--maroon); margin-bottom: 12px; }
.step h2 { font-size: 1.12rem; font-weight: 800; margin-bottom: 6px; }
.step p { color: var(--muted); font-size: .94rem; }

/* ── Student ─────────────────────────────────────────────────────────── */
.view-student { background: radial-gradient(900px 500px at 15% -10%, rgba(106, 13, 24, .07), transparent 60%), radial-gradient(700px 420px at 100% 100%, rgba(255, 193, 7, .08), transparent 60%), var(--bg); background-attachment: fixed; }
.stu-wrap { width: 100%; max-width: 680px; margin: 0 auto; padding: 28px 16px 64px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 5px; border-radius: 14px; background: #ece6e3; margin-bottom: 18px; }
.seg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  border: 0; border-radius: 10px; background: transparent; font-weight: 700; color: var(--muted); cursor: pointer; transition: background .2s, color .2s, box-shadow .2s;
}
.seg-btn[aria-selected="true"] { background: #fff; color: var(--maroon); box-shadow: var(--shadow-sm); }
.live-banner {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px; padding: 12px 14px 12px 16px; border-radius: 14px;
  background: var(--grad); color: #fff; font-weight: 600; box-shadow: 0 12px 28px rgba(106, 13, 24, .25); animation: rise .35s var(--ease);
}
.live-banner .btn { margin-left: auto; }
.state-card { text-align: center; padding: clamp(32px, 6vw, 52px) clamp(20px, 5vw, 44px); animation: rise .4s var(--ease); }
.state-card h2 { font-size: 1.55rem; font-weight: 800; margin-bottom: 8px; }
.state-card p { max-width: 420px; margin: 0 auto 22px; }
.state-icon { width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 16px; background: var(--tint); color: var(--maroon); }
.state-icon.ok { background: var(--ok-bg); color: var(--ok); }
.state-icon.no { background: var(--no-bg); color: var(--no); }
.state-icon.pulse { animation: halo 2.4s infinite; }
@keyframes halo { 0%, 100% { box-shadow: 0 0 0 0 rgba(106, 13, 24, .16); } 60% { box-shadow: 0 0 0 16px rgba(106, 13, 24, 0); } }
.typed { color: var(--ink); background: #f3efed; padding: 1px 8px; border-radius: 6px; }
.waiting-line { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px; background: #f6f2f0; color: var(--muted); font-weight: 600; font-size: .9rem; }
.q-card { animation: rise .4s var(--ease); padding: 0; overflow: hidden; }
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px clamp(18px, 3vw, 26px); border-bottom: 1px solid var(--line); background: #fcfaf9; }
.q-card > .sentence { padding: clamp(22px, 4vw, 32px) clamp(18px, 3vw, 28px) 8px; font-size: clamp(1.15rem, 2.4vw, 1.4rem); font-weight: 500; }
.answer-form { display: grid; gap: 12px; padding: 16px clamp(18px, 3vw, 28px) 4px; margin: 0; }
.form-msg { min-height: 22px; padding: 6px clamp(18px, 3vw, 28px) 20px; font-size: .9rem; font-weight: 600; color: var(--no); }
.form-msg.ok { color: var(--ok); }

/* Practice */
.p-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px clamp(18px, 3vw, 26px) 12px; }
.p-count { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; white-space: nowrap; }
.p-count small { color: var(--muted); font-weight: 600; font-size: .85rem; }
.p-progress { height: 5px; background: #efe9e7; }
.p-progress > span { display: block; height: 100%; background: var(--grad); transition: width .4s var(--ease); }
.p-body { padding: clamp(22px, 4vw, 32px) clamp(18px, 3vw, 28px) clamp(20px, 3vw, 26px); }
.listen {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; margin-bottom: 20px;
  border-radius: 14px; border: 1.5px solid var(--tint-2); background: var(--tint); cursor: pointer; text-align: left;
  transition: border-color .2s, transform .2s var(--ease);
}
.listen:hover { border-color: var(--maroon); transform: translateY(-1px); }
.listen-btn { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--grad); color: #fff; flex-shrink: 0; box-shadow: 0 8px 18px rgba(106, 13, 24, .28); }
.listen.playing .listen-btn { animation: halo 1.4s infinite; }
.listen-text strong { display: block; font-weight: 800; }
.listen-text span { font-size: .85rem; color: var(--muted); }
.listen .speed { margin-left: auto; }
.p-body .sentence { margin-bottom: 20px; }
.p-row { display: flex; gap: 10px; }
.p-row .input { flex: 1; min-width: 0; }
.feedback { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; margin-top: 14px; animation: rise .3s var(--ease); font-weight: 600; }
.feedback.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid var(--ok-line); }
.feedback.no { background: var(--no-bg); color: var(--no); border: 1px solid var(--no-line); }
.feedback .i { margin-top: 2px; }
.feedback b { color: var(--ink); }
.feedback small { display: block; font-weight: 500; color: var(--muted); margin-top: 2px; }
.kbd-hint { margin-top: 12px; font-size: .8rem; color: var(--muted); text-align: center; }
kbd { font-family: inherit; font-size: .75rem; font-weight: 700; padding: 1px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; background: #fff; }
.setup h2 { font-size: 1.6rem; font-weight: 800; margin: 6px 0 6px; }
.setup .muted { margin-bottom: 22px; }
.choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.choice {
  display: grid; gap: 2px; padding: 14px 8px; text-align: center; border-radius: 14px; border: 1.5px solid var(--line-2);
  background: #fff; cursor: pointer; transition: border-color .2s, background .2s, transform .2s var(--ease);
}
.choice strong { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; line-height: 1; }
.choice span { font-size: .75rem; color: var(--muted); font-weight: 600; }
.choice:hover { border-color: var(--maroon); transform: translateY(-1px); }
.choice[aria-pressed="true"] { border-color: var(--maroon); background: var(--tint); color: var(--maroon); box-shadow: 0 0 0 1px var(--maroon) inset; }
.toggle { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: .92rem; cursor: pointer; margin-bottom: 22px; }
.toggle input { width: 18px; height: 18px; accent-color: var(--maroon); }
.setup-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.setup-foot .muted { margin: 0; font-size: .85rem; }

/* Results */
.result-top { display: flex; align-items: center; gap: 22px; margin-bottom: 22px; }
.ring { position: relative; width: 112px; height: 112px; flex-shrink: 0; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 10; }
.ring .track { stroke: #efe9e7; }
.ring .val { stroke: var(--maroon); stroke-linecap: round; transition: stroke-dashoffset 1.1s var(--ease); }
.ring.good .val { stroke: #16a34a; }
.ring.mid .val { stroke: #f59e0b; }
.ring-num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; }
.result-top h2 { font-size: 1.55rem; font-weight: 800; margin-bottom: 4px; }
.review { list-style: none; margin: 0 0 22px; padding: 0; max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
.review li { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: .95rem; }
.review li:last-child { border-bottom: 0; }
.review .n { width: 22px; color: var(--muted); font-size: .8rem; font-weight: 700; }
.review .was { color: var(--no); text-decoration: line-through; }
.review .right { font-weight: 700; }
.review .mark { margin-left: auto; }
.review .mark.ok { color: var(--ok); }
.review .mark.no { color: var(--no); }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Report modal */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgba(26, 31, 53, .6); backdrop-filter: blur(4px); animation: rise .25s var(--ease); }
.modal-card { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; background: #fff; border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
.report-head { display: flex; align-items: center; gap: 14px; padding: 22px 24px; background: var(--grad); color: #fff; position: sticky; top: 0; }
.report-head h2 { color: #fff; font-size: 1.35rem; font-weight: 800; }
.report-award { width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center; background: rgba(255, 255, 255, .14); color: var(--gold); flex-shrink: 0; }
.report-body { padding: 22px 24px 24px; }
.mini-label { font-size: .72rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; }
.fix-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 9px 12px; border-radius: 10px; background: var(--no-bg); border: 1px solid var(--no-line); margin-bottom: 6px; font-size: .93rem; }
.fix-row .was { color: var(--no); text-decoration: line-through; }
.fix-row .should { color: var(--ok); font-weight: 700; }
.fix-row .i.muted { color: var(--muted); }

/* ── Teacher ─────────────────────────────────────────────────────────── */
.band { background: var(--grad); color: #fff; position: relative; overflow: hidden; }
.band::after { content: ''; position: absolute; right: -80px; top: -120px; width: 360px; height: 360px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 193, 7, .16), transparent 65%); pointer-events: none; }
.band-inner { position: relative; z-index: 1; max-width: 1400px; margin: 0 auto; padding: 22px clamp(16px, 3vw, 32px); display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.band-title { color: #fff; font-size: clamp(1.35rem, 2.4vw, 1.8rem); font-weight: 800; margin: 4px 0 4px; }
.band-meta { color: rgba(255, 255, 255, .8); font-size: .92rem; }
.band-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.band-actions form { margin: 0; }
.t-wrap { max-width: 1400px; margin: 0 auto; padding: 24px clamp(16px, 3vw, 32px) 64px; }
.t-wrap.narrow { max-width: 1100px; }
.t-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 22px; align-items: start; }
.t-main { display: grid; gap: 22px; min-width: 0; }
.t-side { display: grid; gap: 16px; min-width: 0; }
.t-side.stick { position: sticky; top: 88px; }
.t-side.stick > .card { max-height: calc(100vh - 108px); overflow: auto; }
#library { scroll-margin-top: 84px; }

.live-card .empty { text-align: center; padding: 18px 10px 10px; }
.live-card .empty h2 { font-size: 1.3rem; font-weight: 800; margin-bottom: 6px; }
.live-card.is-live { border-color: #f3d27a; box-shadow: 0 0 0 1px #f3d27a, 0 16px 40px rgba(180, 130, 0, .1); background: linear-gradient(180deg, #fffdf6, #fff 60%); }
.live-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 16px 0 18px; }
.live-tools .spacer { flex: 1; }
.answer-key { display: inline-flex; align-items: center; gap: 8px; padding: 8px 13px; border-radius: 10px; background: var(--ok-bg); border: 1px solid var(--ok-line); color: var(--ok); font-weight: 800; }
.answer-key .or { color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { padding: 12px 14px; border-radius: 14px; background: #faf8f7; border: 1px solid var(--line); }
.stat strong { display: block; font-family: var(--font-display); font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat span { font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.stat.ok strong { color: var(--ok); }
.stat.no strong { color: var(--no); }
.resp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.resp { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 12px; border: 1px solid; animation: rise .3s var(--ease); min-width: 0; }
.resp.is-ok { background: var(--ok-bg); border-color: var(--ok-line); }
.resp.is-no { background: var(--no-bg); border-color: var(--no-line); }
.resp-text { display: grid; min-width: 0; flex: 1; }
.resp-name { font-weight: 700; font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resp-ans { font-size: .9rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.resp-mark { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.resp.is-ok .resp-mark { background: #16a34a; }
.resp.is-no .resp-mark { background: #e5484d; }

.lib-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.search { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 10px; border: 1.5px solid var(--line-2); background: #fff; color: var(--muted); }
.search:focus-within { border-color: var(--maroon); box-shadow: var(--ring); }
.search input { flex: 1; border: 0; outline: none; min-height: 40px; background: transparent; color: var(--ink); }
.pill-filter { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1.5px solid #fde3a7; background: #fff7e6; color: #92400e; font-weight: 700; font-size: .85rem; cursor: pointer; }
.pill-filter[aria-pressed="true"] { background: #92400e; color: #fff; border-color: #92400e; }
.lib-list { list-style: none; margin: 0; padding: 0; max-height: 72vh; overflow: auto; border-top: 1px solid var(--line); }
.lib-item { display: flex; align-items: center; gap: 16px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.lib-item:last-child { border-bottom: 0; }
.lib-item.is-live { background: linear-gradient(90deg, #fffbea, transparent); border-radius: 12px; padding-left: 12px; }
.lib-item.is-broken .sentence { color: var(--muted); }
.lib-text { flex: 1; min-width: 0; }
.lib-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.lib-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.lib-actions form { margin: 0; }

.score-list { display: grid; gap: 8px; }
.score-row { border: 1px solid var(--line); border-radius: 14px; background: #fff; transition: border-color .2s, box-shadow .2s; }
.score-row[open] { border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.score-row summary { display: flex; align-items: center; gap: 11px; padding: 10px 12px; cursor: pointer; list-style: none; }
.score-row summary::-webkit-details-marker { display: none; }
.score-who { flex: 1; min-width: 0; display: grid; gap: 5px; }
.score-name { font-weight: 700; font-size: .93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.id-tag { font-size: .72rem; font-weight: 700; color: var(--muted); }
.score-num { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; }
.score-num small { font-size: .8rem; color: var(--muted); font-weight: 600; }
.chev { color: var(--muted); transition: transform .2s; }
.score-row[open] .chev { transform: rotate(180deg); }
.score-body { padding: 2px 14px 14px; border-top: 1px solid var(--line); }
.score-body .mini-label:first-child { margin-top: 12px; }
.row-actions { display: flex; gap: 8px; margin-top: 14px; }
.row-actions form { margin: 0; }

/* History */
.page-head { margin: 8px 0 22px; }
.page-head .muted { margin-top: 6px; max-width: 620px; }
.session-list { display: grid; gap: 10px; }
.session-item { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 16px; background: #fff; border: 1px solid var(--line); text-decoration: none; box-shadow: var(--shadow-sm); transition: border-color .2s, transform .2s var(--ease), box-shadow .2s; }
.session-item:hover { border-color: var(--maroon); transform: translateY(-1px); box-shadow: var(--shadow); }
.session-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--tint); color: var(--maroon); flex-shrink: 0; }
.session-icon.live { background: var(--ok-bg); color: var(--ok); }
.session-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.session-title { font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chev-r { transform: rotate(-90deg); color: var(--muted); }
.tools-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 28px; padding: 14px 18px; border-radius: 14px; border: 1.5px dashed var(--line-2); }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .9rem; text-decoration: none; color: var(--muted); margin-bottom: 14px; }
.back-link:hover { color: var(--maroon); }
.session-hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; position: relative; overflow: hidden; }
.session-hero::before { content: ''; position: absolute; left: 0; top: 24px; bottom: 24px; width: 6px; background: var(--maroon); border-radius: 0 6px 6px 0; }
.mini-stats { display: flex; gap: 10px; }
.mini-stats div { min-width: 92px; padding: 10px 14px; border-radius: 12px; background: #faf8f7; border: 1px solid var(--line); }
.mini-stats strong { display: block; font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; color: var(--maroon); line-height: 1.1; }
.mini-stats span { font-size: .7rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.word-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.word-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; }
.word-list .word { font-weight: 700; }
.word-list .meter { grid-column: 1 / -1; grid-row: 2; }
.word-pct { font-weight: 800; font-size: .9rem; }
.word-pct small { color: var(--muted); font-weight: 500; }
.danger-zone { margin: 0; display: flex; justify-content: flex-end; }

/* Dialogs */
.dlg { width: min(560px, calc(100% - 32px)); padding: 0; border: 0; border-radius: var(--r-lg); box-shadow: var(--shadow-lg); color: var(--ink); }
.dlg::backdrop { background: rgba(26, 31, 53, .55); backdrop-filter: blur(3px); }
.dlg[open] { animation: rise .3s var(--ease); }
.dlg-body { display: grid; gap: 14px; padding: 22px 24px 20px; margin: 0; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dlg-head h2 { font-size: 1.3rem; font-weight: 800; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.preview { min-height: 1.6em; padding: 12px 14px; border-radius: 12px; background: #faf8f7; border: 1px solid var(--line); font-size: .98rem; }
.preview:empty { display: none; }
.preview.bad { color: var(--no); background: var(--no-bg); border-color: var(--no-line); font-weight: 600; font-size: .9rem; }
code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85em; background: #f3efed; padding: 1px 6px; border-radius: 5px; color: var(--ink); }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 1080px) {
  .desk-inner { grid-template-columns: 1fr; }
  .board { max-width: 620px; }
  .t-grid { grid-template-columns: 1fr; }
  .t-side.stick { position: static; }
  .t-side.stick > .card { max-height: none; }
}
@media (max-width: 760px) {
  .bar { height: 60px; gap: 10px; }
  .brand span { display: none; }
  .bar-tabs { margin-left: 0; }
  .bar-tabs a { padding: 8px 10px; font-size: .84rem; }
  .hide-sm { display: none; }
  .who-name { max-width: 110px; }
  .lib-item { flex-direction: column; align-items: stretch; gap: 10px; }
  .lib-actions { justify-content: flex-end; }
  .lib-list { max-height: none; overflow: visible; }
  .steps { grid-template-columns: 1fr; gap: 12px; }
  .card-head.wrap .head-actions { width: 100%; }
  .card-head.wrap .head-actions .btn { flex: 1; }
  .live-card .empty { padding: 4px 0 0; }
  .live-tools .spacer { display: none; }
  .mini-stats { width: 100%; }
  .mini-stats div { flex: 1; min-width: 0; }
}
@media (max-width: 560px) {
  .join-row { flex-direction: column; }
  .desk { padding-left: 34px; padding-right: 14px; }
  .desk::before { left: 18px; }
  .join-card { padding: 14px; }
  .board { rotate: none; }
  .rack { padding: 10px 8px 15px; }
  .tiles { gap: 3px; }
  .facts { flex-direction: column; gap: 6px; }
  .bar-tag { display: none; }
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .p-row { flex-direction: column; }
  .p-top { padding-left: 16px; padding-right: 14px; gap: 8px; }
  .p-top .chip { padding: 3px 8px; }
  .result-top { flex-direction: column; text-align: center; gap: 14px; }
  .field-grid { grid-template-columns: 1fr; }
  .stats .stat strong { font-size: 1.45rem; }
  .band-actions { width: 100%; }
  .band-actions .btn, .band-actions form { flex: 1; }
  .band-actions form .btn { width: 100%; }
  .live-banner { display: grid; grid-template-columns: auto 1fr; row-gap: 10px; }
  .live-banner .btn { grid-column: 1 / -1; margin-left: 0; }
}
@media (pointer: coarse) {
  .kbd-hint, .setup-foot .muted { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
