/* Yomu — washi paper, ink, and a vermilion seal */
:root {
  --paper: #F6F1E7;
  --card: #FFFDF8;
  --sunk: #EFE8DA;
  --line: #E3D9C6;
  --line-strong: #CFC3AD;
  --ink: #1E1A16;
  --muted: #6A6155;
  --faint: #B5AA97;
  --accent: #B8432A;
  --accent-ink: #FFFDF8;
  --accent-soft: #F4DDD3;
  --accent-deep: #8E2F1C;
  --indigo: #2E4A6B;
  --indigo-ink: #FFFDF8;
  --radius: 18px;
  --display: 'Shippori Mincho B1', 'Hiragino Mincho ProN', serif;
  --body: 'Zen Kaku Gothic New', 'Hiragino Sans', system-ui, sans-serif;
  --jp: 'Klee One', 'Hiragino Maru Gothic ProN', serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1A1714;
    --card: #24201C;
    --sunk: #1F1B18;
    --line: #3A332C;
    --line-strong: #4D443A;
    --ink: #F1EADF;
    --muted: #B3A897;
    --faint: #6E6558;
    --accent: #E0694D;
    --accent-ink: #1A1714;
    --accent-soft: #4A2A20;
    --accent-deep: #F3A38F;
    --indigo: #8FB0D6;
    --indigo-ink: #1A1714;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
}
a { color: inherit; }
a:hover { color: var(--accent); }
button { font-family: inherit; cursor: pointer; color: inherit; }
code { font-size: 0.9em; background: var(--sunk); padding: 1px 5px; border-radius: 5px; }
.jp { font-family: var(--jp); font-weight: 600; }
.display { font-family: var(--display); font-weight: 700; margin: 0; line-height: 1.2; }
h1.display { font-size: clamp(28px, 4vw, 42px); }
h2.display { font-size: clamp(22px, 3vw, 30px); }
.h3 { font-size: 18px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; justify-content: center; }
.eyebrow { font-size: 12.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.eyebrow.accent, .accent-text { color: var(--accent); }
.accent-text { font-weight: 700; }
p { margin: 0; }

/* ---- Chrome ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px clamp(16px, 5vw, 64px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.seal {
  width: 42px; height: 42px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-size: 25px; font-weight: 700;
}
.brand-name { font-family: var(--display); font-size: 25px; font-weight: 700; }
.nav { display: flex; gap: clamp(14px, 2.5vw, 30px); font-size: 15px; font-weight: 500; flex-wrap: wrap; }
.nav a { text-decoration: none; padding: 6px 0; border-bottom: 2px solid transparent; }
.nav a.active { color: var(--accent); border-bottom-color: var(--accent); }
.badge {
  display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; text-align: center; line-height: 20px;
}
.streak { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.page { padding: clamp(20px, 4vw, 40px) clamp(16px, 5vw, 64px) 56px; max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 36px; }
.footer { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; padding: 24px 16px 40px; font-size: 13px; color: var(--muted); }

/* ---- Building blocks ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card.pad { padding: 24px 28px; display: flex; flex-direction: column; gap: 10px; }
.card.dashed { background: var(--sunk); border-style: dashed; border-color: var(--line-strong); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 24px; min-height: 48px; border-radius: 999px; font-size: 16px; font-weight: 700;
  text-decoration: none; border: 1.5px solid transparent; background: none;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-deep); color: var(--accent-ink); }
.btn.outline { border-color: var(--ink); font-weight: 500; }
.btn.outline:hover { border-color: var(--accent); }
.btn.small { padding: 8px 16px; min-height: 40px; font-size: 14px; }
.btn.wide { width: 100%; }
.icon-btn {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card); text-decoration: none; flex-shrink: 0;
}
.actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.bar { height: 8px; background: var(--sunk); border-radius: 999px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.bar.thin { height: 6px; }
.bar.indigo > div { background: var(--indigo); }
.notice { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-radius: 12px; background: var(--sunk); border: 1px dashed var(--line-strong); color: var(--muted); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.page-head > div { display: flex; flex-direction: column; gap: 6px; max-width: 720px; }
.set-label { font-family: var(--display); font-size: 20px; margin: 8px 0 -18px; }
input[type=password], input[type=file], textarea {
  font: inherit; color: inherit; background: var(--paper); border: 1px solid var(--line-strong); border-radius: 12px; padding: 12px 14px; width: 100%;
}
textarea { font-family: ui-monospace, monospace; font-size: 13px; }

/* ---- Home ---- */
.today-row { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
.today { padding: 34px 38px; display: flex; flex-direction: column; gap: 12px; }
.today .actions { margin-top: 8px; }
.stat { padding: 34px 30px; display: flex; flex-direction: column; gap: 12px; }
.big-num span { font-family: var(--display); font-size: 56px; font-weight: 700; line-height: 1; }
.big-num small { font-size: 18px; color: var(--muted); }
.set { display: flex; flex-direction: column; gap: 18px; }
.set-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.group-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.group-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 17px 19px;
  display: flex; flex-direction: column; gap: 10px; text-decoration: none; min-width: 0;
}
.group-card:hover { color: inherit; border-color: var(--line-strong); }
.group-card.now { border: 2px solid var(--accent); padding: 16px 18px; }
.group-card.locked { background: var(--sunk); border: 1px dashed var(--line-strong); }
.group-card.locked .gc-chars { color: var(--faint); }
.gc-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 2px 6px; font-size: 13px; color: var(--muted); font-weight: 700; }
.gc-top .ok { display: inline-flex; align-items: center; gap: 4px; color: var(--indigo); }
.gc-chars { font-size: 32px; letter-spacing: 0.06em; line-height: 1.25; overflow-wrap: anywhere; }
.gc-chars.long { font-size: 20px; letter-spacing: 0; line-height: 1.6; word-spacing: 0.2em; }
.gc-note { font-size: 12px; color: var(--muted); }
.locked-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.set-locked { display: flex; gap: 26px; align-items: center; padding: 26px 30px; }
.set-locked .preview { font-size: 42px; color: var(--faint); white-space: nowrap; }
.set-locked > div:last-child { display: flex; flex-direction: column; gap: 4px; }

/* ---- Lesson ---- */
.lesson-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; }
.lesson-head > div:first-child { display: flex; flex-direction: column; gap: 4px; }
.tabs { display: flex; gap: 10px; flex-wrap: wrap; }
.tab {
  min-width: 62px; height: 62px; padding: 0 10px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); font-size: 30px; line-height: 1;
}
.tab.wide { font-size: 24px; }
.tab.on { border: 2px solid var(--accent); color: var(--accent); }
.lesson { display: grid; grid-template-columns: 5fr 7fr; gap: 28px; align-items: start; }
.char-card { padding: 30px; display: flex; flex-direction: column; align-items: center; gap: 20px; }
.char-box {
  position: relative; width: min(100%, 340px); aspect-ratio: 1; border: 1.5px solid var(--line-strong); border-radius: 6px;
  display: flex; align-items: center; justify-content: center; gap: 0;
  background:
    linear-gradient(var(--line), var(--line)) center / 100% 1.5px no-repeat,
    linear-gradient(var(--line), var(--line)) center / 1.5px 100% no-repeat;
}
.char-box svg { width: 88%; height: 88%; overflow: visible; }
.char-box.multi svg { width: 50%; height: 50%; }
.char-box path { fill: none; stroke: var(--ink); stroke-width: 3.6; stroke-linecap: round; stroke-linejoin: round; }
.char-box path.ghost { stroke: var(--line); }
.char-box text { fill: var(--accent); font-size: 7.5px; font-family: var(--body); font-weight: 700; }
.char-box .font-fallback { font-family: var(--jp); font-size: 220px; line-height: 1; }
.char-info { display: flex; flex-direction: column; gap: 18px; }
.char-title { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.huge { font-size: clamp(44px, 6vw, 64px); line-height: 1; }
.mnemonic { font-size: 19px; line-height: 1.6; }
.example { flex-direction: row !important; align-items: center; gap: 22px !important; }
.example > div { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; }
.ex-word { font-size: 44px; line-height: 1.2; }
.ex-word ruby rt { font-size: 14px; color: var(--muted); }
.ex-mean { font-size: 18px; }
.pager { display: flex; justify-content: space-between; font-size: 15px; }
.pager a { text-decoration: none; color: var(--muted); }

/* ---- Quiz ---- */
.quiz { max-width: 560px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.quiz-top { display: flex; align-items: center; justify-content: space-between; }
.quiz-title { font-weight: 700; }
.quiz-count { min-width: 44px; text-align: right; font-size: 14px; }
.quiz-card { min-height: 330px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 26px; position: relative; }
.q-show { font-size: 150px; line-height: 1.05; font-weight: 400; text-align: center; }
.q-show.long { font-size: 104px; }
.q-show.text { font-family: var(--display); font-weight: 700; font-size: 48px; }
.q-say { position: absolute; top: 16px; right: 16px; }
.q-feedback { font-weight: 700; text-align: center; min-height: 1.5em; max-width: 440px; }
.q-feedback .hint { display: block; font-weight: 400; color: var(--muted); margin-top: 4px; font-size: 15px; }
.q-feedback.right { color: var(--indigo); }
.q-feedback.wrong { color: var(--accent); }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.choice {
  min-height: 66px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--card);
  font-size: 22px; font-weight: 700; padding: 8px;
}
.choice.big { font-family: var(--jp); font-weight: 600; font-size: 40px; }
.choice:hover:not(:disabled) { border-color: var(--line-strong); }
.choice.correct { background: var(--indigo); border-color: var(--indigo); color: var(--indigo-ink); }
.choice.wrong { border: 2px solid var(--accent); color: var(--accent); }
.choice:disabled { cursor: default; }
.quiz-end { align-items: flex-start; }

/* ---- Stories ---- */
.story-sets { display: flex; flex-direction: column; gap: 10px; }
.story-sets .set-label { margin: 20px 0 4px; }
.story-set { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 22px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.story-set.locked { background: var(--sunk); border-style: dashed; }
.story-set .muted svg { vertical-align: -2px; }
.ss-title { font-weight: 700; }
.story-list { list-style: none; margin: 0 0 8px; padding: 6px 22px; display: flex; flex-direction: column; gap: 8px; }
.story-list li { display: flex; gap: 12px; align-items: baseline; }
.reader { display: grid; grid-template-columns: 8fr 4fr; gap: 28px; align-items: start; }
.story { padding: 36px clamp(22px, 4vw, 52px); display: flex; flex-direction: column; gap: 20px; }
.story-top { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.story-body { display: flex; flex-direction: column; gap: 12px; font-size: clamp(28px, 3.6vw, 40px); line-height: 1.7; }
.line { margin: 0; }
.word {
  font: inherit; line-height: inherit; background: none; border: none; padding: 0 1px; margin: 0; border-radius: 8px; color: inherit;
}
.story.spaced .word { margin-right: 0.45em; }
.story.spaced .punct { margin-left: -0.45em; margin-right: 0.3em; }
.word:hover { background: var(--sunk); }
.word.sel { background: var(--accent-soft); color: var(--accent-deep); }
.word ruby rt { font-size: 0.38em; color: var(--muted); font-family: var(--body); font-weight: 500; }
.punct { color: var(--muted); }
.reader-side { display: flex; flex-direction: column; gap: 20px; }
.gloss-word { font-size: 52px; line-height: 1.2; }
.gloss-kana { font-size: 22px; }
.gloss-mean { font-size: 19px; }
.gloss .btn { align-self: flex-start; }
.check { display: flex; flex-direction: column; gap: 10px; }
.check + .check { margin-top: 14px; }
.check-q { font-size: 17px; font-weight: 500; }
.check-opts { display: flex; gap: 8px; flex-wrap: wrap; }
.opt { flex: 1 1 auto; min-height: 46px; padding: 8px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); font-size: 15px; font-weight: 700; }
.opt.correct { background: var(--indigo); border-color: var(--indigo); color: var(--indigo-ink); }
.opt.wrong { border: 2px solid var(--accent); color: var(--accent); }

/* ---- Import ---- */
.import-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.import-grid .span2 { grid-column: span 2; }
.import-grid .btn { align-self: flex-start; }
.results { gap: 6px !important; }
.result { display: flex; gap: 12px; padding: 8px 12px; border-radius: 10px; font-size: 14px; flex-wrap: wrap; }
.result.ok { background: color-mix(in srgb, var(--indigo) 12%, transparent); }
.result.bad { background: var(--accent-soft); }

/* ---- Login ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 360px; gap: 14px !important; }
.login .brand { margin-bottom: 8px; }
.error { color: var(--accent); font-weight: 700; }

/* ---- Print sheets ---- */
.print-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.print-item { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; }
.print-item .jp { font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.print-item.locked { background: var(--sunk); border-style: dashed; }
.sheet-wrap { overflow-x: auto; padding-bottom: 8px; }
.print-bar { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.sheet {
  width: 210mm; min-height: 297mm; margin: 0 auto; padding: 14mm 14mm 10mm;
  background: #fff; color: #1E1A16; box-shadow: 0 2px 20px rgba(0,0,0,.12);
  display: flex; flex-direction: column; gap: 5mm; font-family: var(--body);
}
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #1E1A16; padding-bottom: 4mm; gap: 8mm; }
.sheet-eyebrow { font-size: 9pt; letter-spacing: 0.14em; text-transform: uppercase; font-weight: 700; color: #B8432A; }
.sheet-title { font-family: var(--display); font-size: 21pt; margin: 1mm 0 0; line-height: 1.2; }
.sheet-fields { display: flex; flex-direction: column; gap: 3mm; font-size: 10pt; padding-top: 1mm; }
.sheet-fields div { display: flex; gap: 2mm; align-items: flex-end; }
.sheet-fields span { width: 38mm; border-bottom: 1px solid #1E1A16; }
.sheet-intro { font-size: 10pt; color: #555048; }
.sheet-h2 { font-family: var(--display); font-size: 14pt; margin: 2mm 0 0; border-bottom: 1px solid #CFC6B6; padding-bottom: 1.5mm; }
.prows { display: flex; flex-direction: column; gap: 3mm; }
.prow { display: flex; align-items: center; gap: 3mm; break-inside: avoid; }
.plabel { width: 20mm; flex-shrink: 0; display: flex; flex-direction: column; line-height: 1.2; }
.pl-main { font-family: var(--display); font-weight: 700; font-size: 12pt; overflow-wrap: anywhere; }
.pl-sub { font-size: 8pt; color: #555048; }
.cells { display: grid; grid-template-columns: repeat(10, 15mm); gap: 0.9mm; }
.cell {
  position: relative; width: 15mm; height: 15mm; border: 1px solid #8A8173;
  display: flex; align-items: center; justify-content: center;
}
.cell::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dashed #D4CCBE; }
.cell::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; border-left: 1px dashed #D4CCBE; }
.cell > * { position: relative; z-index: 1; }
.cell .glyph { width: 88%; height: 88%; overflow: visible; }
.glyph-font { font-family: var(--jp); font-size: 11mm; line-height: 1; }
.glyph-font.trace1 { color: #9E9589; }
.glyph-font.trace2 { color: #C9C1B4; }
.answers { font-size: 9pt; color: #555048; border-top: 1px dashed #CFC6B6; padding-top: 3mm; }
.answers .jp { font-size: 11pt; }
.sheet-foot { margin-top: auto; display: flex; justify-content: space-between; font-size: 8pt; color: #555048; border-top: 1px solid #CFC6B6; padding-top: 2mm; }

@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; }
  .no-print, .topbar, .footer, .print-bar { display: none !important; }
  .page { padding: 0; max-width: none; gap: 0; }
  .sheet-wrap { overflow: visible; padding: 0; }
  .sheet { box-shadow: none; margin: 0; width: 210mm; height: 297mm; min-height: 0; overflow: hidden; }
}


/* ---- Audio-first controls ---- */
.say-big {
  width: 56px; height: 56px; border-radius: 999px; border: none; background: var(--accent); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; align-self: center;
}
.say-big:hover { background: var(--accent-deep); }
.say-huge {
  width: 150px; height: 150px; border-radius: 999px; border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
}
.say-huge:hover { background: var(--accent); color: var(--accent-ink); }
.pic { color: var(--muted); font-size: 15px; }
.pic summary { cursor: pointer; font-weight: 500; }
.pic p { margin-top: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.h2 { font-family: var(--display); font-size: 22px; margin: 0; }

/* ---- Segmented control ---- */
.seg { display: inline-flex; background: var(--sunk); border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 4px; }
.seg-btn { border: none; background: none; padding: 9px 16px; border-radius: 999px; font-size: 14px; font-weight: 700; color: var(--muted); text-decoration: none; min-height: 40px; display: inline-flex; align-items: center; }
.seg-btn.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ---- Tracing ---- */
.trace-wrap { width: min(100%, 340px); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.trace-box { width: 100%; aspect-ratio: 1; border: 1.5px solid var(--line-strong); border-radius: 6px; background: var(--card); touch-action: none; }
.trace-box.big { width: min(100%, 420px); }
.trace-canvas { display: block; touch-action: none; cursor: crosshair; border-radius: 6px; }
.trace-msg { min-height: 1.6em; text-align: center; font-weight: 500; color: var(--muted); }
.trace-page { max-width: 980px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.trace-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.trace-card { padding: 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.trace-side { display: flex; flex-direction: column; gap: 16px; }
.reps { display: flex; gap: 8px; }
.rep { width: 36px; height: 8px; border-radius: 999px; background: var(--sunk); border: 1px solid var(--line); }
.rep.now { background: var(--accent-soft); border-color: var(--accent); }
.rep.done { background: var(--indigo); border-color: var(--indigo); }
.small-mn { font-size: 16px; }

/* ---- Sorting game ---- */
.sort-options { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.sort-options label { display: inline-flex; gap: 8px; align-items: center; font-size: 15px; }
.sort-options select { font: inherit; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--card); color: inherit; min-height: 42px; }
.sort-game { display: flex; flex-direction: column; gap: 18px; }
.sort-status { display: flex; gap: 18px; color: var(--muted); font-size: 14px; }
.bins { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.bin {
  min-height: 120px; border-radius: 16px; border: 2px dashed var(--line-strong); background: var(--sunk);
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; text-align: left;
}
.bins.armed .bin { border-color: var(--accent); background: var(--card); }
.bin.ok { background: color-mix(in srgb, var(--indigo) 15%, var(--card)) !important; border-color: var(--indigo) !important; }
.bin.no { background: var(--accent-soft) !important; }
.bin-label { font-weight: 700; font-size: 15px; }
.bin-items { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 24px; line-height: 1.2; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 10px; }
.sort-card {
  height: 78px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); font-size: 34px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.sort-card.sound { font-size: 16px; font-weight: 700; color: var(--muted); }
.sort-card.sel { border: 2px solid var(--accent); color: var(--accent); background: var(--accent-soft); }
.sort-card.placed { visibility: hidden; }
.sort-card.shake { animation: shake .4s; }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { .sort-card.shake { animation: none; } }

/* ---- Sound chart ---- */
.charts { display: flex; flex-direction: column; gap: 28px; }
.chart { border-collapse: separate; border-spacing: 6px; width: 100%; max-width: 640px; }
.chart caption { text-align: left; font-family: var(--display); font-weight: 700; font-size: 18px; padding: 0 6px 4px; }
.chart th { font-size: 13px; color: var(--muted); }
.chart td.empty { background: none; }
.row-play, .col-play { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 6px 10px; font-size: 13px; font-weight: 700; color: var(--muted); min-height: 36px; width: 100%; }
.row-play:hover, .col-play:hover { color: var(--accent); border-color: var(--accent); }
.cc {
  width: 100%; min-height: 70px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 6px 2px;
}
.cc .jp { font-size: 28px; line-height: 1.1; }
.cc-ro { font-size: 12px; color: var(--muted); }
.cc.known { border-color: var(--indigo); }
.cc.later { background: var(--sunk); border-style: dashed; }
.cc.later .jp { color: var(--faint); }
.cc:hover { border-color: var(--accent); }
.legend { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lg { display: inline-block; width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--line); background: var(--card); margin-left: 8px; }
.lg.known { border-color: var(--indigo); border-width: 2px; }
.lg.later { background: var(--sunk); border-style: dashed; }

/* ---- Practice hub ---- */
.drill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.drill { text-decoration: none; }
.drill:hover { border-color: var(--accent); color: inherit; }

@media (max-width: 800px) {
  .trace-layout { grid-template-columns: 1fr; }
  .say-huge { width: 120px; height: 120px; }
}


/* ---- Welcome / accounts ---- */
.welcome-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.welcome { width: 100%; max-width: 1080px; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 48px; align-items: center; }
.welcome-intro { display: flex; flex-direction: column; gap: 18px; }
.welcome-title { font-size: clamp(30px, 4.4vw, 46px); line-height: 1.15; }
.welcome-lead { font-size: 18px; color: var(--muted); }
.welcome-points { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.welcome-points li { padding-left: 18px; position: relative; }
.welcome-points li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 7px; height: 7px; border-radius: 2px; background: var(--accent); }
.welcome-form { gap: 14px !important; padding: 30px !important; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 15px; }
.form label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; }
.form label.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); flex-shrink: 0; }
input[type=text], input[type=email] {
  font: inherit; color: inherit; background: var(--paper); border: 1px solid var(--line-strong); border-radius: 12px; padding: 12px 14px; width: 100%;
}
.rule { border: none; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.human-status.done { color: var(--indigo); }
.prose { display: flex; flex-direction: column; gap: 10px; }
.ok-notice { background: color-mix(in srgb, var(--indigo) 10%, var(--card)); border-style: solid; border-color: var(--indigo); color: var(--ink); }
.error-notice { background: var(--accent-soft); border-style: solid; border-color: var(--accent); color: var(--ink); }
.danger { border-color: var(--accent-soft); }
.table-wrap { overflow-x: auto; padding: 6px; }
.people { width: 100%; border-collapse: collapse; font-size: 15px; }
.people th { text-align: left; font-size: 12.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.people td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.people tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.row-actions form { margin: 0; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--sunk); color: var(--muted); margin-left: 6px; }
.inline-fields { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-fields label { flex: 1 1 200px; }
@media (max-width: 860px) {
  .welcome { grid-template-columns: 1fr; gap: 28px; }
  .welcome-page { align-items: flex-start; }
}

/* ---- Small screens ---- */
@media (max-width: 1000px) {
  .group-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lesson, .reader { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .streak { display: none; }
  .nav { order: 3; width: 100%; justify-content: space-between; gap: 8px; font-size: 14px; }
  .today-row, .locked-row, .import-grid { grid-template-columns: 1fr; }
  .import-grid .span2 { grid-column: auto; }
  .group-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .gc-chars { font-size: 24px; letter-spacing: 0.02em; }
  .gc-chars.long { font-size: 17px; }
  .group-card, .group-card.now { padding: 14px; }
  .today, .stat { padding: 24px; }
  .set-locked { flex-direction: column; align-items: flex-start; gap: 10px; }
  .q-show { font-size: 120px; }
  .quiz-card { min-height: 280px; }
}
