/* ==========================================================================
   Lexi — design system
   Editorial "study journal" aesthetic: warm paper, deep forest ink,
   coral accents, serif display + compact UI sans.
   ========================================================================== */

/* --- tokens ------------------------------------------------------------- */
:root {
  --paper: #f7f2e9;
  --paper-2: #efe7d9;
  --surface: #fffdf8;
  --surface-2: #faf5eb;
  --surface-3: #f3ecdf;
  --ink: #171a17;
  --ink-2: #3b413a;
  --muted: #5c6157;
  --line: #e5dccb;
  --line-strong: #cdbfa5;
  --forest: #11594a;
  --forest-2: #0c4438;
  --forest-soft: #e2efe8;
  --on-forest: #fdfbf5;
  --coral: #dd5330;
  --coral-soft: #fbe6de;
  --gold: #b98a22;
  --gold-soft: #f8eed6;
  --sky: #37789f;
  --sky-soft: #e3eef5;
  --danger: #b3341f;
  --lv-a1: #2f9e7a;
  --lv-a2: #3f86a8;
  --lv-b1: #8168b8;
  --lv-b2: #c5862c;
  --shadow-sm: 0 1px 2px rgba(38, 32, 20, .05);
  --shadow: 0 1px 2px rgba(38, 32, 20, .05), 0 10px 26px -14px rgba(38, 32, 20, .26);
  --shadow-lg: 0 2px 4px rgba(38, 32, 20, .05), 0 24px 60px -24px rgba(38, 32, 20, .34);
  --radius: 20px;
  --radius-sm: 13px;
  --serif: "Fraunces", ui-serif, "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 0.9;
  --grain-opacity: .05;
}

html[data-theme="dark"] {
  --paper: #0d1512;
  --paper-2: #0a100e;
  --surface: #15201b;
  --surface-2: #1b2822;
  --surface-3: #223128;
  --ink: #ece6d8;
  --ink-2: #d3dbd1;
  --muted: #a3b0a6;
  --line: #2a3b31;
  --line-strong: #3d5445;
  --forest: #5cc9a8;
  --forest-2: #8ce0c5;
  --forest-soft: rgba(92, 201, 168, .13);
  --on-forest: #06140f;
  --coral: #ff8f68;
  --coral-soft: rgba(255, 143, 104, .14);
  --gold: #e5b95f;
  --gold-soft: rgba(229, 185, 95, .14);
  --sky: #7fc3e2;
  --sky-soft: rgba(127, 195, 226, .13);
  --danger: #ff8a73;
  --lv-a1: #52c69f;
  --lv-a2: #6fb4d6;
  --lv-b1: #a893e0;
  --lv-b2: #e3a952;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px -16px rgba(0, 0, 0, .7);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .35), 0 28px 60px -26px rgba(0, 0, 0, .85);
  --grain-opacity: .03;
}

/* --- reset -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.55;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg, canvas { display: block; max-width: 100%; }
::selection { background: var(--forest); color: var(--on-forest); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ico--sm { width: 16px; height: 16px; }
.ico--lg { width: 26px; height: 26px; }

:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; border-radius: 6px; }

.grain {
  position: fixed; inset: 0; z-index: 1; pointer-events: none; opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}
html[data-theme="dark"] .grain { mix-blend-mode: screen; }

/* --- shell -------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: 100vh; }
.main { display: flex; flex-direction: column; min-width: 0; position: relative; z-index: 2; }

.sidebar {
  position: sticky; top: 0; z-index: 30;
  height: 100vh; display: flex; flex-direction: column; gap: 26px;
  padding: 26px 18px 20px;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(120% 60% at 0% 0%, var(--forest-soft), transparent 70%),
    var(--surface-2);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--forest); color: var(--on-forest); flex: none;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18), var(--shadow-sm);
}
.brand-mark svg { width: 30px; height: 30px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: -.02em; }
.brand-text small { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.brand--mobile { display: none; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  height: 43px; padding: 0 11px; border-radius: 12px;
  color: var(--ink-2); font-weight: 500; font-size: 14.5px;
  border: 1px solid transparent; transition: background .16s, color .16s, transform .16s;
  position: relative;
}
.nav-item .ico { color: var(--muted); transition: color .16s; }
.nav-item:hover { background: color-mix(in srgb, var(--surface) 70%, transparent); color: var(--ink); }
.nav-item:hover .ico { color: var(--ink-2); }
.nav-item.is-active {
  background: var(--surface); color: var(--ink); border-color: var(--line);
  box-shadow: var(--shadow-sm); font-weight: 600;
}
.nav-item.is-active .ico { color: var(--forest); }
.nav-item.is-active::before {
  content: ""; position: absolute; left: -18px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--forest);
}
.nav-label { flex: 1; }
.nav-count {
  min-width: 21px; height: 20px; padding: 0 6px; border-radius: 6px;
  background: var(--coral-soft); color: var(--coral);
  font-size: 11.5px; font-weight: 700; display: grid; place-items: center;
  font-variant-numeric: tabular-nums;
}
.nav-count:empty { display: none; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.theme-toggle {
  display: flex; align-items: center; gap: 10px; width: 100%;
  height: 40px; padding: 0 11px; border-radius: 11px; color: var(--muted);
  font-size: 13.5px; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 55%, transparent);
}
.theme-toggle:hover { color: var(--ink); background: var(--surface); }
.sidebar-note { font-size: 12px; color: var(--muted); padding: 0 11px; line-height: 1.45; }

/* --- topbar ------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 25;
  height: 65px; display: flex; align-items: center; gap: 16px;
  padding: 0 clamp(18px, 4vw, 46px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
}
.topbar-title { font-size: 13px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 9px; }
.pills { display: flex; align-items: center; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 33px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2);
}
.pill .ico { color: var(--gold); }
.pill--xp .ico { color: var(--forest); }
.pill--streak.is-hot { border-color: color-mix(in srgb, var(--coral) 35%, var(--line)); background: var(--coral-soft); color: var(--coral); }
.pill--streak.is-hot .ico { color: var(--coral); }
.avatar {
  width: 35px; height: 35px; border-radius: 50%; display: grid; place-items: center;
  background: var(--forest); color: var(--on-forest); font-weight: 650; font-size: 14px;
  border: 2px solid color-mix(in srgb, var(--forest) 30%, var(--surface));
  box-shadow: var(--shadow-sm);
}
.avatar:hover { transform: translateY(-1px); }

/* --- view --------------------------------------------------------------- */
.view {
  flex: 1; width: 100%; max-width: 1160px; margin: 0 auto;
  padding: 30px clamp(18px, 4vw, 46px) 44px;
  animation: viewIn .34s cubic-bezier(.2, .7, .2, 1);
}
@keyframes viewIn { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 18px; margin-bottom: 24px; }
.page-head__text { flex: 1 1 320px; min-width: 0; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--forest); margin-bottom: 9px;
}
.eyebrow::before { content: ""; width: 16px; height: 2px; border-radius: 2px; background: currentColor; opacity: .5; }
.page-title { font-family: var(--serif); font-weight: 600; font-size: clamp(27px, 3.3vw, 38px); line-height: 1.1; letter-spacing: -.025em; }
.page-sub { color: var(--muted); margin-top: 9px; max-width: 62ch; font-size: 14.8px; }

.foot {
  display: flex; flex-wrap: wrap; gap: 10px 22px; justify-content: space-between;
  padding: 18px clamp(18px, 4vw, 46px) 26px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 11.8px;
}
.foot strong { color: var(--ink-2); font-weight: 600; }
.foot-keys { display: inline-flex; align-items: center; gap: 6px; }
kbd {
  font-family: var(--sans); font-size: 10.5px; font-weight: 600; color: var(--ink-2);
  background: var(--surface-3); border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 5px; line-height: 1.5;
}

/* --- generic ------------------------------------------------------------ */
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 1.62fr) minmax(0, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mt-0 { margin-top: 0; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.muted { color: var(--muted); }
.small { font-size: 13.2px; }
.mono { font-family: var(--mono); }
.center { text-align: center; }
.hidden { display: none !important; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); position: relative;
}
.card--pad { padding: 22px; }
.card--flush { overflow: hidden; }
.card--quiet { box-shadow: var(--shadow-sm); background: var(--surface-2); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 16px; }
.card-title { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: -.015em; }
.card-sub { font-size: 12.8px; color: var(--muted); }

/* buttons */
.btn {
  --btn-bg: transparent; --btn-fg: var(--ink); --btn-bd: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 17px; border-radius: 999px;
  background: var(--btn-bg); color: var(--btn-fg); border: 1px solid var(--btn-bd);
  font-size: 14px; font-weight: 600; white-space: nowrap;
  transition: transform .14s, box-shadow .18s, background .18s, border-color .18s, opacity .18s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.99); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn--primary { --btn-bg: var(--forest); --btn-fg: var(--on-forest); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.btn--primary:hover { --btn-bg: var(--forest-2); box-shadow: 0 6px 18px -8px color-mix(in srgb, var(--forest) 80%, transparent); }
.btn--coral { --btn-bg: var(--coral); --btn-fg: #fff8f4; }
.btn--soft { --btn-bg: var(--surface-2); --btn-bd: var(--line); --btn-fg: var(--ink); }
.btn--soft:hover { --btn-bg: var(--surface-3); --btn-bd: var(--line-strong); }
.btn--ghost { --btn-fg: var(--ink-2); }
.btn--ghost:hover { --btn-bg: var(--surface-2); }
.btn--danger { --btn-bg: var(--coral-soft); --btn-fg: var(--danger); --btn-bd: color-mix(in srgb, var(--coral) 25%, transparent); }
.btn--warn { --btn-bg: var(--coral-soft); --btn-fg: var(--danger); --btn-bd: color-mix(in srgb, var(--coral) 42%, transparent); }
.btn--warn:hover { --btn-bg: color-mix(in srgb, var(--coral) 18%, var(--surface)); }
.btn--lg { height: 50px; padding: 0 24px; font-size: 15px; }
.btn--sm { height: 34px; padding: 0 13px; font-size: 13px; }
.btn--block { width: 100%; }
.btn--icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; }
.btn[aria-pressed="true"] { --btn-bg: var(--forest-soft); --btn-fg: var(--forest); --btn-bd: color-mix(in srgb, var(--forest) 30%, transparent); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px;
  border-radius: 7px; font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; background: var(--surface-3); color: var(--ink-2);
  border: 1px solid var(--line); white-space: nowrap;
}
.chip--a1 { background: color-mix(in srgb, var(--lv-a1) 14%, var(--surface)); color: var(--lv-a1); border-color: color-mix(in srgb, var(--lv-a1) 28%, transparent); }
.chip--a2 { background: color-mix(in srgb, var(--lv-a2) 14%, var(--surface)); color: var(--lv-a2); border-color: color-mix(in srgb, var(--lv-a2) 28%, transparent); }
.chip--b1 { background: color-mix(in srgb, var(--lv-b1) 14%, var(--surface)); color: var(--lv-b1); border-color: color-mix(in srgb, var(--lv-b1) 28%, transparent); }
.chip--b2 { background: color-mix(in srgb, var(--lv-b2) 14%, var(--surface)); color: var(--lv-b2); border-color: color-mix(in srgb, var(--lv-b2) 28%, transparent); }
.chip--pos { text-transform: lowercase; letter-spacing: 0; font-weight: 600; font-size: 12px; color: var(--muted); background: transparent; border-color: var(--line); }
.chip--xs { height: 20px; padding: 0 7px; font-size: 10px; border-radius: 6px; letter-spacing: .06em; }
.chip--new { background: var(--surface-3); color: var(--muted); border-color: var(--line); }
.chip--learning { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.chip--review { background: var(--sky-soft); color: var(--sky); border-color: transparent; }
.chip--mastered { background: var(--forest); color: var(--on-forest); border-color: transparent; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.progress { display: block; height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress__fill { display: block; height: 100%; border-radius: 99px; background: var(--forest); transition: width .5s cubic-bezier(.2,.8,.2,1); }
.progress--lg { height: 10px; }

/* level bar rows */
.level-row { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 12px; }
.level-tag { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.level-bar { height: 9px; border-radius: 99px; background: var(--surface-3); overflow: hidden; position: relative; }
.level-bar__fill { height: 100%; border-radius: 99px; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.level-bar__fill[data-lv="A1"] { background: var(--lv-a1); }
.level-bar__fill[data-lv="A2"] { background: var(--lv-a2); }
.level-bar__fill[data-lv="B1"] { background: var(--lv-b1); }
.level-bar__fill[data-lv="B2"] { background: var(--lv-b2); }
.level-num { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 76px; text-align: right; }

/* --- hero --------------------------------------------------------------- */
.hero {
  padding: 26px; border-radius: 24px; margin-bottom: 16px;
  background:
    radial-gradient(90% 130% at 100% 0%, color-mix(in srgb, var(--coral) 10%, transparent), transparent 60%),
    radial-gradient(80% 120% at 0% 100%, color-mix(in srgb, var(--forest) 10%, transparent), transparent 55%),
    var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  display: grid; grid-template-columns: minmax(0, 1.45fr) auto; gap: 24px; align-items: center;
  overflow: hidden; position: relative;
}
.hero h1 { font-family: var(--serif); font-size: clamp(26px, 3.1vw, 37px); font-weight: 600; line-height: 1.12; letter-spacing: -.025em; }
.hero h1 em {
  font-style: normal; color: var(--forest);
  box-shadow: inset 0 -0.2em 0 color-mix(in srgb, var(--forest) 15%, transparent);
}
.hero-sub { color: var(--muted); margin-top: 10px; font-size: 14.5px; max-width: 48ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.hero-aside { display: flex; align-items: center; gap: 18px; padding-right: 4px; }

.ring { position: relative; width: 118px; height: 118px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring__track { fill: none; stroke: var(--surface-3); stroke-width: 8; }
.ring__bar { fill: none; stroke: var(--forest); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset .8s cubic-bezier(.2,.8,.2,1); }
.ring__inner { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 1px; padding: 0 18px; }
.ring__value { font-family: var(--serif); font-size: 25px; font-weight: 600; line-height: 1; letter-spacing: -.03em; }
.ring__label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; line-height: 1.2; }
.ring-wrap { display: flex; flex-direction: column; align-items: center; gap: 7px; flex: none; }
.ring__foot { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.mini-stats { display: flex; flex-direction: column; gap: 11px; }
.mini-stat { display: flex; gap: 9px; align-items: center; }
.mini-stat__icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); flex: none; }
.mini-stat__icon .ico { width: 16px; height: 16px; }
.mini-stat__value { font-weight: 650; font-size: 15px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.mini-stat__label { font-size: 12px; color: var(--muted); line-height: 1.2; }

/* action tiles */
.action-tile {
  display: flex; flex-direction: column; gap: 6px; padding: 20px; text-align: left;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--shadow); transition: transform .18s, box-shadow .18s, border-color .18s;
  min-height: 148px; position: relative; overflow: hidden;
}
.action-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--line-strong); }
.action-tile__icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 4px; }
.action-tile h3 { font-family: var(--serif); font-size: 19px; font-weight: 600; }
.action-tile p { color: var(--muted); font-size: 13.2px; }
.action-tile__go { position: absolute; right: 18px; top: 20px; color: var(--muted); transition: transform .2s, color .2s; }
.action-tile:hover .action-tile__go { transform: translateX(3px); color: var(--ink); }
.action-tile--learn .action-tile__icon { background: var(--forest-soft); color: var(--forest); }
.action-tile--review .action-tile__icon { background: var(--coral-soft); color: var(--coral); }
.action-tile--quiz .action-tile__icon { background: var(--sky-soft); color: var(--sky); }
.action-tile--dict .action-tile__icon { background: var(--gold-soft); color: var(--gold); }
.action-tile.is-idle { opacity: .78; }
.action-tile.is-idle:hover { opacity: 1; }
.action-tile__meta { margin-top: auto; display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); font-weight: 600; }
.action-tile__meta .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--coral); }

/* --- level path --------------------------------------------------------- */
.path { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 4px 0 2px; }
.path-step { position: relative; display: flex; flex-direction: column; gap: 9px; padding: 0 10px 0 0; }
.path-step::before {
  content: ""; position: absolute; left: 18px; right: 0; top: 17px; height: 2px;
  background: var(--line); z-index: 0;
}
.path-step:last-child::before { display: none; }
.path-node {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 2px solid var(--line-strong); color: var(--muted);
  font-size: 12px; font-weight: 700; letter-spacing: .03em; position: relative; z-index: 1;
}
.path-step.is-started .path-node { border-color: var(--gold); color: var(--gold); }
.path-step.lv-a1.is-started .path-node { border-color: var(--lv-a1); color: var(--lv-a1); }
.path-step.lv-a2.is-started .path-node { border-color: var(--lv-a2); color: var(--lv-a2); }
.path-step.lv-b1.is-started .path-node { border-color: var(--lv-b1); color: var(--lv-b1); }
.path-step.lv-b2.is-started .path-node { border-color: var(--lv-b2); color: var(--lv-b2); }
.path-step.is-done .path-node { background: var(--forest); border-color: var(--forest); color: var(--on-forest); }
.path-name { font-size: 12.5px; font-weight: 600; }
.path-meta { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* --- stats / charts ----------------------------------------------------- */
.stat-block { padding: 16px 18px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.stat-block__value { font-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: -.03em; line-height: 1.1; }
.stat-block__label { font-size: 11.5px; color: var(--muted); margin-top: 3px; letter-spacing: .01em; }
.stat-block__delta { font-size: 11.5px; font-weight: 600; color: var(--forest); margin-top: 6px; }

.bars { display: flex; align-items: flex-end; gap: 7px; height: 118px; margin-top: 6px; }
.bar-wrap { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 6px; min-width: 0; }
.bar { width: 100%; border-radius: 5px 5px 2px 2px; background: color-mix(in srgb, var(--forest) 26%, var(--surface-3)); min-height: 2px; transition: height .5s, background .2s; position: relative; }
.bar.is-today { background: var(--coral); }
.bar:hover { background: var(--forest); }
.bar-labels { display: flex; gap: 7px; margin-top: 7px; }
.bar-labels span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); min-width: 0; overflow: hidden; }

.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); gap: 4px; overflow-x: auto; padding-bottom: 4px; }
.heat-cell { width: 12px; height: 12px; border-radius: 3px; background: var(--surface-3); }
.heat-cell[data-l="1"] { background: color-mix(in srgb, var(--forest) 28%, var(--surface-3)); }
.heat-cell[data-l="2"] { background: color-mix(in srgb, var(--forest) 52%, var(--surface-3)); }
.heat-cell[data-l="3"] { background: color-mix(in srgb, var(--forest) 76%, var(--surface-3)); }
.heat-cell[data-l="4"] { background: var(--forest); }
.heat-cell.is-today { outline: 1.5px solid var(--coral); outline-offset: 1px; }
.heat-legend { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--muted); margin-top: 10px; }

.forecast { display: flex; align-items: flex-end; gap: 5px; height: 84px; }
.forecast__col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; height: 100%; }
.forecast__bar { width: 100%; border-radius: 4px; background: color-mix(in srgb, var(--sky) 55%, var(--surface-3)); min-height: 2px; }
.forecast__n { font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* vocabulary mosaic */
.map-wrap { position: relative; margin-top: 2px; }
.map-wrap canvas { display: block; width: 100%; border-radius: 10px; cursor: crosshair; }
.map-tip {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -135%);
  padding: 4px 8px; border-radius: 6px; background: var(--ink); color: var(--paper);
  font-size: 11.5px; font-weight: 500; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .12s; z-index: 3;
}
.map-tip.is-on { opacity: 1; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 11.5px; color: var(--muted); margin-top: 12px; }
.map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.map-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.map-legend b { color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }

/* words that keep slipping */
.attention-list { display: flex; flex-direction: column; }
.attention-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 6px; border-bottom: 1px solid var(--line); border-radius: 8px;
  text-align: left; transition: background .14s;
}
.attention-row:last-child { border-bottom: 0; }
.attention-row:hover { background: var(--surface-2); }
.attention-row__word { flex: 1; min-width: 0; font-family: var(--serif); font-size: 16.5px; font-weight: 600; letter-spacing: -.01em; }
.attention-row__word small { display: block; font-family: var(--sans); font-size: 11.5px; font-weight: 400; color: var(--muted); }
.attention-row__meta { font-size: 12px; font-weight: 600; color: var(--coral); white-space: nowrap; }
.attention-row__go { color: var(--muted); display: inline-flex; }
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important;
  transition-duration: .001ms !important; scroll-behavior: auto !important;
}

/* --- session / flashcard ------------------------------------------------ */
.session { max-width: 760px; margin: 0 auto; }
.session-top { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.session-top .progress { flex: 1; }
.session-count { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.session-exit { color: var(--muted); display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; }
.session-exit:hover { color: var(--ink); }

.flip-scene { perspective: 1600px; min-height: 410px; }
.wordcard { position: relative; transform-style: preserve-3d; transition: transform .62s cubic-bezier(.3, .9, .2, 1); min-height: 410px; }
.wordcard.is-flipped { transform: rotateY(180deg); }
.wc-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; padding: 26px;
  border-radius: 24px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.wc-back { transform: rotateY(180deg); overflow-y: auto; }
.wc-face::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, var(--lv-a1), var(--lv-a2), var(--lv-b1), var(--lv-b2));
  opacity: .35;
}
.wc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.wc-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 10px 0 4px; }
.word-huge { font-family: var(--serif); font-size: clamp(38px, 7vw, 62px); line-height: 1.04; font-weight: 600; letter-spacing: -.035em; word-break: break-word; }
.word-huge--sm { font-size: clamp(28px, 4.6vw, 40px); }
.ipa { font-family: var(--mono); font-size: 14px; color: var(--muted); }
.audio-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--forest-soft); color: var(--forest); border: 1px solid color-mix(in srgb, var(--forest) 38%, transparent);
  transition: transform .18s, background .18s;
}
.audio-btn:hover { transform: scale(1.06); background: color-mix(in srgb, var(--forest) 20%, var(--surface)); }
.audio-btn.is-speaking { animation: breathe 1.1s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.1); } }
.wc-hint { text-align: center; font-size: 12.5px; color: var(--muted); padding-top: 12px; border-top: 1px dashed var(--line); display: flex; align-items: center; justify-content: center; gap: 8px; }
.wc-hint kbd { background: var(--surface-2); }

.def { font-size: 16.5px; line-height: 1.55; }
.gloss {
  display: inline-flex; align-items: baseline; gap: 9px; flex-wrap: wrap;
  padding: 11px 15px; border-radius: 12px; background: var(--coral-soft);
  border: 1px solid color-mix(in srgb, var(--coral) 22%, transparent);
  font-weight: 600; color: var(--ink); align-self: flex-start;
}
.gloss__label { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--coral); font-weight: 700; }
.gloss__value { font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.example { font-size: 14.5px; color: var(--ink-2); font-style: italic; border-left: 2px solid var(--line-strong); padding-left: 13px; }
.example mark { background: color-mix(in srgb, var(--gold) 30%, transparent); color: inherit; padding: 0 2px; border-radius: 3px; font-style: normal; font-weight: 600; }
.senses { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; }
.sense-row { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: baseline; }
.sense-row b { color: var(--ink-2); font-weight: 600; }

.grade-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-top: 18px; }
.grade {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px;
  border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 650; font-size: 13.5px; transition: transform .14s, box-shadow .18s, border-color .18s;
  color: var(--ink);
}
.grade small { font-size: 10.5px; color: var(--muted); font-weight: 500; }
.grade:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.grade[data-grade="0"] { border-color: color-mix(in srgb, var(--coral) 32%, var(--line)); }
.grade[data-grade="0"]:hover { background: var(--coral-soft); }
.grade[data-grade="1"] { border-color: color-mix(in srgb, var(--gold) 32%, var(--line)); }
.grade[data-grade="1"]:hover { background: var(--gold-soft); }
.grade[data-grade="2"] { border-color: color-mix(in srgb, var(--forest) 34%, var(--line)); }
.grade[data-grade="2"]:hover { background: var(--forest-soft); }
.grade[data-grade="3"] { border-color: color-mix(in srgb, var(--sky) 34%, var(--line)); }
.grade[data-grade="3"]:hover { background: var(--sky-soft); }
.mastery { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }
.mastery .progress { width: 62px; height: 5px; }

/* learn-mode reveal */
.reveal-box { display: flex; flex-direction: column; gap: 12px; }
.learn-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }

/* --- quiz --------------------------------------------------------------- */
.quiz-card { max-width: 720px; margin: 0 auto; }
.quiz-prompt { font-family: var(--serif); font-size: clamp(24px, 3.4vw, 33px); line-height: 1.2; letter-spacing: -.02em; }
.quiz-question { text-align: center; padding: 24px 8px 6px; }
.quiz-type { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--coral); font-weight: 700; }
.blank { letter-spacing: .04em; }
.blank__slot { display: inline-block; min-width: 96px; border-bottom: 2px dashed var(--line-strong); }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 22px; }
.option {
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 14px 16px; border-radius: 13px; border: 1px solid var(--line); background: var(--surface);
  font-size: 14.5px; font-weight: 500; transition: transform .14s, border-color .16s, background .16s;
  min-height: 54px;
}
.option:hover:not(:disabled) { border-color: var(--forest); background: var(--forest-soft); transform: translateY(-1px); }
.option__key { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--muted); flex: none; }
.option.is-correct { border-color: var(--forest); background: var(--forest-soft); font-weight: 650; }
.option.is-correct .option__key { background: var(--forest); color: var(--on-forest); }
.option.is-wrong { border-color: var(--coral); background: var(--coral-soft); }
.option.is-wrong .option__key { background: var(--coral); color: #fff; }
.option:disabled { cursor: default; }
.quiz-feedback { margin-top: 14px; font-size: 13.5px; display: flex; align-items: flex-start; gap: 9px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.quiz-feedback .ico { color: var(--forest); margin-top: 2px; }

/* --- dictionary --------------------------------------------------------- */
.dict-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.search-field { position: relative; flex: 1 1 260px; }
.search-field .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-field input {
  width: 100%; height: 44px; padding: 0 40px 0 42px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 14.5px; transition: border-color .15s, box-shadow .15s;
}
.search-field input::placeholder { color: var(--muted); }
.search-field input:focus { outline: none; border-color: var(--forest); box-shadow: 0 0 0 3px var(--forest-soft); }
.search-clear { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.search-clear:hover { background: var(--surface-3); color: var(--ink); }

.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); gap: 2px; }
.seg button { height: 34px; padding: 0 11px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.seg button:hover { color: var(--ink); }
.seg button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.seg__dot { width: 6px; height: 6px; border-radius: 50%; }

select.select {
  height: 36px; padding: 0 30px 0 11px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface) 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='%23777570' stroke-width='2.4'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  font-size: 13px; font-weight: 500; appearance: none; color: var(--ink);
}

.dict-list { border-top: 0; }
.dict-head, .dict-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.15fr) minmax(0, 2.2fr) 96px 64px 128px 34px;
  gap: 12px;
  align-items: center;
}
.dict-head {
  padding: 9px 14px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.dict-head__right { text-align: right; }
.dict-row {
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  cursor: pointer; transition: background .14s; position: relative;
}
.dict-row:last-child { border-bottom: 0; }
.dict-row:hover { background: var(--surface-2); }
.dict-row:focus-visible { outline: 2px solid var(--forest); outline-offset: -2px; border-radius: 6px; }
.dict-row__word {
  font-family: var(--serif); font-size: 17.5px; font-weight: 600; letter-spacing: -.015em;
  display: flex; align-items: center; gap: 7px; min-width: 0; overflow-wrap: anywhere;
}
.dict-fav { color: var(--gold); display: inline-flex; flex: none; }
.dict-row__gloss { font-size: 13.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dict-row__status, .dict-row__level { display: flex; min-width: 0; }
.dict-row__mastery {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.dict-row__mastery .progress { width: 64px; height: 6px; flex: none; background: color-mix(in srgb, var(--ink) 12%, var(--surface)); }
.dict-row__mastery b { font-weight: 600; color: var(--ink-2); min-width: 34px; text-align: right; }
.dict-row__dash { color: var(--line-strong); }
.dict-audio {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  color: var(--muted); opacity: 0; transition: opacity .15s, background .15s, color .15s;
}
.dict-row:hover .dict-audio,
.dict-row:focus-within .dict-audio,
.dict-audio:focus-visible { opacity: 1; }
.dict-audio:hover { background: var(--forest-soft); color: var(--forest); }
@media (hover: none) { .dict-audio { opacity: .7; } }
.dict-row__pos { font-size: 11.5px; color: var(--muted); font-style: italic; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); flex: none; }
.dot[data-s="new"] { background: var(--line-strong); }
.dot[data-s="learning"] { background: var(--gold); }
.dot[data-s="review"] { background: var(--sky); }
.dot[data-s="mastered"] { background: var(--forest); }
.dict-more { display: flex; justify-content: center; padding-top: 18px; }
.dict-count { font-size: 12.5px; color: var(--muted); }

/* --- badges ------------------------------------------------------------- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.badge-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 14px 8px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2);
  position: relative;
}
.badge-item__icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent); }
.badge-item__name { font-size: 12px; font-weight: 600; line-height: 1.25; }
.badge-item__desc { font-size: 11px; color: var(--muted); line-height: 1.3; }
.badge-item.is-locked { opacity: .55; filter: grayscale(.7); }
.badge-item.is-locked .badge-item__icon { background: var(--surface-3); color: var(--muted); border-color: var(--line); }
.badge-item.is-unlocked { background: linear-gradient(160deg, var(--gold-soft), var(--surface)); border-color: color-mix(in srgb, var(--gold) 34%, var(--line)); }

/* --- word of day -------------------------------------------------------- */
.wotd { display: flex; flex-direction: column; gap: 12px; }
.wotd__word { font-family: var(--serif); font-size: 28px; font-weight: 600; letter-spacing: -.025em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wotd__gloss { font-size: 13.5px; color: var(--forest); font-weight: 600; }
.wotd__def { font-size: 13.5px; color: var(--ink-2); line-height: 1.5; }

/* --- empty / misc ------------------------------------------------------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 40px 20px; }
.empty__icon { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.empty__icon .ico { width: 30px; height: 30px; }
.empty h3 { font-family: var(--serif); font-size: 20px; font-weight: 600; }
.empty p { color: var(--muted); font-size: 13.8px; max-width: 44ch; }

.note {
  display: flex; gap: 10px; padding: 13px 15px; border-radius: 12px; font-size: 13px;
  background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 26%, transparent);
  color: var(--ink-2); line-height: 1.5;
}
.note .ico { color: var(--gold); flex: none; margin-top: 1px; }
.note--forest { background: var(--forest-soft); border-color: color-mix(in srgb, var(--forest) 22%, transparent); }
.note--forest .ico { color: var(--forest); }

.kv { display: flex; flex-direction: column; gap: 0; }
.kv__row { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.kv__row:last-child { border-bottom: 0; }
.kv__row dt { color: var(--muted); }
.kv__row dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 11.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

/* --- forms -------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.input {
  height: 44px; padding: 0 13px; border-radius: 11px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-size: 14.5px; width: 100%;
}
.input::placeholder { color: var(--muted); opacity: .85; }
.input:focus { outline: none; border-color: var(--forest); box-shadow: 0 0 0 3px var(--forest-soft); }
.hint { font-size: 12.2px; color: var(--muted); line-height: 1.45; }
.switch { position: relative; width: 48px; height: 28px; border-radius: 99px; background: var(--line-strong); transition: background .2s; flex: none; }
.switch::before { content: ""; position: absolute; inset: -8px; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--forest); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row__text { display: flex; flex-direction: column; gap: 2px; }
.setting-row__text strong { font-size: 14px; font-weight: 600; }
.setting-row__text span { font-size: 12.5px; color: var(--muted); }

@media (max-width: 480px) {
  .setting-row--stack { flex-direction: column; align-items: stretch; gap: 10px; }
  .setting-row--stack .seg { width: 100%; }
  .setting-row--stack .seg button { flex: 1; justify-content: center; }
}

/* --- modal -------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(12, 18, 15, .5); backdrop-filter: blur(6px);
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: var(--shadow-lg); padding: 24px; animation: modalIn .28s cubic-bezier(.2,.8,.2,1);
  position: relative;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.97); } }
.modal--wide { max-width: 680px; }
.modal__close { position: absolute; right: 14px; top: 14px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.modal__close:hover { background: var(--surface-3); color: var(--ink); }
.modal h2 { font-family: var(--serif); font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin-bottom: 6px; padding-right: 34px; }
.modal p.lead { color: var(--muted); font-size: 13.8px; margin-bottom: 18px; }
.modal-foot { display: flex; gap: 9px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }

/* --- toasts / confetti -------------------------------------------------- */
.toast-root { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 9px; padding: 10px 16px; border-radius: 999px;
  background: var(--ink); color: var(--paper); font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: toastIn .26s cubic-bezier(.2,.8,.2,1);
  max-width: min(90vw, 460px);
}
.toast .ico { color: var(--forest); width: 17px; height: 17px; }
html[data-theme="dark"] .toast { background: var(--surface-3); color: var(--ink); border: 1px solid var(--line-strong); }
.toast.is-out { animation: toastOut .22s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }
.confetti { position: fixed; inset: 0; z-index: 110; pointer-events: none; width: 100%; height: 100%; }

/* --- onboarding --------------------------------------------------------- */
.onboard {
  position: fixed; inset: 0; z-index: 100; overflow-y: auto;
  background:
    radial-gradient(70% 60% at 15% 0%, var(--forest-soft), transparent 60%),
    radial-gradient(60% 50% at 100% 100%, var(--coral-soft), transparent 60%),
    var(--paper);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.onboard-inner { width: 100%; max-width: 560px; animation: viewIn .4s ease; }
.onboard-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; }
.onboard h1 { font-family: var(--serif); font-size: clamp(30px, 5vw, 42px); line-height: 1.08; letter-spacing: -.03em; font-weight: 600; margin-bottom: 12px; }
.onboard h1 em { font-style: italic; color: var(--forest); }
.onboard .lead { color: var(--muted); font-size: 15px; margin-bottom: 26px; max-width: 46ch; }
.onboard-card { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 22px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 16px; }
.choice-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.choice-card {
  text-align: left; padding: 13px 14px; border-radius: 13px; border: 1.5px solid var(--line);
  background: var(--surface-2); display: flex; flex-direction: column; gap: 2px; transition: border-color .15s, background .15s, transform .15s;
}
.choice-card strong { font-size: 14px; font-weight: 650; }
.choice-card span { font-size: 12px; color: var(--muted); line-height: 1.35; }
.choice-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.choice-card.is-selected { border-color: var(--forest); background: var(--forest-soft); }
.choice-card.is-selected strong { color: var(--forest); }
.goal-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.goal-opt { padding: 11px 6px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface-2); text-align: center; display: flex; flex-direction: column; gap: 1px; }
.goal-opt b { font-family: var(--serif); font-size: 20px; font-weight: 600; line-height: 1.1; }
.goal-opt span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.goal-opt.is-selected { border-color: var(--forest); background: var(--forest-soft); }
.goal-opt.is-selected b { color: var(--forest); }

.placement-progress { display: flex; gap: 4px; margin-bottom: 4px; }
.placement-progress i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.placement-progress i.is-done { background: var(--forest); }
.placement-progress i.is-now { background: var(--gold); }

/* --- responsive --------------------------------------------------------- */
@media (max-width: 1080px) {
  .grid--sidebar { grid-template-columns: minmax(0, 1fr); }
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-aside { padding: 0; justify-content: flex-start; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .brand--mobile { display: flex; }
  .brand--mobile strong { font-family: var(--serif); font-size: 19px; }
  .brand--mobile .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
  .brand--mobile .brand-mark svg { width: 25px; height: 25px; }
  .topbar-title { display: none; }
  .view { padding-bottom: 104px; }
  .toast-root { bottom: calc(86px + env(safe-area-inset-bottom)); }
  .avatar { width: 40px; height: 40px; font-size: 15px; }
  .foot { display: none; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px;
    padding: 7px 8px calc(7px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    border-top: 1px solid var(--line); backdrop-filter: blur(14px);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0;
    border-radius: 10px; font-size: 10px; font-weight: 600; color: var(--muted); position: relative;
  }
  .tab .ico { width: 22px; height: 22px; }
  .tab.is-active { color: var(--forest); background: var(--forest-soft); }
  .tab__badge {
    position: absolute; top: 2px; right: 50%; transform: translateX(19px);
    min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px;
    background: var(--coral); color: #fff; font-size: 9.5px; font-weight: 700;
    display: grid; place-items: center;
  }
}
@media (min-width: 901px) { .tabbar { display: none; } }
@media (max-width: 480px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .top-pills { gap: 6px; }
  .pill { height: 31px; padding: 0 9px; font-size: 12.5px; gap: 5px; }
  .pill--xp .pill__sep,
  .pill--xp .xp-total { display: none; }
  .topbar-right { gap: 8px; }
  .goal-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .goal-opt { padding: 10px 4px; }
  .learn-actions { grid-template-columns: minmax(0, 1fr); }
  .learn-actions .btn { width: 100%; }
}
@media (max-width: 365px) {
  .brand--mobile strong { display: none; }
}

@media (max-width: 720px) {
  .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
  .page-title { font-size: 28px; }
  .hero { padding: 20px; }
  .hero-aside { gap: 14px; }
  .ring { width: 104px; height: 104px; }
  .wc-face { padding: 20px 18px; }
  .wordcard, .flip-scene { min-height: 390px; }
  .grade-row { grid-template-columns: repeat(2, 1fr); }
  .options { grid-template-columns: 1fr; }
  .dict-head { display: none; }
  .dict-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "word level" "gloss status" "meter meter";
    gap: 2px 10px; padding: 10px 12px;
  }
  .dict-row__word { grid-area: word; font-size: 17px; }
  .dict-row__level { grid-area: level; justify-self: end; }
  .dict-row__gloss { grid-area: gloss; white-space: normal; }
  .dict-row__status { grid-area: status; justify-self: end; }
  .dict-row__mastery { grid-area: meter; justify-content: flex-start; gap: 8px; margin-top: 2px; }
  .dict-row__mastery .progress { width: auto; flex: 1; }
  .dict-row__mastery b { min-width: 0; }
  .dict-row__mastery.is-empty { display: none; }
  .dict-audio { display: none; }
  .choice-row { grid-template-columns: 1fr; }
  .path { grid-template-columns: repeat(2, 1fr); gap: 14px 0; }
  .nav-count { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .wordcard { transition: none; }
}
