/* Greek Vocabulary — clean, modern, functional (6.2). Mobile-first (NFR-02). */

:root {
  color-scheme: light; /* native scrollbars/selects follow the theme (QW-5) */
  --accent: #0d9488;
  --accent-strong: #0f766e;
  --accent-soft: rgba(13, 148, 136, 0.12);
  /* fills vs text: the strong accent is the AA-safe fill under white text in
     light mode (4.5:1+); --accent-text is the accent shade that is readable
     AS text on surfaces in the current theme (QW-1/QW-4) */
  --accent-fill: var(--accent-strong);
  --accent-text: var(--accent-strong);
  --on-accent: #fff;
  --on-danger: #fff;
  --on-success: #fff;
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f1f3f4;
  --text: #1f2426;
  --text-dim: #5f6b70;
  --border: #e0e4e6;
  --border-input: #879298; /* 3.18:1 vs white surface (QW-9, computed) */
  --danger: #b92525;
  --success: #28702c;
  --warn: #d97706;
  --warn-text: #9e4907;
  --warn-soft: rgba(245, 158, 11, 0.15);
  --success-soft: rgba(46, 125, 50, 0.14);
  --danger-soft: rgba(198, 40, 40, 0.12);
  --scrim: rgba(0, 0, 0, 0.45);
  --mark: rgba(13, 148, 136, 0.18);
  --mark-text: #0b6b62;
  /* elevation: cards float in light mode, hairlines return in dark (QW-6) */
  --shadow-1: 0 1px 2px rgba(15, 30, 35, 0.06), 0 2px 8px rgba(15, 30, 35, 0.05);
  --shadow-2: 0 2px 6px rgba(15, 30, 35, 0.08), 0 8px 24px rgba(15, 30, 35, 0.10);
  --card-border: transparent;
  --shadow: var(--shadow-1);
  /* type scale + radius tokens (QW-8) */
  --fs-xs: 12px; --fs-sm: 13.5px; --fs-base: 15px; --fs-md: 17px;
  --fs-lg: 19px; --fs-xl: 22px; --fs-2xl: 28px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
  --nav-h: 60px;
  --touch: 44px; /* NFR-05 */
}

[data-theme="dark"] {
  color-scheme: dark;
  /* Material dark: dark gray, not pure black (NFR-06) */
  --bg: #191c1e;
  --surface: #232729;
  --surface-2: #2b3033;
  --text: #e6e9ea;
  --text-dim: #9aa6ab;
  --border: #3a4145;
  --border-input: #707b81; /* 3.47:1 vs dark surface */
  --accent: #2dd4bf;
  --accent-strong: #14b8a6;
  --accent-soft: rgba(45, 212, 191, 0.15);
  --accent-fill: var(--accent);
  --accent-text: var(--accent);
  /* dark text on pastel fills — white fails at 1.6–2.2:1 (QW-1) */
  --on-accent: #10312d;
  --on-danger: #3d0f0f;
  --on-success: #0e2410;
  --danger: #ef9a9a;
  --success: #a5d6a7;
  --warn: #f59e0b;
  --warn-text: #fbbf24;
  --success-soft: rgba(165, 214, 167, 0.16);
  --danger-soft: rgba(239, 154, 154, 0.14);
  --scrim: rgba(0, 0, 0, 0.6);
  --mark: rgba(45, 212, 191, 0.22);
  --mark-text: #7ce8dc;
  --shadow-1: none;
  --shadow-2: 0 4px 14px rgba(0, 0, 0, 0.4);
  --card-border: var(--border);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
html { overscroll-behavior-y: contain; }

body {
  font-family: 'Noto Sans', system-ui, sans-serif; /* NFR-04 */
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#app { min-height: 100%; }
body.modal-open { overflow: hidden; }

/* ---------- layout: bottom nav (mobile) / sidebar (desktop) — 6.1 ---------- */

.layout { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.content { flex: 1; display: flex; flex-direction: column; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
.screen { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 0 14px 24px; }

.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: stretch; justify-content: space-around;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.nav-brand { display: none; }
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; flex: 1; min-height: var(--touch);
  color: var(--text-dim); text-decoration: none; font-size: 11px;
}
.nav-item.active { color: var(--accent-text); }
.nav-icon { width: 24px; height: 24px; }

@media (min-width: 800px) {
  .layout { flex-direction: row; }
  .nav {
    position: sticky; top: 0; bottom: auto; height: 100vh; width: 220px;
    flex-direction: column; justify-content: flex-start; gap: 4px;
    border-top: none; border-right: 1px solid var(--border);
    padding: 18px 10px;
  }
  .nav-brand {
    display: flex; align-items: center; gap: 10px; padding: 4px 12px 22px;
    font-weight: 700; font-size: 18px;
  }
  .brand-gamma {
    width: 34px; height: 34px; border-radius: var(--r-sm); background: var(--accent-fill);
    color: var(--on-accent); display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 20px;
  }
  .nav-item {
    flex: none; flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 0 12px; height: var(--touch); border-radius: 10px; font-size: 15px;
  }
  .nav-item.active { background: var(--accent-soft); }
  .content { flex: 1; padding-bottom: 0; }
}

/* ---------- visual-aid toggle rail (FR-TR) ---------- */

.tool-toggle {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--touch); padding: 0 14px;
  background: var(--surface); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: var(--r-pill);
  font: inherit; font-size: var(--fs-sm); cursor: pointer;
}
.tool-toggle.active {
  /* solid fill when ON so it reads as clearly enabled, not a washed-out tint */
  background: var(--accent-fill); color: var(--on-accent);
  border-color: var(--accent-fill);
}
.tool-icon { font-weight: 700; letter-spacing: 1px; }
.dg-icon { text-decoration: underline; text-underline-offset: 3px; }

/* the rail: a floating vertical stack of round glyph buttons in the thumb zone */
.toggle-rail { display: flex; flex-direction: column; gap: 10px; z-index: 30; }
.rail-toggle {
  width: 48px; height: 48px; min-height: 48px; padding: 0; border-radius: 50%;
  box-shadow: var(--shadow-2); font-size: var(--fs-sm);
}
.rail-toggle .tool-icon { letter-spacing: 0; }
/* Words: stacked directly above the FAB (FR-TR-02) */
.rail-words {
  position: fixed; right: 22px;
  bottom: calc(var(--nav-h) + 18px + 58px + 14px + env(safe-area-inset-bottom));
}
/* Running quiz: anchored inside the question card's bottom-right corner */
.rail-quiz-run { position: absolute; right: 12px; bottom: 12px; gap: 8px; }
/* pronounce action button on top of the toggles — deliberately NOT toggle-like:
   an outlined accent circle (no on/off states) so it reads as a momentary action */
.rail-speak {
  width: 48px; height: 48px; border-radius: 50%; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; cursor: pointer;
  background: var(--surface); color: var(--accent-text);
  border: 2px solid var(--accent); box-shadow: var(--shadow-2);
  margin-bottom: 4px; /* a touch of separation from the toggle group */
}
.rail-speak:active { transform: translateY(1px); }
@media (min-width: 800px) {
  .rail-words { bottom: calc(26px + 58px + 14px); }
}

/* ---------- Greek text & digraph highlighting (FR-VA-01) ---------- */

.gr { font-family: 'Noto Sans', system-ui, sans-serif; }
mark.dg {
  background: var(--mark); color: var(--mark-text);
  border-radius: 3px; padding: 0 1px; font-weight: inherit;
}

/* gender color coding (FR-CC-01): muted, AA-contrast in both themes */
:root {
  --gen-m: #2563eb;
  --gen-f: #c2185b;
  --gen-n: #047857;
}
[data-theme="dark"] {
  --gen-m: #82b3ff;
  --gen-f: #f48fb1;
  --gen-n: #6fd6ad;
}
.gr.g-m, .g-m .gr { color: var(--gen-m); }
.gr.g-f, .g-f .gr { color: var(--gen-f); }
.gr.g-n, .g-n .gr { color: var(--gen-n); }
.gender-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: baseline; }
.gender-dot.g-m { background: var(--gen-m); }
.gender-dot.g-f { background: var(--gen-f); }
.gender-dot.g-n { background: var(--gen-n); }

/* ---------- buttons & inputs (44px targets, NFR-05) ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--touch); padding: 0 18px;
  border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: var(--fs-base); font-weight: 500; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(0.96); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--accent-text); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: var(--fs-sm); }
.btn:disabled { opacity: 0.5; cursor: default; }

input[type="text"], input[type="search"], input[type="number"], select, textarea {
  width: 100%; min-height: var(--touch);
  padding: 10px 12px; font: inherit; font-size: 16px; /* ≥16px: no iOS zoom */
  border: 1px solid var(--border-input); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
}
textarea { resize: vertical; min-height: 72px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .tool-toggle:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.chip:focus-visible, .seg:focus-visible, .nav-item:focus-visible,
.word-item:focus-visible, .quiz-mode-card:focus-visible, .word-star:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
label.field-label { display: block; font-size: var(--fs-sm); font-weight: 600; color: var(--text-dim); margin: 16px 0 6px; }

/* checkbox rows ≥44px */
.check-row {
  display: flex; align-items: center; gap: 12px; min-height: var(--touch);
  padding: 4px 2px; cursor: pointer;
}
.check-row input[type="checkbox"] { width: 22px; height: 22px; flex: none; }

/* ---------- word list ---------- */

.screen-head { display: flex; align-items: center; gap: 10px; margin: 14px 0 10px; }
.screen-head h1 { font-size: var(--fs-xl); margin: 0; flex: 1; }

/* filter diet (M-2): search+sort share one row, chips scroll horizontally */
.filters { display: flex; flex-wrap: nowrap; gap: 8px; margin-bottom: 12px; }
.filters .search-box { flex: 1 1 220px; min-width: 0; }
.filters select { width: auto; flex: 0 1 auto; }
.filters input[type="search"] { text-overflow: ellipsis; }

.chip-row {
  display: flex; flex-wrap: nowrap; gap: 6px; margin-bottom: 12px;
  overflow-x: auto; scrollbar-width: none;
  margin-inline: -14px; padding-inline: 14px;
}
.chip-row::-webkit-scrollbar { display: none; }
@media (min-width: 800px) {
  .chip-row { flex-wrap: wrap; overflow-x: visible; margin-inline: 0; padding-inline: 0; }
}
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  min-height: 36px; padding: 0 14px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); font: inherit; font-size: var(--fs-sm); cursor: pointer;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }

.word-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.word-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 10px 14px; min-height: 60px; cursor: pointer;
  user-select: none; -webkit-user-select: none;
}
.word-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.word-main { flex: 1; min-width: 0; }
.word-base { font-size: var(--fs-md); font-weight: 600; }
.word-tr { color: var(--text-dim); font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.word-star {
  background: none; border: none; cursor: pointer; font-size: 20px;
  color: var(--text-dim); min-width: var(--touch); min-height: var(--touch);
}
.word-star.starred { color: var(--warn); }
.word-cat-badge {
  font-size: var(--fs-xs); color: var(--text-dim); background: var(--surface-2);
  padding: 2px 8px; border-radius: var(--r-sm); white-space: nowrap;
}

.empty-state { text-align: center; color: var(--text-dim); padding: 48px 20px; }
.empty-state h2 { color: var(--text); }
.empty-icon { width: 96px; height: 96px; color: var(--border-input); margin: 0 auto 6px; display: block; }
.empty-state .btn { margin-top: 14px; }

/* floating action button (6.3) */
.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent-fill); color: var(--on-accent); border: none;
  font-size: 30px; line-height: 1; cursor: pointer;
  box-shadow: var(--shadow-2); z-index: 30;
  display: flex; align-items: center; justify-content: center;
}
.fab svg { width: 26px; height: 26px; }
@media (min-width: 800px) { .fab { bottom: 26px; } }

/* bulk toolbar: ✕ pinned first (leading edge), then count, then a horizontally
   scrollable action row — the exit never migrates off-screen (FR-WS-04) */
.bulk-bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
  background: var(--surface); border: 1px solid var(--accent); border-radius: var(--r-md);
  padding: 8px 10px; margin-bottom: 12px; box-shadow: var(--shadow-2);
}
.bulk-exit { flex: none; }
.bulk-count { font-weight: 600; flex: none; white-space: nowrap; }
.bulk-actions {
  display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0;
  overflow-x: auto; scrollbar-width: thin; padding: 2px;
  /* right-edge fade hints that actions (Delete) scroll off (FR-WS-04) */
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent);
          mask-image: linear-gradient(to right, #000 calc(100% - 22px), transparent);
}
.bulk-actions .btn { flex: none; }
/* clear the FAB + the full 3-button toggle rail stacked above it (FR-TR-05) */
.word-list { padding-bottom: 230px; }
@media (min-width: 800px) { .word-list { padding-bottom: 200px; } }

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: var(--scrim);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--surface); color: var(--text);
  width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh;
  overflow-y: auto; border-radius: 18px 18px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-2);
}
.modal-wide { max-width: 720px; }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: var(--r-lg); }
}
.modal h2 { margin: 0 0 14px; font-size: var(--fs-lg); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.confirm-text { font-size: 16px; }

/* tags input (FR-TG-03) */
.tag-box {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  border: 1px solid var(--border-input); border-radius: var(--r-md); padding: 6px 8px;
  background: var(--surface); min-height: var(--touch);
}
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--accent-soft); color: var(--accent-text);
  border-radius: var(--r-pill); padding: 3px 6px 3px 10px; font-size: var(--fs-sm);
}
.tag-chip button {
  background: none; border: none; cursor: pointer; color: inherit;
  font-size: var(--fs-sm); padding: 2px 4px; min-height: 0;
}
.tag-box input {
  border: none; background: none; flex: 1; min-width: 110px; min-height: 30px;
  padding: 4px; font: inherit; color: var(--text);
}
.tag-box input:focus { outline: none; }

/* structured grammar editors (FR-GN-04, FR-GV-03, FR-GA-01) */
.grammar-section { border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px; margin-top: 8px; }
.grammar-section h4 { margin: 0 0 10px; font-size: var(--fs-sm); color: var(--text-dim); }
.grammar-row { display: grid; grid-template-columns: 110px 1fr; gap: 8px; align-items: center; margin-bottom: 6px; }
.grammar-row label { font-size: var(--fs-sm); color: var(--text-dim); }
.gender-seg { display: flex; gap: 8px; }
.gender-seg .seg { flex: 1; }
.article-preview { font-size: var(--fs-base); margin-top: 8px; display: flex; gap: 18px; flex-wrap: wrap; }

/* dynamic field rows in the editor */
.multi-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.multi-row input { flex: 1; }
.row-remove {
  flex: none; width: var(--touch); height: var(--touch);
  border: none; background: none; color: var(--text-dim);
  font-size: 22px; cursor: pointer; border-radius: var(--r-md);
}
.row-remove:hover { color: var(--danger); background: var(--surface-2); }
.field-error { color: var(--danger); font-size: var(--fs-sm); margin: 6px 0 0; }

/* ---------- quiz ---------- */

.quiz-menu { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
@media (min-width: 800px) {
  .quiz-menu { display: grid; grid-template-columns: 1fr 1fr; }
}
.quiz-mode-card {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px;
  cursor: pointer; font: inherit; color: var(--text);
}
.quiz-mode-card:hover { border-color: var(--accent); }
.quiz-mode-card h3 { margin: 0 0 4px; font-size: var(--fs-md); }
.quiz-mode-card p { margin: 0; color: var(--text-dim); font-size: var(--fs-sm); }
.card-icon { flex: none; width: 40px; height: 40px; overflow: hidden; border-radius: var(--r-md);
  background: var(--accent-soft); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center; font-weight: 700; }
.card-icon svg { width: 24px; height: 24px; }
.card-body { flex: 1; min-width: 0; }
.card-chevron { flex: none; color: var(--text-dim); width: 20px; height: 20px; }

.seg-group { display: flex; flex-wrap: wrap; gap: 8px; }
.seg {
  flex: 1 1 auto; min-height: var(--touch); padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-base);
  cursor: pointer; text-align: center;
}
.seg.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.seg-desc { font-size: var(--fs-xs); color: var(--text-dim); display: block; font-weight: 400; }

.kbd-note {
  display: flex; gap: 8px; align-items: flex-start;
  background: var(--surface-2); border-radius: var(--r-md); padding: 10px 12px;
  color: var(--text-dim); font-size: var(--fs-sm); margin-top: 14px;
}
.kbd-note svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }

.layout-quiz { padding: 0 14px; }
.quiz-run {
  max-width: 620px; margin: 0 auto; width: 100%;
  display: flex; flex-direction: column; min-height: calc(100dvh - 70px);
  padding-bottom: 20px;
}
.quiz-top { display: flex; align-items: center; gap: 10px; padding: 10px 0; color: var(--text-dim); font-size: var(--fs-sm); }
.quiz-progress { flex: 1; }
.quiz-progress-bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.quiz-progress-fill { height: 100%; background: var(--accent); transition: width 0.25s; min-width: 6px; border-radius: 3px; }

.quiz-card {
  position: relative; /* anchors the in-run toggle rail (FR-TR-03) */
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 30px 22px 68px; text-align: center; gap: 14px; margin-bottom: 16px;
  cursor: pointer;
}
.quiz-card.no-flip { cursor: default; }
.quiz-back { font-size: 20px; padding: 0 12px; flex: none; }
.quiz-prompt { font-size: 30px; font-weight: 600; overflow-wrap: anywhere; }
.quiz-answer-side { font-size: 24px; font-weight: 500; overflow-wrap: anywhere; animation: fade-in 0.18s ease-out; }
.quiz-hint { color: var(--text-dim); font-size: var(--fs-sm); }
.quiz-actions { display: flex; gap: 12px; }
.quiz-actions .btn { flex: 1; font-size: var(--fs-md); min-height: 52px; }
.btn-correct { background: var(--success); border-color: var(--success); color: var(--on-success); }
.btn-wrong { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }

.type-area { display: flex; flex-direction: column; gap: 10px; }
.type-row { display: flex; gap: 8px; }
.type-row input { flex: 1; font-size: 18px; }
.feedback { border-radius: var(--r-md); padding: 12px 14px; font-size: var(--fs-base); }
.feedback-ok { background: var(--success-soft); color: var(--success); }
.feedback-bad { background: var(--danger-soft); color: var(--danger); }
.feedback .gr { font-weight: 600; }

.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 16px 0; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 14px; text-align: center;
}
.stat-value { font-size: 26px; font-weight: 700; color: var(--accent-text); }
.stat-label { font-size: var(--fs-xs); color: var(--text-dim); }

.wrong-list { list-style: none; padding: 0; margin: 10px 0; display: flex; flex-direction: column; gap: 6px; }
.wrong-list li {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 10px 14px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}

/* ---------- stats ---------- */

.chart-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; margin-bottom: 14px; overflow-x: auto; }
.chart-box h3 { margin: 0 0 10px; font-size: var(--fs-base); color: var(--text-dim); font-weight: 600; }
.chart-box svg { display: block; width: 100%; height: auto; }
/* pack unit titles carry the card's hierarchy (M-4) */
.chart-box h3.unit-title { font-size: var(--fs-md); color: var(--text); }
@media (min-width: 800px) {
  .stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
  .stats-grid .chart-box { margin-bottom: 0; }
}

.stats-table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
.stats-table th, .stats-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.stats-table th { color: var(--text-dim); font-size: var(--fs-xs); font-weight: 600; }
.stats-table td.num, .stats-table th.num { text-align: right; }
.acc-badge { padding: 2px 8px; border-radius: var(--r-sm); font-weight: 600; font-size: var(--fs-sm); }
.acc-good { background: var(--success-soft); color: var(--success); }
.acc-mid { background: var(--warn-soft); color: var(--warn-text); }
.acc-bad { background: var(--danger-soft); color: var(--danger); }

.weak-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 10px 14px; margin-bottom: 8px;
}
.weak-item .word-main { flex: 1; }

.session-list { list-style: none; padding: 0; margin: 0; font-size: var(--fs-base); }
.session-list li {
  display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap;
  padding: 10px 4px; border-bottom: 1px solid var(--border); color: var(--text-dim);
}
.session-score { font-weight: 600; color: var(--text); }

/* ---------- login ---------- */

.login-screen { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-screen {
  background: radial-gradient(120% 90% at 50% 0%, var(--accent-soft) 0%, transparent 55%);
}
.login-card {
  background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--r-lg);
  padding: 40px 30px; text-align: center; max-width: 380px; width: 100%; box-shadow: var(--shadow-2);
}
.login-gamma {
  width: 72px; height: 72px; border-radius: var(--r-lg); background: var(--accent-fill);
  color: var(--on-accent); font-size: 44px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 18px;
}
.login-card h1 { font-size: var(--fs-xl); margin: 0 0 6px; }
.login-sub { color: var(--text-dim); margin: 0 0 26px; }
.btn-google { width: 100%; }
.google-icon { width: 20px; height: 20px; }
.login-offline { color: var(--text-dim); background: var(--surface-2); border-radius: 10px; padding: 12px; }

.banner-expired {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  max-width: 860px; margin: 10px auto 0; width: calc(100% - 28px);
  background: var(--warn-soft); border: 1px solid var(--warn);
  border-radius: var(--r-md); padding: 10px 14px; font-size: var(--fs-sm);
}

/* ---------- toasts (6.3) ---------- */

.toast-container {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
/* while a modal is open, toasts sit over the backdrop, not the form (M-7) */
.toast-container.toast-top {
  bottom: auto; top: calc(12px + env(safe-area-inset-top));
}
.toast {
  background: var(--text); color: var(--bg);
  border-radius: var(--r-md); padding: 11px 18px; font-size: var(--fs-base);
  opacity: 0; transform: translateY(8px); transition: all 0.25s; box-shadow: var(--shadow-2);
}
.toast-show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success); color: var(--on-success); }
.toast-error { background: var(--danger); color: var(--on-danger); }

/* ---------- settings ---------- */

.settings-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; margin-bottom: 14px; }
.settings-section h3 { margin: 0 0 12px; font-size: var(--fs-base); color: var(--text-dim); }
/* label/control grid keeps wrapped rows tidy (M-5) */
.settings-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; min-height: var(--touch); }
.settings-row + .settings-row { border-top: 1px solid var(--border); }
.settings-row .row-hint { grid-column: 1 / -1; color: var(--text-dim); font-size: var(--fs-sm); margin: 0 0 8px; }
.offline-badge {
  display: inline-block; background: var(--surface-2); color: var(--text-dim);
  font-size: var(--fs-xs); padding: 2px 10px; border-radius: var(--r-sm); margin-left: 8px;
}

/* import preview: surface tones instead of border-in-border (M-4) */
.import-word {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface-2); border: none; border-radius: var(--r-sm);
  padding: 12px 14px; margin-bottom: 8px;
}
.import-word input[type="checkbox"] { width: 22px; height: 22px; margin-top: 4px; flex: none; }
.dup-badge {
  display: inline-block; background: var(--warn-soft); color: var(--warn-text);
  font-size: var(--fs-xs); padding: 2px 8px; border-radius: var(--r-sm); margin-top: 4px;
}

.share-link-box {
  width: 100%; word-break: break-all; font-size: var(--fs-xs); color: var(--text-dim);
  background: var(--surface-2); border-radius: var(--r-md); padding: 10px 12px;
  max-height: 110px; overflow-y: auto; margin: 12px 0;
}

/* ---------- v4: spaced repetition + audio ---------- */

.quiz-mode-card.review-card { border-color: var(--accent); }
/* an exhausted review card is not a tap target: no accent ring, no chevron */
.quiz-mode-card.review-card.review-done { opacity: 0.75; cursor: default; border-color: var(--card-border); }
.review-card.review-done .card-chevron { display: none; }
.review-count {
  display: inline-block; margin-left: 8px; padding: 1px 9px;
  background: var(--accent-fill); color: var(--on-accent); border-radius: var(--r-pill);
  font-size: var(--fs-sm); vertical-align: middle;
}
.speak-btn { padding: 2px 8px; font-size: 16px; line-height: 1.2; flex: none; }
.quiz-listen { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.listen-play { font-size: 26px; padding: 10px 22px; }
.listen-reveal { width: 100%; margin-top: 10px; }
.forecast-row { display: flex; gap: 6px; margin-top: 10px; }
.forecast-cell { flex: 1; text-align: center; background: var(--surface-2); border-radius: var(--r-sm); padding: 6px 2px; }
.forecast-n { font-weight: 600; }
.forecast-d { font-size: 11px; color: var(--text-dim); }

/* ---------- elevation (QW-6): light mode floats, dark mode keeps hairlines ---------- */

.word-item, .quiz-mode-card, .stat-card, .chart-box, .settings-section, .weak-item {
  border-color: var(--card-border); box-shadow: var(--shadow-1);
}
.quiz-card { border-color: var(--card-border); box-shadow: var(--shadow-1); }

/* ---------- motion base layer (QW-7) ---------- */

.btn, .chip, .seg, .tool-toggle, .nav-item, .word-item, .quiz-mode-card {
  transition: background-color 0.15s ease, border-color 0.15s ease,
              color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease,
              filter 0.15s ease;
}
.chip:active, .seg:active, .word-item:active, .quiz-mode-card:active { transform: scale(0.985); }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
.modal { animation: sheet-up 0.22s cubic-bezier(0.2, 0.8, 0.3, 1); }
.modal-backdrop { animation: fade-in 0.18s ease-out; }
.screen { animation: fade-in 0.15s ease-out; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- V5 additions ---------- */

/* explicit Export/Import icon button, not a "⋯" (FR-WS-03) */
.btn-icon { padding: 0 12px; }
.btn-icon svg { width: 20px; height: 20px; }

/* quiz tag scope control (FR-TQ-02) */
.scope-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.scope-chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; min-width: 0; }
.scope-all { color: var(--text-dim); font-size: var(--fs-sm); }
.scope-chip { cursor: pointer; }
.scope-count { font-weight: 600; margin-right: auto; }
.scope-tag-count { color: var(--text-dim); font-size: var(--fs-sm); flex: none; }
