:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --surface-2: #efe8da;
  --ink: #1f1b16;
  --muted: #6f665a;
  --line: #e2d8c6;
  --accent: #c8402a;
  --accent-soft: #f6dcd3;
  --on-accent: #fffaf2;
  --again: #c8402a;
  --hard: #a86a12;
  --good: #2f7d4f;
  --easy: #2a6aa8;
  --mark: #f5ddb3;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 8px 24px rgba(60, 40, 20, .07);
  --serif: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --sans: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16130f; --surface: #211d18; --surface-2: #2a251f; --ink: #efe8dc; --muted: #a49a8b;
    --line: #3a332a; --accent: #e3654c; --accent-soft: #3d221b; --on-accent: #1a0f0b;
    --again: #e3654c; --hard: #d79a3e; --good: #5fb07f; --easy: #6aa3dc; --mark: #5a4220;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16130f; --surface: #211d18; --surface-2: #2a251f; --ink: #efe8dc; --muted: #a49a8b;
  --line: #3a332a; --accent: #e3654c; --accent-soft: #3d221b; --on-accent: #1a0f0b;
  --again: #e3654c; --hard: #d79a3e; --good: #5fb07f; --easy: #6aa3dc; --mark: #5a4220;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
code { font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
[lang="ja"], .ja { font-feature-settings: "palt"; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  max-width: 720px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); border-radius: 9px;
  font-family: var(--serif); font-weight: 700; font-size: 19px;
}
.brand-name { font-weight: 700; letter-spacing: .02em; }
.sync-dot {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; position: relative;
}
.sync-dot::after {
  content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--line);
}
.sync-dot[data-state="ok"]::after { background: var(--good); }
.sync-dot[data-state="busy"]::after { background: var(--hard); animation: pulse 1s infinite; }
.sync-dot[data-state="err"]::after { background: var(--again); }
@keyframes pulse { 50% { opacity: .3; } }

.view { max-width: 720px; margin: 0 auto; padding: 4px 16px 24px; outline: none; }

/* Tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: center; gap: 4px;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 0 1 140px; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 4px; border-radius: 12px; text-decoration: none; color: var(--muted); font-size: .75rem;
}
.tab-ico { font-family: var(--serif); font-size: 1.2rem; line-height: 1.2; }
.tabbar a.active { color: var(--accent); background: var(--accent-soft); }
body.in-session .tabbar { display: none; }
body.in-session { padding-bottom: 0; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 500; text-decoration: none;
  transition: transform .06s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.ghost { background: transparent; }
.btn.danger-ghost { background: transparent; color: var(--again); border-color: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: .9rem; border-radius: 10px; }
.icon-btn {
  border: none; background: transparent; cursor: pointer; color: var(--muted);
  width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.link { background: none; border: none; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 6px; }

/* Home */
.hello { margin: 12px 2px 18px; }
.hello h1 { font-size: 1.5rem; margin: 0; letter-spacing: .01em; }
.hello p { margin: 2px 0 0; color: var(--muted); }
.deck-grid { display: grid; gap: 12px; }
@media (min-width: 640px) { .deck-grid { grid-template-columns: 1fr 1fr; } }
.deck {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px;
}
.deck-head { display: grid; gap: 2px; }
.deck-title { font-weight: 700; font-size: 1.1rem; }
.deck-title .arrow { color: var(--accent); margin: 0 4px; }
.deck-sub { color: var(--muted); font-size: .85rem; }
.deck-stats { display: flex; gap: 22px; }
.stat b { display: block; font-size: 1.9rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .8rem; }
.stat.new b { color: var(--easy); }
.stat.due b { color: var(--good); }
.home-foot { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-top: 12px;
}
.panel h2 { font-size: 1.05rem; margin: 0 0 6px; }
.panel p { margin: 0 0 12px; }
.empty { text-align: center; padding: 36px 18px; }
.empty .big { font-family: var(--serif); font-size: 3rem; color: var(--accent); }

/* Session */
.session { display: flex; flex-direction: column; min-height: calc(100dvh - 70px); padding-bottom: env(safe-area-inset-bottom); }
.session-top { display: flex; align-items: center; gap: 10px; margin: 2px 0 10px; }
.progress { flex: 1; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .25s ease; }
.session-count { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; min-width: 52px; text-align: right; }
.flash {
  flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: var(--shadow); padding: 22px 20px; display: flex; flex-direction: column;
  cursor: pointer; user-select: text; min-height: 52vh;
}
.flash .tag { align-self: flex-start; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 99px; padding: 1px 9px; }
.flash .tag.new { color: var(--easy); border-color: color-mix(in srgb, var(--easy) 40%, transparent); }
.front { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 20px 0; }
.front .big-word { font-family: var(--serif); font-weight: 700; font-size: clamp(2.8rem, 13vw, 5.2rem); line-height: 1.15; word-break: keep-all; overflow-wrap: anywhere; }
.front .big-meaning { font-size: clamp(1.5rem, 6.5vw, 2.3rem); font-weight: 500; line-height: 1.3; max-width: 22ch; }
.hint { color: var(--muted); font-family: var(--serif); font-size: 1.2rem; min-height: 1.6em; }
.tap-hint { color: var(--muted); font-size: .8rem; }

.answer { display: flex; flex-direction: column; gap: 14px; }
.answer .head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.answer .word { font-family: var(--serif); font-weight: 700; font-size: clamp(2.2rem, 10vw, 3.4rem); line-height: 1.15; }
.answer .reading { font-family: var(--serif); color: var(--muted); font-size: 1.25rem; margin-top: -8px; }
.answer .meaning { font-size: 1.25rem; font-weight: 700; }
.answer .note { font-size: .9rem; color: var(--muted); }
.answer h4 { margin: 0 0 4px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.answer .nuance p { margin: 0; }
.examples { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.examples li { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.examples .ja-line { display: flex; gap: 6px; align-items: flex-start; justify-content: space-between; }
.examples .ja-line p { margin: 0; font-family: var(--serif); font-size: 1.08rem; }
.examples .en { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }
.missing { border: 1px dashed var(--line); border-radius: 12px; padding: 12px; color: var(--muted); font-size: .9rem; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

.actions { padding: 12px 0 8px; position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grade { min-height: 58px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; font-weight: 700; }
.grade small { font-weight: 400; color: var(--muted); font-size: .75rem; }
.grade.again { color: var(--again); }
.grade.hard { color: var(--hard); }
.grade.good { color: var(--good); }
.grade.easy { color: var(--easy); }
.kbd { display: none; }
@media (hover: hover) and (pointer: fine) { .kbd { display: inline; color: var(--muted); font-size: .72rem; font-weight: 400; } }

.done { text-align: center; padding: 40px 10px; }
.done .big { font-family: var(--serif); font-size: 2.6rem; font-weight: 700; }

/* Words */
.words-head { display: flex; gap: 8px; margin: 8px 0 12px; flex-wrap: wrap; }
.search { flex: 1 1 100%; min-height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 0 14px; }
.word-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.word-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 16px; border-top: 1px solid var(--line); cursor: pointer; }
.word-row:first-child { border-top: none; }
.word-row:hover { background: var(--surface-2); }
.word-row .w { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; }
.word-row .w small { font-weight: 500; color: var(--muted); font-size: .85rem; margin-left: 8px; }
.word-row .m { grid-column: 1; color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-size: .72rem; border-radius: 99px; padding: 2px 10px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.new { color: var(--easy); }
.chip.due { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.chip.noai { color: var(--hard); }
.list-meta { display: flex; justify-content: space-between; align-items: center; margin: 4px 2px 8px; color: var(--muted); font-size: .85rem; gap: 8px; flex-wrap: wrap; }

/* Settings */
.settings h2 { font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin: 22px 4px 8px; }
.card-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 16px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.row:first-child { border-top: none; }
.row .lbl { flex: 1 1 180px; }
.row .lbl small { display: block; color: var(--muted); font-size: .82rem; }
.row input[type="number"], .row input[type="time"], .row select { min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 0 10px; }
.row input[type="number"] { width: 80px; }
.stack { display: grid; gap: 10px; padding: 12px 0; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Forms / dialogs */
label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
label small { font-size: .78rem; }
input:not([type="checkbox"]):not([type="file"]), textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  padding: 10px 12px; color: var(--ink); font-size: 1rem;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus, .btn:focus-visible, .grade:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 12px; display: grid; gap: 8px; margin: 0; }
legend { font-size: .85rem; color: var(--muted); padding: 0 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

dialog.sheet {
  border: none; padding: 0; background: var(--surface); color: var(--ink);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 32px);
  border-radius: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog.sheet::backdrop { background: rgba(20, 14, 8, .45); }
.sheet-body { padding: 20px; display: grid; gap: 12px; }
.sheet-body h2 { margin: 0; font-size: 1.2rem; }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.spacer { flex: 1; }
@media (max-width: 520px) {
  dialog.sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: 92dvh; }
  .sheet-body { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}

/* Toasts */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); top: calc(64px + env(safe-area-inset-top)); z-index: 100; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 12px; font-size: .92rem; box-shadow: var(--shadow); animation: rise .2s ease; }
.toast.err { background: var(--again); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(-8px); } }

.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* keep compact controls compact (overrides the full-width input rule above) */
.settings .row input[type="number"] { width: 90px; flex: none; }
.settings .row input[type="time"] { width: auto; flex: none; }
label small { display: inline; }
.stat b small { font-size: .55em; color: var(--muted); font-weight: 500; }

/* Japanese-first explanations */
.answer .sec { display: grid; gap: 6px; }
.answer .ja-text { margin: 0; font-size: 1.08rem; line-height: 1.75; }
.answer .sec > h4 + .ja-text { font-weight: 500; }
.answer .en-line { margin: 0; color: var(--muted); font-size: .92rem; padding-left: 10px; border-left: 2px solid var(--line); }
.en-tag { display: inline-block; font-size: .65rem; font-weight: 700; letter-spacing: .06em; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-right: 6px; vertical-align: 1px; }
.answer.en-hidden .en-text { display: none; }
.en-toggle { align-self: flex-start; font-size: .85rem; padding: 2px 0; }

/* ---------- 読む: reading lessons ---------- */
.read-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.lesson-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.lesson-row { display: grid; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; }
.lesson-row:hover { background: var(--surface-2); }
.lesson-row.done { opacity: .72; }
.lr-top { display: flex; gap: 8px; align-items: center; }
.lr-top .chip { grid-row: auto; grid-column: auto; }
.lr-title { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; }
.done-mark { margin-left: auto; color: var(--good); font-size: .8rem; font-weight: 700; }

.lesson { display: grid; gap: 18px; padding-bottom: 24px; }
.lesson-nav { display: flex; align-items: center; gap: 10px; margin-left: -8px; }
.lesson-nav .chip { grid-row: auto; grid-column: auto; }
.lesson-title { font-family: var(--serif); font-size: clamp(1.6rem, 6vw, 2.1rem); line-height: 1.3; margin: 0; }
.lesson-sub { margin: -12px 0 0; }
.setting-box { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; }
.setting-box p { margin: 0; }
.lesson section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.sec-title { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; margin: 0 0 12px; }
.sec-title > span { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: .78rem; flex: none; }
.sec-title small { color: var(--muted); font-weight: 400; font-size: .8rem; }

.vocab-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.vocab-item { padding: 10px 0; border-top: 1px solid var(--line); display: grid; gap: 2px; }
.vocab-item:first-child { border-top: none; padding-top: 0; }
.vh { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.vw { font-family: var(--serif); font-weight: 700; font-size: 1.2rem; }
.vr { color: var(--muted); font-family: var(--serif); }
.vm { font-weight: 700; }
.vj { font-size: .95rem; }
.vn { color: var(--muted); font-size: .85rem; }
.add-word:disabled { opacity: .7; }

.read-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.lines { display: grid; gap: 10px; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 2px 6px; align-items: start; cursor: pointer; border-radius: 14px; }
.line .sp { grid-column: 1 / -1; font-size: .75rem; font-weight: 700; color: var(--muted); padding-left: 4px; }
.line .bubble { border-radius: 16px; padding: 9px 13px; }
.line .jp { margin: 0; font-size: 1.05rem; line-height: 1.7; }
.line .tr { margin: 4px 0 0; color: var(--muted); font-size: .88rem; }
.line-say { align-self: center; }
.lines.chat .line.has-sp .bubble { background: var(--surface-2); border-top-left-radius: 4px; }
.lines.chat .line.s1 .bubble { background: color-mix(in srgb, var(--good) 14%, var(--surface)); }
.lines.chat .line.s2 .bubble { background: color-mix(in srgb, var(--easy) 14%, var(--surface)); }
.lines.chat .line.s3 .bubble { background: color-mix(in srgb, var(--hard) 14%, var(--surface)); }
.lines.prose .line .bubble { padding: 4px 6px; }
.lines.prose .line.has-sp .bubble { border-left: 3px solid var(--line); border-radius: 4px; }
.line.s0 .sp { color: var(--accent); } .line.s1 .sp { color: var(--good); } .line.s2 .sp { color: var(--easy); } .line.s3 .sp { color: var(--hard); }
.line.playing .bubble { outline: 2px solid var(--accent); }
.lesson.en-hidden .line:not(.show-en) .en-text, .lesson.en-hidden .setting-box .en-text { display: none; }

.expr-list, .q-list { margin: 0; padding: 0 0 0 0; list-style: none; display: grid; gap: 12px; }
.q-list { padding-left: 20px; list-style: decimal; }
.expr-list li { border-left: 3px solid var(--accent); padding-left: 12px; }
.ep { font-family: var(--serif); font-weight: 700; font-size: 1.1rem; }
.expr-list p, .q-list p { margin: 4px 0 0; }
.expr-list .ex { background: var(--surface-2); border-radius: 8px; padding: 6px 10px; }
.ans, .sample { background: var(--surface-2); border-radius: 8px; padding: 6px 10px; margin: 4px 0 0; }
.lesson-end { padding-top: 4px; }

/* settings: switch + day toggles */
.switch { position: relative; display: inline-block; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 99px; cursor: pointer; transition: background .15s; }
.switch span::before { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.day { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-family: var(--serif); }
.day.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
@media (max-width: 420px) { .tabbar a { font-size: .7rem; } }

/* ---------- 話す: shadowing ---------- */
.sh-head { display: grid; gap: 2px; margin-bottom: 10px; }
.sh-title { font-family: var(--serif); font-size: 1.2rem; line-height: 1.45; margin: 4px 0 0; }
.chip.cont { color: var(--hard); border-color: color-mix(in srgb, var(--hard) 40%, transparent); }
.chip.done { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.sh-stage { background: var(--bg); padding-bottom: 6px; }
.shadow.tx-open .sh-stage { position: sticky; top: calc(52px + env(safe-area-inset-top)); z-index: 5; }
.sh-player { position: relative; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #000; }
.sh-player iframe, .sh-player > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.sh-player.fallback { aspect-ratio: auto; background: var(--surface); border: 1px solid var(--line); }
.sh-player.fallback > div { position: static; }
.sh-fallback { display: grid; gap: 10px; justify-items: start; padding: 18px; }
.sh-fallback p { margin: 0; }
.sh-tools { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; gap: 4px; }
.seg .btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.sh-time { font-variant-numeric: tabular-nums; }
.sh-bar { height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.sh-bar span { display: block; height: 100%; background: var(--accent); transition: width .5s linear; }
.sh-status { color: var(--muted); font-size: .9rem; margin: 10px 0; }
.sh-links { display: flex; gap: 10px; margin: 4px 0 6px -6px; }
.tx { margin-top: 14px; }
.tx-lines { display: grid; gap: 2px; }
.tx-line { display: grid; grid-template-columns: 52px 1fr auto; gap: 8px; align-items: baseline; padding: 6px 4px; border-radius: 10px; cursor: pointer; }
.tx-line.looping { background: var(--accent-soft); }
.tx-rep { background: none; border: 0; padding: 4px 6px; cursor: pointer; opacity: .55; font-size: .95rem; border-radius: 8px; }
.tx-rep:hover, .tx-line.looping .tx-rep { opacity: 1; }
.tx-line:hover { background: var(--surface); }
.tx-line .jp { margin: 0; font-size: 1.05rem; line-height: 1.7; }
.tx-line .tr { margin: 2px 0 0; color: var(--muted); font-size: .88rem; }
.tx.en-hidden .tx-line:not(.show-en) .en-text { display: none; }
.tx-t { background: none; border: 0; padding: 2px 0; color: var(--accent); font-variant-numeric: tabular-nums; font-size: .85rem; cursor: pointer; text-align: left; }
.tx-sp { font-size: .75rem; font-weight: 700; color: var(--muted); margin-right: 6px; }
.tx-note { margin-top: 12px; }
.sh-progress h2 { margin-bottom: 4px; }
.sh-hist { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.sh-hist li { display: grid; grid-template-columns: auto 1fr; gap: 0 8px; }
.sh-hist .done-mark { margin: 0; grid-row: span 2; }
.sh-hist .t { font-size: .95rem; }

/* shadowing controls */
.sh-ctrl { display: grid; grid-template-columns: 64px 1fr 1.8fr; gap: 8px; margin-top: 10px; }
.ctrl { min-height: 52px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-size: 1rem; font-weight: 500; cursor: pointer; padding: 0 10px; }
.ctrl:active { transform: scale(.97); }
.ctrl.play { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-size: 1.35rem; }
.ctrl.loop.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.sh-sub { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.sh-loop { margin-top: 8px; background: var(--surface); border: 1px solid var(--accent); border-radius: 14px; padding: 8px 10px; }
.sh-loop-top { display: flex; align-items: center; gap: 6px; }
.sh-loop-top .chip { grid-row: auto; grid-column: auto; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.sh-loop-top .btn.sm { min-height: 34px; padding: 0 10px; }
.sh-loop .jp { margin: 6px 2px 2px; font-size: 1.1rem; line-height: 1.6; }
.sh-return { margin: 0 0 14px; border-color: var(--accent); }
.rt-time { display: flex; align-items: center; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.sh-return .rt-time input[type="number"] { width: 72px; flex: none; min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 0 8px; text-align: center; }
.sh-return .link { margin: 8px 0 0 -6px; }

/* Khmer translations: Khmer font and taller lines for stacked vowels */
[lang="km"] { font-family: "Noto Sans Khmer", var(--sans); line-height: 1.85; }
.front .big-meaning[lang="km"] { line-height: 1.6; }

/* word counts + "Add 50 words" */
.words-panel { display: grid; gap: 12px; }
.wstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.wstat { background: var(--surface-2); border-radius: 12px; padding: 10px 4px; }
.wstat b { display: block; font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.wstat span { font-size: .78rem; color: var(--muted); }
.wstat.learned b { color: var(--good); }
.wstat.unlearned b { color: var(--easy); }
.wleft { text-align: center; margin-top: -4px; }
.words-panel + .list-meta { margin-top: 12px; }
