:root {
  color-scheme: dark;
  --bg: #202020;
  --surface: #242424;
  --surface-2: #2c2c2c;
  --text: #ededed;
  --muted: #a0a0a0;
  --line: #424242;
  --line-strong: #626262;
  --accent: #dd612e;
  --accent-ink: #ffffff;
  --red: #ee5d55;
  --blue: #79a8e8;
  --radius: 3px;
}

html.light {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f3f3f1;
  --text: #343434;
  --muted: #858585;
  --line: #dededb;
  --line-strong: #aaa9a4;
  --accent: #ce5425;
  --accent-ink: #ffffff;
  --red: #bd3832;
  --blue: #2d66ad;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--text); font: 16px/1.5 Arial, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, label[for], .word-display { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.app-shell { width: 100%; min-height: 100vh; margin: 0 auto; }
.topbar { height: 52px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; background: var(--surface); }
.brand { width: fit-content; display: inline-flex; align-items: center; gap: 10px; padding: 0; border: 0; background: transparent; color: var(--text); font: 700 .92rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace; letter-spacing: -.02em; cursor: pointer; }
.nav-tabs { display: flex; align-self: stretch; gap: 26px; }
.nav-tab { border: 0; border-bottom: 2px solid transparent; padding: 2px 0 0; background: transparent; color: var(--muted); font-size: .88rem; cursor: pointer; }
.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.top-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.saved-note { color: var(--muted); font: .72rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace; }

button { transition: border-color .12s ease, background .12s ease, color .12s ease; }
.primary, .secondary, .icon-button, .text-button, .close-button { cursor: pointer; }
.primary { border: 1px solid var(--accent); border-radius: 2px; padding: 10px 15px; background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.primary:hover { background: color-mix(in srgb, var(--accent) 88%, white); }
.primary.small { padding: 7px 13px; font-size: .82rem; }
.secondary { border: 1px solid var(--line); border-radius: 2px; padding: 9px 14px; background: var(--surface); color: var(--text); font-weight: 600; cursor: pointer; }
.secondary.compact { padding: 6px 10px; font-size: .8rem; }
.secondary:hover { border-color: var(--line-strong); background: var(--surface-2); }
.secondary.full { width: 100%; }
.icon-button { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 4px; background: transparent; }
.icon-button svg, .search-box svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.text-button { border: 0; padding: 3px 0; background: transparent; color: var(--muted); font: 650 .78rem/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.text-button:hover { color: var(--text); }
.danger-text, .delete { color: var(--red) !important; }

.view { display: none; padding: 0; }
.view.active { display: block; }
.practice-layout { min-height: calc(100vh - 52px); display: grid; grid-template-columns: 204px minmax(0, 1fr); border: 0; background: var(--surface); }
.session-panel { padding: 22px 17px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 21px; background: var(--surface-2); }
.eyebrow { margin: 0 0 7px; color: var(--accent); font: 700 .68rem/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace; letter-spacing: .12em; text-transform: uppercase; }
.session-panel h2, .page-head h1, .dialog-head h2, .card-head h2 { margin: 0; }
.session-panel h2 { font-size: 1.12rem; font-weight: 700; }
.session-panel .muted { margin: 3px 0 0; font-size: .8rem; }
.mode-group { display: grid; grid-template-columns: 1fr; border: 0; }
.mode { min-height: 34px; border: 0; border-left: 2px solid transparent; padding: 0 11px; background: transparent; color: var(--muted); font-size: .84rem; text-align: left; cursor: pointer; }
.mode:nth-child(2n), .mode:nth-last-child(-n+2) { border-right: 0; border-bottom: 0; }
.mode:hover { color: var(--text); background: var(--surface-2); }
.mode.active { color: var(--text); border-left-color: var(--accent); background: var(--surface); }
.session-size-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .8rem; }
.session-size-label select { width: 92px; border: 1px solid var(--line); border-radius: 3px; padding: 6px 8px; background: var(--surface); color: var(--text); }
.session-progress { margin-top: auto; }
.progress-copy, .today-goal > div:first-child { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font: .72rem/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.progress-copy strong, .today-goal strong { color: var(--text); font-weight: 600; }
.progress-track, .goal-track { height: 3px; overflow: hidden; background: var(--line); }
.progress-track span, .goal-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .25s ease; }
.mini-stats { display: flex; justify-content: center; gap: clamp(34px, 6vw, 78px); margin: 18px 0 0; border: 0; }
.mini-stats div { min-width: 82px; padding: 0; border: 0; text-align: center; }
.mini-stats dt { color: var(--muted); font-size: .7rem; }
.mini-stats dd { margin: 4px 0 0; color: var(--text); font: 500 1.45rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.mini-stats dd small { color: var(--muted); font-size: .65rem; }

.typing-stage { min-width: 0; position: relative; padding: 23px 36px 34px; display: flex; flex-direction: column; background: var(--bg); }
#practiceContent { flex: 1; display: flex; flex-direction: column; }
.stage-topline { display: flex; justify-content: space-between; color: var(--muted); font: .72rem/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.stage-actions { display: flex; flex-wrap: wrap; gap: 19px; }
.auto-speak-toggle { border: 0; padding: 3px 0; background: transparent; color: var(--muted); font: 650 .78rem/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace; cursor: pointer; }
.auto-speak-toggle[aria-pressed="true"] { color: var(--accent); }
.speaker-icon { margin-right: 4px; }
.favorite-button[aria-pressed="true"] { color: var(--accent); }
.meaning-block { min-height: 76px; margin: clamp(38px, 6vh, 72px) 0 14px; text-align: center; }
.meaning-block > span { display: block; margin-bottom: 12px; color: var(--muted); font-size: .78rem; }
.meaning-block h1 { margin: 0; font-size: clamp(1.15rem, 2.2vw, 1.65rem); font-weight: 500; letter-spacing: .01em; }
.word-display { width: 100%; min-height: 86px; border: 0; padding: 0; background: transparent; color: var(--muted); text-align: center; font: 500 clamp(2.2rem, 6vw, 4.7rem)/1 ui-monospace, "SFMono-Regular", Consolas, monospace; letter-spacing: .01em; cursor: text; }
.letter, .dictation-slot { display: inline-block; position: relative; min-width: .64em; border-bottom: 2px solid transparent; }
.letter.correct, .dictation-slot.correct { color: var(--text); }
.letter.wrong, .dictation-slot.wrong { color: var(--red); border-bottom-color: var(--red); }
.dictation-slot.entered { color: var(--text); border-bottom-color: var(--line-strong); }
.letter.cursor::after, .dictation-slot.cursor::after { content: ""; position: absolute; left: 0; right: 0; bottom: -.1em; height: 2px; background: var(--accent); animation: blink 1s steps(1) infinite; }
.dictation-slot { margin: 0 .06em; color: var(--line-strong); border-bottom: 2px solid var(--line-strong); }
.dictation-slot.hint { color: var(--muted); }
.word-gap { display: inline-block; width: .45em; }
@keyframes blink { 50% { opacity: 0; } }
.typing-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.typing-hint { min-height: 40px; margin-top: 17px; padding-top: 13px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; color: var(--muted); font: .72rem/1.4 ui-monospace, "SFMono-Regular", Consolas, monospace; }
kbd { border: 1px solid var(--line); border-bottom-color: var(--line-strong); border-radius: 3px; padding: 2px 5px; background: var(--surface-2); color: var(--text); font: inherit; }
.result-line { height: 31px; margin-top: 13px; text-align: center; font-size: .84rem; }
.result-line.good { color: var(--accent); }
.result-line.bad { color: var(--red); }
.keyboard-wrap { width: min(880px, 100%); margin: 36px auto 0; }
.keyboard-caption { display: flex; justify-content: space-between; margin-bottom: 9px; color: var(--muted); font-size: .7rem; }
.keyboard-caption i { display: inline-block; width: 11px; height: 11px; margin-right: 4px; vertical-align: -1px; border: 1px solid var(--line-strong); }
.keyboard-caption .legend-next { background: var(--accent); border-color: var(--accent); }
.keyboard-caption .legend-word { background: #6eaa70; border-color: #6eaa70; }
.keyboard-caption .legend-error { background: #dc514b; border-color: #dc514b; }
.keyboard-caption .legend-pressed { background: var(--text); }
.onscreen-keyboard { position: relative; user-select: none; }
.keyboard-row { display: flex; gap: 5px; margin-bottom: 5px; }
.keyboard-key { --finger: var(--line-strong); position: relative; flex: var(--key-width) 1 0; min-width: 0; height: 40px; display: grid; place-items: center; overflow: hidden; border: 1px solid color-mix(in srgb, var(--finger) 52%, var(--line-strong)); border-radius: 3px; background: color-mix(in srgb, var(--finger) 13%, var(--surface)); color: var(--muted); box-shadow: 0 2px 0 color-mix(in srgb, var(--line-strong) 80%, transparent); font: 500 .74rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace; transition: transform .06s ease, background .12s ease, color .06s ease, box-shadow .12s ease; }
.keyboard-key::after { content: ""; position: absolute; left: 4px; right: 4px; bottom: 3px; height: 2px; background: var(--finger); opacity: .62; }
.finger-l5 { --finger: #de6a62; } .finger-l4 { --finger: #d99350; } .finger-l3 { --finger: #c4a84b; } .finger-l2 { --finger: #6eaa70; }
.finger-r2 { --finger: #5f9f91; } .finger-r3 { --finger: #5d94bd; } .finger-r4 { --finger: #777db6; } .finger-r5 { --finger: #a66ca3; }
.keyboard-key.next-key { border-color: var(--accent); background: var(--accent); color: #fff; box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 65%, #000); }
.keyboard-key.next-key::after { background: #fff; }
.keyboard-key.expected-used { border-color: color-mix(in srgb, var(--line-strong) 70%, #aaa); }
.keyboard-key.word-used { background: color-mix(in srgb, #55a86a 35%, var(--surface)); color: var(--text); box-shadow: inset 0 0 0 1px #55a86a, 0 2px 0 color-mix(in srgb, #55a86a 55%, var(--line)); }
.keyboard-key.error-used { background: color-mix(in srgb, #dc514b 42%, var(--surface)); color: var(--text); box-shadow: inset 0 0 0 1px #dc514b, 0 2px 0 color-mix(in srgb, #dc514b 58%, var(--line)); }
.keyboard-key.pressed { transform: translateY(2px); background: var(--text); color: var(--bg); box-shadow: none; }
.keyboard-key.pressed::after { opacity: 0; }
.finger-guide { width: 64%; margin: 14px auto 0; display: flex; justify-content: center; align-items: flex-start; gap: 8px; }
.finger-marker { --finger: var(--line-strong); width: 38px; height: 47px; display: grid; place-content: center; justify-items: center; border: 1px solid color-mix(in srgb, var(--finger) 55%, var(--line)); border-radius: 18px 18px 9px 9px; background: color-mix(in srgb, var(--finger) 11%, var(--surface)); color: var(--muted); transition: transform .12s ease, background .12s ease, color .12s ease; }
.finger-marker b { font-size: .72rem; font-weight: 600; }
.finger-marker small { font-size: .6rem; opacity: .72; }
.finger-marker.active { transform: translateY(-5px); border-color: var(--finger); background: color-mix(in srgb, var(--finger) 44%, var(--surface)); color: var(--text); }
.hand-gap { flex: 0 0 46px; }
.word-complete .finger-marker { opacity: .45; transform: none; }
.key-trace-layer { position: absolute; inset: 0; z-index: 5; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.key-trace-layer path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.trace-expected { stroke: var(--line-strong); stroke-width: 1.3; stroke-dasharray: 4 5; opacity: .55; }
.trace-correct { stroke: #55a86a; stroke-width: 2.7; opacity: .92; }
.trace-error { stroke: #dc514b; stroke-width: 3.2; opacity: .96; }
.arrow-expected { fill: var(--line-strong); opacity: .65; }
.arrow-correct { fill: #55a86a; }
.arrow-error { fill: #dc514b; }
.trace-dot-correct { fill: #55a86a; stroke: var(--surface); stroke-width: 1.2; }
.trace-dot-error { fill: #dc514b; stroke: var(--surface); stroke-width: 1.2; }

.empty-state { flex: 1; display: grid; place-content: center; justify-items: center; text-align: center; }
.empty-glyph { margin-bottom: 23px; color: var(--accent); font: 500 4rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.empty-state h1 { margin: 0 0 8px; font-size: 1.55rem; }
.empty-state p { margin: 0 0 24px; color: var(--muted); }
.session-summary { width: min(980px, 100%); margin: 28px auto 0; }
.summary-heading { display: flex; align-items: end; justify-content: space-between; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.summary-heading h2 { margin: 0; font-size: 1.55rem; }
.summary-score { text-align: right; }
.summary-score strong { display: block; color: var(--accent); font: 500 2.3rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.summary-score span { color: var(--muted); font-size: .72rem; }
.summary-grid { display: grid; grid-template-columns: 1.35fr .65fr; border: 1px solid var(--line); border-top: 0; }
.summary-card { min-height: 265px; padding: 21px; }
.summary-card + .summary-card { border-left: 1px solid var(--line); }
.summary-card-head { display: flex; justify-content: space-between; gap: 15px; }
.summary-card h3 { margin: 0; font-size: .95rem; }
.summary-card p { margin: 3px 0 0; color: var(--muted); font-size: .72rem; }
.summary-card-head > strong { color: var(--accent); font: 600 .82rem/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.wpm-curve { width: 100%; height: 190px; overflow: visible; }
.curve-gridline { fill: none; stroke: var(--line); stroke-width: 1; }
#wpmCurve { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
#wpmPoints circle { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.session-mistakes { max-height: 206px; margin-top: 15px; overflow: auto; }
.session-mistake { display: grid; gap: 2px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.session-mistake strong { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
.session-mistake span { color: var(--muted); font-size: .76rem; }
.perfect-round { color: var(--muted); padding-top: 45px; text-align: center; }
.perfect-round b { color: var(--accent); margin-right: 8px; }
.summary-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 16px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 32px auto 30px; max-width: 1180px; }
.page-head h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); letter-spacing: -.035em; }
.page-head .muted { margin: 6px 0 0; }
.head-actions { display: flex; gap: 8px; }
.toolbar { max-width: 1180px; margin: 0 auto 10px; display: flex; justify-content: space-between; gap: 10px; }
.bulk-actions { max-width: 1180px; min-height: 43px; margin: 0 auto 10px; padding: 7px 10px 7px 14px; border: 1px solid var(--line); background: var(--surface-2); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bulk-actions strong { font: 650 .78rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.bulk-actions > div { display: flex; align-items: center; gap: 7px; }
.search-box { width: min(420px, 100%); display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 4px 0 8px; color: var(--muted); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.table-card { max-width: 1180px; margin: 0 auto; border: 1px solid var(--line); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: var(--surface-2); font: 600 .7rem/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 72%, transparent); }
.star-column { width: 58px; text-align: center; }
.select-column { width: 42px; text-align: center; }
.select-column input, .word-select { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.english-cell { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-weight: 650; }
.level-bar { width: 92px; height: 3px; background: var(--line); }
.level-bar span { display: block; height: 100%; background: var(--accent); }
.row-actions { display: flex; justify-content: flex-end; gap: 11px; }
.row-action { border: 0; padding: 3px; background: transparent; color: var(--muted); font-size: .76rem; cursor: pointer; }
.star-word { color: var(--muted); font-size: 1.15rem; }
.star-word.active { color: var(--accent); }
.table-empty, .no-data { padding: 45px 20px; color: var(--muted); text-align: center; }

.stat-grid { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); }
.stat-card { min-height: 140px; padding: 21px; border-right: 1px solid var(--line); }
.stat-card:last-child { border-right: 0; }
.stat-card span, .stat-card small { color: var(--muted); font-size: .76rem; }
.stat-card strong { display: block; margin: 16px 0 5px; font: 500 2.25rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.stat-card.accent strong { color: var(--accent); }
.stats-lower { max-width: 1180px; margin: 12px auto 0; display: grid; grid-template-columns: 1.2fr .8fr; border: 1px solid var(--line); }
.mode-stats-card { max-width: 1180px; margin: 12px auto 0; border: 1px solid var(--line); padding: 20px 22px; }
.mode-stats-table { margin-top: 16px; border-top: 1px solid var(--line); }
.mode-stat-row { display: grid; grid-template-columns: minmax(110px, 1.5fr) repeat(4, minmax(70px, 1fr)); gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--muted); font: .78rem/1.35 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.mode-stat-row strong { color: var(--text); font-family: inherit; }
.mode-stat-row span { text-align: right; }
.mode-stats-empty { padding: 28px 12px; }
.chart-card, .weak-card { min-height: 365px; padding: 22px; }
.chart-card { border-right: 1px solid var(--line); }
.card-head { display: flex; justify-content: space-between; gap: 20px; }
.card-head h2 { font-size: 1rem; }
.card-head p { margin: 3px 0 0; font-size: .76rem; }
.chart-total { color: var(--accent); font: 600 .78rem/1.2 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.bar-chart { height: 260px; display: flex; align-items: stretch; gap: 8px; padding-top: 36px; }
.bar-item { flex: 1; display: flex; flex-direction: column; gap: 8px; text-align: center; }
.bar-wrap { flex: 1; display: flex; align-items: flex-end; border-bottom: 1px solid var(--line); }
.bar { width: 100%; min-height: 2px; background: var(--accent); position: relative; }
.bar::before { content: attr(data-value); position: absolute; left: 50%; top: -22px; transform: translateX(-50%); color: var(--muted); font: .68rem/1 monospace; }
.bar-label { color: var(--muted); font-size: .68rem; }
.weak-list { margin-top: 25px; }
.weak-row { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.weak-word { display: grid; }
.weak-word strong { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
.weak-word small { color: var(--muted); }
.weak-rate { color: var(--red); font-size: .78rem; }

.dialog { width: min(540px, calc(100vw - 28px)); max-height: calc(100vh - 28px); padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.dialog::backdrop { background: rgba(0, 0, 0, .72); }
.large-dialog { width: min(820px, calc(100vw - 28px)); }
.dialog-shell { padding: 24px; }
.dialog-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.dialog-head h2 { font-size: 1.35rem; }
.dialog-head .muted { margin: 5px 0 0; }
.close-button { width: 31px; height: 31px; border: 1px solid var(--line); border-radius: 3px; background: transparent; color: var(--muted); font-size: 1.25rem; }
.import-tabs { display: flex; gap: 22px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.import-tab { border: 0; border-bottom: 2px solid transparent; padding: 0 0 9px; background: transparent; color: var(--muted); cursor: pointer; }
.import-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.import-pane { display: none; position: relative; }
.import-pane.active { display: block; }
.field-label { display: grid; gap: 7px; margin: 14px 0; color: var(--muted); font-size: .8rem; }
textarea, .field-label input, .preview-table input { width: 100%; border: 1px solid var(--line); border-radius: 3px; padding: 11px 12px; outline: 0; background: var(--bg); color: var(--text); }
textarea:focus, .field-label input:focus, .preview-table input:focus { border-color: var(--accent); }
.sample-button { position: absolute; right: 9px; bottom: 9px; padding: 6px 9px; font-size: .72rem; }
.drop-zone { min-height: 240px; border: 1px dashed var(--line-strong); display: grid; place-content: center; justify-items: center; gap: 7px; padding: 28px; cursor: pointer; text-align: center; background: var(--bg); }
.drop-zone.dragging { border-color: var(--accent); }
.drop-zone input { display: none; }
.drop-zone small, .file-status, .parse-message { color: var(--muted); font-size: .8rem; }
.import-note { margin: 8px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.6; }
.upload-icon { color: var(--accent); font: 400 2rem/1 monospace; }
.file-status, .parse-message { min-height: 20px; margin: 9px 0 0; }
.parse-message.error { color: var(--red); }
.dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-top: 21px; padding-top: 17px; border-top: 1px solid var(--line); }
.dialog-actions > div { display: flex; gap: 8px; }
.replace-choice { color: var(--muted); font-size: .8rem; }
.replace-choice input { accent-color: var(--accent); }
.mode-guide-copy { display: grid; gap: 9px; padding: 2px 0 18px; color: var(--muted); }
.mode-guide-copy p { margin: 0; }
.mode-guide-copy strong { color: var(--text); font-weight: 650; }
.check-row { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .82rem; cursor: pointer; }
.check-row input { accent-color: var(--accent); }
.config-section { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 22px; padding: 17px 0; border-top: 1px solid var(--line); }
.config-section:first-of-type { border-top: 0; padding-top: 0; }
.config-section h3 { margin: 0 0 4px; font-size: .95rem; }
.config-section p { margin: 0; color: var(--muted); font-size: .8rem; }
.config-wide { min-width: 0; grid-column: 1 / -1; }
.voice-config-section { align-items: stretch; }
.voice-row { display: grid; grid-template-columns: 44px minmax(130px, 1fr) minmax(145px, .75fr) auto; align-items: center; gap: 10px; margin-top: 12px; }
.voice-row > strong { font-size: .82rem; }
.voice-row select { min-width: 0; width: 100%; border: 1px solid var(--line); border-radius: 3px; padding: 8px 9px; background: var(--bg); color: var(--text); font-size: .78rem; }
.rate-control { display: grid; grid-template-columns: auto 1fr 42px; align-items: center; gap: 7px; color: var(--muted); font-size: .72rem; white-space: nowrap; }
.rate-control input { width: 100%; accent-color: var(--accent); }
.rate-control output { color: var(--text); font: .72rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace; text-align: right; }
.config-section .voice-note { margin-top: 10px; font-size: .72rem; }
.file-button { display: inline-block; text-align: center; }
.hidden-file { display: none; }
.config-message { min-height: 20px; margin: 12px 0 0; color: var(--muted); font-size: .8rem; }
.config-message.error { color: var(--red); }
.preview-table-wrap { max-height: 54vh; overflow: auto; border: 1px solid var(--line); }
.preview-table td { padding: 7px; }
.preview-table th { position: sticky; top: 0; z-index: 2; }
.preview-table input { padding: 8px 9px; }
.preview-table input.unresolved:placeholder-shown { border-color: color-mix(in srgb, var(--red) 55%, var(--line)); }
.preview-table input.unresolved::placeholder { color: var(--red); opacity: .78; }
.preview-table input.loading-meaning { color: var(--muted); }
.preview-table input.loading-meaning::placeholder { color: var(--muted); opacity: .72; }
.toast { position: fixed; left: 50%; bottom: 23px; transform: translate(-50%, 12px); opacity: 0; pointer-events: none; z-index: 100; border: 1px solid var(--line-strong); border-radius: 3px; padding: 9px 13px; background: var(--text); color: var(--bg); font-size: .8rem; transition: .18s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.translation-progress { position: fixed; left: 50%; bottom: 22px; z-index: 95; width: min(430px, calc(100vw - 30px)); transform: translateX(-50%); border: 1px solid var(--line-strong); border-radius: 4px; padding: 11px 13px 10px; background: color-mix(in srgb, var(--panel) 94%, transparent); box-shadow: 0 10px 34px rgba(0, 0, 0, .22); backdrop-filter: blur(10px); }
.translation-progress > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--muted); font-size: .78rem; }
.translation-progress strong { color: var(--text); font: .75rem/1 ui-monospace, "SFMono-Regular", Consolas, monospace; }
.translation-progress-track { overflow: hidden; height: 3px; margin-top: 9px; background: var(--line); }
.translation-progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .25s ease; }
.translation-progress.complete .translation-progress-track span { background: var(--green); }

@media (max-width: 900px) {
  .topbar { padding: 0 17px; }
  .saved-note { display: none; }
  .view { padding: 17px; }
  .practice-layout { grid-template-columns: 1fr; }
  .session-panel { border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 17px; display: grid; grid-template-columns: 1fr 2fr auto; align-items: center; gap: 14px; }
  .mode-group { grid-template-columns: repeat(7, 1fr); }
  .mode { min-height: 34px; border: 0 !important; border-right: 1px solid var(--line) !important; }
  .mode:last-child { border-right: 0 !important; }
  .session-size-label, .session-progress, .today-goal, .session-panel > .secondary { display: none; }
  .typing-stage { min-height: 580px; padding: 22px 25px; }
  .meaning-block { margin-top: 38px; }
  .keyboard-key { height: 36px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card:nth-child(2) { border-right: 0; }
  .stat-card:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .stats-lower { grid-template-columns: 1fr; }
  .chart-card { border-right: 0; border-bottom: 1px solid var(--line); }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-card + .summary-card { border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 620px) {
  .topbar { height: 54px; padding: 0 11px; }
  .brand { font-size: .8rem; }
  .nav-tabs { gap: 17px; }
  .nav-tab { font-size: .82rem; }
  .icon-button { display: none; }
  .config-button { padding: 5px 8px !important; }
  .view { padding: 0; }
  .practice-layout { min-height: calc(100vh - 54px); border: 0; }
  .session-panel { grid-template-columns: 1fr; padding: 10px 12px; }
  .session-panel > div:first-child { display: none; }
  .mode-group { overflow-x: auto; }
  .mode { min-width: 60px; font-size: .75rem; }
  .typing-stage { min-height: calc(100vh - 99px); padding: 18px 15px; }
  .stage-topline { gap: 10px; }
  .stage-actions { justify-content: flex-end; gap: 12px; }
  .stage-actions .text-button, .auto-speak-toggle { font-size: .68rem; }
  .favorite-button { display: none; }
  .meaning-block { margin: 68px 0 18px; }
  .word-display { font-size: clamp(2rem, 12vw, 3.4rem); }
  .typing-hint { flex-direction: column; gap: 8px; }
  .keyboard-wrap { display: none; }
  .mini-stats { gap: 28px; margin-top: 16px; }
  .mini-stats dd { font-size: 1.15rem; }
  .session-summary { margin-top: 18px; }
  .summary-heading { align-items: flex-start; }
  .summary-score strong { font-size: 1.7rem; }
  .summary-card { min-height: 230px; padding: 15px; }
  .wpm-curve { height: 160px; }
  .summary-actions { display: grid; grid-template-columns: 1fr; padding-bottom: 16px; }
  .summary-actions .primary { order: -1; }
  .page-head { display: block; margin: 25px 15px 22px; }
  .head-actions { margin-top: 16px; }
  .toolbar { margin: 0 15px 10px; flex-wrap: wrap; }
  .bulk-actions { margin: 0 15px 10px; align-items: flex-start; flex-direction: column; padding: 10px; }
  .bulk-actions > div { width: 100%; flex-wrap: wrap; }
  .search-box { width: 100%; }
  .table-card { border-inline: 0; }
  th:nth-child(5), td:nth-child(5), th:nth-child(7), td:nth-child(7) { display: none; }
  th, td { padding: 11px 8px; }
  .stat-grid, .stats-lower, .mode-stats-card { border-inline: 0; }
  .mode-stats-card { padding: 16px 15px; }
  .mode-stat-row { grid-template-columns: 1.25fr repeat(2, 1fr); gap: 7px; }
  .mode-stat-row span:nth-child(2), .mode-stat-row span:nth-child(3) { display: none; }
  .stat-card { min-height: 120px; padding: 15px; }
  .stat-card strong { font-size: 1.85rem; }
  .chart-card, .weak-card { min-height: 310px; padding: 16px; }
  .dialog-shell { padding: 18px 15px; }
  .dialog-actions { align-items: stretch; flex-direction: column; }
  .dialog-actions > div { display: grid; grid-template-columns: 1fr 1fr; }
  .config-section { grid-template-columns: 1fr; gap: 10px; }
  .config-section .secondary { width: 100%; }
  .voice-row { grid-template-columns: 42px 1fr; }
  .voice-row .rate-control, .voice-row .secondary { grid-column: 2; }
}

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