/* app.css — mobile-first styles for Listening Cards. Light/dark via prefers-color-scheme,
   overridable with <html data-theme="light|dark">. Touch targets ≥ 48px; works at 320px.
   NOTE: there is intentionally no styling for audio progress/duration — none exists. */

:root {
  /* Pastel theme: lilac surfaces, lavender accent with dark text. Tone/grade colours are fixed. */
  --bg: #f7f3fa;
  --surface: #fffdfd;
  --surface-2: #efe8f5;
  --fg: #2f2740;
  --muted: #7d7391;
  --border: #e3d9ec;
  --accent: #b9a6e6;
  --accent-fg: #2a1f45;
  --accent-soft: #ece4f7;
  --accent-text: #6f56b8; /* accent used as text/borders needs more contrast on light surfaces */
  --danger: #c04a5a;
  --ok: #3f9a6e;
  --t1: #e30000; /* tone colours: Pleco scheme (also used by Hack Chinese): 1 red, 2 green, 3 blue, 4 purple, 5 grey */
  --t2: #02b31c;
  --t3: #1510f0;
  --t4: #8900bf;
  --t5: #777777;
  --g-again: #dc2626;
  --g-hard: #d97706;
  --g-good: #16a34a;
  --g-easy: #2563eb;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --font-zh: "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1924;
    --surface: #27232f;
    --surface-2: #322d3d;
    --fg: #f1ecf7;
    --muted: #a99fbd;
    --border: #3d3749;
    --accent: #cdbcf0;
    --accent-fg: #221a38;
    --accent-soft: #3a3150;
    --accent-text: #cdbcf0;
    --danger: #f87171;
    --ok: #4ade80;
    --t1: #ff5a5a; /* Pleco hues, lightened for dark backgrounds */
    --t2: #35d64d;
    --t3: #6b8cff;
    --t4: #c86dff;
    --t5: #9a9a9a;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  }
}
:root[data-theme="dark"] {
  --bg: #1c1924;
  --surface: #27232f;
  --surface-2: #322d3d;
  --fg: #f1ecf7;
  --muted: #a99fbd;
  --border: #3d3749;
  --accent: #cdbcf0;
  --accent-fg: #221a38;
  --accent-soft: #3a3150;
  --accent-text: #cdbcf0;
  --danger: #f87171;
  --ok: #4ade80;
  --t1: #ff5a5a; /* Pleco hues, lightened for dark backgrounds */
  --t2: #35d64d;
  --t3: #6b8cff;
  --t4: #c86dff;
  --t5: #9a9a9a;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 var(--font);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: var(--accent-text); }
code { font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 6px; }
h1 { font-size: 1.5rem; margin: 0.25rem 0 1rem; line-height: 1.2; }
h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.25rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.row { display: flex; align-items: center; }
.row.gap { gap: 0.5rem; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 0; min-width: 0; }

/* ---- Top bar ------------------------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 0.25rem;
  padding: calc(env(safe-area-inset-top) + 4px) 8px 4px;
  min-height: 56px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 0.4rem; text-decoration: none; color: var(--fg); padding: 0 6px; min-height: 48px; align-items: center; }
.brand-zh { font-family: var(--font-zh); font-weight: 700; font-size: 1.25rem; color: var(--accent-text); }
.brand-en { font-weight: 600; font-size: 0.95rem; }
.topbar-spacer { flex: 1; }
body[data-route="study"] .topbar { display: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 48px; min-height: 48px; padding: 0 8px;
  border: 0; border-radius: 12px; background: transparent; color: var(--fg);
  font-size: 1.35rem; text-decoration: none; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.small { min-width: 40px; min-height: 40px; font-size: 1rem; }

/* ---- Layout -------------------------------------------------------------------------------- */
main { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 640px; margin: 0 auto; outline: none; }
.screen { padding: 16px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card.danger { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }

.loading { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; text-align: center; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.banner { background: #fef3c7; color: #78350f; padding: 8px 16px; font-size: 0.9rem; text-align: center; }

/* ---- Buttons & form controls --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 48px; padding: 0 18px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--fg);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  touch-action: manipulation; user-select: none;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.warn { color: var(--danger); }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 56px; font-size: 1.1rem; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 0.9rem; }
.file-btn input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-btn { position: relative; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }

input, select, textarea { font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
input[type="search"], input[type="number"], select, textarea { min-height: 44px; padding: 8px 10px; max-width: 100%; }
textarea { width: 100%; resize: vertical; font-family: var(--font); }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.field.stacked { flex-direction: column; align-items: stretch; }
.field select { min-width: 0; flex: 1 1 auto; max-width: 65%; }

/* ---- Home ---------------------------------------------------------------------------------- */
.empty { text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: stretch; padding: 24px 4px; }
.empty-glyph { font-family: var(--font-zh); font-size: 72px; line-height: 1; color: var(--accent-text); margin: 8px auto; width: 120px; height: 120px; display: grid; place-items: center; background: var(--accent-soft); border-radius: 28px; }
.tiles { display: grid; gap: 12px; grid-template-columns: 1fr; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.tile.last { border-color: var(--accent); }
.tile-head { display: flex; gap: 12px; align-items: center; }
.tile-head h2 { margin: 0; }
.tile-head p { margin: 0; }
.tile-zh { font-family: var(--font-zh); font-size: 1.6rem; width: 48px; height: 48px; flex: none; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); border-radius: 12px; }
.counts { margin: 0; font-size: 0.95rem; }
.counts .due { font-weight: 700; color: var(--accent-text); }
.counts .new { font-weight: 700; }
.today { margin: -2px 0 0; color: var(--fg); }
.today:empty { display: none; }
.today .saved { color: var(--ok); font-weight: 600; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 6px; display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.stat strong { font-size: 1.3rem; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---- Import -------------------------------------------------------------------------------- */
.mapping { display: grid; gap: 6px; }
.table-wrap { overflow-x: auto; max-width: 100%; }
.preview-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.preview-table th, .preview-table td { text-align: left; padding: 6px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.preview-table .hz { font-family: var(--font-zh); font-size: 1.05rem; white-space: nowrap; }
.preview-table .def { overflow-wrap: anywhere; }
.preview-table .ok { color: var(--ok); }
.hsk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.check { display: flex; align-items: center; gap: 6px; white-space: nowrap; min-height: 48px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.check .muted { margin-left: auto; }

/* ---- Vocab --------------------------------------------------------------------------------- */
.search { width: 100%; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--fg); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 0.85rem; min-height: 36px; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.chip.status { min-height: 0; padding: 2px 8px; font-size: 0.75rem; cursor: default; flex: none; }
.chip.status.review { color: var(--ok); }
.chip.status.learning { color: var(--g-hard); }
.chip.status.suspended { color: var(--danger); }
.vocab-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.vocab-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); min-height: 56px; user-select: none; }
.vocab-row .hz { font-family: var(--font-zh); font-size: 1.35rem; min-width: 3.2em; }
.vocab-row .grow { display: flex; flex-direction: column; }
.vocab-row .def { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audio-flag { color: var(--border); font-size: 1.1rem; }
.audio-flag.has { color: var(--accent-text); }

/* ---- Settings ------------------------------------------------------------------------------ */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; border-bottom: 1px solid var(--border); padding: 4px 0; }
.setting:last-child { border-bottom: 0; }
.setting > span { display: flex; flex-direction: column; min-width: 0; }
.setting select, .setting input[type="number"] { max-width: 55%; }
.setting input[type="number"] { width: 6em; text-align: right; }
.sources { margin: 0; padding-left: 1.2em; }
.sources li { margin: 4px 0; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 0.9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

/* ---- Study --------------------------------------------------------------------------------- */
body[data-route="study"] main { max-width: 640px; }
.study { flex: 1; padding: 0; gap: 0; height: 100vh; height: 100dvh; }
.study-bar { display: flex; align-items: center; gap: 4px; padding: calc(env(safe-area-inset-top) + 4px) 8px 4px; min-height: 56px; }
.mode-name { font-weight: 700; flex: 1; }
.session-count { font-variant-numeric: tabular-nums; color: var(--muted); padding: 0 6px; }
.icon-btn.undo { font-size: 1.4rem; min-width: 44px; }
.icon-btn.undo:disabled { opacity: 0.3; cursor: default; }
.icon-btn.undo:disabled:hover { background: transparent; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: 100%; z-index: 20; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 200px; padding: 4px; }
.menu button { min-height: 48px; text-align: left; padding: 0 14px; border: 0; background: transparent; color: var(--fg); font: inherit; border-radius: 8px; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }

.card-area {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  margin: 0 12px; padding: 20px 12px; min-height: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow);
  overflow-y: auto; overflow-x: hidden;
}
/* Controls are anchored at the top on both sides so hints (front) or the answer (back) grow
   downward and the play/rewind buttons never move under the thumb. */
.card-area { justify-content: flex-start; }
.card-area:not(.revealed) { padding-top: clamp(20px, 9vh, 72px); }
.reveal-zone { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; cursor: pointer; z-index: 1; }

/* Replay: one big round button. Only a pulsing ring while playing — no time UI of any kind. */
.replay {
  position: relative; z-index: 2;
  width: 128px; height: 128px; border-radius: 50%;
  border: 0; background: var(--accent); color: var(--accent-fg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font: inherit; cursor: pointer; touch-action: manipulation; flex: none;
  box-shadow: 0 6px 24px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform 0.1s ease;
  /* Room for the pulse ring, which grows ~24px past the edge (~16px on the small button), so it
     never runs into the label above or the transport buttons below. */
  margin: 12px 0;
}
.replay:active { transform: scale(0.96); }
.replay-icon { display: block; width: 56px; height: 56px; line-height: 0; }
.replay-icon svg { width: 100%; height: 100%; fill: currentColor; display: block; }
/* The hint sits under the icon without moving it, so the icon stays centred in every state. */
.replay-hint { position: absolute; left: 0; right: 0; bottom: 16px; text-align: center; font-size: 0.8rem; font-weight: 600; line-height: 1; }
.replay-hint:empty { display: none; }
.replay.blocked .replay-icon { width: 44px; height: 44px; }
.replay.playing::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 3px solid var(--accent); opacity: 0.6; animation: pulse 1.2s ease-out infinite;
}
@keyframes pulse { from { transform: scale(1); opacity: 0.6; } to { transform: scale(1.25); opacity: 0; } }
.replay.small { width: 64px; height: 64px; margin: 6px 0; }
.replay.small .replay-icon { width: 30px; height: 30px; }
.replay.small .replay-hint { font-size: 0.6rem; bottom: 5px; }
@media (prefers-reduced-motion: reduce) { .replay.playing::after { animation: none; opacity: 0.5; } }
.replay.paused { background: color-mix(in srgb, var(--accent) 80%, var(--surface)); }

/* Transport row: restart + relative rewinds. Small steps are meant to be tapped repeatedly, so
   the buttons are wide, react instantly and never move. No time or position is shown. */
.transport {
  position: relative; z-index: 2;
  display: flex; gap: 8px; justify-content: center; flex-wrap: nowrap; width: 100%; max-width: 300px;
}
.tbtn {
  flex: 1 1 0; min-width: 0; height: 48px; padding: 0 4px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2, var(--surface));
  color: var(--fg); font: inherit; font-size: 0.95rem; font-weight: 600; font-variant-numeric: tabular-nums;
  cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.tbtn:active { background: var(--accent-soft); border-color: var(--accent); }
.tbtn:first-child { flex: 0 0 48px; font-size: 1.35rem; }
.transport.small .tbtn { height: 40px; font-size: 0.85rem; }
.transport.small .tbtn:first-child { flex-basis: 40px; font-size: 1.15rem; }

/* 0.25× slow-down toggle (pitch preserved), in the transport row. */
.tbtn.speed-toggle.active { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }


.answer { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; text-align: center; }
.hanzi { font-family: var(--font-zh); font-size: clamp(56px, 18vw, 88px); line-height: 1.1; font-weight: 500; }
.trad { font-family: var(--font-zh); font-size: 1.3rem; }
.pinyin { font-size: 1.1rem; }
.pinyin.big { font-size: 1.6rem; font-weight: 500; }
.tones .t1, .py.t1 { color: var(--t1); }
.tones .t2, .py.t2 { color: var(--t2); }
.tones .t3, .py.t3 { color: var(--t3); }
.tones .t4, .py.t4 { color: var(--t4); }
.tones .t5, .py.t5 { color: var(--t5); }
.defs { list-style: none; margin: 0; padding: 0; color: var(--fg); }
.defs li { margin: 2px 0; }
.defs li + li { color: var(--muted); }
.badge { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); }

/* Sentence: tokens wrap; each token is a 2-row grid (hanzi / pinyin), one column per char. */
.sentence { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; padding: 4px 0; }
/* Default: no word gaps, as Chinese is written. "tight" keeps 1.9em columns for the pinyin row
   but no extra gap; "spaced" is the optional hint. */
.sentence.unspaced { gap: 6px 0; }
.sentence.unspaced .tok { padding: 4px 0; grid-auto-columns: auto; }
.sentence.tight { gap: 6px 0; }
.sentence.tight .tok { padding: 4px 0; }
.tok {
  display: inline-grid; grid-template-rows: auto auto; grid-auto-flow: column; grid-auto-columns: minmax(1.9em, auto);
  justify-items: center; padding: 4px 3px; border-radius: 8px; cursor: pointer; min-height: 48px;
}
.tok:hover, .tok:focus-visible { background: var(--surface-2); }
.tok .hz { font-family: var(--font-zh); font-size: 1.75rem; line-height: 1.2; grid-row: 1; }
.tok .py { font-size: 0.72rem; line-height: 1.2; grid-row: 2; color: var(--muted); white-space: nowrap; user-select: none; -webkit-user-select: none; }
/* Characters take the tone colour of their syllable (same Pleco scheme as the pinyin). */
.tok .hz.t1, .hanzi .hz.t1 { color: var(--t1); }
.tok .hz.t2, .hanzi .hz.t2 { color: var(--t2); }
.tok .hz.t3, .hanzi .hz.t3 { color: var(--t3); }
.tok .hz.t4, .hanzi .hz.t4 { color: var(--t4); }
.tok .hz.t5, .hanzi .hz.t5 { color: var(--t5); }
.tok .py.t1 { color: var(--t1); }
.tok .py.t2 { color: var(--t2); }
.tok .py.t3 { color: var(--t3); }
.tok .py.t4 { color: var(--t4); }
.tok .py.t5 { color: var(--t5); }
.translation { margin: 4px 0 0; font-size: 1.05rem; color: var(--fg); }
.card-tools { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.chip.toggle {
  border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--muted);
  font: inherit; font-size: 0.78rem; font-weight: 600; padding: 4px 12px; cursor: pointer; touch-action: manipulation;
}
.chip.toggle.on { border-color: var(--accent-text); color: var(--accent-text); background: var(--accent-soft); }
.sentence.no-pinyin .tok { grid-template-rows: auto; row-gap: 0; }
.tok[data-known="false"] .hz { text-decoration: underline dotted var(--muted); text-underline-offset: 5px; text-decoration-thickness: 2px; }

.popover {
  position: absolute; z-index: 5;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 8px 32px rgb(0 0 0 / 18%);
  padding: 10px 12px; text-align: left; display: flex; flex-direction: column; gap: 6px;
}
.pop-head { display: flex; align-items: center; gap: 8px; }
.pop-alt { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--border); font-size: 0.9rem; }
.pop-alt ul { margin-top: 2px; }
.pop-hz { font-family: var(--font-zh); font-size: 1.6rem; }
.pop-head .pinyin { flex: 1; }
.pop-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.popover .defs li + li { color: var(--fg); }

.actions { padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }
.grades { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.grade { flex-direction: column; gap: 0; min-height: 60px; padding: 4px 2px; }
.grade-label { font-size: 0.95rem; }
.grade-ivl { font-size: 0.75rem; font-weight: 500; color: var(--muted); }
.grade-again .grade-label { color: var(--g-again); }
.grade-hard .grade-label { color: var(--g-hard); }
.grade-good .grade-label { color: var(--g-good); }
.grade-easy .grade-label { color: var(--g-easy); }
.summary { text-align: center; display: flex; flex-direction: column; gap: 12px; width: 100%; }
.summary .stats { width: 100%; }

/* ---- Toast --------------------------------------------------------------------------------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 50;
  width: max-content; max-width: calc(100vw - 24px);
  display: flex; align-items: center; gap: 12px;
  background: var(--fg); color: var(--bg); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); font-size: 0.95rem;
}
.toast-action { background: transparent; border: 0; color: var(--accent); font: inherit; font-weight: 700; min-height: 40px; padding: 0 6px; cursor: pointer; }
body[data-route="study"] .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }

/* Local data & activity screen */
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.95rem; }
.kv > span { flex: 0 0 auto; }
.kv > strong { text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.activity h3 { font-size: 1rem; margin: 16px 0 6px; }
table.plain { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
table.plain th, table.plain td { text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--border); }
table.plain th:first-child, table.plain td:first-child { text-align: left; }
table.plain tr.muted { color: var(--muted); }
ul.log { list-style: none; margin: 0; padding: 0; font-size: 0.92rem; }
ul.log li { padding: 6px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
ul.log .grade-again { color: var(--g-again); font-weight: 700; }
ul.log .grade-hard { color: var(--g-hard); font-weight: 700; }
ul.log .grade-good { color: var(--g-good); font-weight: 700; }
ul.log .grade-easy { color: var(--g-easy); font-weight: 700; }

/* Hints on the card front: revealed syllables (pinyin, optionally with the character) + button.
   Sits above the tap-to-reveal zone so tapping a hint never reveals the answer. */
.hints { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 4px; max-width: 100%; }
.hint-strip { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 6px; max-width: 100%; }
.hint-syl {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 40px; min-height: 40px;
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
  color: var(--fg); font: inherit; cursor: pointer; touch-action: manipulation;
}
.hint-syl .hint-py { font-size: 1.05rem; font-weight: 600; }
.hint-syl .hint-hz { font-family: var(--font-zh); font-size: 1.5rem; line-height: 1.1; }
.hint-syl.with-char { border-color: var(--accent-text); }
.hint-more { color: var(--muted); font-size: 1.2rem; padding: 0 2px 6px; }
.hint-btn:disabled { opacity: 0.5; cursor: default; }
.hint-tip { margin: -4px 0 0; }
