/* ============================================================
   TED-Ed 受験リスニング道場 — red-forward design system
   ============================================================ */

:root {
  /* brand ramp */
  --red-900: #4a0d08;
  --red-700: #a3160d;
  --red-600: #c81f13;
  --red: #e62b1e;
  --red-400: #ff4436;
  --red-300: #ff7a70;
  --red-100: #ffd9d5;

  --bg: #fbf7f6;
  --bg-2: #f2e9e7;
  --surface: #ffffff;
  --surface-2: #fdf6f5;
  --line: #e6d8d5;
  --line-strong: #cdb8b4;

  --ink: #1a0f0d;
  --ink-2: #5c4a46;
  --ink-3: #92807b;

  --ok: #12805a;
  --ok-bg: #dff5ec;
  --warn: #a35c00;
  --warn-bg: #fdeed6;
  --bad: #c81f13;
  --bad-bg: #fde6e4;
  --info: #1b5fb4;
  --info-bg: #e5eefb;

  --focus: #e62b1e;
  --glow: 0 0 0 1px rgba(230, 43, 30, .3), 0 6px 26px -6px rgba(230, 43, 30, .45);

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  --r-xl: 22px;

  --shadow: 0 1px 2px rgba(60, 15, 10, .06), 0 6px 18px -6px rgba(60, 15, 10, .12);
  --shadow-lg: 0 18px 50px -12px rgba(60, 15, 10, .3);

  --sans: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", system-ui, -apple-system, "Segoe UI", sans-serif;
  --en: "Charter", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --disp: "Helvetica Neue", "Arial Black", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  --topbar-h: 58px;
  --film: linear-gradient(135deg, var(--red) 0%, #ff5e2e 100%);
}

:root[data-theme="dark"] {
  --bg: #0d0908;
  --bg-2: #171010;
  --surface: #150f0e;
  --surface-2: #1e1514;
  --line: #2e201f;
  --line-strong: #4a3230;

  --ink: #fdf3f1;
  --ink-2: #bda8a4;
  --ink-3: #8a736f;

  --ok: #3fd99a;
  --ok-bg: #0c2a20;
  --warn: #f0b45c;
  --warn-bg: #2e2110;
  --bad: #ff6b5c;
  --bad-bg: #33110e;
  --info: #74b0f5;
  --info-bg: #0f2135;

  --focus: #ff4436;
  --glow: 0 0 0 1px rgba(255, 68, 54, .35), 0 8px 34px -8px rgba(255, 68, 54, .55);
  --shadow: 0 1px 2px rgba(0, 0, 0, .55), 0 6px 20px -6px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 60px -16px rgba(0, 0, 0, .85), 0 0 0 1px rgba(255, 68, 54, .08);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0908;
    --bg-2: #171010;
    --surface: #150f0e;
    --surface-2: #1e1514;
    --line: #2e201f;
    --line-strong: #4a3230;
    --ink: #fdf3f1;
    --ink-2: #bda8a4;
    --ink-3: #8a736f;
    --ok: #3fd99a;
    --ok-bg: #0c2a20;
    --warn: #f0b45c;
    --warn-bg: #2e2110;
    --bad: #ff6b5c;
    --bad-bg: #33110e;
    --info: #74b0f5;
    --info-bg: #0f2135;
    --focus: #ff4436;
    --glow: 0 0 0 1px rgba(255, 68, 54, .35), 0 8px 34px -8px rgba(255, 68, 54, .55);
    --shadow: 0 1px 2px rgba(0, 0, 0, .55), 0 6px 20px -6px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 60px -16px rgba(0, 0, 0, .85), 0 0 0 1px rgba(255, 68, 54, .08);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  overflow-x: hidden;
  background-image:
    radial-gradient(1100px 520px at 78% -12%, rgba(230, 43, 30, .13), transparent 62%),
    radial-gradient(760px 420px at 4% 0%, rgba(255, 94, 46, .08), transparent 58%);
  background-attachment: fixed;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0; font-weight: 800; letter-spacing: -.02em; }
p { margin: 0 0 .8em; }
a { color: var(--red); text-underline-offset: 2px; }

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.skip-link { position: absolute; left: -9999px; top: 0; z-index: 200; background: var(--surface); padding: 10px 16px; }
.skip-link:focus { left: 0; }

.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.accent { color: var(--red); }

/* ---------------- topbar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(230, 43, 30, .12);
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--film); opacity: .9;
}

.brand {
  display: flex; align-items: center; gap: 9px;
  background: none; border: 0; cursor: pointer; padding: 4px 4px;
  color: inherit; font-family: inherit;
}
.brand-mark {
  font-family: var(--disp);
  font-weight: 900; font-size: 15px; letter-spacing: -.05em;
  color: #fff; background: var(--film);
  padding: 4px 9px; border-radius: 7px;
  box-shadow: 0 4px 14px -4px rgba(230, 43, 30, .8);
}
.brand-mark em { font-style: normal; opacity: .78; }
.brand-name { font-size: 13px; color: var(--ink-2); font-weight: 700; letter-spacing: .01em; }
@media (max-width: 900px) { .brand-name { display: none; } }

.topnav { display: flex; gap: 2px; margin-left: 6px; }
.navbtn {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  border: 0; background: none; cursor: pointer;
  padding: 7px 11px; border-radius: var(--r);
  color: var(--ink-2); font: inherit; font-size: 13.5px; font-weight: 700;
  white-space: nowrap; transition: color .12s, background .12s;
}
.navbtn:hover { background: var(--bg-2); color: var(--ink); }
.navbtn[aria-current="page"] { color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); }
.navbtn .i { font-size: 15px; }
@media (max-width: 760px) { .navbtn span:not(.i):not(.badge) { display: none; } .navbtn { padding: 7px 9px; } }

.badge {
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 800; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--red) 22%, transparent);
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.streak {
  font-size: 13px; font-weight: 800; color: var(--ink-2);
  padding: 4px 10px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--line);
}
.streak b { color: var(--red); }

.iconbtn {
  width: 32px; height: 32px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); cursor: pointer; font-size: 14px;
  display: grid; place-items: center; transition: .12s;
}
.iconbtn:hover { background: var(--bg-2); color: var(--red); border-color: var(--red); }

.net-banner {
  padding: 8px 16px; font-size: 13px; text-align: center;
  background: var(--warn-bg); color: var(--warn);
  border-bottom: 1px solid var(--line);
}

/* ---------------- layout ---------------- */
.main { min-height: calc(100vh - var(--topbar-h)); }
.wrap { max-width: 1260px; margin: 0 auto; padding: 24px 16px 90px; }
.wrap-narrow { max-width: 880px; margin: 0 auto; padding: 24px 16px 90px; }

.page-head { margin-bottom: 20px; }
.page-head h1 {
  font-size: clamp(24px, 3.4vw, 32px); font-family: var(--disp);
  letter-spacing: -.035em; font-weight: 900;
}
.page-head h1 .hl {
  background: var(--film); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.page-head p { color: var(--ink-2); font-size: 14px; margin-top: 5px; }

/* hero */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--r-xl); padding: 26px 26px 24px;
  background: linear-gradient(115deg, var(--red-900) 0%, #7a1109 45%, var(--red-600) 100%);
  color: #fff; margin-bottom: 22px;
  box-shadow: 0 22px 50px -20px rgba(200, 31, 19, .8);
}
.hero::before {
  content: ""; position: absolute; inset: -40% -10% auto auto; width: 420px; height: 420px;
  background: radial-gradient(circle, rgba(255, 190, 120, .32), transparent 62%);
  pointer-events: none;
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background-image: repeating-linear-gradient(90deg, rgba(255, 255, 255, .05) 0 1px, transparent 1px 44px);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { font-family: var(--disp); font-size: clamp(22px, 3.6vw, 34px); font-weight: 900; letter-spacing: -.035em; }
.hero p { color: rgba(255, 255, 255, .84); font-size: 14.5px; max-width: 62ch; margin: 8px 0 0; }
.hero-stats { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 18px; }
.hero-stats div { line-height: 1.2; }
.hero-stats b { display: block; font-size: 25px; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.hero-stats span { font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; opacity: .72; font-weight: 700; }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); font: inherit; font-size: 13.5px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
  transition: background .13s, border-color .13s, transform .07s, box-shadow .13s;
}
.btn:hover:not(:disabled) { background: var(--bg-2); border-color: var(--red); color: var(--red); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.primary {
  background: var(--film); border-color: transparent; color: #fff;
  box-shadow: 0 6px 18px -6px rgba(230, 43, 30, .75);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.09); color: #fff; box-shadow: 0 8px 26px -6px rgba(230, 43, 30, .9); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover:not(:disabled) { background: var(--bg-2); color: var(--red); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover:not(:disabled) { filter: brightness(1.08); color: #fff; border-color: var(--ok); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; }
.btn.lg { padding: 12px 22px; font-size: 15px; }
.btn.block { width: 100%; }

/* ---------------- cards ---------------- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

.card {
  position: relative;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden;
  display: flex; flex-direction: column;
  text-align: left; padding: 0; cursor: pointer; color: inherit; font: inherit;
  transition: transform .15s cubic-bezier(.2,.7,.3,1), box-shadow .15s, border-color .15s;
}
.card::after {
  content: ""; position: absolute; inset: 0; border-radius: var(--r-lg);
  box-shadow: inset 0 0 0 2px transparent; transition: box-shadow .15s; pointer-events: none;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.card:hover::after { box-shadow: inset 0 0 0 2px var(--red); }

.thumb { position: relative; aspect-ratio: 16/9; background: var(--bg-2); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s cubic-bezier(.2,.7,.3,1); }
.card:hover .thumb img { transform: scale(1.06); }
.thumb::before {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(to top, rgba(30, 5, 3, .55), transparent 45%);
}
.thumb .dur {
  position: absolute; right: 7px; bottom: 7px; z-index: 2;
  background: rgba(0, 0, 0, .84); color: #fff;
  font-size: 11.5px; font-weight: 800; padding: 1px 6px; border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.thumb .prog { position: absolute; left: 0; bottom: 0; z-index: 3; height: 3px; background: var(--film); }
.thumb .corner { position: absolute; left: 7px; top: 7px; z-index: 2; display: flex; gap: 4px; }
.thumb .rank {
  position: absolute; left: 0; top: 0; z-index: 2;
  font-family: var(--disp); font-weight: 900; font-size: 30px; line-height: 1;
  color: #fff; padding: 6px 11px 8px; letter-spacing: -.05em;
  background: linear-gradient(135deg, var(--red) 0%, transparent 78%);
  text-shadow: 0 2px 8px rgba(0, 0, 0, .6);
}

.card-body { padding: 11px 13px 13px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.card-title {
  font-size: 14.5px; font-weight: 700; line-height: 1.42;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: auto; }

.tag {
  font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px;
  background: var(--bg-2); color: var(--ink-2); white-space: nowrap; letter-spacing: .01em;
}
.tag.ja { background: color-mix(in srgb, var(--red) 13%, transparent); color: var(--red); }
.tag.hot { background: var(--film); color: #fff; }
.tag.new { background: var(--ok-bg); color: var(--ok); }
.tag.done { background: var(--ok-bg); color: var(--ok); }
.tag.lv1 { background: var(--ok-bg); color: var(--ok); }
.tag.lv2 { background: var(--warn-bg); color: var(--warn); }
.tag.lv3 { background: var(--bad-bg); color: var(--bad); }
.tag.mine { background: var(--info-bg); color: var(--info); }

/* ---------------- filters ---------------- */
.filters {
  position: sticky; top: var(--topbar-h); z-index: 40;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px);
  padding: 12px 0; margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-row + .filter-row { margin-top: 9px; }

.search { flex: 1 1 250px; min-width: 180px; position: relative; }
.search input {
  width: 100%; padding: 9px 12px 9px 34px;
  border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px;
  transition: border-color .13s, box-shadow .13s;
}
.search input:focus { border-color: var(--red); box-shadow: var(--glow); outline: none; }
.search::before {
  content: "🔍"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  font-size: 13px; opacity: .55; pointer-events: none;
}

select, input[type="text"], input[type="number"], textarea {
  padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 13.5px;
}
select:focus, input:focus, textarea:focus { border-color: var(--red); outline: none; box-shadow: var(--glow); }
textarea { line-height: 1.6; resize: vertical; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 700; color: var(--ink-2); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 13px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 700;
  white-space: nowrap; transition: .13s;
}
.chip:hover { border-color: var(--red); color: var(--red); }
.chip[aria-pressed="true"] {
  background: var(--film); border-color: transparent; color: #fff;
  box-shadow: 0 4px 14px -4px rgba(230, 43, 30, .7);
}
.chip .n { opacity: .65; font-weight: 700; margin-left: 4px; font-size: 11.5px; }

/* ---------------- study view ---------------- */
.study {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(348px, 1fr);
  gap: 20px;
  max-width: 1560px; margin: 0 auto; padding: 18px 16px 60px;
  align-items: start;
}
@media (max-width: 1120px) { .study { grid-template-columns: minmax(0, 1fr); } }

.stage { position: sticky; top: calc(var(--topbar-h) + 14px); }
@media (max-width: 1120px) { .stage { position: static; } }

.study-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.study-head h1 { font-size: 19px; font-weight: 800; line-height: 1.35; }
.study-head .sub { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; }

.player-box {
  position: relative; aspect-ratio: 16/9; width: 100%;
  background: #000; border-radius: var(--r-lg); overflow: hidden;
  box-shadow: 0 20px 50px -18px rgba(0, 0, 0, .7), 0 0 0 1px var(--line);
}
.player-box iframe, .player-box > div { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.overlay-cc {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 20px 20px 18px; pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, .9) 10%, rgba(0, 0, 0, .55) 55%, transparent);
  display: flex; flex-direction: column; gap: 5px; align-items: center; text-align: center;
}
.overlay-cc:empty { display: none; }
.overlay-cc .en {
  font-family: var(--en); font-size: clamp(15px, 2.05vw, 24px); line-height: 1.4;
  color: #fff; font-weight: 500; text-shadow: 0 2px 10px rgba(0, 0, 0, .95);
}
.overlay-cc .ja {
  font-size: clamp(12px, 1.45vw, 16px); line-height: 1.5;
  color: #ffc9c2; text-shadow: 0 2px 10px rgba(0, 0, 0, .95);
}
.overlay-cc .blank {
  display: inline-block; min-width: 3.4em; border-bottom: 2px solid var(--red-400);
  margin: 0 .18em;
}

.transport {
  display: flex; flex-wrap: wrap; align-items: center; gap: 7px;
  margin-top: 11px; padding: 9px 11px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
}
.tbtn {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  border-radius: var(--r-sm); cursor: pointer; font: inherit; font-size: 13px; font-weight: 700;
  padding: 6px 10px; white-space: nowrap; transition: .12s;
}
.tbtn:hover { border-color: var(--red); color: var(--red); }
.tbtn[aria-pressed="true"] { background: var(--film); color: #fff; border-color: transparent; }
.tbtn.wide { min-width: 46px; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; }
.seg button {
  border: 0; background: var(--surface); color: var(--ink-2); cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 800; padding: 6px 12px;
  border-right: 1px solid var(--line); transition: .12s;
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--film); color: #fff; }
.seg button:hover:not([aria-pressed="true"]) { background: var(--bg-2); color: var(--red); }

/* ---------------- activity panel ---------------- */
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden;
  display: flex; flex-direction: column;
  max-height: calc(100vh - var(--topbar-h) - 38px);
  box-shadow: var(--shadow);
}
@media (max-width: 1120px) { .panel { max-height: none; } }

.tabs {
  display: flex; overflow-x: auto; border-bottom: 1px solid var(--line);
  background: var(--surface-2); scrollbar-width: thin;
}
.tab {
  flex: 0 0 auto; border: 0; background: none; cursor: pointer;
  padding: 12px 14px; font: inherit; font-size: 13px; font-weight: 800;
  color: var(--ink-3); white-space: nowrap; position: relative; transition: color .12s;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--red); }
.tab[aria-selected="true"]::after {
  content: ""; position: absolute; left: 9px; right: 9px; bottom: 0; height: 3px;
  background: var(--film); border-radius: 3px 3px 0 0;
}
.panel-body { overflow-y: auto; flex: 1; padding: 14px; scroll-behavior: smooth; }
.panel-body.flush { padding: 0; }

/* ---------------- transcript ---------------- */
.cue {
  display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 10px;
  padding: 9px 12px; border-radius: var(--r); cursor: pointer;
  border: 1px solid transparent; scroll-margin: 90px; transition: background .12s;
}
.cue:hover { background: var(--bg-2); }
.cue.active {
  background: color-mix(in srgb, var(--red) 9%, transparent);
  border-color: color-mix(in srgb, var(--red) 38%, transparent);
}
.cue.learned { opacity: .58; }
.cue-t {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-3);
  font-variant-numeric: tabular-nums; padding-top: 3px;
}
.cue.active .cue-t { color: var(--red); font-weight: 800; }
.cue-en { font-family: var(--en); font-size: 15.5px; line-height: 1.55; }
.cue-ja { font-size: 13px; color: var(--ink-2); line-height: 1.6; margin-top: 3px; }
.cue-tools { display: flex; gap: 4px; margin-top: 6px; opacity: 0; transition: opacity .12s; }
.cue:hover .cue-tools, .cue.active .cue-tools { opacity: 1; }
.minibtn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 5px; cursor: pointer; font: inherit; font-size: 11px; font-weight: 800;
  padding: 2px 8px; transition: .12s;
}
.minibtn:hover { border-color: var(--red); color: var(--red); }
.minibtn.on { background: var(--red); border-color: var(--red); color: #fff; }

.w { cursor: pointer; border-radius: 3px; padding: 0 .5px; transition: background .1s; }
.w:hover { background: color-mix(in srgb, var(--red) 22%, transparent); }
.w.saved { background: color-mix(in srgb, var(--red) 20%, transparent); box-shadow: inset 0 -2px 0 var(--red); }

/* ---------------- dictation ---------------- */
.dict-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.dict-counter { font-family: var(--mono); font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.dict-hint {
  font-family: var(--mono); font-size: 15px; letter-spacing: .06em;
  color: var(--ink-3); background: var(--surface-2);
  padding: 10px 12px; border-radius: var(--r); border: 1px dashed var(--line-strong);
  word-break: break-word; line-height: 1.9;
}
.dict-input { width: 100%; min-height: 92px; font-family: var(--en); font-size: 16px; line-height: 1.6; padding: 11px 13px; }
.diff { font-family: var(--en); font-size: 16px; line-height: 1.95; word-break: break-word; }
.diff .tok { padding: 1px 5px; border-radius: 4px; margin: 0 1px; display: inline-block; }
.diff .tok.ok { background: var(--ok-bg); color: var(--ok); }
.diff .tok.miss { background: var(--bad-bg); color: var(--bad); font-weight: 700; }
.diff .tok.extra { background: var(--bg-2); color: var(--ink-3); text-decoration: line-through; }
.diff .tok.near { background: var(--warn-bg); color: var(--warn); }

.scorebar { height: 9px; border-radius: 5px; background: var(--bg-2); overflow: hidden; }
.scorebar > i { display: block; height: 100%; background: var(--film); transition: width .4s cubic-bezier(.2,.7,.3,1); }
.scorebar.good > i { background: linear-gradient(90deg, var(--ok), #4fe0a8); }

/* ---------------- quiz ---------------- */
.qcard { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; background: var(--surface-2); }
.qprompt { font-family: var(--en); font-size: 17.5px; line-height: 1.55; margin-bottom: 13px; }
.qprompt.ja { font-family: var(--sans); font-size: 15px; }
.opts { display: flex; flex-direction: column; gap: 7px; }
.opt {
  text-align: left; padding: 11px 14px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; line-height: 1.55;
  transition: .12s;
}
.opt:hover:not(:disabled) { border-color: var(--red); background: var(--bg-2); }
.opt.correct { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); font-weight: 700; }
.opt.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.opt:disabled { cursor: default; }

/* ---------------- vocab / review ---------------- */
.vlist { display: flex; flex-direction: column; gap: 8px; }
.vitem {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: start;
  padding: 10px 13px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
  transition: border-color .12s;
}
.vitem:hover { border-color: var(--line-strong); }
.vword { font-family: var(--en); font-size: 16.5px; font-weight: 700; }
.vctx { font-size: 12.5px; color: var(--ink-2); line-height: 1.55; margin-top: 3px; }
.vctx b { color: var(--red); font-weight: 800; }
.vmeta { display: flex; gap: 5px; align-items: center; }

.flash {
  border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--surface);
  padding: 34px 24px; text-align: center; box-shadow: var(--shadow-lg);
  position: relative; overflow: hidden;
}
.flash::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--film); }
.flash .front { font-family: var(--en); font-size: 32px; font-weight: 700; line-height: 1.3; }
.flash .front.jp { font-family: var(--sans); font-size: 20px; font-weight: 600; }
.flash .back { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.grade-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 18px; }

/* ---------------- stats ---------------- */
.stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(152px, 1fr)); }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 15px 17px; position: relative; overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--film); }
.stat .k { font-size: 11.5px; color: var(--ink-2); font-weight: 800; letter-spacing: .03em; }
.stat .v {
  font-family: var(--disp); font-size: 30px; font-weight: 900; letter-spacing: -.035em;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.stat .v small { font-size: 14px; font-weight: 800; color: var(--ink-2); margin-left: 2px; }

.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat i { width: 12px; height: 12px; border-radius: 3px; background: var(--bg-2); display: block; }
.heat i[data-l="1"] { background: color-mix(in srgb, var(--red) 28%, var(--bg-2)); }
.heat i[data-l="2"] { background: color-mix(in srgb, var(--red) 52%, var(--bg-2)); }
.heat i[data-l="3"] { background: color-mix(in srgb, var(--red) 76%, var(--bg-2)); }
.heat i[data-l="4"] { background: var(--red); }

/* ---------------- misc ---------------- */
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 17px; }
.box + .box { margin-top: 14px; }
.box h3 { font-size: 15.5px; margin-bottom: 9px; }

.empty { text-align: center; padding: 64px 20px; color: var(--ink-2); }
.empty .ico { font-size: 44px; display: block; margin-bottom: 10px; opacity: .45; }

.notice { padding: 11px 14px; border-radius: var(--r); font-size: 13px; line-height: 1.6; }
.notice.info { background: var(--info-bg); color: var(--info); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }

.spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--red);
  animation: spin .7s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

.skel { background: linear-gradient(90deg, var(--bg-2) 25%, var(--surface-2) 50%, var(--bg-2) 75%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: var(--r); }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

kbd {
  font-family: var(--mono); font-size: 11.5px; padding: 2px 6px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 5px; background: var(--surface-2); color: var(--ink-2); font-weight: 700;
}

.dialog {
  border: 1px solid var(--line); border-radius: var(--r-xl); padding: 24px;
  background: var(--surface); color: var(--ink); max-width: 480px; width: calc(100% - 32px);
  box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(30, 5, 3, .62); backdrop-filter: blur(4px); }
.kbd-grid { display: grid; grid-template-columns: auto 1fr; gap: 9px 14px; margin: 15px 0; font-size: 13.5px; align-items: center; }

.toast-host {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--film); color: #fff; padding: 9px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 700; box-shadow: 0 10px 30px -8px rgba(230, 43, 30, .8);
  animation: pop .22s cubic-bezier(.2,.7,.3,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.96); } }

hr.sep { border: 0; border-top: 1px solid var(--line); margin: 17px 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 5px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--red); }
::-webkit-scrollbar-track { background: transparent; }
::selection { background: color-mix(in srgb, var(--red) 30%, transparent); }
