/* ===== デザイントークン ===== */
:root {
  --bg: #f7f3ea;
  --surface: #fffdf8;
  --surface-2: #f1ebdf;
  --line: #e2d9c7;
  --ink: #23201b;
  --ink-2: #5d564b;
  --muted: #8a8174;
  --accent: #c8402c;       /* 朱色: 現在の画・書き始め */
  --accent-ink: #fff;
  --accent-soft: #f6dcd5;
  --brand: #2f4f6f;        /* 藍色 */
  --brand-soft: #dde6ef;
  --ghost: #ddd4c3;
  --grid: #e3b8ad;
  --end-t: #2c6cb0;        /* とめ */
  --end-h: #c97a06;        /* はね */
  --end-p: #2e8a55;        /* はらい */
  --good: #2e8a55;
  --bad: #c0392b;
  --warn: #b7791f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 45, 20, .06), 0 4px 16px rgba(60, 45, 20, .06);
  --font-jp: 'Klee One', 'UD デジタル 教科書体 N-R', 'UD Digi Kyokasho N-R', 'YuKyokasho', 'Hiragino Mincho ProN', serif;
  --font-ui: 'Zen Kaku Gothic New', 'Hiragino Sans', 'Yu Gothic UI', 'Meiryo', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1916; --surface: #24221e; --surface-2: #2d2a25; --line: #3b3730;
    --ink: #f0ebe1; --ink-2: #c9c1b3; --muted: #968d7f;
    --accent: #ef6a52; --accent-ink: #1a1916; --accent-soft: #4a2a23;
    --brand: #9cbbdb; --brand-soft: #2b3946;
    --ghost: #46413a; --grid: #6b4740;
    --end-t: #6aa6e6; --end-h: #f0a63a; --end-p: #5cc28a;
    --good: #5cc28a; --bad: #f07a6c; --warn: #f0b85a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1916; --surface: #24221e; --surface-2: #2d2a25; --line: #3b3730;
  --ink: #f0ebe1; --ink-2: #c9c1b3; --muted: #968d7f;
  --accent: #ef6a52; --accent-ink: #1a1916; --accent-soft: #4a2a23;
  --brand: #9cbbdb; --brand-soft: #2b3946;
  --ghost: #46413a; --grid: #6b4740;
  --end-t: #6aa6e6; --end-h: #f0a63a; --end-p: #5cc28a;
  --good: #5cc28a; --bad: #f07a6c; --warn: #f0b85a;
  color-scheme: dark;
}

/* ===== ベース ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-ui); font-size: 16px; line-height: 1.6;
  min-height: 100vh; display: flex; flex-direction: column;
}
.jp { font-family: var(--font-jp); }
button { font: inherit; color: inherit; cursor: pointer; }
small { font-size: .72em; color: var(--muted); font-weight: 400; letter-spacing: .02em; }
h2 { font-size: 1.3rem; margin: 0 0 .8rem; }
h2 small, h3 small { margin-left: .4em; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* ===== ヘッダー・ナビ ===== */
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px 10px; max-width: 1180px; width: 100%; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 46px; height: 46px; display: grid; place-items: center; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink); font-size: 30px; font-weight: 600; line-height: 1;
}
body[data-script="kata"] .brand-mark::before { content: 'ア'; }
body[data-script="kata"] .brand-mark { font-size: 0; }
body[data-script="kata"] .brand-mark::before { font-size: 30px; }
h1 { font-size: 1.25rem; margin: 0; line-height: 1.2; }
.sub { margin: 0; font-size: .78rem; color: var(--muted); }

.segmented { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; border: 1px solid var(--line); }
.segmented button {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 9px; display: flex; flex-direction: column; align-items: center;
  line-height: 1.25; min-height: 40px; justify-content: center; color: var(--ink-2);
}
.segmented button .jp { font-size: 1.05rem; font-weight: 600; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.segmented.small button { padding: 6px 12px; font-size: .92rem; }
.segmented.wrap { flex-wrap: wrap; }

.main-nav {
  display: flex; gap: 4px; max-width: 1180px; width: 100%; margin: 0 auto; padding: 0 16px;
  border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none;
}
.main-nav button {
  border: 0; background: none; padding: 10px 14px 9px; font-weight: 600; color: var(--ink-2); white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.main-nav button small { margin-left: .35em; }
.main-nav button[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

main { flex: 1; max-width: 1180px; width: 100%; margin: 0 auto; padding: 18px 16px 32px; }

/* ===== ボタン ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 8px 14px; min-height: 42px; font-weight: 600;
}
.btn:hover { background: var(--surface-2); }
.btn svg { width: 20px; height: 20px; fill: currentColor; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.06); }
.btn.big { min-height: 52px; padding: 10px 40px; font-size: 1.1rem; }
.icon-btn { width: 46px; padding: 0; }
.btn-ghost { background: transparent; }
.link-btn { border: 0; background: none; color: var(--brand); text-decoration: underline; text-underline-offset: 3px; padding: 4px 6px; font-size: .9rem; }

/* ===== 50音表 ===== */
.view-chart { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; align-items: start; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button {
  border: 1px solid var(--line); background: var(--surface); padding: 6px 12px; border-radius: 999px;
  font-weight: 600; font-size: .95rem; color: var(--ink-2);
}
.tabs button small { margin-left: .35em; }
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tabs button[aria-selected="true"] small { color: inherit; opacity: .7; }

.chart { display: flex; flex-direction: column; gap: 6px; }
.chart-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.chart.cols-3 .chart-row { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 420px; }
.chart-head div { text-align: center; font-size: .78rem; color: var(--muted); font-weight: 600; letter-spacing: .05em; }
.cell {
  position: relative; border: 1px solid var(--line); background: var(--surface); border-radius: 12px;
  min-height: 70px; padding: 6px 2px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: transform .08s ease, border-color .15s, box-shadow .15s;
}
.cell:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.cell:active { transform: scale(.97); }
.cell[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.cell.empty { border: 1px dashed transparent; background: transparent; }
.cell-kana { font-size: clamp(1.6rem, 4.2vw, 2.2rem); line-height: 1.1; font-weight: 600; }
.section-yoon .cell-kana { font-size: clamp(1.4rem, 3.6vw, 1.9rem); }
.cell-romaji { font-size: .78rem; color: var(--muted); letter-spacing: .03em; }
.cell .dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; }
.cell[data-level="1"] .dot, .dot.lv1 { background: var(--warn); }
.cell[data-level="2"] .dot, .dot.lv2 { background: var(--good); }
.legend-progress { display: flex; gap: 16px; font-size: .8rem; color: var(--muted); margin: 12px 2px 0; flex-wrap: wrap; }
.legend-progress .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* ===== 書き方ビューア ===== */
.viewer {
  position: sticky; top: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 16px; box-shadow: var(--shadow); scroll-margin-top: 12px;
}
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.v-title { display: flex; align-items: center; gap: 12px; }
.v-char { font-size: 3rem; line-height: 1; font-weight: 600; min-width: 1.1em; }
.v-romaji { font-size: 1.3rem; font-weight: 700; letter-spacing: .03em; line-height: 1.2; }
.v-meta { font-size: .9rem; color: var(--ink-2); }
.v-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-speak { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.btn-speak:hover { background: var(--brand-soft); filter: brightness(.97); }
.btn-speak svg { fill: currentColor; }
#v-pair b { font-size: 1.2rem; margin-left: 2px; }
.voice-warning { font-size: .82rem; color: var(--warn); background: var(--surface-2); padding: 8px 10px; border-radius: 8px; margin: 10px 0 0; }

.canvas-wrap { position: relative; margin: 12px 0 10px; }
.kana-svg { display: block; width: 100%; height: auto; background: var(--surface); border-radius: 12px; touch-action: none; user-select: none; -webkit-user-select: none; }
.viewer-svg { max-height: 52vh; aspect-ratio: auto; border: 1px solid var(--line); }
.v-status { position: absolute; right: 10px; bottom: 8px; font-size: .8rem; color: var(--muted); background: var(--surface); padding: 0 6px; border-radius: 6px; }

/* SVG の中身 */
.grid-frame { fill: none; stroke: var(--grid); stroke-width: .6; }
.grid-line { stroke: var(--grid); stroke-width: .45; stroke-dasharray: 2 2; }
.hide-grid .grid { display: none; }
.ghost path { fill: none; stroke: var(--ghost); stroke-width: 4.6; stroke-linecap: round; stroke-linejoin: round; }
.hide-ghost .ghost { display: none; }
.ink path, .stroke { fill: none; stroke: var(--ink); stroke-width: 4.2; stroke-linecap: round; stroke-linejoin: round; }
.ink path:not(.visible) { visibility: hidden; }
.ink path.current { stroke: var(--accent); }
.start-dot { fill: var(--accent); opacity: 0; transition: opacity .15s; }
.start-dot.shown { opacity: 1; }
.brush-tip { fill: var(--accent); opacity: 0; }
.brush-tip.shown { opacity: .9; }
.end-mark { fill: none; stroke-width: 1.4; opacity: 0; transition: opacity .2s; }
.end-mark.shown { opacity: 1; }
.end-mark.end-t { stroke: var(--end-t); }
.end-mark.end-h { stroke: var(--end-h); }
.end-mark.end-p { stroke: var(--end-p); }
.hide-ends .end-mark { display: none; }
.num { opacity: 0; transition: opacity .15s; }
.num.shown { opacity: 1; }
.num circle { fill: var(--surface); stroke: var(--accent); stroke-width: .6; }
.num text { fill: var(--accent); font-size: 6px; font-weight: 700; text-anchor: middle; dominant-baseline: central; font-family: var(--font-ui); }
.hide-numbers .num { display: none; }

.controls { display: flex; justify-content: center; gap: 6px; }
.play-btn { min-width: 128px; }
.play-btn svg { width: 20px; height: 20px; }

.v-tip { font-size: .9rem; color: var(--ink-2); min-height: 2.9em; margin: 12px 0 8px; }
.start-sample { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.end-badge { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: .82rem; font-weight: 700; line-height: 1.6; color: #fff; }
.end-badge.end-t { background: var(--end-t); }
.end-badge.end-h { background: var(--end-h); }
.end-badge.end-p { background: var(--end-p); }
:root[data-theme="dark"] .end-badge { color: #1a1916; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .end-badge { color: #1a1916; } }

.stroke-list { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.stroke-list button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 8px 3px 4px;
  display: inline-flex; align-items: center; gap: 6px; opacity: .55;
}
.stroke-list li.done button { opacity: 1; }
.stroke-list li.active button { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.stroke-list .n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 700; color: var(--accent); border: 1.5px solid var(--accent); }

.settings { border-top: 1px solid var(--line); padding-top: 8px; }
.settings summary { cursor: pointer; font-weight: 600; font-size: .92rem; padding: 4px 0; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 8px 0 4px; font-size: .9rem; }
.range { display: flex; flex-direction: column; gap: 2px; grid-column: span 1; }
.range input { width: 100%; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.ends-legend { display: flex; gap: 14px; font-size: .85rem; margin-top: 10px; color: var(--ink-2); flex-wrap: wrap; }
.end-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid; margin-right: 5px; vertical-align: -1px; }
.end-dot.end-t { border-color: var(--end-t); }
.end-dot.end-h { border-color: var(--end-h); }
.end-dot.end-p { border-color: var(--end-p); }
.ends-legend small { margin-left: 3px; }

/* ===== クイズ ===== */
.quiz-card { max-width: 760px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.mode-card {
  text-align: left; border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; padding: 12px 14px;
  display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
}
.mode-card[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.mode-icon { grid-row: span 2; width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; font-size: 1.05rem; }
.mode-title { font-weight: 700; }
.mode-title small { margin-left: .4em; }
.mode-desc { font-size: .84rem; color: var(--ink-2); line-height: 1.45; }
.opt-row { display: flex; align-items: center; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
.opt-label { width: 4em; font-weight: 600; color: var(--ink-2); font-size: .92rem; }
.setup-actions { display: flex; align-items: center; gap: 14px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.setup-msg { background: var(--surface-2); padding: 10px 12px; border-radius: 10px; color: var(--warn); }

.quiz-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-weight: 600; }
.quiz-mode { background: var(--ink); color: var(--bg); padding: 2px 10px; border-radius: 999px; font-size: .88rem; }
.quiz-progress { color: var(--ink-2); }
.quiz-score { color: var(--good); }
.quiz-top .link-btn { margin-left: auto; }
.bar { height: 6px; background: var(--surface-2); border-radius: 99px; margin: 10px 0 14px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); width: 0; transition: width .3s ease; }
.quiz-stage { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.quiz-prompt { margin: 0; text-align: center; font-size: 1.05rem; }
.quiz-prompt b.jp { font-size: 1.6rem; vertical-align: -2px; }
.quiz-prompt .romaji { color: var(--muted); margin-left: 6px; font-size: .9rem; }
.quiz-stage .kana-svg { width: min(100%, 380px); border: 1px solid var(--line); }
.quiz-stage .kana-svg[viewBox^="0 0 187"] { width: min(100%, 560px); }
.quiz-feedback { text-align: center; min-height: 1.6em; font-weight: 600; margin: 12px 0 4px; }
.quiz-feedback.good { color: var(--good); }
.quiz-feedback.bad { color: var(--bad); }
.quiz-feedback.warn { color: var(--warn); }
.quiz-actions { display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }

/* 書き順クイズ */
.pick { cursor: pointer; outline: none; }
.pick-vis { fill: none; stroke: var(--ghost); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; transition: stroke .15s; }
.pick-hit { fill: none; stroke: transparent; stroke-width: 12; stroke-linecap: round; pointer-events: stroke; }
.pick:hover .pick-vis, .pick:focus-visible .pick-vis { stroke: var(--muted); }
.pick.done { pointer-events: none; }
.pick.done .pick-vis { stroke: var(--ink); stroke-width: 4.2; }
.pick.wrong .pick-vis { stroke: var(--bad); animation: shake .4s; }
.pick.hint .pick-vis { animation: glow 1s ease-in-out infinite; }
@keyframes glow { 50% { stroke: var(--accent); } }

/* なぞり書き */
.trace-svg { cursor: crosshair; }
.user-line { fill: none; stroke: var(--brand); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.hint-stroke { fill: none; stroke: var(--accent); stroke-width: 4.2; stroke-linecap: round; stroke-linejoin: round; opacity: .55; animation: draw 1.4s ease-in-out infinite; }
@keyframes draw { from { stroke-dashoffset: var(--len); } 70%, to { stroke-dashoffset: 0; } }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* 画数・聞き取り */
.count-char { font-size: 7rem; line-height: 1.1; font-weight: 600; }
.listen-btn {
  width: 120px; height: 120px; border-radius: 50%; border: 0; background: var(--brand-soft); color: var(--brand);
  font-size: 2.6rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.listen-btn span { font-size: .78rem; font-weight: 600; }
.choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 520px; }
.choice { border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; min-height: 64px; font-size: 1.2rem; font-weight: 700; }
.choice.jp { font-size: 2.2rem; font-weight: 600; min-height: 84px; }
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice:disabled { cursor: default; opacity: .6; }
.choice.right { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--surface)); opacity: 1; }
.choice.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, var(--surface)); opacity: 1; }

/* 結果 */
.result { text-align: center; }
.stars { font-size: 2.6rem; color: #e0a526; letter-spacing: 6px; }
.result-score { font-size: 2.4rem; font-weight: 700; }
.result h3 { font-size: 1rem; margin: 18px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.kana-chip {
  font-family: var(--font-jp); font-weight: 600; font-size: 1.35rem; min-width: 48px; min-height: 48px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 0 8px; margin: 2px;
}
.kana-chip:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ===== 書き方のポイント ===== */
.tips { max-width: 860px; margin: 0 auto; }
.tips h2 { margin-top: 28px; }
.tips h2:first-child { margin-top: 0; }
.end-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.end-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.end-card svg { width: 100%; height: 86px; background: var(--surface-2); border-radius: 10px; }
.end-card h3 { margin: 10px 0 4px; font-size: 1rem; }
.end-card p { margin: 4px 0; font-size: .9rem; color: var(--ink-2); }
.end-card .ex { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin-top: 8px; }
.ill { fill: none; stroke: var(--ink); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.ill-fill { fill: var(--ink); }
.ill-end { fill: none; stroke-width: 2.5; }
.ill-end.end-t { stroke: var(--end-t); }
.ill-end.end-h { stroke: var(--end-h); }
.ill-end.end-p { stroke: var(--end-p); }
.note { font-size: .86rem; color: var(--ink-2); background: var(--surface-2); padding: 10px 12px; border-radius: 10px; }
.rules { padding-left: 1.4em; }
.rules li { margin: 8px 0; }
.rules .kana-chip { font-size: 1.1rem; min-width: 40px; min-height: 40px; }
.pairs { display: grid; gap: 8px; }
.pairs > div { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; }
.pairs span { margin-left: 8px; font-size: .9rem; color: var(--ink-2); }

.app-footer { text-align: center; font-size: .78rem; color: var(--muted); padding: 16px; border-top: 1px solid var(--line); }
.app-footer p { margin: 0; }

/* ===== レスポンシブ ===== */
@media (max-width: 899px) {
  .view-chart { grid-template-columns: 1fr; }
  .viewer { position: static; order: -1; }
  .viewer-svg { max-height: 46vh; }
}
@media (max-width: 560px) {
  .app-header { padding-top: 10px; }
  h1 { font-size: 1.08rem; }
  .brand-mark { width: 40px; height: 40px; }
  .sub { display: none; }
  .segmented button { padding: 4px 10px; }
  .main-nav button { padding: 7px 10px 6px; font-size: .95rem; line-height: 1.25; }
  .main-nav button small { display: block; margin-left: 0; font-size: .68rem; }
  .header-tools { width: 100%; justify-content: space-between; }
  .lang-select { flex: 1 1 auto; min-width: 0; }
  .lang-select select { min-width: 0; width: 100%; }
  main { padding: 14px 12px 24px; }
  .chart-row { gap: 4px; }
  .chart { gap: 4px; }
  .cell { min-height: 58px; border-radius: 10px; }
  .viewer { padding: 12px; border-radius: 14px; }
  .v-char { font-size: 2.4rem; }
  .settings-grid { grid-template-columns: 1fr; }
  .mode-grid { grid-template-columns: 1fr; }
  .end-cards { grid-template-columns: 1fr; }
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .count-char { font-size: 5.5rem; }
  .quiz-card { padding: 14px; }
  .tabs button { padding: 5px 10px; font-size: .88rem; }
  .tabs button small { margin-left: .3em; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ===== 説明の言語 ===== */
.header-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lang-select {
  display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 0 4px 0 10px; min-height: 44px; color: var(--ink-2);
}
.lang-select svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; flex: none; }
.lang-select select {
  border: 0; background: transparent; color: var(--ink); font: inherit; font-weight: 600; padding: 8px 6px; cursor: pointer;
  font-family: 'Noto Sans', 'Noto Sans Thai', var(--font-ui);
}
.lang-select:focus-within { outline: 3px solid var(--brand); outline-offset: 2px; }
.lang-select select:focus-visible { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ex-label { color: var(--ink-2); margin: 0 2px 0 8px; font-size: .9rem; }

/* 訳文の書体: ベトナム語の声調記号やタイ文字を正しく表示する */
[lang="en"], [lang="vi"], [lang="ms"], [lang="id"] { font-family: 'Noto Sans', var(--font-ui); }
[lang="th"] { font-family: 'Noto Sans Thai', 'Noto Sans', var(--font-ui); line-height: 1.7; }
.voice-row { grid-column: 1 / -1; }
.voice-row select { width: 100%; min-height: 36px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; padding: 4px 8px; }
