/* Quiet typography and outlined controls, inspired by the reference app. */
:root {
  color-scheme: light;
  --bg: #f3f0e7; --panel: #f3f0e7; --panel-2: #e9e6dc;
  --border: #cccfc5; --text: #14282b; --muted: #626e69;
  --accent: #174e42; --accent-fg: #f8f5e9;
  --danger: #ae4037; --ok: #157758; --warn: #90601d;
  --shadow: 0 20px 70px #162a2914;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a1b20; --panel: #10252a; --panel-2: #163036;
    --border: #304448; --text: #f5f2e6; --muted: #9baaa8;
    --accent: #f5f2e6; --accent-fg: #0a1b20;
    --danger: #f29d91; --ok: #20d99a; --warn: #dec28b;
    --shadow: 0 20px 70px #0005;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a1b20; --panel: #10252a; --panel-2: #163036;
  --border: #304448; --text: #f5f2e6; --muted: #9baaa8;
  --accent: #f5f2e6; --accent-fg: #0a1b20;
  --danger: #f29d91; --ok: #20d99a; --warn: #dec28b;
  --shadow: 0 20px 70px #0005;
}
body { background: radial-gradient(ellipse at 85% 90%, #408b7810, transparent 65%), var(--bg); font-size: 15px; -webkit-font-smoothing: antialiased; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--ok); outline-offset: 4px; }
input, select { accent-color: var(--ok); }
.btn { min-height: 42px; padding: 9px 19px; border-radius: 999px; background: transparent; border-color: var(--border); transition: background .18s, border-color .18s; }
.btn:hover { background: var(--panel-2); border-color: var(--text); color: var(--text); }
.btn.primary { background: transparent; color: var(--text); border: 1.5px solid var(--text); }
.btn.primary:hover { background: var(--text); color: var(--bg); opacity: 1; }
.btn:disabled { opacity: .4; }
.btn.icon { width: 42px; height: 42px; padding: 0; border-radius: 50%; font-size: 19px; }
.inp { border-radius: 12px; background: transparent; min-height: 44px; padding: 10px 14px; }
.inp:focus { border-color: var(--text); box-shadow: 0 0 0 2px var(--border); }
select option { background: var(--panel); color: var(--text); }
textarea { line-height: 1.65; }
header { background: transparent; padding: 22px 40px; border-bottom: 1px solid var(--border); gap: 22px; }
header .logo { font-size: 17px; letter-spacing: -.6px; }
header .ver { display: block; margin: 3px 0 0; font-size: 10px; letter-spacing: .6px; }
header .who { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.tabs { position: relative; background: transparent; gap: 6px; padding: 0; }
.tabs button { position: relative; z-index: 1; min-height: 42px; padding: 8px 24px; border-radius: 999px; border: 1px solid transparent; transition: color .2s; }
.tabs button.on { background: transparent; border-color: transparent; box-shadow: none; }
.tab-indicator { position: absolute; top: 0; left: 0; border: 1px solid var(--text); border-radius: 999px; pointer-events: none; transition: transform .36s cubic-bezier(.22, 1, .36, 1), width .36s cubic-bezier(.22, 1, .36, 1), height .2s; }
.overview { flex: 1; min-height: 0; overflow-y: auto; padding: 54px 64px 48px; display: flex; flex-direction: column; gap: 80px; }
.overview h1 { font-size: clamp(64px, 7.2vw, 112px); line-height: 1; letter-spacing: -.065em; font-weight: 850; margin: 24px 0 30px; }
.overview-balance { display: flex; flex-direction: column; gap: 8px; }
.overview-balance strong { font-size: clamp(56px, 6vw, 84px); line-height: 1; letter-spacing: -.055em; font-weight: 750; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.overview-balance > span { color: var(--muted); font-size: 14px; }
.overview-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 38px; }
.overview-actions .btn { min-height: 48px; padding: 10px 24px; font-size: 17px; }
.overview-actions .btn span { margin-right: 9px; }
.overview-stats { display: flex; gap: 100px; margin: auto 0 0; padding-top: 20px; }
.overview-stats dt { color: var(--muted); font-size: 16px; }
.overview-stats dd { margin: 10px 0 0; font-size: 32px; letter-spacing: -.7px; font-variant-numeric: tabular-nums; }
.btn:active:not(:disabled) { transform: scale(.97); }
main, #view-table { min-height: 0; }
main { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); isolation: isolate; }
main > [id^="view-"] { grid-area: 1 / 1; min-width: 0; position: relative; }
main > [inert] { pointer-events: none; }
.library-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; padding: 40px 40px 32px; flex: none; }
.eyebrow { color: var(--muted); font-size: 10px; font-weight: 500; letter-spacing: 2.5px; }
.library-heading h1 { font-size: clamp(38px, 4.5vw, 72px); line-height: 1.05; letter-spacing: -3px; margin: 13px 0 0; font-weight: 850; }
.heading-dot { color: var(--ok); }
.library-total { display: flex; flex-direction: column; text-align: right; gap: 5px; flex: none; }
.library-total strong { font-size: 48px; font-weight: 750; letter-spacing: -2px; line-height: 1; font-variant-numeric: tabular-nums; }
.library-total span { font-size: 9px; letter-spacing: 1.8px; color: var(--muted); }
.toolbar { padding: 16px 40px 24px; gap: 10px; border: 0; }
.toolbar #q { border-radius: 999px; min-width: 180px; }
.toolbar .count { flex-basis: 100%; margin: 4px 0 0; font-size: 11px; }
.table-wrap { padding: 0 40px 28px; }
table { font-size: 14px; }
thead th { background: var(--bg); font-weight: 400; color: var(--muted); }
.th-in { padding: 16px 12px; }
tbody td { padding: 18px 12px; line-height: 1.65; }
td.c-english { font-weight: 600; }
.th-f.on { background: var(--panel-2); }
.rankbox { gap: 7px; }
.rankbox button { border-radius: 50%; width: 28px; height: 28px; background: transparent; }
.rowdel { min-width: 32px; min-height: 32px; }
.card, .flash, .rc-edit { background: transparent; box-shadow: none; }
.center-wrap .card { max-width: 430px; padding: 40px 20px; border: 0; }
.card h1 { font-size: 48px; line-height: 1.15; font-weight: 850; letter-spacing: -2px; margin-bottom: 40px; }
.center-wrap .card label { margin-top: 22px; }
.center-wrap .card .btn { margin-top: 30px; min-height: 50px; }
.card .alt { margin-top: 24px; }
.recite { padding: 44px 40px; }
.setup { max-width: 660px; border: 0; padding: 0; }
.setup .row { margin-bottom: 0; padding: 15px 0; border-bottom: 1px solid var(--border); gap: 22px; }
.setup .row label { width: 90px; margin: 0; font-size: 14px; }
.setup .row .inp { min-width: 0; }
.setup input[type="range"] { border: 0; padding: 0; box-shadow: none; }
.setup .hint { margin: 18px 0; }
.setup #rc-start { margin-top: 32px; min-height: 54px; font-size: 18px; }
.bar { height: 2px; max-width: 820px; margin-bottom: 30px; }
.bar > i { background: var(--ok); }
.flash { border: 0; border-radius: 0; padding: 12px 0 40px; max-width: 820px; text-align: left; min-height: 310px; }
.flash .meta { justify-content: flex-start; align-items: center; gap: 10px; margin-bottom: 48px; }
.flash .chip { padding: 7px 12px; background: transparent; border: 1px solid var(--border); }
.flash .chip-btn { min-height: 36px; margin-left: auto; }
.flash .front { font-size: clamp(28px, 3.6vw, 48px); font-weight: 750; line-height: 1.4; letter-spacing: -.8px; }
.flash .front .mn { margin-top: 28px; font-size: 17px; line-height: 1.8; letter-spacing: 0; }
.flash .back { border-top-style: solid; padding-top: 28px; margin-top: 30px; }
.flash .back .v.en { font-size: 28px; }
/* 朗读按钮：和卡片顶部 ← Back / ✎ Edit 同一套描边胶囊；朗读中用绿色（同 Remembered） */
.flash .back .speak { min-height: 32px; padding: 6px 12px; transition: border-color .18s, color .18s; }
.flash .back .speak:hover { border-color: var(--text); color: var(--text); }
.flash .back .speak.on { border-color: var(--ok); color: var(--ok); }
.acts { max-width: 820px; gap: 16px; }
.acts .btn { border-radius: 999px; min-height: 54px; }
#rc-good { border-color: var(--ok); color: var(--ok); }
.rc-edit { max-width: 820px; border-radius: 20px; padding: 24px; }
#rc-done { border: 0; max-width: 500px; }
.done .big { font-size: 72px; color: var(--ok); }
#rc-summary { font-size: 22px; line-height: 1.9; }
.mask { background: #020d12b8; backdrop-filter: blur(10px); }
.modal { border-radius: 24px; max-height: 88dvh; }
.modal-hd { padding: 22px 24px; }
.modal-hd strong { font-size: 22px; line-height: 1.2; letter-spacing: -.6px; }
.modal-bd { padding: 24px; }
.modal-ft { padding: 18px 24px; }
.modal-hd .btn { flex-shrink: 0; }
.modal .rc-edit { background: var(--panel); }
.fpop { border-radius: 18px; }
.fp-sec { padding: 12px; }
.fp-item { min-height: 34px; }
#toast { border-radius: 999px; max-width: calc(100vw - 32px); overflow-wrap: anywhere; }
@media (min-width: 1500px) {
  header, main { width: 100%; max-width: 1680px; margin-inline: auto; }
}
@media (max-width: 1100px) and (min-width: 769px) {
  header { padding: 18px 24px; gap: 14px; }
  header .who { max-width: 150px; }
  .library-heading { padding: 32px 24px 24px; }
  .toolbar { padding: 12px 24px 20px; }
  .table-wrap { padding-inline: 24px; }
}
@media (max-width: 768px) {
  #app { height: 100dvh; padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  header { padding: calc(16px + env(safe-area-inset-top)) 20px 14px; gap: 12px; border: 0; }
  header .logo { font-size: 16px; }
  header .ver { font-size: 9px; }
  header .btn { min-height: 38px; padding: 7px 14px; }
  header .btn.icon { width: 38px; height: 38px; padding: 0; }
  .tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 50; justify-content: center; gap: 8px; border-top: 1px solid var(--border); background: var(--bg); padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); }
  .tabs button { flex: 1; min-width: 0; max-width: 240px; min-height: 48px; font-size: 15px; padding-inline: 12px; }
  .tabs button.on { border-color: transparent; }
  .overview { padding: 32px 20px 30px; gap: 64px; }
  .overview h1 { font-size: clamp(44px, 12.5vw, 88px); letter-spacing: -.06em; margin: 24px 0 28px; }
  .overview-balance strong { font-size: 62px; }
  .overview-balance > span { font-size: 13px; }
  .overview-actions { gap: 12px; margin-top: 32px; }
  .overview-actions .btn { font-size: 16px; padding: 10px 20px; }
  .overview-stats { flex-direction: column; gap: 28px; }
  .overview-stats dt { font-size: 15px; }
  .overview-stats dd { font-size: 28px; margin-top: 6px; }
  #view-table { overflow-y: auto !important; display: block !important; }
  #view-table.hidden { display: none !important; }
  .library-heading { padding: 24px 20px 26px; display: block; }
  .eyebrow { font-size: 9px; letter-spacing: 2px; }
  .library-heading h1 { font-size: clamp(38px, 10.5vw, 64px); letter-spacing: -2.4px; margin-top: 12px; }
  .library-total { text-align: left; margin-top: 24px; gap: 7px; }
  .library-total strong { font-size: 42px; }
  .library-total span { font-size: 8px; }
  .toolbar { padding: 0 20px 20px; gap: 8px; }
  .toolbar #q { flex: 1 0 100%; width: 100%; min-width: 0; margin-bottom: 4px; }
  .toolbar .btn { padding: 8px 14px; min-height: 42px; }
  #m-sort { flex: 1; width: 0; min-width: 120px; border-radius: 999px; }
  #btn-clearfilter { order: 5; }
  #btn-clearfilter:disabled { display: none; }
  #btn-shuffle { order: 4; }
  #btn-more { order: 6; width: 42px; padding: 0; font-size: 22px; }
  .toolbar .count { order: 7; margin-top: 10px; }
  #more-wrap { top: 100%; right: 20px; border-radius: 18px; padding: 10px; }
  .table-wrap { overflow: visible; padding: 0 20px 24px; }
  .card-row { background: transparent; border: 0; border-top: 1px solid var(--border); border-radius: 0; margin: 0; }
  .cr-head { padding: 22px 0; gap: 14px; min-height: 86px; }
  .cr-content { font-size: 20px; font-weight: 600; letter-spacing: -.3px; line-height: 1.45; }
  .cr-sub { font-size: 14px; margin-top: 7px; }
  .cr-head > .rankval { border: 1px solid var(--border); border-radius: 50%; min-width: 36px; height: 36px; display: grid; place-items: center; font-size: 13px; }
  .cr-body { border-top-style: solid; padding: 18px 0 24px; }
  .cr-k { font-size: 12px; margin-top: 18px; }
  .cr-v { padding: 7px 0; line-height: 1.7; }
  .cr-foot .rankbox button { width: 36px; height: 36px; }
  .recite { padding: 26px 20px 28px; }
  .card h1 { font-size: 44px; margin-bottom: 28px; }
  .setup .row { gap: 12px; padding: 16px 0; }
  .setup .row label { width: 84px; font-size: 13px; }
  .setup .dat { gap: 8px; }
  .setup .dat input { flex: 1 1 140px; min-width: 0; width: 100%; max-width: 100%; }
  .setup .dat .btn { min-height: 36px; }
  .setup #rc-start { margin-top: 28px; }
  .flash { padding: 0 0 24px; min-height: 290px; }
  .flash .meta { gap: 6px; margin-bottom: 40px; flex-wrap: wrap; }
  .flash .front { font-size: 30px; }
  .flash .front .mn { font-size: 16px; }
  .flash .back .v.en { font-size: 24px; }
  .acts { gap: 12px; }
  .acts .btn { border-radius: 999px; font-size: 16px; }
  .mask { padding: max(12px, env(safe-area-inset-top)) 0 0; align-items: flex-end; }
  .modal { border-radius: 24px 24px 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
  .modal-hd { padding: 20px 18px; gap: 8px; }
  .modal-hd strong { font-size: 20px; }
  .modal-hd .btn { padding: 8px 12px; }
  .modal-bd { padding: 18px; }
  .modal-ft { padding: 14px 18px; gap: 8px; }
  .modal-ft .btn { min-height: 46px; font-size: 14px; }
  .im-row .inp { min-width: 0; width: 100%; }
  #im-paste, input, select, textarea, [contenteditable] { font-size: 16px; }
  .fpop { padding-bottom: env(safe-area-inset-bottom); }
  #toast { bottom: calc(94px + env(safe-area-inset-bottom)); }
}
@media (max-width: 360px) {
  header, .toolbar, .recite { padding-inline: 16px; }
  .library-heading { padding-inline: 16px; }
  .table-wrap { padding-inline: 16px; }
  .toolbar .btn { padding-inline: 11px; }
  .modal-ft .btn { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* v1.20: mobile Practice — tighter spacing and grading buttons pinned above the tab bar. */
@media (max-width: 768px) {
  .recite { padding: 14px 18px 8px; }
  .bar { margin-bottom: 14px; }
  .flash { padding: 0 0 12px; min-height: 0; }
  .flash .meta { margin-bottom: 16px; }
  .flash .front { font-size: 24px; line-height: 1.35; }
  .flash .front .mn { margin-top: 12px; font-size: 15px; line-height: 1.6; }
  .flash .back { margin-top: 14px; padding-top: 14px; }
  .flash .back .v.en { font-size: 22px; }
  .flash .back .v { margin-bottom: 8px; }
  #rc-card { min-height: 100%; }
  #rc-card > .flash { flex: 1 0 auto; }
  #rc-acts-front, #rc-acts-back {
    position: sticky; bottom: 0; z-index: 5; margin-top: 8px;
    padding: 12px 0 10px; background: var(--bg);
    box-shadow: 0 -14px 12px -6px var(--bg);
  }
  .acts .btn { min-height: 50px; }
}
