/* =========================================================
   不規則動詞特訓 — Design System
   ========================================================= */

:root {
  --bg: #f4f2ec;
  --surface: #ffffff;
  --surface-2: #faf8f2;
  --surface-3: #f1eee6;
  --ink: #1d2330;
  --ink-soft: #3b4356;
  --muted: #6f7787;
  --line: #e6e1d6;
  --line-strong: #d8d2c4;
  --primary: #4f46e5;
  --primary-2: #6d5efc;
  --primary-ink: #ffffff;
  --primary-soft: #eceafe;
  --accent: #0d9488;
  --accent-soft: #d7f3ee;
  --success: #15803d;
  --success-soft: #dcfce7;
  --warn: #c2410c;
  --warn-soft: #ffedd5;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --gold: #b45309;
  --shadow-sm: 0 1px 2px rgba(24, 28, 40, .06), 0 1px 3px rgba(24, 28, 40, .05);
  --shadow: 0 12px 32px rgba(24, 28, 40, .09), 0 2px 8px rgba(24, 28, 40, .05);
  --shadow-lg: 0 24px 60px rgba(24, 28, 40, .16);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 26px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
          "Hiragino Sans TC", "Microsoft JhengHei", "Noto Sans TC", "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0e1120;
  --surface: #171b2b;
  --surface-2: #1d2235;
  --surface-3: #242a40;
  --ink: #eef0f8;
  --ink-soft: #c7ccdd;
  --muted: #98a1b8;
  --line: #2a3148;
  --line-strong: #39415c;
  --primary: #8b85ff;
  --primary-2: #a79dff;
  --primary-ink: #14162a;
  --primary-soft: #262550;
  --accent: #2dd4bf;
  --accent-soft: #103c3a;
  --success: #4ade80;
  --success-soft: #123a24;
  --warn: #fb923c;
  --warn-soft: #3a2413;
  --danger: #f87171;
  --danger-soft: #3a1a1d;
  --gold: #fbbf24;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 14px 40px rgba(0, 0, 0, .45);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  transition: background .35s ease, color .35s ease;
}

h1, h2, h3, h4, p, dl, dd, dt { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
mark { background: var(--primary-soft); color: var(--primary); padding: 0 .28em; border-radius: 5px; font-weight: 700; }
[data-theme="dark"] mark { color: var(--primary-2); }

.bg-orbs { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; }
.orb-a { width: 480px; height: 480px; background: radial-gradient(circle, #c7c2ff, transparent 70%); top: -160px; right: -100px; }
.orb-b { width: 420px; height: 420px; background: radial-gradient(circle, #b8ece4, transparent 70%); top: 380px; left: -160px; opacity: .5; }
.orb-c { width: 380px; height: 380px; background: radial-gradient(circle, #ffe2c2, transparent 70%); bottom: -120px; right: 10%; opacity: .45; }
[data-theme="dark"] .orb { opacity: .22; }

/* ---------- Layout ---------- */
.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 22px 40px;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 12px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  margin-bottom: 26px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border: 1px solid var(--line);
  border-radius: 100px;
  box-shadow: var(--shadow-sm);
}

.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; padding-left: 4px; }
.brand-logo {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; font-weight: 800; font-size: 20px;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 40%, transparent);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: .01em; }
.brand-text small { font-size: 11px; color: var(--muted); letter-spacing: .04em; }

.tabs { display: flex; gap: 4px; margin: 0 auto; background: var(--surface-3); padding: 4px; border-radius: 100px; }
.tab {
  padding: 8px 18px; border-radius: 100px; font-size: 14px; font-weight: 600;
  color: var(--muted); transition: all .2s ease; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .tab.is-active { background: var(--primary); color: var(--primary-ink); }

.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px;
  border-radius: 50%; font-size: 18px; background: var(--surface-3);
  transition: transform .2s ease, background .2s ease;
}
.icon-btn:hover { transform: rotate(-12deg) scale(1.06); background: var(--line); }

/* ---------- Views ---------- */
.view { display: none; animation: fadeUp .4s ease both; }
.view.is-active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 26px;
  align-items: stretch;
  padding: 34px;
  margin-bottom: 26px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 58%),
    radial-gradient(120% 140% at 0% 100%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 55%),
    var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.hero .pill {
  display: inline-block; padding: 5px 13px; border-radius: 100px;
  background: var(--primary-soft); color: var(--primary);
  font-size: 12.5px; font-weight: 700; letter-spacing: .02em; margin-bottom: 16px;
}
.hero h1 { font-size: clamp(28px, 4vw, 44px); line-height: 1.16; letter-spacing: -.01em; font-weight: 800; }
.grad {
  background: linear-gradient(120deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-copy > p { margin-top: 14px; max-width: 30em; color: var(--muted); font-size: 15.5px; }
.hero-actions { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

.hero-panel {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 20px;
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.ring-wrap { position: relative; width: 148px; height: 148px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface-3); stroke-width: 9; }
.ring-fg {
  fill: none; stroke: url(#none); stroke: var(--primary); stroke-width: 9;
  stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset .8s cubic-bezier(.2,.8,.2,1), stroke .4s;
}
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-label strong { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.ring-label span { font-size: 12px; color: var(--muted); }
.hero-stats { list-style: none; display: flex; gap: 14px; padding: 0; flex-wrap: wrap; justify-content: center; }
.hero-stats li { text-align: center; }
.hero-stats strong { display: block; font-size: 19px; font-weight: 800; }
.hero-stats span { font-size: 11.5px; color: var(--muted); }

/* ---------- Section titles ---------- */
.section-title { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ---------- Clinic ---------- */
.clinic { margin-bottom: 30px; }
.clinic-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 14px; }
.clinic-card {
  position: relative;
  padding: 22px 20px 18px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.clinic-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.clinic-icon {
  display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 12px;
  border-radius: 10px; font-weight: 800; font-size: 15px;
  background: var(--primary-soft); color: var(--primary);
}
.clinic-card:nth-child(2) .clinic-icon { background: var(--accent-soft); color: var(--accent); }
.clinic-card:nth-child(3) .clinic-icon { background: var(--warn-soft); color: var(--warn); }
.clinic-card h3 { font-size: 16px; margin-bottom: 8px; }
.clinic-card p { font-size: 13.5px; color: var(--ink-soft); }
.clinic-card .mini { margin-top: 12px; font-family: var(--mono); font-size: 12.5px; color: var(--muted); background: var(--surface-3); padding: 8px 10px; border-radius: 9px; }

.pattern-legend { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.legend-card {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--pcolor, var(--primary));
}
.legend-card b { font-family: var(--mono); font-size: 13px; color: var(--pcolor, var(--primary)); letter-spacing: .02em; }
.legend-card span { display: block; font-size: 12px; color: var(--muted); line-height: 1.4; margin-top: 1px; }

/* ---------- Reference ---------- */
.reference { padding-bottom: 10px; }
.ref-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 16px 0 18px; }
.search-wrap { position: relative; flex: 1 1 240px; min-width: 200px; }
.search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 16px; pointer-events: none; }
#searchInput {
  width: 100%; padding: 11px 14px 11px 36px;
  border: 1px solid var(--line); border-radius: 100px;
  background: var(--surface); color: var(--ink); font-size: 14px;
  transition: border-color .2s, box-shadow .2s;
}
#searchInput:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
#searchInput::-webkit-search-cancel-button { cursor: pointer; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 7px 14px; border-radius: 100px; font-size: 13px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted);
  transition: all .18s ease;
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.is-active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }

.switch { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 100px; background: var(--line-strong); position: relative; cursor: pointer; transition: background .2s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(16px); }

.verb-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.verb-card {
  padding: 18px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
  position: relative;
}
.verb-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.verb-card .vc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.vc-id { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.vc-badge { font-family: var(--mono); font-size: 10.5px; font-weight: 700; padding: 3px 8px; border-radius: 100px; letter-spacing: .03em; background: color-mix(in srgb, var(--pcolor) 14%, transparent); color: var(--pcolor); }
.vc-base { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin-top: 6px; }
.vc-zh { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.vc-freq { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.vc-freq .speak-btn { flex: none; }
.vc-forms { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.vc-form { padding: 8px 10px; border-radius: 10px; background: var(--surface-3); }
.vc-form dt { font-size: 10.5px; color: var(--muted); letter-spacing: .02em; text-transform: uppercase; margin-bottom: 1px; }
.vc-form dd { font-family: var(--mono); font-size: 14px; font-weight: 700; color: var(--ink); }
.vc-form.is-past dd { color: var(--gold); }
.vc-form.is-pp dd { color: var(--accent); }
.vc-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 10px; background: var(--surface-2);
  font-size: 12.5px; font-weight: 600; color: var(--muted); transition: background .2s, color .2s;
}
.vc-toggle:hover { background: var(--surface-3); color: var(--ink); }
.vc-toggle .arrow { transition: transform .25s ease; }
.verb-card.open .vc-toggle .arrow { transform: rotate(180deg); }
.vc-detail { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s ease; }
.verb-card.open .vc-detail { grid-template-rows: 1fr; }
.vc-detail-inner { overflow: hidden; }
.vc-ex { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border-left: 3px solid var(--line-strong); }
.vc-ex .lbl { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.vc-ex.past .lbl { color: var(--gold); }
.vc-ex.pp .lbl { color: var(--accent); }
.vc-ex .en { font-size: 13.5px; margin-top: 2px; }
.vc-ex .en b { color: var(--primary); }
.vc-ex .zh { font-size: 12px; color: var(--muted); margin-top: 2px; }
.vc-note { margin-top: 10px; font-size: 12px; color: var(--muted); display: flex; gap: 6px; }
.vc-note::before { content: "💡"; }

.vc-mastery { display: flex; gap: 3px; margin-top: 10px; }
.vc-mastery i { height: 4px; flex: 1; border-radius: 2px; background: var(--surface-3); }
.vc-mastery i.on { background: var(--accent); }

.speak-btn, .speak {
  display: inline-grid; place-items: center; gap: 4px;
  padding: 6px 10px; border-radius: 100px; font-size: 12px; font-weight: 600;
  background: var(--primary-soft); color: var(--primary); transition: transform .15s, background .2s;
}
.speak-btn:hover, .speak:hover { transform: scale(1.05); }
.speak-btn.playing { background: var(--accent-soft); color: var(--accent); }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 14px; }

/* ---------- Panels ---------- */
.panel {
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.deck-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
select {
  padding: 9px 34px 9px 14px; border-radius: 100px; font-size: 13.5px;
  border: 1px solid var(--line); background-color: var(--surface); color: var(--ink);
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236f7787' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
}
select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 22px; border-radius: 100px; font-size: 14px; font-weight: 700;
  transition: transform .16s ease, box-shadow .2s ease, background .2s ease, opacity .2s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: var(--primary-ink); box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 35%, transparent); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 26px color-mix(in srgb, var(--primary) 45%, transparent); }
.btn-ghost { background: var(--surface-3); color: var(--ink-soft); }
.btn-ghost:hover { background: var(--line); color: var(--ink); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.06); }
.btn-warn { background: var(--warn-soft); color: var(--warn); }
.btn-warn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* ---------- Flashcards ---------- */
.card-stage { perspective: 1600px; display: flex; justify-content: center; padding: 8px 0 4px; }
.flashcard {
  width: 100%; max-width: 560px; height: 360px;
  border-radius: var(--radius-lg); cursor: pointer; outline: none;
}
.flashcard:focus-visible { box-shadow: 0 0 0 4px var(--primary-soft); }
.flash-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform .6s cubic-bezier(.2,.8,.2,1);
}
.flashcard.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 30px; border-radius: var(--radius-lg);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.flash-front {
  background:
    radial-gradient(120% 120% at 100% 0%, color-mix(in srgb, var(--primary) 12%, transparent), transparent 60%),
    var(--surface);
  text-align: center;
}
.flash-back {
  transform: rotateY(180deg);
  background: var(--surface);
  align-items: stretch; justify-content: flex-start; overflow-y: auto;
}
.flash-num { position: absolute; top: 18px; left: 22px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.flash-badge { position: absolute; top: 16px; right: 20px; font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 100px; }
.flash-base { font-size: 54px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.flash-zh { font-size: 17px; color: var(--muted); margin-top: 8px; }
.flash-front .speak { margin-top: 22px; padding: 9px 18px; font-size: 13px; }
.flash-hint { position: absolute; bottom: 18px; font-size: 12px; color: var(--muted); opacity: .8; }

.flash-back h3 { font-size: 24px; font-weight: 800; margin-bottom: 12px; }
.forms { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.forms > div { padding: 10px; border-radius: 11px; background: var(--surface-3); text-align: center; }
.forms dt { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.forms dd { font-family: var(--mono); font-size: 15px; font-weight: 700; }
.forms .f-past dd { color: var(--gold); }
.forms .f-pp dd { color: var(--accent); }
.flash-examples { display: grid; gap: 8px; }
.flash-examples .fx { padding: 9px 12px; border-radius: 10px; background: var(--surface-2); border-left: 3px solid var(--line-strong); font-size: 13px; }
.flash-examples .fx.past { border-left-color: var(--gold); }
.flash-examples .fx.pp { border-left-color: var(--accent); }
.flash-examples .fx .lbl { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.flash-examples .fx b { color: var(--primary); }
.flash-examples .fx .zh { font-size: 11.5px; color: var(--muted); }

.flash-meta { display: flex; justify-content: space-between; max-width: 560px; margin: 16px auto 14px; font-size: 12.5px; color: var(--muted); }
.flash-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.flash-actions .btn { min-width: 118px; }

/* ---------- Quiz ---------- */
.quiz-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 22px 0; }
.mode-card {
  padding: 24px 20px; border-radius: var(--radius); text-align: center;
  background: var(--surface-2); border: 1px solid var(--line);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.mode-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.mode-emoji { font-size: 30px; display: block; margin-bottom: 8px; }
.mode-card h3 { font-size: 17px; margin-bottom: 6px; }
.mode-card p { font-size: 13px; color: var(--muted); min-height: 46px; }
.mode-card .btn { margin-top: 12px; }
.quiz-scope { display: flex; align-items: center; gap: 12px; justify-content: center; padding-top: 18px; border-top: 1px dashed var(--line); font-size: 13.5px; color: var(--muted); flex-wrap: wrap; }

.quiz-top { display: flex; align-items: center; gap: 18px; margin-bottom: 24px; }
.quiz-progress { flex: 1; display: flex; align-items: center; gap: 12px; }
.bar { flex: 1; height: 8px; border-radius: 100px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 100px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .35s ease; }
#quizCounter { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.quiz-body { max-width: 680px; margin: 0 auto; }
.q-prompt { text-align: center; margin-bottom: 6px; }
.q-kicker { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--primary); background: var(--primary-soft); padding: 4px 12px; border-radius: 100px; margin-bottom: 14px; }
.q-word { font-size: clamp(30px, 5vw, 42px); font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.q-zh { color: var(--muted); font-size: 15px; margin-top: 4px; }
.q-sentence { font-size: clamp(19px, 2.6vw, 24px); font-weight: 600; line-height: 1.7; margin: 22px 0 4px; }
.q-sentence .blank { display: inline-block; min-width: 92px; border-bottom: 2.5px dashed var(--primary); color: var(--primary); font-family: var(--mono); font-weight: 700; text-align: center; }
.q-sentence .blank.filled { border-bottom-style: solid; }
.q-trans { color: var(--muted); font-size: 13.5px; margin-top: 8px; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 26px; }
.option {
  padding: 16px 18px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--surface-2); font-family: var(--mono); font-size: 17px; font-weight: 700;
  text-align: left; transition: all .16s ease; display: flex; align-items: center; gap: 10px;
}
.option .key { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--surface-3); font-size: 12px; font-family: var(--font); color: var(--muted); flex: none; }
.option:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-2px); }
.option.correct { border-color: var(--success); background: var(--success-soft); color: var(--success); }
.option.wrong { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.option.dim { opacity: .55; }
.option:disabled { cursor: default; }

.spell-input-wrap { margin-top: 28px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.spell-input {
  width: 100%; max-width: 360px; padding: 16px 20px; text-align: center;
  font-family: var(--mono); font-size: 24px; font-weight: 700; letter-spacing: .06em;
  border: 2px solid var(--line-strong); border-radius: 14px; background: var(--surface-2); color: var(--ink);
}
.spell-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.spell-input.correct { border-color: var(--success); background: var(--success-soft); }
.spell-input.wrong { border-color: var(--danger); background: var(--danger-soft); }
.spell-hint { font-size: 12.5px; color: var(--muted); }

.feedback { margin-top: 24px; padding: 18px 20px; border-radius: 14px; animation: fadeUp .3s ease both; }
.feedback.ok { background: var(--success-soft); border: 1px solid color-mix(in srgb, var(--success) 35%, transparent); }
.feedback.no { background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); }
.feedback .fb-head { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px; margin-bottom: 8px; }
.feedback.ok .fb-head { color: var(--success); }
.feedback.no .fb-head { color: var(--danger); }
.feedback .fb-answer { font-size: 14px; color: var(--ink-soft); }
.feedback .fb-answer b { font-family: var(--mono); font-size: 16px; color: var(--ink); }
.feedback .fb-explain { font-size: 13px; color: var(--muted); margin-top: 8px; }
.feedback .fb-forms { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.feedback .fb-forms span { font-family: var(--mono); font-size: 12.5px; background: color-mix(in srgb, var(--surface) 60%, transparent); padding: 4px 10px; border-radius: 100px; }
.feedback .fb-forms b { color: var(--primary); }
.fb-next { margin-top: 14px; display: flex; justify-content: flex-end; }

/* Result */
.quiz-result { text-align: center; }
.result-emoji { font-size: 54px; line-height: 1; margin-bottom: 8px; }
.result-stats { display: flex; justify-content: center; gap: 26px; flex-wrap: wrap; margin: 22px 0; }
.result-stats .rs { text-align: center; }
.result-stats .rs strong { display: block; font-size: 30px; font-weight: 800; }
.result-stats .rs span { font-size: 12.5px; color: var(--muted); }
.result-wrong { max-width: 560px; margin: 0 auto 8px; text-align: left; }
.result-wrong h4 { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.result-wrong ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.result-wrong li { padding: 8px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px; display: flex; justify-content: space-between; gap: 10px; }
.result-wrong li b { font-family: var(--mono); color: var(--primary); }
.result-actions { display: flex; justify-content: center; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

/* ---------- Progress ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px; }
.stat-card { padding: 18px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.stat-card strong { display: block; font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.stat-card span { font-size: 12.5px; color: var(--muted); }
.stat-card:nth-child(1) strong { color: var(--primary); }
.stat-card:nth-child(2) strong { color: var(--success); }
.stat-card:nth-child(3) strong { color: var(--accent); }
.stat-card:nth-child(4) strong { color: var(--gold); }

.mastery-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.mastery-head h3, .wrong-section h3 { font-size: 16px; }
.legend-note { font-size: 12px; color: var(--muted); }
.mastery-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; margin-bottom: 30px; }
.mastery-row { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.mastery-row .mr-name { font-family: var(--mono); font-weight: 700; font-size: 13.5px; width: 96px; flex: none; }
.mastery-row .mr-zh { font-size: 12px; color: var(--muted); width: 74px; flex: none; }
.mr-bar { flex: 1; display: flex; gap: 3px; }
.mr-bar i { height: 7px; flex: 1; border-radius: 3px; background: var(--surface-3); }
.mr-bar i.on { background: var(--accent); }
.mr-state { font-size: 11px; color: var(--muted); width: 44px; text-align: right; flex: none; }

.wrong-section { padding-top: 22px; border-top: 1px solid var(--line); }
.wrong-list { display: grid; gap: 8px; margin-top: 12px; }
.wrong-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.wrong-item .wi-word { font-family: var(--mono); font-weight: 700; font-size: 15px; min-width: 110px; }
.wrong-item .wi-zh { font-size: 12px; color: var(--muted); flex: 1; }
.wrong-item .wi-count { font-size: 11.5px; color: var(--danger); background: var(--danger-soft); padding: 3px 9px; border-radius: 100px; }
.wrong-item .btn { flex: none; }
.wrong-empty { text-align: center; color: var(--muted); font-size: 13.5px; padding: 26px 0; }
.wrong-empty .big { font-size: 34px; display: block; margin-bottom: 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 20px);
  padding: 12px 22px; border-radius: 100px; background: var(--ink); color: var(--surface);
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: all .3s ease; z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Footer ---------- */
.site-footer { text-align: center; margin-top: 40px; color: var(--muted); font-size: 12.5px; }
.site-footer .tiny { font-size: 11.5px; margin-top: 3px; opacity: .8; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding: 26px; }
  .hero-panel { flex-direction: row; gap: 22px; }
  .clinic-grid { grid-template-columns: 1fr; }
  .pattern-legend { grid-template-columns: 1fr 1fr; }
  .verb-grid { grid-template-columns: repeat(2, 1fr); }
  .quiz-modes { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .mastery-list { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .app-shell { padding: 14px 14px 30px; }
  .topbar { flex-wrap: wrap; gap: 10px; border-radius: 22px; padding: 10px 12px; }
  .brand-text small { display: none; }
  .tabs { order: 3; width: 100%; justify-content: space-between; margin: 0; }
  .tab { flex: 1; text-align: center; padding: 8px 6px; font-size: 13px; }
  .icon-btn { margin-left: auto; }
  .hero { padding: 22px; }
  .hero-panel { flex-direction: column; }
  .ring-wrap { width: 120px; height: 120px; }
  .verb-grid { grid-template-columns: 1fr; }
  .panel { padding: 20px 16px; }
  .flashcard { height: 400px; }
  .flash-base { font-size: 44px; }
  .forms { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .forms dd { font-size: 13px; }
  .options { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .flash-actions .btn { flex: 1; min-width: 0; }
  .flash-meta { flex-direction: column; gap: 3px; align-items: center; }
  .q-word { font-size: 32px; }
  .result-stats { gap: 18px; }
}

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