/* LEC — light theme with a dark variant (html[data-theme="dark"], chosen by the learner). Design spec: design/codex-design-review.md (Codex). */
:root {
  color-scheme: light;

  /* Canvas and surfaces */
  --bg: #f5f4ff;
  --bg-wash: #edf7ff;
  --surface: #ffffff;
  --surface-2: #f4f2ff;
  --surface-3: #e8e8f5;
  --text: #20213a;
  --muted: #5f647b;
  --subtle: #777d92;
  --line: #dedff0;
  --line-strong: #c8cbe0;

  /* Brand */
  --accent: #5144c9;
  --accent-hover: #4033ad;
  --accent-soft: #eceaff;
  --accent-ink: #4033ad;
  --brand-violet: #654be8;
  --brand-purple: #963fe1;
  --brand-coral: #ed6b78;
  --brand-orange: #f29a58;
  --brand-gradient: linear-gradient(112deg, #5c48df 0%, #9446db 56%, #ee796c 100%);
  --brand-gradient-deep: linear-gradient(120deg, #4033ad 0%, #654be8 54%, #a23fc7 100%);
  --violet: #7041bd;
  --violet-soft: #f1e9fc;
  --teal: #087d8b;
  --teal-soft: #e1f6f8;

  /* Skill tokens: dark ink + light tint */
  --skill-vocabulary: #087b72;
  --skill-vocabulary-soft: #e1f5ef;
  --skill-grammar: #a15316;
  --skill-grammar-soft: #fff0df;
  --skill-reading: #2853b9;
  --skill-reading-soft: #e7efff;
  --skill-listening: #6740b3;
  --skill-listening-soft: #f0eaff;
  --skill-writing: #a83e78;
  --skill-writing-soft: #fbe8f2;
  --skill-speaking: #087d8b;
  --skill-speaking-soft: #e1f6f8;

  /* Level colors: saturated two-stop gradient + soft tint */
  --level-b1: #167b69;
  --level-b1-end: #22a788;
  --level-b1-gradient: linear-gradient(135deg, #167b69, #22a788);
  --level-b1-soft: #e2f5ef;

  --level-b2: #3158c8;
  --level-b2-end: #5379ee;
  --level-b2-gradient: linear-gradient(135deg, #3158c8, #5379ee);
  --level-b2-soft: #e8eeff;

  --level-c1: #7041bd;
  --level-c1-end: #a04fd1;
  --level-c1-gradient: linear-gradient(135deg, #7041bd, #a04fd1);
  --level-c1-soft: #f1e9fc;

  --level-c2: #b14d27;
  --level-c2-end: #e17c35;
  --level-c2-gradient: linear-gradient(135deg, #b14d27, #e17c35);
  --level-c2-soft: #fff0e4;

  /* Feedback */
  --ok: #167245;
  --ok-soft: #e3f5e9;
  --bad: #b52f3c;
  --bad-soft: #fde9eb;
  --warn: #815500;
  --warn-soft: #fff2d5;
  --highlight: #ffedaa;
  --on-color: #fff;          /* text on a solid accent/ok/bad/skill fill */
  --pill-bg: #efedfb;
  --pill-ink: #4f5270;

  /* Shape, depth, and layout */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --shadow-sm: 0 2px 5px rgb(45 39 100 / 7%), 0 5px 14px rgb(45 39 100 / 5%);
  --shadow-card: 0 4px 12px rgb(45 39 100 / 8%), 0 14px 32px rgb(45 39 100 / 9%);
  --shadow-pop: 0 12px 30px rgb(35 30 81 / 18%);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  --text-xs: .75rem;
  --text-sm: .875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;

  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease-out: cubic-bezier(.2, .75, .25, 1);
  --ease-standard: cubic-bezier(.2, 0, 0, 1);
  --topbar-h: 53px;
  --level-color: var(--level-b1);
  --level-end: var(--level-b1-end);
  --level-gradient: var(--level-b1-gradient);
  --level-soft: var(--level-b1-soft);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 120px; }
body {
  margin: 0; min-height: 100vh; color: var(--text);
  font: var(--text-base)/1.6 var(--font-sans);
  background:
    radial-gradient(ellipse 38rem 28rem at 0% 0%, rgb(101 75 232 / 10%), transparent 72%),
    radial-gradient(ellipse 34rem 26rem at 100% 6%, rgb(38 176 189 / 9%), transparent 70%),
    radial-gradient(ellipse 30rem 24rem at 86% 100%, rgb(242 154 88 / 8%), transparent 72%),
    linear-gradient(145deg, #f8f7ff 0%, #f3f7ff 48%, #fff8f3 100%);
  background-attachment: fixed;
}
a { color: var(--accent); text-decoration: none; }
code, pre { font-family: var(--font-mono); font-size: .86em; background: var(--surface-2); border-radius: 6px; }
code { padding: 1px 5px; } pre { padding: 10px 12px; overflow-x: auto; }
h1 { font-size: var(--text-2xl); line-height: 1.2; margin: .15em 0; letter-spacing: -.01em; }
h2 { font-size: var(--text-xl); line-height: 1.25; margin: 1.2em 0 .5em; letter-spacing: -.005em; }
h3 { font-size: var(--text-lg); margin: 1.6em 0 .6em; }
.muted { color: var(--muted); } .ok { color: var(--ok); } .bad { color: var(--bad); }
:where(button, a, input, textarea, summary, [tabindex]):focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

.icon { width: 20px; height: 20px; flex: none; }
.icon-sm { width: 16px; height: 16px; flex: none; }
.icon-lg { width: 24px; height: 24px; flex: none; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 6; min-height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 8px max(16px, calc((100vw - 1080px) / 2 + 16px));
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; letter-spacing: .03em; }
.brand .logo { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--violet)); box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent); }
.brand .tagline { color: var(--muted); font-size: var(--text-sm); font-weight: 450; letter-spacing: 0; }
.unitnav { display: flex; gap: 6px; }
.unitnav a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--muted); font-size: var(--text-sm); font-weight: 600; }
.unitnav a:hover { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.wrap { max-width: 1080px; margin: 0 auto; padding: var(--space-8) 16px 96px; }
.wrap > * { animation: page-in .32s var(--ease-out) both; }
.wrap > *:nth-child(2) { animation-delay: .05s; } .wrap > *:nth-child(3) { animation-delay: .1s; }
.wrap > *:nth-child(4) { animation-delay: .15s; } .wrap > *:nth-child(5) { animation-delay: .2s; }

/* ---------- buttons ---------- */
.btn {
  min-height: 42px; display: inline-flex; justify-content: center; align-items: center; gap: 8px; padding: 9px 16px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font: 600 var(--text-sm)/1.2 var(--font-sans); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .16s var(--ease-standard), border-color .16s, color .16s, transform .16s var(--ease-out), box-shadow .16s;
}
.btn:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 28%, transparent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.primary .icon { transition: transform .2s var(--ease-out); }
.btn.primary:hover .icon:last-child { transform: translateX(3px); }
.btn.secondary { color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); box-shadow: none; }
.btn.ai { background: var(--violet-soft); border-color: transparent; color: var(--violet); }
.btn.ai:hover { border-color: color-mix(in srgb, var(--violet) 35%, transparent); }
.btn.ai .icon { transition: transform .4s var(--ease-out); } .btn.ai:hover .icon { transform: rotate(18deg) scale(1.1); }
.btn.danger, .btn.recording { background: var(--bad); border-color: var(--bad); color: var(--on-color); }
.btn.small { min-height: 34px; padding: 6px 11px; font-size: var(--text-xs); }

.play, .btn-icon {
  width: 38px; height: 38px; display: inline-grid; place-items: center; flex: none; padding: 0;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line)); border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); cursor: pointer;
  transition: transform .18s var(--ease-out), background .18s, color .18s, box-shadow .18s;
}
.play .icon { width: 16px; height: 16px; }
.play:hover, .btn-icon:hover { transform: scale(1.07); background: var(--accent); color: var(--on-color); box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 30%, transparent); }
.play.playing { background: var(--accent); color: var(--on-color); animation: play-state .22s var(--ease-out) both, play-ring 1.6s ease-out .2s infinite; }
.play.labeled { width: auto; border-radius: var(--radius-pill); padding: 0 14px 0 10px; gap: 6px; display: inline-flex; align-items: center; font: 600 var(--text-sm)/1 var(--font-sans); height: 36px; }
.play.small { width: 32px; height: 32px; } .play.small .icon { width: 14px; height: 14px; }

/* ---------- dashboard ---------- */
.hero {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: var(--space-6); overflow: hidden;
  padding: clamp(20px, 4vw, 32px) clamp(20px, 4vw, 36px); border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: linear-gradient(115deg, color-mix(in srgb, var(--level-color) 12%, var(--surface)), var(--surface) 62%);
  box-shadow: var(--shadow-card);
}
.hero::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--level-color); }
.hero::after { content: ""; position: absolute; right: 0; top: 0; width: 320px; height: 100%; background-image: radial-gradient(color-mix(in srgb, var(--level-color) 32%, transparent) 1.3px, transparent 1.6px); background-size: 14px 14px;
  -webkit-mask-image: radial-gradient(circle at 100% 0%, #000 0%, transparent 70%); mask-image: radial-gradient(circle at 100% 0%, #000 0%, transparent 70%); pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
.hero p { max-width: 64ch; margin: var(--space-2) 0 0; color: var(--muted); }
.hero h1 { margin: 6px 0 2px; font-size: clamp(1.45rem, 3vw, 2rem); }
.hero .hero-main { flex: 1; min-width: 0; }
.hero .hero-progress { display: flex; align-items: center; gap: var(--space-3); margin-top: var(--space-4); max-width: 420px; font-size: var(--text-sm); color: var(--muted); }
.hero .hero-progress .bar { flex: 1; margin: 0; }
.eyebrow { display: flex; align-items: center; gap: 8px; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .09em; color: var(--level-color); font-weight: 700; }
.level-chip { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--level-color); color: #fff; font-size: var(--text-xs); font-weight: 800; letter-spacing: .04em; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); margin-top: var(--space-4); }
.stat { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 85%, transparent); box-shadow: var(--shadow-sm); }
.stat .ic { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.stat:nth-child(2) .ic { background: var(--ok-soft); color: var(--ok); } .stat:nth-child(3) .ic { background: var(--violet-soft); color: var(--violet); }
.stat b { display: block; font-size: var(--text-xl); line-height: 1.1; } .stat small { color: var(--muted); font-size: var(--text-xs); }

.level { --level-color: var(--level-b1); margin: var(--space-10) 0; }
.level[data-level="B2"] { --level-color: var(--level-b2); } .level[data-level="C1"] { --level-color: var(--level-c1); } .level[data-level="C2"] { --level-color: var(--level-c2); }
.level > h2 { display: flex; align-items: center; gap: var(--space-3); margin: 0 0 var(--space-4); }
.level > h2 .level-chip { font-size: var(--text-sm); padding: 3px 10px; }
.level h2 small { font-size: var(--text-sm); font-weight: 500; }
.level-sub { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 160px; }
.level-sub .bar { flex: 1; margin: 0; }

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.card {
  position: relative; min-height: 124px; display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4) var(--space-4) var(--space-4) calc(var(--space-4) + 3px);
  overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-sm); transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-standard), border-color .2s;
}
.card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--level-color); opacity: .8; }
.card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--level-color) 55%, var(--line)); box-shadow: var(--shadow-card); }
.card.empty { background: color-mix(in srgb, var(--surface) 55%, transparent); box-shadow: none; }
.card.empty::before { opacity: .25; } .card.empty .card-title { color: var(--muted); }
.card.empty:hover { transform: none; box-shadow: none; border-color: var(--line-strong); }
.card.complete { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); background: linear-gradient(160deg, color-mix(in srgb, var(--ok-soft) 70%, var(--surface)), var(--surface) 60%); }
.card.complete::before { background: var(--ok); }
.card.started { border-color: color-mix(in srgb, var(--level-color) 35%, var(--line)); }
.card.next { box-shadow: 0 0 0 2px color-mix(in srgb, var(--level-color) 50%, transparent), var(--shadow-card); }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.num { color: var(--level-color); font-size: var(--text-xs); font-weight: 800; letter-spacing: .08em; }
.card-title { font-weight: 650; line-height: 1.3; }
.bar { height: 6px; margin-top: auto; overflow: hidden; border-radius: var(--radius-pill); background: var(--surface-2); }
.bar i { display: block; height: 100%; width: var(--progress, 0%); border-radius: inherit; background: var(--level-color); animation: progress-fill .8s var(--ease-out) .2s both; }
.card.complete .bar i { background: var(--ok); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--muted); font-size: var(--text-xs); font-weight: 650; line-height: 1.3; white-space: nowrap; }
.pill .icon { width: 13px; height: 13px; }
.pill.ok { color: var(--ok); background: var(--ok-soft); } .pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.accent { color: var(--accent-ink); background: var(--accent-soft); }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.hist { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.hist td { padding: 10px 14px; border-bottom: 1px solid var(--line); } .hist tr:last-child td { border-bottom: 0; }
.hist tr:hover td { background: var(--surface-2); }
.section-title { display: flex; align-items: center; gap: 10px; }
.section-title .icon { color: var(--muted); }

/* ---------- unit header + tabs ---------- */
.unit-head { position: relative; padding: var(--space-6) var(--space-6) var(--space-5); border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: linear-gradient(120deg, color-mix(in srgb, var(--level-color) 13%, var(--surface)), var(--surface) 58%); box-shadow: var(--shadow-card); overflow: hidden; }
.unit-head::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--level-color); }
.unit-head::after { content: ""; position: absolute; right: 0; top: 0; width: 300px; height: 100%; background-image: radial-gradient(color-mix(in srgb, var(--level-color) 32%, transparent) 1.3px, transparent 1.6px); background-size: 14px 14px;
  -webkit-mask-image: radial-gradient(circle at 100% 0%, #000 0%, transparent 70%); mask-image: radial-gradient(circle at 100% 0%, #000 0%, transparent 70%); pointer-events: none; }
.unit-head > * { position: relative; z-index: 1; }
.cando { font-size: var(--text-lg); color: var(--muted); margin: .3em 0 0; max-width: 70ch; }
.unit-progress { display: flex; gap: 6px; margin-top: var(--space-4); flex-wrap: wrap; }
.unit-progress span { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 7px; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid var(--line); font-size: var(--text-xs); font-weight: 600; color: var(--muted); }
.unit-progress span.done { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.unit-progress .icon { width: 14px; height: 14px; }

.tabs {
  position: sticky; top: var(--topbar-h); z-index: 5; display: flex; gap: 2px; overflow-x: auto;
  margin: var(--space-5) 0 var(--space-6); padding: 0 4px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px);
  scrollbar-width: none; scroll-snap-type: x proximity;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  position: relative; flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; min-height: 50px; padding: 10px 14px;
  border: 0; background: transparent; color: var(--muted); font: 550 var(--text-sm)/1 var(--font-sans); cursor: pointer;
  scroll-snap-align: start; transition: color .18s;
}
.tabs button::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2.5px; border-radius: 3px 3px 0 0;
  background: var(--accent); transform: scaleX(0); transition: transform .25s var(--ease-out); }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent-ink); font-weight: 700; }
.tabs button.active::after { transform: scaleX(1); }
.tabs button .icon { width: 18px; height: 18px; transition: transform .25s var(--ease-out); }
.tabs button.active .icon { transform: translateY(-1px) scale(1.08); }
.tick { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; background: var(--ok); color: var(--on-color); }
.tick .icon { width: 11px; height: 11px; stroke-width: 3; }
.tab:not([hidden]) { animation: tab-enter .26s var(--ease-out) both; }

.sec-head { display: flex; align-items: center; gap: 10px; margin: var(--space-8) 0 var(--space-3); padding-top: var(--space-4); border-top: 1px dashed var(--line); }
.sec-head:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.sec-head h2, .sec-head h3 { margin: 0; }
.sec-head .ic { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.sec-head .ic .icon { width: 18px; height: 18px; }
.sec-head .spacer { flex: 1; }

/* ---------- content blocks ---------- */
.notice { margin: var(--space-4) 0; padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 20%, transparent); }
.notice.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 20%, transparent); }
.tip { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 var(--space-4); padding: var(--space-3) var(--space-4);
  border: 1px solid color-mix(in srgb, var(--accent) 16%, var(--line)); border-radius: var(--radius); background: var(--accent-soft); font-size: var(--text-sm); }
.tip .icon { color: var(--accent); margin-top: 1px; }
.prose { max-width: 72ch; }
.prose h1 { display: none; }
.prose h2 { font-size: var(--text-lg); }
.prose table { border-collapse: collapse; margin: 12px 0; display: block; overflow-x: auto; }
.prose td, .prose th { border: 1px solid var(--line); padding: 7px 11px; background: var(--surface); }
.prose th { background: var(--surface-2); }
.card-prose { padding: var(--space-5) var(--space-6); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); max-width: none; }
.reading-text { font-size: 1.1rem; line-height: 1.8; padding: var(--space-6) var(--space-8); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); max-width: 76ch; }
.reading-text p { margin: 0 0 1.1em; } .reading-text p:last-child { margin: 0; }
.gl { background: var(--highlight); border-radius: 4px; padding: 0 3px; cursor: help; position: relative; box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--warn) 30%, transparent); }
/* one floating hint for all highlighted words, placed by app.js inside the screen (never past its edges) */
.gl-tip { position: fixed; z-index: 60; left: 0; top: 0; max-width: min(320px, calc(100vw - 24px)); width: max-content;
  background: var(--text); color: #fff; font-size: var(--text-sm); line-height: 1.45; padding: 8px 11px; border-radius: 8px;
  box-shadow: var(--shadow-pop); pointer-events: none; overflow-wrap: anywhere; animation: pop-in .16s var(--ease-out); }
.gl-tip[hidden] { display: none; }
.gl.on { box-shadow: inset 0 -2px 0 var(--warn); }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0 0 var(--space-4); }
.title-row h2 { margin: 0; }

.vocab { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); }
.vcard { padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); font-size: var(--text-sm); transition: transform .2s var(--ease-out), box-shadow .2s; }
.vcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }
.vhead { display: flex; align-items: flex-start; gap: 10px; margin-bottom: var(--space-2); }
.vhead .vw { flex: 1; min-width: 0; }
.vhead b { display: block; font-size: var(--text-lg); line-height: 1.3; }
.vhead .pos { display: inline-block; margin-top: 2px; font-size: var(--text-xs); font-weight: 600; color: var(--teal); background: var(--teal-soft); padding: 1px 8px; border-radius: var(--radius-pill); }
.ex-sent { margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px dashed var(--line); color: var(--muted); font-style: italic; }

.examples { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.examples li { padding: 8px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--teal); }
.errors { display: grid; gap: 8px; }
.err-row { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 12px; align-items: start; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); font-size: var(--text-sm); }
.err-row > div { display: flex; gap: 6px; align-items: flex-start; }
.err-row .icon { width: 16px; height: 16px; margin-top: 2px; }
.wrong { color: var(--bad); } .right { color: var(--ok); }

/* ---------- exercises ---------- */
.ex { margin: 0 0 var(--space-3); padding: var(--space-4) var(--space-5); border: 1px solid var(--line); border-left: 4px solid var(--line-strong);
  border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); transition: background .25s, border-color .25s; }
.ex.right { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok-soft) 45%, var(--surface)); animation: answer-pop .28s var(--ease-out) both; }
.ex.wrong { border-left-color: var(--bad); background: color-mix(in srgb, var(--bad-soft) 45%, var(--surface)); animation: answer-shake .34s var(--ease-standard) both; }
.ex-prompt { font-weight: 550; display: flex; gap: 10px; }
.ex-prompt .qn { flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: var(--text-xs); font-weight: 800; }
.ex.right .qn { background: var(--ok); color: var(--on-color); } .ex.wrong .qn { background: var(--bad); color: var(--on-color); }
.ex-body { padding-left: 36px; }
.gap-mark { display: inline-block; min-width: 3.5em; border-bottom: 2px solid var(--accent); color: transparent; line-height: 1.1; margin: 0 2px; }
.ex-fb { display: flex; gap: 6px; align-items: flex-start; margin-top: var(--space-2); font-size: var(--text-sm); }
.ex-fb:empty { display: none; }
.ex-fb .icon { width: 16px; height: 16px; margin-top: 2px; }
.ex.right .ex-fb { color: var(--ok); } .ex.wrong .ex-fb { color: var(--bad); }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin-top: var(--space-3); }
.opt { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s, transform .15s; }
.opt:hover { border-color: var(--line-strong); background: var(--surface-2); }
.opt:active { transform: scale(.99); }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.opt.is-answer { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.opt input { accent-color: var(--accent); margin: 0; }
.gap-input, .dict-row input {
  width: 100%; max-width: 380px; min-height: 44px; margin-top: var(--space-3); padding: 9px 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s;
}
.gap-input:focus, .dict-row input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: var(--space-4) 0; }
.score-badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--radius-pill); font-weight: 700; font-size: var(--text-sm); animation: pop-in .3s var(--ease-out); }
.score-badge.ok { background: var(--ok-soft); color: var(--ok); } .score-badge.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- listening ---------- */
.player { padding: var(--space-4) var(--space-5); border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(135deg, var(--surface-3), var(--surface) 70%); box-shadow: var(--shadow-sm); }
.player .situation { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 var(--space-3); color: var(--muted); }
audio { max-width: 100%; height: 40px; }
#listening-audio { width: 100%; }
.speed { display: inline-flex; align-items: center; gap: 2px; margin-top: var(--space-3); padding: 3px; border-radius: var(--radius-pill); background: var(--surface-2); font-size: var(--text-xs); color: var(--muted); }
.speed .icon { width: 16px; height: 16px; margin: 0 6px 0 8px; }
.speed button { border: 0; background: transparent; color: var(--muted); border-radius: var(--radius-pill); padding: 5px 11px; cursor: pointer; font: 600 var(--text-xs)/1 var(--font-sans); transition: background .15s, color .15s; }
.speed button.active { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
details { margin: var(--space-3) 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
summary { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 var(--space-4); cursor: pointer; font-weight: 600; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s var(--ease-out); }
details[open] > summary::after { transform: rotate(-135deg); }
summary .icon { color: var(--muted); }
details > :not(summary) { margin-left: var(--space-4); margin-right: var(--space-4); }
details[open] > :not(summary) { animation: tab-enter .22s var(--ease-out); }
details > :last-child { margin-bottom: var(--space-4); }
.seg { cursor: pointer; margin: 4px 0; padding: 6px 10px; border-radius: var(--radius-sm); transition: background .15s; }
.seg:hover { background: var(--surface-2); }
.seg.active { background: var(--accent-soft); }
.dict-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.dict-row input { flex: 1; margin: 0; max-width: none; min-width: 200px; }
.dict-fb { flex-basis: 100%; font-size: var(--text-sm); } .dict-fb:empty { display: none; }
.tok.ok { color: var(--ok); } .tok.missing { color: var(--bad); text-decoration: underline wavy; } .tok.extra { color: var(--warn); text-decoration: line-through; }

/* ---------- writing ---------- */
.task { padding: var(--space-4) var(--space-5); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.task > :first-child { margin-top: 0; } .task > :last-child { margin-bottom: 0; }
.must { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; }
.must li { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: var(--radius-pill); background: var(--accent-soft); color: var(--accent-ink); font-size: var(--text-sm); font-weight: 550; }
.editor { margin-top: var(--space-4); border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
textarea { display: block; width: 100%; min-height: 280px; margin: 0; padding: var(--space-4) var(--space-5); font: inherit; font-size: 1.04rem; line-height: 1.75; border: 0; background: transparent; color: var(--text); resize: vertical; }
.editor-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 10px 8px var(--space-5); border-top: 1px solid var(--line); background: var(--surface-2); }
.wc { display: inline-flex; align-items: center; gap: 8px; font-size: var(--text-sm); font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.wc .meter { width: 90px; height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.wc .meter i { display: block; height: 100%; width: 0; background: var(--warn); border-radius: inherit; transition: width .25s var(--ease-out), background .25s; }
.wc.ok { color: var(--ok); } .wc.ok .meter i { background: var(--ok); } .wc.over { color: var(--bad); } .wc.over .meter i { background: var(--bad); }
.check { display: flex; flex-direction: column; gap: 8px; margin-top: var(--space-4); padding: var(--space-4) var(--space-5); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); font-size: var(--text-sm); animation: tab-enter .25s var(--ease-out); }
.check .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- submissions + AI feedback ---------- */
.sub { margin: var(--space-3) 0; padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); animation: tab-enter .25s var(--ease-out); }
.sub-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; font-size: var(--text-sm); }
.sub-head .meta { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.sub-text { white-space: pre-wrap; font-size: var(--text-sm); margin-top: 8px; color: var(--muted); max-height: 9em; overflow: auto; padding: 8px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.fb-card { margin-top: var(--space-4); padding: var(--space-5); border: 1px solid color-mix(in srgb, var(--violet) 28%, var(--line)); border-radius: var(--radius);
  background: linear-gradient(145deg, var(--violet-soft), var(--surface) 55%); font-size: .95rem; animation: tab-enter .3s var(--ease-out); }
.fb-top { display: flex; align-items: flex-start; gap: var(--space-4); } .fb-top p { margin: 0; }
.level-badge { flex: none; display: grid; place-items: center; min-width: 64px; padding: 8px 10px; border-radius: var(--radius); background: linear-gradient(135deg, var(--violet), var(--accent)); color: #fff; text-align: center; box-shadow: 0 6px 16px color-mix(in srgb, var(--violet) 30%, transparent); }
.level-badge small { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; opacity: .85; font-weight: 600; }
.level-badge b { font-size: var(--text-xl); line-height: 1.1; }
.crits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; margin: var(--space-5) 0; }
.crit { display: grid; grid-template-columns: 100px 1fr auto; align-items: center; gap: 10px; }
.crit span { color: var(--muted); font-size: var(--text-sm); text-transform: capitalize; }
.dots { display: flex; gap: 4px; }
.dots i { flex: 1; height: 7px; border-radius: var(--radius-pill); background: var(--surface-3); }
.dots i.on { background: var(--violet); animation: dot-in .35s var(--ease-out) both; }
.dots i.on:nth-child(2) { animation-delay: .06s; } .dots i.on:nth-child(3) { animation-delay: .12s; } .dots i.on:nth-child(4) { animation-delay: .18s; } .dots i.on:nth-child(5) { animation-delay: .24s; }
.fb-card h4 { display: flex; align-items: center; gap: 8px; margin: var(--space-4) 0 6px; font-size: var(--text-sm); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.fb-card h4 .icon { width: 16px; height: 16px; }
.ferr { margin: 8px 0; padding: 10px 12px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid var(--line); }
.inst { margin: 5px 0 0; font-size: var(--text-sm); }
.inst .wrong { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.corrected { line-height: 1.75; }
.ai-wait { display: flex; gap: 10px; align-items: center; margin-top: var(--space-3); padding: 12px 14px; border-radius: var(--radius-sm); color: var(--violet); font-weight: 600; font-size: var(--text-sm);
  background: linear-gradient(100deg, var(--violet-soft) 20%, color-mix(in srgb, var(--surface) 90%, var(--violet-soft)) 45%, var(--violet-soft) 70%); background-size: 220% 100%; animation: ai-shimmer 1.8s ease-in-out infinite; }
.ai-wait .icon { animation: spin-slow 2.4s linear infinite; }

/* ---------- speaking ---------- */
.speak-task { padding: var(--space-5); margin-bottom: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.speak-task h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 var(--space-3); }
.speak-task h3 .n { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--accent); color: #fff; font-size: var(--text-sm); }
.speak-task .task { background: var(--surface-2); box-shadow: none; border-color: transparent; font-size: 1.04rem; }
.phrases { display: flex; flex-wrap: wrap; gap: 6px; margin: var(--space-3) 0; }
.phrases span { background: var(--teal-soft); color: var(--teal); padding: 3px 11px; border-radius: var(--radius-pill); font-size: var(--text-sm); font-weight: 550; }
.timer { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--muted); font-size: var(--text-sm); }
.timer.live { color: var(--bad); } .timer.prep { color: var(--accent); }
.btn.recording { animation: record-pulse 1.4s ease-out infinite; }
.btn.recording .icon { animation: blink 1s steps(2, start) infinite; }
.shadow-list { display: grid; gap: 8px; }
.shadow-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.shadow-row span { flex: 1; min-width: 200px; }
.shadow-row audio { flex-basis: 100%; }

/* ---------- motion ---------- */
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes tab-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
@keyframes answer-pop { 0% { transform: scale(.985); } 65% { transform: scale(1.012); } 100% { transform: scale(1); } }
@keyframes answer-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-2px); } }
@keyframes progress-fill { from { width: 0; } to { width: var(--progress, 0%); } }
@keyframes dot-in { from { transform: scaleX(0); transform-origin: left; } to { transform: scaleX(1); transform-origin: left; } }
@keyframes ai-shimmer { from { background-position: 160% 0; } to { background-position: -160% 0; } }
@keyframes play-state { 0% { transform: scale(.92); } 70% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes play-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 40%, transparent); } 80%, 100% { box-shadow: 0 0 0 10px transparent; } }
@keyframes record-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 45%, transparent); } 70% { box-shadow: 0 0 0 12px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes blink { to { opacity: .35; } }
@keyframes spin-slow { to { transform: rotate(360deg); } }

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

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .vocab { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .err-row { grid-template-columns: 1fr 1fr; } .err-row > .muted { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  :root { --topbar-h: 49px; }
  .wrap { padding: var(--space-5) 16px 80px; }
  .topbar { min-height: 48px; padding-inline: 16px; }
  .brand .tagline { display: none; }
  .hero { align-items: stretch; flex-direction: column; gap: var(--space-4); }
  .hero .btn { width: 100%; }
  .stats { grid-template-columns: 1fr; }
  .level-sub { display: none; }
  .grid, .vocab { grid-template-columns: 1fr; }
  .card { min-height: 96px; }
  .unit-head { padding: var(--space-5) var(--space-4) var(--space-4) var(--space-5); }
  .tabs { margin-inline: -16px; padding-inline: 12px; }
  .tabs button { min-height: 46px; padding-inline: 11px; }
  .reading-text { padding: var(--space-4) var(--space-5); font-size: 1.04rem; }
  .ex { padding: var(--space-4); } .ex-body { padding-left: 0; }
  .err-row { grid-template-columns: 1fr; }
  .crits { grid-template-columns: 1fr; }
  .fb-top { flex-direction: column; }
  .actions > .btn { flex: 1 1 auto; }
  .speak-task { padding: var(--space-4); }
}


/* ===== Colorful theme — design/codex-color-spec.md (Codex), adapted ===== */
/* Level color bindings */
[data-level="B1"] {
  --level-color: var(--level-b1);
  --level-end: var(--level-b1-end);
  --level-gradient: var(--level-b1-gradient);
  --level-soft: var(--level-b1-soft);
}
[data-level="B2"] {
  --level-color: var(--level-b2);
  --level-end: var(--level-b2-end);
  --level-gradient: var(--level-b2-gradient);
  --level-soft: var(--level-b2-soft);
}
[data-level="C1"] {
  --level-color: var(--level-c1);
  --level-end: var(--level-c1-end);
  --level-gradient: var(--level-c1-gradient);
  --level-soft: var(--level-c1-soft);
}
[data-level="C2"] {
  --level-color: var(--level-c2);
  --level-end: var(--level-c2-end);
  --level-gradient: var(--level-c2-gradient);
  --level-soft: var(--level-c2-soft);
}

body {
  color: var(--text);
}

/* Top bar */
.topbar {
  border-bottom-color: rgb(81 68 201 / 13%);
  background: rgb(250 249 255 / 88%);
  box-shadow: 0 2px 14px rgb(56 48 130 / 5%);
}
.brand .logo {
  background: var(--brand-gradient);
  box-shadow: 0 5px 16px rgb(101 75 232 / 28%);
}

/* Dashboard hero: retain the flex layout; reserve room for an avatar and bubble */
.hero {
  border-color: rgb(255 255 255 / 75%);
  background:
    radial-gradient(circle at 90% 15%, rgb(255 255 255 / 20%), transparent 34%),
    var(--brand-gradient);
  color: #fff;
  box-shadow: 0 12px 34px rgb(89 58 184 / 20%);
}
.hero::before {
  width: 7px;
  background: rgb(255 255 255 / 62%);
}
.hero::after {
  background-image: radial-gradient(rgb(255 255 255 / 34%) 1.4px, transparent 1.8px);
}
.hero p,
.hero .hero-progress,
.hero .eyebrow {
  color: rgb(255 255 255 / 90%);
}
.hero h1 { color: #fff; }
.hero .level-chip {
  background: rgb(255 255 255 / 20%);
  border: 1px solid rgb(255 255 255 / 36%);
}
.hero .bar { background: rgb(255 255 255 / 27%); }
.hero .bar i { background: #fff; }
.hero .btn.primary {
  background: #fff;
  border-color: #fff;
  color: #4033ad;
  box-shadow: 0 6px 18px rgb(37 27 99 / 20%);
}
.hero .btn.primary:hover {
  background: #f7f3ff;
  border-color: #f7f3ff;
}

/* Stats */
.stat {
  border-color: rgb(101 75 232 / 12%);
  background: rgb(255 255 255 / 92%);
  box-shadow: var(--shadow-sm);
}
.stat:nth-child(1) .ic { color: var(--skill-reading); background: var(--skill-reading-soft); }
.stat:nth-child(2) .ic { color: var(--ok); background: var(--ok-soft); }
.stat:nth-child(3) .ic { color: var(--violet); background: var(--violet-soft); }

/* Level headings */
.level > h2 {
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--level-color) 18%, var(--surface));
  border-radius: 14px;
  background: linear-gradient(100deg, var(--level-soft), color-mix(in srgb, var(--surface) 88%, transparent) 72%);
}
.level > h2 .level-chip {
  background: var(--level-gradient);
  box-shadow: 0 4px 10px color-mix(in srgb, var(--level-color) 24%, transparent);
}
.level .bar i { background: var(--level-gradient); }

/* Unit cards */
.card {
  --card-tint: color-mix(in srgb, var(--level-color) 8%, var(--surface));
  background:
    radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--level-color) 10%, transparent), transparent 58%),
    linear-gradient(145deg, var(--surface), var(--card-tint));
  border-color: color-mix(in srgb, var(--level-color) 18%, var(--line));
}
.card::before {
  width: 5px;
  background: var(--level-gradient);
  opacity: 1;
}
.card:hover {
  border-color: color-mix(in srgb, var(--level-color) 48%, var(--surface));
}
.card.complete {
  background: linear-gradient(145deg, var(--ok-soft), var(--surface) 70%);
}
.card.next {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--level-color) 48%, transparent), var(--shadow-card);
}
.num {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--level-color);
}
.num::before {
  content: attr(data-n);
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  background: var(--level-gradient);
  font-size: .75rem;
  letter-spacing: 0;
  box-shadow: 0 3px 8px color-mix(in srgb, var(--level-color) 26%, transparent);
}
.card.empty .num::before {
  background: linear-gradient(135deg, #aeb3c7, #858ba4);
  box-shadow: none;
}
.card .bar { background: color-mix(in srgb, var(--level-color) 12%, var(--surface)); }
.card .bar i { background: var(--level-gradient); }

/* Unit header */
.unit-head {
  border-color: color-mix(in srgb, var(--level-color) 18%, var(--surface));
  background:
    radial-gradient(circle at 94% 10%, color-mix(in srgb, var(--level-color) 11%, transparent), transparent 36%),
    linear-gradient(110deg, var(--level-soft), var(--surface) 68%);
}
.unit-head::before { width: 7px; background: var(--level-gradient); }
.unit-head::after {
  background-image: radial-gradient(color-mix(in srgb, var(--level-color) 28%, transparent) 1.5px, transparent 1.9px);
}
.unit-head .level-chip {
  background: var(--level-gradient);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--level-color) 23%, transparent);
}

/* Skill tab colors */
.tabs { background: rgb(248 247 255 / 91%); }
.tabs button { --skill: var(--accent); --skill-soft: var(--accent-soft); }
.tabs button[data-tab="vocabulary"] { --skill: var(--skill-vocabulary); --skill-soft: var(--skill-vocabulary-soft); }
.tabs button[data-tab="grammar"] { --skill: var(--skill-grammar); --skill-soft: var(--skill-grammar-soft); }
.tabs button[data-tab="reading"] { --skill: var(--skill-reading); --skill-soft: var(--skill-reading-soft); }
.tabs button[data-tab="listening"] { --skill: var(--skill-listening); --skill-soft: var(--skill-listening-soft); }
.tabs button[data-tab="writing"] { --skill: var(--skill-writing); --skill-soft: var(--skill-writing-soft); }
.tabs button[data-tab="speaking"] { --skill: var(--skill-speaking); --skill-soft: var(--skill-speaking-soft); }
.tabs button.active {
  color: var(--skill);
  background: var(--skill-soft);
  border-radius: 10px 10px 0 0;
}
.tabs button::after { background: var(--skill); }
.tabs button.active .icon { color: var(--skill); }

/* Skill colors per tab panel and section heading */
.tab { --skill: var(--accent); --skill-soft: var(--accent-soft); }
[data-skill="vocabulary"] { --skill: var(--skill-vocabulary); --skill-soft: var(--skill-vocabulary-soft); }
[data-skill="grammar"] { --skill: var(--skill-grammar); --skill-soft: var(--skill-grammar-soft); }
[data-skill="reading"] { --skill: var(--skill-reading); --skill-soft: var(--skill-reading-soft); }
[data-skill="listening"] { --skill: var(--skill-listening); --skill-soft: var(--skill-listening-soft); }
[data-skill="writing"] { --skill: var(--skill-writing); --skill-soft: var(--skill-writing-soft); }
[data-skill="speaking"] { --skill: var(--skill-speaking); --skill-soft: var(--skill-speaking-soft); }
.sec-head .ic { color: var(--skill); background: var(--skill-soft); }

/* Primary and audio controls */
.btn.primary {
  border-color: transparent;
  background: var(--brand-gradient);
  box-shadow: 0 5px 16px rgb(101 75 232 / 25%);
}
.btn.primary:hover {
  background: var(--brand-gradient-deep);
  box-shadow: 0 7px 20px rgb(101 75 232 / 30%);
}
.play {
  color: var(--skill, var(--accent));
  background: var(--skill-soft, var(--accent-soft));
  border-color: color-mix(in srgb, var(--skill, var(--accent)) 18%, var(--surface));
}
.play:hover, .play.playing { background: var(--skill, var(--accent)); color: var(--on-color); box-shadow: 0 4px 12px color-mix(in srgb, var(--skill, var(--accent)) 30%, transparent); }
@keyframes play-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--skill, var(--accent)) 40%, transparent); } 80%, 100% { box-shadow: 0 0 0 10px transparent; } }

/* Exercises */
.ex {
  border-color: color-mix(in srgb, var(--skill) 15%, var(--line));
  border-left-color: var(--skill);
}
.ex.right {
  border-color: color-mix(in srgb, var(--ok) 24%, var(--surface));
  border-left-color: var(--ok);
  background: linear-gradient(100deg, var(--ok-soft), var(--surface) 75%);
}
.ex.wrong {
  border-color: color-mix(in srgb, var(--bad) 22%, var(--surface));
  border-left-color: var(--bad);
  background: linear-gradient(100deg, var(--bad-soft), var(--surface) 75%);
}
.ex-prompt .qn { color: var(--skill); background: var(--skill-soft); }
.ex.right .qn { color: var(--on-color); background: var(--ok); }
.ex.wrong .qn { color: var(--on-color); background: var(--bad); }

/* Vocabulary cards */
.vcard {
  border-color: color-mix(in srgb, var(--skill-vocabulary) 18%, var(--surface));
  background: linear-gradient(145deg, var(--surface), var(--skill-vocabulary-soft) 150%);
}
.vhead .pos {
  color: #075d56;
  background: var(--skill-vocabulary-soft);
}

/* Listening player */
.player {
  border-color: color-mix(in srgb, var(--skill-listening) 20%, var(--surface));
  background: linear-gradient(125deg, var(--skill-listening-soft), var(--surface) 76%);
}
.speed { background: var(--surface-3); }
.speed button.active { color: var(--accent-ink); }

/* Writing tasks and AI feedback */
.task {
  border-color: color-mix(in srgb, var(--skill-writing) 16%, var(--surface));
  background: linear-gradient(140deg, var(--skill-writing-soft), var(--surface) 52%);
}
.must li {
  color: var(--skill-writing);
  background: var(--skill-writing-soft);
}
.fb-card {
  --coach: var(--violet);
  border-color: color-mix(in srgb, var(--coach) 28%, var(--surface));
  background: linear-gradient(130deg, var(--violet-soft), var(--surface) 60%, var(--skill-writing-soft));
  box-shadow: var(--shadow-sm);
}
.fb-card:has(.coach-avatar[data-coach="kai"]) {
  --coach: var(--skill-speaking);
  background: linear-gradient(130deg, var(--skill-speaking-soft), var(--surface) 62%);
}
.fb-top { align-items: center; }
.fb-card .level-badge { background: var(--brand-gradient-deep); }

/* Speaking */
.speak-task {
  border-color: color-mix(in srgb, var(--skill-speaking) 22%, var(--surface));
  background: linear-gradient(135deg, var(--skill-speaking-soft), var(--surface) 48%);
}
.speak-task h3 .n {
  background: linear-gradient(135deg, var(--skill-speaking), #20a6ad);
}
.phrases span {
  color: #075b66;
  background: var(--skill-speaking-soft);
}
.timer.prep { color: #075b66; }

/* Pills */
.pill {
  border: 1px solid transparent;
  background: var(--pill-bg);
  color: var(--pill-ink);
}
.pill.ok { background: var(--ok-soft); color: #126039; }
.pill.warn { background: var(--warn-soft); color: #714900; }
.pill.accent { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- avatars ---------- */
.avatar {
  display: inline-block;
  flex: none;
  width: var(--avatar-size, 48px);
  height: var(--avatar-size, 48px);
  overflow: hidden;
  border: 3px solid #fff;
  border-radius: 50%;
  background: linear-gradient(145deg, #fff, var(--accent-soft));
  box-shadow: 0 5px 16px rgb(37 31 94 / 20%);
  object-fit: cover;
  vertical-align: middle;
}
.avatar.sm { --avatar-size: 36px; border-width: 2px; }
.avatar.md { --avatar-size: 52px; }
.avatar.lg { --avatar-size: 76px; border-width: 4px; }
.avatar.xl { --avatar-size: 104px; border-width: 4px; }

.bubble {
  position: relative;
  max-width: 260px;
  padding: 11px 15px;
  border: 1px solid rgb(255 255 255 / 80%);
  border-radius: 16px 16px 16px 5px;
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-card);
  font-size: var(--text-sm);
  line-height: 1.45;
}
.bubble::before {
  content: "";
  position: absolute;
  left: 15px;
  bottom: -7px;
  width: 12px;
  height: 12px;
  border-right: 1px solid rgb(255 255 255 / 80%);
  border-bottom: 1px solid rgb(255 255 255 / 80%);
  background: #fff;
  transform: rotate(45deg);
}
.hero .bubble { color: var(--text); }

/* ---------- playful motion ---------- */
.hero-tutor .avatar {
  animation: tutor-float 3.8s ease-in-out infinite;
}
.hero-tutor .bubble {
  animation: bubble-arrive .45s var(--ease-out) both;
}
.btn.primary:not(:disabled) {
  background-size: 180% 180%;
  transition: background-position .35s var(--ease-out), transform .18s var(--ease-out), box-shadow .18s;
}
.btn.primary:not(:disabled):hover {
  background-position: 100% 50%;
}
.card:not(.empty):hover {
  transform: translateY(-4px) rotate(-.25deg);
}
.avatar.wave {
  transform-origin: 70% 90%;
  animation: tutor-wave 2.8s ease-in-out infinite;
}

@keyframes tutor-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes bubble-arrive {
  from { opacity: 0; transform: translateY(5px) scale(.97); }
  to { opacity: 1; transform: none; }
}
@keyframes tutor-wave {
  0%, 78%, 100% { transform: rotate(0); }
  83% { transform: rotate(8deg); }
  88% { transform: rotate(-6deg); }
  93% { transform: rotate(4deg); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-tutor .avatar,
  .hero-tutor .bubble,
  .avatar.wave {
    animation: none !important;
  }
  .card:not(.empty):hover {
    transform: none;
  }
}

/* ---------- avatar placements ---------- */
.hero-side { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-4); flex: none; }
.hero-tutor { display: flex; align-items: flex-end; gap: var(--space-3); }
.hero-tutor .bubble { order: -1; margin-bottom: 26px; border-radius: 16px 16px 5px 16px; }
.hero-tutor .bubble::before { left: auto; right: -6px; bottom: 12px; border-right: 1px solid rgb(255 255 255 / 80%); border-bottom: 0; border-top: 1px solid rgb(255 255 255 / 80%); transform: rotate(45deg); }
.hero-tutor .bubble strong { color: var(--accent-ink); }
.level > h2 .avatar { margin-left: -4px; }
.unit-head { display: grid; grid-template-columns: 1fr auto; gap: 0 var(--space-6); align-items: center; }
.unit-head > .head-main { min-width: 0; }
.unit-head .head-tutor { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: var(--text-xs); color: var(--muted); font-weight: 600; }
.unit-head .head-tutor b { display: block; color: var(--level-color); font-size: var(--text-sm); }
.coach { display: flex; align-items: center; gap: var(--space-4); margin: 0 0 var(--space-5); }
.coach .bubble { max-width: 560px; border-color: color-mix(in srgb, var(--skill) 18%, var(--surface)); }
.coach .bubble strong { color: var(--skill); }
.fb-top .avatar { margin-top: -2px; }
.fb-who { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; font-size: var(--text-xs); font-weight: 700; color: var(--muted); }
@media (max-width: 560px) {
  .hero-side { align-items: stretch; }
  .hero-tutor { justify-content: flex-end; }
  .unit-head { grid-template-columns: 1fr; }
  .unit-head .head-tutor { display: none; }
  .coach .avatar.lg { --avatar-size: 56px; }
}

/* ---------- placement, gates, mistakes ---------- */
.ex-prompt > div { white-space: pre-line; }
.mainnav { display: flex; align-items: center; gap: 4px; }
.mainnav > a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--muted); font-size: var(--text-sm); font-weight: 600; }
.mainnav > a:hover { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.mainnav .unitnav { margin-left: 6px; padding-left: 8px; border-left: 1px solid var(--line); }
.cta-card { display: flex; align-items: center; gap: var(--space-4); margin-top: var(--space-4); padding: var(--space-4) var(--space-5);
  border: 1px solid color-mix(in srgb, var(--brand-violet) 25%, var(--surface)); border-radius: var(--radius-lg);
  background: linear-gradient(110deg, var(--accent-soft), var(--surface) 70%); box-shadow: var(--shadow-sm); }
.cta-card > div { flex: 1; }
.level.locked .grid { filter: grayscale(.55); opacity: .75; }
.lock-note { display: flex; align-items: center; gap: 8px; margin: -6px 0 var(--space-3); color: var(--muted); font-size: var(--text-sm); }
.card.milestone { border-style: dashed; }
.card-title .pill { margin-left: 4px; vertical-align: 2px; }
.lock-card { display: flex; gap: var(--space-5); align-items: flex-start; margin: var(--space-6) 0; padding: var(--space-6);
  border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card); }
.lock-card h2 { margin: 0 0 4px; }
.lock-ic { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--surface-2); color: var(--muted); flex: none; }
.milestone-banner { display: flex; gap: var(--space-3); align-items: flex-start; margin: var(--space-5) 0 0; padding: var(--space-4) var(--space-5);
  border-radius: var(--radius); color: #fff; background: var(--level-gradient, var(--brand-gradient)); box-shadow: var(--shadow-card); }
.milestone-banner .pill { margin-left: 6px; }
.part-head { display: flex; align-items: center; gap: 10px; margin: var(--space-6) 0 var(--space-3); font-weight: 700; color: var(--level-color); }
.part-head::after { content: ""; flex: 1; height: 2px; border-radius: 2px; background: var(--level-gradient); opacity: .35; }
.part-head .level-chip { background: var(--level-gradient); }
.pl-card { display: flex; gap: var(--space-5); align-items: flex-start; margin: var(--space-5) 0; padding: var(--space-6);
  border-radius: var(--radius-lg); border: 1px solid color-mix(in srgb, var(--level-color) 25%, var(--surface));
  background: linear-gradient(120deg, var(--level-soft), var(--surface) 65%); box-shadow: var(--shadow-card); animation: pop-in .35s var(--ease-out); }
.pl-card h2 { margin: 2px 0 6px; } .pl-main { flex: 1; min-width: 0; }
.pl-row { display: grid; grid-template-columns: 44px 1fr 52px 74px; align-items: center; gap: 10px; margin: 8px 0; font-size: var(--text-sm); }
.pl-row .bar { margin: 0; } .pl-row .bar i { background: var(--level-gradient); }
.pl-row .level-chip { background: var(--level-gradient); justify-content: center; }
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: var(--space-5) 0; padding: 4px; border-radius: var(--radius-pill); background: var(--surface-2); width: fit-content; }
.filter-bar button { border: 0; background: transparent; padding: 6px 14px; border-radius: var(--radius-pill); font: 600 var(--text-sm)/1 var(--font-sans); color: var(--muted); cursor: pointer; }
.filter-bar button.active { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.filter-bar .toggle { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; font-size: var(--text-sm); color: var(--muted); }
.type-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.mlist { display: grid; gap: 10px; }
.mcard { padding: var(--space-4) var(--space-5); border: 1px solid var(--line); border-left: 4px solid var(--skill, var(--bad)); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.mcard.fixed { border-left-color: var(--ok); opacity: .8; }
.mmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: var(--text-sm); margin-bottom: 8px; }
.mmeta .level-chip { background: var(--level-gradient); }
.mq { font-weight: 550; white-space: pre-line; }
.mans { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-weight: 600; }
.mans span { display: inline-flex; align-items: center; gap: 5px; }
.mexp { margin-top: 6px; font-size: var(--text-sm); }
@media (max-width: 560px) {
  .mainnav > a span { display: none; }
  .cta-card, .lock-card, .pl-card { flex-direction: column; align-items: stretch; }
  .pl-row { grid-template-columns: 40px 1fr 46px; } .pl-row .pill { display: none; }
}

/* default skill color for pages outside unit tabs (placement, mistakes) */
:root { --skill: var(--accent); --skill-soft: var(--accent-soft); }

/* ===== Test counting: placement status bar + unanswered warning ===== */
.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; }
.test-status {
  position: sticky; top: var(--topbar-h); z-index: 4;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin: 0 0 var(--space-4); padding: 8px 14px 11px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  font-size: var(--text-sm); color: var(--muted); overflow: hidden;
}
.test-status b { color: var(--text); font-variant-numeric: tabular-nums; }
.test-status > span { display: inline-flex; align-items: center; gap: 6px; }
.ts-timer { padding: 3px 10px; border-radius: var(--radius-pill); background: var(--surface-2); transition: background .25s, color .25s; }
.ts-timer .icon { color: var(--accent); }
.test-status.over .ts-timer { background: var(--warn-soft); color: var(--warn); }
.test-status.over .ts-timer .icon, .test-status.over .ts-timer b { color: var(--warn); }
.test-status.timer-hidden .ts-timer { display: none; }
.test-status.done .ts-timer { background: var(--ok-soft); color: var(--ok); }
.test-status.done .ts-timer .icon, .test-status.done .ts-timer b { color: var(--ok); }
.ts-part .level-chip { background: var(--level-gradient, var(--level-color)); }
.ts-toggle { margin-left: auto; }
.ts-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: color-mix(in srgb, var(--accent) 10%, transparent); }
.ts-bar i { display: block; height: 100%; width: var(--progress, 0%); background: var(--level-gradient, var(--accent)); transition: width .3s var(--ease-out), background .3s; }
.unanswered-warn { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: var(--space-4) 0 0; padding: 10px 14px;
  border-radius: var(--radius); background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 22%, transparent);
  font-size: var(--text-sm); animation: pop-in .25s var(--ease-out); }
.unanswered-warn[hidden] { display: none; }
.unanswered-warn > span { flex: 1 1 220px; color: var(--text); }
.unanswered-warn b { color: var(--warn); }
.pl-meta { margin: 6px 0 var(--space-3); }
@media (max-width: 560px) {
  .test-status { gap: 6px 10px; padding: 6px 12px 9px; margin-inline: -4px; font-size: var(--text-xs); }
  .test-status .ts-long { display: none; }
  .ts-timer { padding: 2px 8px; }
  .ts-toggle { min-height: 28px; padding: 3px 9px; }
}
@media (prefers-reduced-motion: reduce) { .ts-bar i, .ts-timer { transition: none; } }

/* ===== Photo listening task ===== */
.photo-intro { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.photo-task { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--space-4) var(--space-5); align-items: start;
  margin: 0 0 var(--space-5); padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.photo { margin: 0; position: relative; }
.photo img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; border-radius: calc(var(--radius) - 4px); background: var(--surface-2); }
.photo figcaption { position: absolute; left: 10px; top: 10px; padding: 2px 9px; border-radius: var(--radius-pill); background: rgb(20 18 50 / 62%); color: #fff; font-size: var(--text-xs); font-weight: 700; }
.photo-qs { display: flex; flex-direction: column; gap: 10px; }
.photo-form .photo-q { margin: 0; padding: 10px 12px; }
.pq-row { display: flex; align-items: center; gap: 10px; }
.pq-row .qn { flex: none; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: var(--text-xs); font-weight: 800; }
.pq-row .gap-input { flex: 1; min-width: 0; }
.photo-q .ex-transcript { display: none; margin: 8px 0 0 36px; font-style: italic; color: var(--muted); font-size: var(--text-sm); }
.photo-form.checked .photo-q .ex-transcript { display: block; }
.photo-q .ex-fb { margin-left: 36px; }
.photo-q .ex-fb:empty { display: none; }
.mthumb { float: right; width: 120px; aspect-ratio: 3 / 2; object-fit: cover; margin: 0 0 8px 12px; border-radius: 8px; }
@media (max-width: 860px) { .photo-task { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .photo-task { padding: var(--space-3); margin-inline: -4px; } .photo-q .ex-transcript, .photo-q .ex-fb { margin-left: 0; } }

/* ===== Header profile chip ===== */
.mainnav { margin-left: auto; }
.me { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 10px 4px 5px; border-radius: var(--radius-pill); color: var(--text);
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .15s; }
.me:hover { box-shadow: 0 4px 14px rgb(56 48 130 / 14%); transform: translateY(-1px); }
.me .level-chip { background: var(--level-gradient); min-width: 30px; justify-content: center; padding: 4px 8px; }
.me-streak { display: inline-flex; align-items: center; gap: 2px; color: var(--subtle); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.me-streak.on { color: #e8590c; }
.me-streak b { font-weight: 750; }

/* ===== Profile page ===== */
.pf-hero { display: flex; gap: var(--space-6); align-items: center; padding: var(--space-6); margin-bottom: var(--space-5);
  border-radius: calc(var(--radius) + 6px); background: linear-gradient(135deg, var(--level-soft), var(--surface) 70%);
  border: 1px solid color-mix(in srgb, var(--level-color) 25%, var(--line)); box-shadow: var(--shadow-sm); }
.pf-emblem img { display: block; width: 132px; height: 132px; border-radius: 50%; object-fit: cover; background: var(--surface-2);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--level-color) 35%, var(--surface)), 0 12px 30px color-mix(in srgb, var(--level-color) 25%, transparent); }
.pf-main { flex: 1; min-width: 0; }
.pf-main .eyebrow { color: var(--level-color); }
.pf-main .eyebrow .level-chip { background: var(--level-gradient); }
.pf-name { display: flex; gap: 8px; align-items: center; margin: 4px 0 6px; }
.pf-name input { font: 800 1.7rem/1.2 var(--font-sans); border: 1px solid transparent; border-radius: 8px; background: transparent; padding: 2px 6px; margin-left: -6px; width: min(100%, 420px); color: var(--text); }
.pf-name input:hover, .pf-name input:focus { border-color: var(--line); background: var(--surface); outline: none; }
.pf-level { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.pf-stats { margin-bottom: var(--space-6); }
.badge-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: var(--space-6); }
.bdg { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 10px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); text-align: center; box-shadow: var(--shadow-sm); }
.bdg img, .bdg > i { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; background: #f1eeff; }
.bdg small { color: var(--muted); font-size: var(--text-xs); line-height: 1.35; }
.bdg.locked img, .bdg.locked > i { filter: grayscale(1); opacity: .4; }
.bdg.locked b { color: var(--muted); }
.bdg-prog { width: 70%; height: 5px; border-radius: 5px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.bdg-prog i { display: block; height: 100%; background: var(--accent); }
table.keys { width: 100%; border-collapse: collapse; font-size: var(--text-sm); margin: 8px 0; }
table.keys th, table.keys td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.keys tr.revoked td { color: var(--muted); text-decoration: line-through; }
table.keys tr.revoked td:last-child { text-decoration: none; }
@media (max-width: 560px) { table.keys { display: block; overflow-x: auto; } }  /* scroll inside, never widen the page */
.mcp h3 { margin: var(--space-5) 0 var(--space-2); }
.key-form { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; padding: var(--space-4); border-radius: var(--radius); background: var(--surface-2); }
.key-form label { display: flex; flex-direction: column; gap: 4px; font-size: var(--text-sm); font-weight: 600; }
.key-form input[type=text], .key-form input:not([type]) { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; min-width: 220px; }
.key-form fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: var(--text-sm); }
.key-form fieldset label { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; }
.key-form legend { font-weight: 600; margin-bottom: 4px; }
.new-key { margin: var(--space-3) 0; padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 25%, transparent); }
.copy-row { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; }
.copy-row pre, .copy-row code { flex: 1; min-width: 0; margin: 0; padding: 10px 12px; border-radius: 8px; background: #1f1b3a; color: #f1eeff;
  font: 500 .82rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-all; }
.copy-row code { display: block; }
.setup-tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-pill); background: var(--surface-2); margin-bottom: 8px; flex-wrap: wrap; }
.setup-tabs button { border: 0; background: transparent; padding: 6px 12px; border-radius: var(--radius-pill); font: 600 var(--text-sm)/1 var(--font-sans); color: var(--muted); cursor: pointer; }
.setup-tabs button.active { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.small-note { font-size: var(--text-xs); }
.prompts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.prompt { display: flex; flex-direction: column; gap: 6px; padding: var(--space-4); border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
.prompt p { margin: 0; font-size: var(--text-sm); color: var(--muted); flex: 1; }
.prompt .btn { align-self: flex-start; }
@media (max-width: 860px) { .badge-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .prompts { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .pf-hero { flex-direction: column; text-align: center; padding: var(--space-5) var(--space-4); } .pf-name { justify-content: center; } .pf-level { justify-content: center; }
  .pf-emblem img { width: 108px; height: 108px; } table.keys th:nth-child(4), table.keys td:nth-child(4), table.keys th:nth-child(5), table.keys td:nth-child(5) { display: none; } }

/* ===== Reading illustration ===== */
.reading-art { float: right; width: min(300px, 38%); margin: 0 0 var(--space-4) var(--space-5); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.reading-art img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: cover; }
@media (max-width: 560px) { .reading-art { float: none; width: 100%; margin: 0 0 var(--space-4); } .reading-art img { aspect-ratio: 4 / 3; } }

.pf-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .pf-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ===== Answer feedback: calmer wrong state, staggered motion ===== */
/* .right/.wrong are also generic text-colour helpers — keep the question itself in body text */
.ex.right, .ex.wrong { color: var(--text); }
.ex.right {
  border-color: color-mix(in srgb, var(--ok) 16%, var(--line));
  background: linear-gradient(100deg, color-mix(in srgb, var(--ok-soft) 80%, var(--surface)), var(--surface) 45%);
}
.ex.wrong {
  border-color: color-mix(in srgb, var(--bad) 14%, var(--line));
  background: linear-gradient(100deg, color-mix(in srgb, var(--bad-soft) 60%, var(--surface)), var(--surface) 35%);
  animation: answer-nudge .3s var(--ease-standard) both;
}
.ex.wrong .ex-fb b { color: var(--text); }
@keyframes answer-nudge { 0%, 100% { transform: translateX(0); } 35% { transform: translateX(-3px); } 70% { transform: translateX(2px); } }

/* ===== Home: compact unit cards, folded locked levels ===== */
.num-label { text-transform: uppercase; }
.level-fold { margin: 0; border: 0; background: none; box-shadow: none; }
.level-fold > summary { width: fit-content; min-height: 44px; padding: 0 16px; gap: 8px; border: 1px dashed var(--line-strong); border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--surface) 80%, transparent); color: var(--muted); font-size: var(--text-sm); }
.level-fold > summary::after { margin-left: 4px; }
.level-fold > summary:hover { color: var(--text); border-color: var(--level-color); }
.level-fold > .grid { margin: var(--space-3) 0 0; }

/* ===== Unit page ===== */
.sec-head .jump { min-height: 36px; }
.brand { min-height: 44px; }

/* ===== Placement: part shortcuts ===== */
html:has(.test-status) { scroll-padding-top: 170px; }
.ts-jump { display: inline-flex; gap: 4px; }
.ts-jump a { display: inline-grid; place-items: center; min-width: 40px; min-height: 32px; padding: 0 8px; border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--muted); font: 700 var(--text-xs)/1 var(--font-sans); letter-spacing: .03em; transition: background .2s, color .2s; }
.ts-jump a:hover { color: var(--text); }
.ts-jump a.on { background: var(--level-gradient); color: #fff; }

/* ===== Small controls: comfortable tap targets ===== */
.filter-bar button, .setup-tabs button { min-height: 40px; padding-inline: 14px; }
.filter-bar .toggle { min-height: 40px; cursor: pointer; }

/* ===== Phones ===== */
@media (max-width: 560px) {
  /* header: icon + short label, 44px targets; drop the word "LEC" when the unit arrows need the room */
  .topbar { gap: 6px; padding-inline: 12px; }
  .topbar:has(.unitnav a) .brand { font-size: 0; gap: 0; }
  .mainnav { gap: 2px; }
  .mainnav > a { flex-direction: column; justify-content: center; gap: 3px; min-width: 46px; min-height: 44px; padding: 4px 4px; font-size: 10.5px; line-height: 1; }
  .mainnav > a span { display: inline; }
  .mainnav .unitnav { gap: 0; margin-left: 2px; padding-left: 4px; }
  .unitnav a { min-height: 44px; padding: 4px 6px; gap: 3px; font-size: var(--text-xs); }
  .me { min-height: 44px; padding: 4px 8px 4px 5px; }

  /* home */
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat { flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 12px; }
  .stat .ic { width: 30px; height: 30px; border-radius: 8px; }
  .stat .ic .icon { width: 16px; height: 16px; }
  .stat b { font-size: var(--text-lg); }
  .stat small { display: block; line-height: 1.3; }
  .st-long { display: none; }
  .pf-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .level { margin: var(--space-8) 0; }
  .level > h2 { flex-wrap: wrap; gap: 6px 10px; font-size: var(--text-lg); }
  .grid { gap: 8px; }
  .card { min-height: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 6px 10px; padding: 10px 12px 10px 16px; }
  .card .card-top { display: contents; }
  .card .num { grid-column: 1; grid-row: 1; }
  .num-label { display: none; }
  .card .card-title { grid-column: 2; grid-row: 1; font-size: .95rem; }
  .card .card-top > .pill { grid-column: 3; grid-row: 1; }
  .card .bar { grid-column: 2 / -1; grid-row: 2; height: 4px; margin: 0; }
  .card:not(.empty):hover { transform: none; }

  /* unit page: the tab bar already lists the six sections */
  .skill-chips { display: none; }
  .unit-head h1 { font-size: 1.5rem; }
  .unit-head .cando { font-size: var(--text-base); }
  .card-prose { padding: var(--space-4); }
  .prose td, .prose th { min-width: 8.5em; vertical-align: top; }
  .prose td code, .prose th code { white-space: nowrap; }

  /* vocabulary: denser cards so practice is closer */
  .vocab { gap: 8px; }
  .vcard { padding: 12px 14px; }
  .vhead { align-items: center; margin-bottom: 4px; }
  .vhead .vw { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
  .vhead b { display: inline; font-size: 1.05rem; }
  .vhead .pos { margin-top: 0; }
  .ex-sent { margin-top: 6px; padding-top: 6px; }

  /* placement status bar */
  .test-status > .ts-part { display: none; }
  .test-status { flex-wrap: nowrap; }
  .ts-jump { gap: 3px; }
  .ts-toggle { padding-inline: 8px; }
  .ts-toggle .icon { width: 16px; height: 16px; }
  .ts-jump a { min-width: 38px; min-height: 34px; }
  .ts-toggle { min-height: 34px; }

  /* mistakes + profile controls */
  .filter-bar { width: 100%; border-radius: 14px; }
  .filter-bar button { flex: 1; }
  .filter-bar .toggle { flex-basis: 100%; justify-content: center; }
  .hist td:first-child { display: none; }
  .hist td { padding: 9px 10px; }
  .hist td a { white-space: nowrap; }
  .filter-bar button, .setup-tabs button, .filter-bar .toggle { min-height: 44px; }
  .pf-name { flex-wrap: wrap; justify-content: center; }
  .pf-name input { width: 100%; text-align: center; margin-left: 0; }
}

/* very narrow phones (iPhone SE): unit arrows lose their labels */
@media (max-width: 380px) {
  .unitnav a { font-size: 0; gap: 0; min-width: 36px; justify-content: center; }
  .mainnav > a { min-width: 48px; }
}

/* ===== First-run welcome guide ===== */
.wl-wrap { max-width: 960px; padding-top: var(--space-4); padding-bottom: var(--space-6); }
.wl { display: flex; flex-direction: column; }
.wl-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); }
.wl-top .brand { min-height: 0; }
.wl-dots { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; }
.wl-dots li { width: 8px; height: 8px; border-radius: var(--radius-pill); background: var(--line-strong); transition: width .3s var(--ease-out), background .3s; }
.wl-dots li.done { background: color-mix(in srgb, var(--accent) 45%, var(--line-strong)); }
.wl-dots li.on { width: 24px; background: var(--brand-gradient); }
/* language dropdown (.lp): pill button + floating list with a check on the chosen language */
.lp { position: relative; }
.lp-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 12px 0 6px; border: 1px solid var(--line);
  border-radius: var(--radius-pill); background: var(--surface); color: var(--text); font: 650 var(--text-sm)/1 var(--font-sans);
  box-shadow: var(--shadow-sm); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.lp-btn:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.lp-btn:focus-visible, .lp.open .lp-btn { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.lp-globe { display: grid; place-items: center; width: 30px; height: 30px; padding: 6px; border-radius: 50%; background: var(--brand-gradient); color: #fff; }
.lp-cur { max-width: 10em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lp-chev { color: var(--muted); transition: transform .2s var(--ease-out); }
.lp.open .lp-chev { transform: rotate(180deg); }
.lp.changed .lp-btn { animation: lp-flash .9s var(--ease-out); }
@keyframes lp-flash { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }
.lp-menu { position: absolute; z-index: 30; top: calc(100% + 8px); right: 0; width: 260px; max-height: min(380px, 60vh); overflow-y: auto; margin: 0; padding: 6px;
  list-style: none; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: 0 18px 40px rgb(30 20 80 / 18%);
  animation: lp-in .16s var(--ease-out); overscroll-behavior: contain; }
.lp-menu[hidden] { display: none; }
@keyframes lp-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.lp-menu li { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 6px 10px; border-radius: var(--radius-sm); cursor: pointer; outline: none; }
.lp-menu li:hover, .lp-menu li:focus { background: var(--surface-2); }
.lp-menu li:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.lp-menu li[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.lp-name { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.lp-name b { font-weight: 650; }
.lp-local { color: var(--muted); font-size: var(--text-xs); }
.lp-local:empty { display: none; }
.lp-check { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--on-color); opacity: 0; transform: scale(.6);
  transition: opacity .15s, transform .15s; }
.lp-menu li[aria-selected="true"] .lp-check { opacity: 1; transform: none; }
/* step 2: the language sits with the country, so the top-bar copy steps aside there */
.wl[data-step="2"] .lp-top { visibility: hidden; }
.wl-langfield { display: flex; align-items: center; justify-content: space-between; gap: 12px var(--space-4); flex-wrap: wrap; margin-top: var(--space-3);
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.wl-langfield-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 200px; }
.wl-langfield-txt small { color: var(--muted); font-size: var(--text-xs); }
.wl-langfield .lp-menu { top: auto; bottom: calc(100% + 8px); }
@media (max-width: 560px) {
  .lp-top .lp-btn { padding-right: 10px; }
  .lp-top .lp-cur { max-width: 6.5em; }
  .wl-langfield .lp { flex: 1 1 100%; }
  .wl-langfield .lp-btn { width: 100%; }
  .wl-langfield .lp-chev { margin-left: auto; }
  .wl-langfield .lp-menu { left: 0; right: 0; width: auto; }
}

.wl-step { display: flex; flex-direction: column; width: 100%; max-width: 620px; margin-inline: auto; animation: wl-in .38s var(--ease-out) both; }
.wl-step.from-left { animation-name: wl-in-back; }
.wl-step[hidden] { display: none; }
.wl-step h1, .wl-step h2 { text-align: center; margin: 0 0 6px; outline: none; }
.wl-step h1 { font-size: clamp(1.7rem, 7vw, 2.3rem); letter-spacing: -.02em; }
.wl-step h2 { font-size: clamp(1.4rem, 5.6vw, 1.75rem); }
.wl-lead { text-align: center; font-size: var(--text-lg); font-weight: 550; margin: 4px 0 6px; }
.wl-step > .muted, .wl-hint { text-align: center; margin: 0 auto var(--space-4); max-width: 46ch; }

/* artwork frames */
.wl-art { position: relative; margin: 0 auto var(--space-5); width: 100%; overflow: hidden; border-radius: 24px; }
.wl-art img:not(.avatar) { display: block; width: 100%; height: 100%; object-fit: cover; }
.wl-art-hero { aspect-ratio: 4 / 3; box-shadow: var(--shadow-card);
  background: radial-gradient(circle at 20% 15%, rgb(255 255 255 / 30%), transparent 40%), var(--brand-gradient); }
.wl-art-hero::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgb(255 255 255 / 28%) 1.4px, transparent 1.8px); background-size: 16px 16px;
  -webkit-mask-image: linear-gradient(160deg, #000, transparent 60%); mask-image: linear-gradient(160deg, #000, transparent 60%); }
.wl-tutors { position: absolute; inset: 0; }
.wl-tutors .avatar { position: absolute; translate: -50% -50%; border-width: 4px; box-shadow: 0 10px 26px rgb(30 20 80 / 30%);
  animation: wl-float 4.2s ease-in-out calc(var(--i) * -.7s) infinite, wl-pop .5s var(--ease-out) calc(.1s + var(--i) * .07s) both; }
.wl-tutors .avatar:nth-child(1) { left: 50%; top: 48%; width: 36%; height: auto; aspect-ratio: 1; z-index: 2; }
.wl-tutors .avatar:nth-child(2) { left: 17%; top: 30%; width: 22%; height: auto; aspect-ratio: 1; }
.wl-tutors .avatar:nth-child(3) { left: 83%; top: 30%; width: 22%; height: auto; aspect-ratio: 1; }
.wl-tutors .avatar:nth-child(4) { left: 21%; top: 78%; width: 19%; height: auto; aspect-ratio: 1; }
.wl-tutors .avatar:nth-child(5) { left: 79%; top: 78%; width: 19%; height: auto; aspect-ratio: 1; }
.wl-tutors .avatar:nth-child(6) { left: 50%; top: 88%; width: 15%; height: auto; aspect-ratio: 1; }

.wl-art.wl-art-world { width: min(150px, 42%); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--skill-speaking) 35%, var(--surface)), color-mix(in srgb, var(--accent) 30%, var(--surface)) 70%);
  box-shadow: inset 0 0 0 6px color-mix(in srgb, var(--surface) 60%, transparent), var(--shadow-card); }
.wl-art-world img { position: absolute; inset: 0; }
.wl-flag { position: relative; z-index: 1; font-size: 64px; line-height: 1; filter: drop-shadow(0 6px 10px rgb(0 0 0 / 22%)); }
.wl-art-world img ~ .wl-flag { position: absolute; right: 6%; bottom: 6%; display: grid; place-items: center; width: 34%; aspect-ratio: 1;
  border-radius: 50%; background: var(--surface); font-size: 40px; box-shadow: var(--shadow-card); }
.wl-flag.pop { animation: wl-pop .4s var(--ease-out); }
.wl-art-hero:has(img)::after { display: none; }
.wl-art.wl-art-world:has(img) { width: min(180px, 48%); }

.wl-art-start { display: flex; align-items: center; justify-content: center; gap: var(--space-3); min-height: 170px; padding: var(--space-4);
  background: linear-gradient(135deg, var(--level-b1-soft), var(--accent-soft)); }
.wl-art-start:has(img:not(.avatar)) { aspect-ratio: 4 / 3; padding: 0; display: block; }
.wl-art-start .bubble { order: -1; max-width: 230px; border-radius: 16px 16px 5px 16px; animation: bubble-arrive .45s var(--ease-out) .25s both; }
.wl-art-start .bubble::before { left: auto; right: -6px; bottom: 14px; }
.wl-art-start .bubble strong { color: var(--level-b1); }
.wl-art-start:has(img:not(.avatar)) .bubble { position: absolute; left: 14px; bottom: 14px; border-radius: 16px 16px 16px 5px; }
.wl-art-start:has(img:not(.avatar)) .bubble::before { left: 15px; right: auto; bottom: -7px; }

/* step 2: country + name */
.wl-search { position: relative; display: flex; align-items: center; }
.wl-search .icon-sm { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.wl-search input, .wl-name input { width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; transition: border-color .15s, box-shadow .15s; }
.wl-search input { padding-left: 40px; }
.wl-search input:focus, .wl-name input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
.wl-countries { margin-top: 8px; max-height: min(320px, 42vh); overflow-y: auto; overscroll-behavior: contain; padding: 4px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.wl-group { position: sticky; top: -4px; z-index: 1; padding: 8px 10px 4px; background: var(--surface); color: var(--muted);
  font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.wl-country { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 6px 10px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: background .15s; }
.wl-country:hover { background: var(--surface-2); }
.wl-country[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; }
.wl-cflag { font-size: 1.5rem; line-height: 1; }
.wl-cname { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.wl-cname small { color: var(--muted); font-size: var(--text-xs); font-weight: 500; }
.wl-ccheck { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--on-color);
  opacity: 0; transform: scale(.6); transition: opacity .2s, transform .2s var(--ease-out); }
.wl-country[aria-selected="true"] .wl-ccheck { opacity: 1; transform: none; }
.wl-empty { padding: 16px; text-align: center; margin: 0; }
.wl-name { display: flex; flex-direction: column; gap: 6px; margin-top: var(--space-5); font-weight: 650; }

/* step 3: tour */
.wl-note { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0 var(--space-4); padding: 12px 14px; border-radius: var(--radius);
  background: var(--violet-soft); color: var(--text); font-size: var(--text-sm); }
.wl-note .icon-sm { color: var(--violet); margin-top: 2px; }
.wl-features { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.wl-feat { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid color-mix(in srgb, var(--skill) 18%, var(--line)); border-radius: var(--radius);
  background: linear-gradient(150deg, var(--skill-soft), var(--surface) 70%); box-shadow: var(--shadow-sm);
  animation: wl-pop .4s var(--ease-out) calc(.05s + var(--i) * .05s) both; }
.wl-feat .ic { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--surface); color: var(--skill); box-shadow: var(--shadow-sm); }
.wl-feat b { display: block; color: var(--skill); }
.wl-feat small { display: block; color: var(--muted); font-size: var(--text-sm); line-height: 1.4; }
.wl-extras { display: grid; gap: 8px; margin-top: 10px; }
.wl-extra { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: var(--text-sm); }
.wl-extra .icon { color: var(--accent); }

/* step 4: choices */
.wl-choices { display: grid; gap: 10px; margin-top: var(--space-3); }
.wl-choice { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 2px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); cursor: pointer; transition: border-color .2s, background .2s, transform .15s; }
.wl-choice:active { transform: scale(.99); }
.wl-choice input { position: absolute; opacity: 0; pointer-events: none; }
.wl-choice .ic { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; background: var(--accent-soft); color: var(--accent); }
.wl-choice b { display: block; }
.wl-choice small { display: block; color: var(--muted); font-size: var(--text-sm); line-height: 1.4; }
.wl-choice:has(input:checked) { border-color: var(--accent); background: linear-gradient(135deg, var(--accent-soft), var(--surface) 80%); }
.wl-choice:has(input:checked) .ic { background: var(--brand-gradient); color: #fff; }
.wl-choice:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

/* actions follow the content (never over it); the country list scrolls inside its own box */
.wl-actions { display: flex; gap: 10px; margin-top: var(--space-5); padding-bottom: env(safe-area-inset-bottom); }
.wl-step:first-of-type .wl-actions, .wl-step[data-step="1"] .wl-actions { justify-content: center; }
.wl-big { flex: 1; min-height: 52px; font-size: var(--text-base); border-radius: var(--radius); }
.wl-step[data-step="1"] .wl-big { max-width: 360px; }
.wl-actions .btn.ghost { min-height: 52px; }

@keyframes wl-in { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes wl-in-back { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }
@keyframes wl-pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }
@keyframes wl-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
/* "Make it yours": the optional AI agent / field pack idea, introduced lightly */
.wl-personal { display: flex; gap: 12px; align-items: flex-start; margin-top: var(--space-3); padding: var(--space-4);
  border: 1px solid color-mix(in srgb, var(--agent) 28%, var(--line)); border-radius: var(--radius); background: linear-gradient(115deg, var(--agent-soft), var(--surface) 80%); }
.wl-personal .ic { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; color: #fff;
  background: linear-gradient(135deg, var(--agent), var(--agent-2)); }
.wl-personal b { display: block; color: var(--agent-ink); }
.wl-personal p { margin: 4px 0; font-size: var(--text-sm); }
.wl-personal small { display: block; color: var(--muted); font-size: var(--text-xs); }

/* desktop: wider steps; hello and how-to-start put the art beside the text */
@media (min-width: 761px) {
  .wl-step[data-step="1"]:not([hidden]), .wl-step[data-step="4"]:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--space-6);
    align-items: center; max-width: 960px; margin-top: var(--space-5); }
  .wl-step[data-step="1"] .wl-art, .wl-step[data-step="4"] .wl-art { margin: 0; }
  .wl-copy { min-width: 0; }
  .wl-step[data-step="1"] .wl-copy > *, .wl-step[data-step="1"] h1 { text-align: left; margin-inline: 0; }
  .wl-step[data-step="1"] .wl-actions { justify-content: flex-start; }
  .wl-step[data-step="4"] h2 { text-align: left; }
  .wl-step[data-step="2"] { max-width: 640px; }
  .wl-step[data-step="3"] { max-width: 900px; }
  .wl-features { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .wl-extras { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .wl-extra { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) { .wl-tutors .avatar, .wl-feat, .wl-step { animation: none !important; } }
@media (max-width: 560px) {
  .wl-wrap { padding-inline: 16px; }
  .wl-top { margin-bottom: var(--space-4); }
  .wl-top .brand { font-size: 0; gap: 0; }
  .wl-art { border-radius: 20px; margin-bottom: var(--space-4); }
  .wl-art.wl-art-world { width: 112px; border-radius: 50%; margin-bottom: var(--space-3); }
  .wl-flag { font-size: 52px; }
  .wl-art.wl-art-world:has(img) { width: 136px; }
  .wl-art-world img ~ .wl-flag { font-size: 24px; }
}
@media (max-width: 360px) { .wl-features { grid-template-columns: 1fr; } }

/* profile: country row */
.pf-country { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.pf-flag { font-size: 1.4rem; line-height: 1; }
.pf-country select { min-height: 36px; padding: 4px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-size: var(--text-sm); max-width: 14em; }
@media (max-width: 560px) { .pf-country { justify-content: center; } }

/* ===== Printable progress report (/report) ===== */
.rp-wrap { max-width: 900px; }
.rp-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-bottom: var(--space-5); }
.rp-toolbar .btn.primary { margin-left: auto; }
.rp-scope { margin: 0; }
.rp-scope a { display: inline-flex; align-items: center; min-height: 40px; padding: 6px 14px; border-radius: var(--radius-pill);
  color: var(--muted); font: 600 var(--text-sm)/1 var(--font-sans); }
.rp-scope a.active { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.rp-tip { flex-basis: 100%; display: flex; align-items: flex-start; gap: 6px; margin: 0; font-size: var(--text-xs); }
.rp-tip .icon-sm { flex: none; margin-top: 2px; }

/* the sheet always looks like paper, also in dark mode, so what you see is what you print */
.report {
  color-scheme: light;
  --surface: #fff; --surface-2: #f4f2ff; --surface-3: #e8e8f5; --text: #20213a; --muted: #5f647b; --line: #dedff0; --line-strong: #c8cbe0;
  --accent: #5144c9; --accent-soft: #eceaff; --accent-ink: #4033ad; --violet: #7041bd; --violet-soft: #f1e9fc;
  --ok: #167245; --ok-soft: #e3f5e9; --warn: #815500; --warn-soft: #fff2d5; --bad: #b52f3c; --bad-soft: #fde9eb;
  --pill-bg: #efedfb; --pill-ink: #4f5270; --on-color: #fff;
  --skill-vocabulary: #087b72; --skill-grammar: #a15316; --skill-reading: #2853b9; --skill-listening: #6740b3; --skill-writing: #a83e78; --skill-speaking: #087d8b;
  --level-b1: #167b69; --level-b2: #3158c8; --level-c1: #7041bd; --level-c2: #b14d27;
  --level-b1-soft: #e2f5ef; --level-b2-soft: #e8eeff; --level-c1-soft: #f1e9fc; --level-c2-soft: #fff0e4;
  position: relative; padding: 32px 36px; border-radius: 6px; background: #fff; color: var(--text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 8%), 0 18px 50px rgb(40 30 100 / 14%); font-size: 14px; line-height: 1.5;
}
.report .pill.ok { color: #126039; } .report .pill.warn { color: #714900; }
.report h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 1.15rem; }
.report h2 .icon { width: 20px; height: 20px; color: var(--accent); }
.report h3 { margin: 18px 0 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.report .bar { margin: 0; height: 8px; background: var(--surface-3); }
.report .bar i { background: var(--level-gradient); animation: none; }
.report .level-chip { background: var(--level-gradient); }
.report .icon-sm { width: 14px; height: 14px; }

.rp-head { display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: center; padding-bottom: 18px; margin-bottom: 18px;
  border-bottom: 3px solid transparent; border-image: var(--brand-gradient) 1; }
.rp-brand { display: flex; align-items: center; gap: 10px; align-self: start; }
.rp-brand .logo, .auth-brand .logo { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; color: #fff; background: var(--brand-gradient); }
.rp-brand b { display: block; letter-spacing: .04em; } .rp-brand small { color: var(--muted); font-size: 11px; }
.rp-title h1 { margin: 2px 0; font-size: 1.7rem; }
.rp-title .eyebrow { color: var(--accent); }
.rp-title p { margin: 0; font-size: 13px; }
.rp-level { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 16px; border-radius: 14px; background: var(--level-soft); }
.rp-level small { color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.rp-level .level-chip { font-size: 1.5rem; padding: 4px 14px; }

.rp-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }
.rp-summary > div { padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(160deg, var(--surface-2), #fff 70%); }
.rp-summary b { display: block; font-size: 1.35rem; line-height: 1.2; } .rp-summary b span { font-size: .85rem; color: var(--muted); }
.rp-summary small { color: var(--muted); font-size: 12px; }

.rp-sec { padding: 18px 0; border-top: 1px solid var(--line); }
.rp-sec:first-of-type { border-top: 0; }
.rp-place { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.rp-place-main { padding: 14px 16px; border-radius: 14px; background: linear-gradient(150deg, var(--level-soft), #fff 85%); border: 1px solid var(--line); }
.rp-place-main > small { color: var(--muted); font-size: 12px; }
.rp-start { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; font-weight: 700; font-size: 1.05rem; }
.rp-start .level-chip { font-size: 1.15rem; padding: 3px 12px; }
.rp-meta { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.rp-meta span { display: inline-flex; align-items: center; gap: 6px; }
.rp-parts { display: grid; gap: 10px; }
.rp-part { display: grid; grid-template-columns: 40px 1fr 46px 70px; align-items: center; gap: 10px; }
.rp-part .level-chip { justify-content: center; }
.rp-part b { text-align: right; font-variant-numeric: tabular-nums; }
.rp-part .pill { justify-content: center; }
.rp-note { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

.rp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rp-table th { text-align: left; padding: 6px 8px; border-bottom: 2px solid var(--line); color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.rp-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rp-table td:first-child { white-space: nowrap; }
.rp-table td small { display: block; color: var(--muted); font-size: 11px; }
.rp-table .level-chip { font-size: 11px; }
.rp-delta { font-size: 11px; font-weight: 700; color: var(--muted); } .rp-delta.up { color: var(--ok); } .rp-delta.down { color: var(--bad); }

.rp-levels { display: grid; gap: 10px; }
.rp-lv { padding: 12px 14px; border: 1px solid var(--line); border-left: 4px solid var(--level-color); border-radius: 12px; }
.rp-lv.locked { opacity: .65; }
.rp-lv-head { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 12px; }
.rp-lv-head > b { font-size: 13px; white-space: nowrap; }
.rp-skills { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.rp-skills > div { padding: 6px 8px; border-radius: 8px; background: var(--surface-2); }
.rp-skills small { display: block; color: var(--skill); font-size: 11px; font-weight: 700; }
.rp-skills b { font-size: 1rem; }
.rp-mini { display: block; height: 4px; margin-top: 3px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.rp-mini i { display: block; height: 100%; background: var(--skill); }
.rp-sub { display: block; color: var(--muted); font-size: 10.5px; line-height: 1.2; }

.rp-focus-top, .rp-types { display: flex; flex-wrap: wrap; gap: 6px; }
.report h2 .rp-focus-top { margin-left: auto; font-size: 12px; font-weight: 600; }
.rp-parts h3 { margin-top: 10px; }
.rp-review { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.rp-review li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 5px 10px; border-radius: 8px; background: var(--surface-2); }
.rp-rv-unit { flex: none; width: 7.5em; color: var(--muted); font-size: .85em; font-weight: 600; }
.rp-rv-q { flex: 1 1 18em; min-width: 0; }
.rp-rv-a { flex: none; }
.rp-rv-a small { color: var(--bad); font-weight: 700; }
.rp-types { align-items: center; margin-top: 4px; }
.rp-types-h { margin-right: 6px; font-size: .78em; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.rp-foot { margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12px; }
.rp-foot p { margin: 0 0 4px; }

@media (max-width: 700px) {
  .report { padding: 20px 16px; margin-inline: -8px; }
  .rp-head { grid-template-columns: 1fr auto; }
  .rp-brand { display: none; }
  .rp-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rp-place, .rp-month { grid-template-columns: 1fr; }
  .rp-part { grid-template-columns: 36px 1fr 40px 64px; gap: 8px; }
  .rp-lv-head { grid-template-columns: auto 1fr auto; } .rp-lv-head .bar { grid-column: 1 / -1; grid-row: 2; }
  .rp-skills { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rp-table { font-size: 12px; } .rp-table th, .rp-table td { padding: 6px 5px; }
  .rp-toolbar .btn.primary { flex: 1 1 100%; order: 3; margin-left: 0; }
}

@page { size: A4; margin: 10mm 11mm 11mm; }
@media print {
  html, body { background: #fff !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; animation: none !important; transition: none !important; }
  .topbar, .rp-toolbar { display: none !important; }
  .wrap.rp-wrap { max-width: none; padding: 0; margin: 0; }
  .report { padding: 0; box-shadow: none; border-radius: 0; font-size: 12px; margin: 0; }
  .rp-sec { padding: 8px 0; }
  .rp-parts h3 { margin-top: 6px; } .report h3 { margin: 8px 0 4px; }
  .rp-skills > div { padding: 3px 7px; } .rp-levels { gap: 6px; }
  .report h2 { margin-bottom: 8px; font-size: 1.05rem; }
  .rp-skills { margin-top: 7px; gap: 6px; } .rp-skills > div { padding: 4px 7px; }
  .rp-place-main { padding: 10px 12px; } .rp-parts { gap: 7px; }
  .rp-month { gap: 18px; }
  .report { font-size: 11px; }
  .rp-head { gap: 14px; } .rp-title h1 { font-size: 1.45rem; }
  .rp-level { padding: 6px 12px; } .rp-level .level-chip { font-size: 1.25rem; }
  .rp-summary > div { padding: 7px 10px; } .rp-summary b { font-size: 1.15rem; }
  .rp-sub { display: none; }
  .rp-table th { padding: 4px 8px; } .rp-table td { padding: 4px 8px; }
  .rp-review li { padding: 3px 8px; }
  .rp-foot { margin-top: 4px; padding-top: 8px; font-size: 10px; }
  .rp-skills b { font-size: .95rem; } .rp-lv-head { gap: 10px; }
  .rp-note { margin-top: 4px; font-size: 10.5px; }
  .rp-head { padding-bottom: 12px; margin-bottom: 12px; }
  .rp-summary { margin-bottom: 14px; }
  .rp-levels { gap: 8px; } .rp-lv { padding: 9px 12px; }
  .report h3 { margin: 12px 0 6px; }
  .rp-table td { padding: 5px 8px; }
  /* keep the desktop layout on paper, whatever the device */
  .rp-head { grid-template-columns: auto 1fr auto; } .rp-brand { display: flex; }
  .rp-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .rp-place { grid-template-columns: 200px 1fr; } .rp-month { grid-template-columns: 1fr 1fr; }
  .rp-lv-head { grid-template-columns: auto auto 1fr auto; } .rp-lv-head .bar { grid-column: auto; grid-row: auto; }
  .rp-skills { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .rp-lv, .rp-place, .rp-month, .rp-summary, .rp-table tr, .rp-foot, .rp-units { break-inside: avoid; }
  .rp-sec h2, .report h3 { break-after: avoid; }
}

/* ===== Home: weekly card + reminders ===== */
.nudge { display: flex; align-items: center; gap: var(--space-4); margin-top: var(--space-4); padding: var(--space-4) var(--space-5);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line)); border-radius: var(--radius-lg);
  background: linear-gradient(110deg, var(--accent-soft), var(--surface) 70%); box-shadow: var(--shadow-sm); }
.nudge .ic { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; background: var(--brand-gradient); color: #fff; }
.nudge > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.nudge .muted { font-size: var(--text-sm); }
.week-card { margin-top: var(--space-4); padding: var(--space-4) var(--space-5); border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-sm); }
.wk-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.wk-head h2 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: var(--text-lg); }
.wk-head h2 .icon-sm { color: #e8590c; }
.wk-days { display: flex; gap: 5px; }
.wk-days span { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); color: var(--muted);
  font-size: var(--text-xs); font-weight: 700; }
.wk-days span.on { background: linear-gradient(135deg, #f29a58, #e8590c); color: #fff; }
.wk-days span.today:not(.on) { box-shadow: inset 0 0 0 2px #f29a58; color: var(--text); }
.wk-days span.future { opacity: .45; }
.wk-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: var(--space-3); }
.wk-stats > div { display: flex; flex-direction: column; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.wk-stats b { font-size: var(--text-lg); line-height: 1.2; }
.wk-stats small { color: var(--muted); font-size: var(--text-xs); }
.wk-prev { color: var(--subtle); font-size: 11px; margin-top: 2px; }

/* ===== Profile: reports + badges ===== */
.pf-reports { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: var(--space-6); }
.pf-report { display: flex; flex-direction: column; gap: 4px; padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-sm); }
.pf-report p { margin: 0; flex: 1; font-size: var(--text-sm); }
.pf-report .actions { margin: 8px 0 0; gap: 8px; }
.pf-report select { min-height: 34px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-size: var(--text-sm); }
.pf-badge-note { margin: -4px 0 var(--space-3); font-size: var(--text-sm); }

/* ===== Monthly report ===== */
.rp-month-pick { min-height: 40px; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--surface); color: var(--text); font: inherit; font-size: var(--text-sm); }
.rp-month { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.rp-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; max-width: 320px; }
.rp-cal span { display: grid; place-items: center; aspect-ratio: 1; border-radius: 7px; background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 600; }
.rp-cal .rp-cal-h { aspect-ratio: auto; background: none; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.rp-cal .out { background: none; color: transparent; }
.rp-cal .on { background: color-mix(in srgb, #f29a58 55%, #fff); color: #6b2a00; }
.rp-cal .on.lots { background: linear-gradient(135deg, #f29a58, #e8590c); color: #fff; }
.rp-mskills { display: grid; gap: 7px; }
.rp-mskills > div { display: grid; grid-template-columns: 80px 1fr 44px 58px; align-items: center; gap: 8px; }
.rp-mskills small { color: var(--skill); font-size: 12px; font-weight: 700; }
.rp-mskills .rp-mini { height: 7px; margin: 0; }
.rp-mskills b { text-align: right; font-variant-numeric: tabular-nums; }
.rp-mskills .rp-count { grid-column: 2 / -1; text-align: left; font-weight: 600; font-size: 13px; }
.rp-units { display: flex; flex-wrap: wrap; gap: 6px; }
.rp-unit { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: var(--radius-pill); font-size: 12.5px; }
.rp-unit .level-chip { font-size: 10px; }
.rp-unit.ms { border-color: var(--ok); background: var(--ok-soft); }

.rp-idle { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 8px 12px; border: 1px dashed var(--line-strong); border-radius: 12px; font-size: 12.5px; color: var(--muted); }
.rp-idle > span { display: inline-flex; align-items: center; gap: 6px; }
.rp-idle .level-chip { font-size: 10px; }
.rp-idle small { flex-basis: 100%; font-size: 11px; }
@media (max-width: 860px) { .pf-reports { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .rp-month { grid-template-columns: 1fr; } .rp-cal { max-width: none; } }
@media (max-width: 560px) {
  .nudge { flex-wrap: wrap; padding: var(--space-4); }
  .nudge .btn { flex: 1 1 100%; }
  .week-card { padding: var(--space-4); }
  .wk-days span { width: 30px; height: 30px; }
  .wk-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .badge-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .me .level-chip { padding: 3px 7px; }
}
@media (max-width: 380px) { .me-streak { display: none; } .me { padding-right: 5px; } }

/* ===== In-app PDF preview (/report/view) ===== */
.pv [hidden] { display: none !important; }  /* the flex/inline-flex rules below must not reveal hidden parts */
.pv-wrap { max-width: 860px; }
.pv-card { padding: var(--space-5); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.pv-file { display: flex; align-items: center; gap: var(--space-4); }
.pv-icon { position: relative; flex: none; display: grid; place-items: center; width: 56px; height: 64px; border-radius: 10px;
  background: var(--brand-gradient); color: #fff; box-shadow: 6px 6px 0 -1px color-mix(in srgb, var(--accent) 30%, var(--surface)); }
.pv-icon::after { content: ""; position: absolute; top: 0; right: 0; width: 16px; height: 16px; border-radius: 0 10px 0 6px; background: rgb(255 255 255 / 35%); }
.pv-icon span { font: 800 13px/1 var(--font-sans); letter-spacing: .06em; }
.pv-name { min-width: 0; }
.pv-name h1 { margin: 0; font-size: clamp(1.35rem, 4.5vw, 1.75rem); }
.pv-meta { margin: 2px 0 0; color: var(--muted); font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.pv-sk { display: inline-block; width: 13em; max-width: 60vw; height: .9em; border-radius: 6px; vertical-align: middle;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: ai-shimmer 1.4s ease-in-out infinite; }
.pv-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: var(--space-4); }
.pv-dl { min-height: 52px; padding-inline: 22px; font-size: var(--text-base); }
.pv-dl.is-wait { opacity: .55; pointer-events: none; }
.pv-actions .btn:not(.pv-dl) { min-height: 52px; }
.pv-kinds { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: var(--space-4); padding: 4px; border-radius: var(--radius-pill); background: var(--surface-2); width: fit-content; max-width: 100%; }
.pv-kinds a { display: inline-flex; align-items: center; min-height: 40px; padding: 4px 14px; border-radius: var(--radius-pill); color: var(--muted); font: 600 var(--text-sm)/1 var(--font-sans); }
.pv-kinds a.active { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.pv-kinds select { min-height: 36px; margin-left: 4px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--surface); color: var(--text); font: inherit; font-size: var(--text-sm); }

.pv-stage { margin-top: var(--space-4); padding: var(--space-4); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--surface-3) 70%, var(--bg)); min-height: 60vh; }
.pv-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 52vh; text-align: center; }
.pv-loading h2 { margin: 0; font-size: var(--text-xl); }
.pv-loading p { margin: 0; }
.pv-bar { position: relative; width: min(420px, 80%); height: 8px; overflow: hidden; border-radius: var(--radius-pill); background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.pv-bar i { position: absolute; top: 0; bottom: 0; left: 0; width: 45%; border-radius: inherit; background: var(--accent); animation: pv-slide 1.3s var(--ease-standard) infinite; }
.pv-bar.is-determinate i { width: var(--p, 0%); animation: none; transition: width .25s var(--ease-out); }
@keyframes pv-slide { from { transform: translateX(-100%); } to { transform: translateX(230%); } }
.pv-pages { display: grid; gap: var(--space-4); }
.pv-page { margin: 0; animation: tab-enter .3s var(--ease-out) both; }
.pv-page canvas { display: block; width: 100%; height: auto; background: #fff; border-radius: 4px; box-shadow: 0 1px 3px rgb(0 0 0 / 12%), 0 10px 28px rgb(30 25 80 / 14%); }
.pv-page figcaption { margin-top: 6px; text-align: center; color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.pv-frame { display: block; width: 100%; min-height: 60vh; border: 0; border-radius: 6px; background: #fff; box-shadow: 0 10px 28px rgb(30 25 80 / 14%); }
.pv-error a { font-weight: 700; }
.rp-embed { max-width: none; padding: 0; }
.rp-embed .report { box-shadow: none; border-radius: 0; }
@media (max-width: 560px) {
  .pv-card { padding: var(--space-4); }
  .pv-icon { width: 46px; height: 54px; } .pv-icon span { font-size: 11px; }
  .pv-meta { font-size: var(--text-base); }
  .pv-dl { flex: 1 1 100%; }
  .pv-actions .btn:not(.pv-dl) { flex: 1 1 0; }
  .pv-stage { margin-inline: -8px; padding: 10px; }
}
@media (prefers-reduced-motion: reduce) { .pv-bar i { animation-duration: 3s; } }

/* ===== The learner's AI agent: suggestion boxes, buttons, waiting state ===== */
:root { --agent: #0b7285; --agent-ink: #08596a; --agent-soft: #e3f6f8; --agent-2: #5c48df; }
.agent-box { display: flex; align-items: flex-start; gap: var(--space-4); margin: var(--space-4) 0; padding: var(--space-4) var(--space-5);
  border: 1px solid color-mix(in srgb, var(--agent) 35%, var(--line)); border-left: 5px solid var(--agent); border-radius: var(--radius-lg);
  background: linear-gradient(115deg, var(--agent-soft), color-mix(in srgb, var(--accent-soft) 70%, var(--surface)) 70%); box-shadow: var(--shadow-sm); }
.agent-box.is-wait { border-left-color: var(--agent-2); background: linear-gradient(115deg, var(--accent-soft), var(--surface) 75%); }
.agent-box.compact { margin: var(--space-3) 0 0; padding: var(--space-3) var(--space-4); box-shadow: none; }
.agent-ic { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: #fff;
  background: linear-gradient(135deg, var(--agent), var(--agent-2)); box-shadow: 0 4px 12px color-mix(in srgb, var(--agent) 30%, transparent); }
.agent-main { flex: 1; min-width: 0; }
.agent-main > b { display: block; color: var(--agent-ink); }
.agent-box.is-wait .agent-main > b { color: var(--accent-ink); }
.agent-main p { margin: 4px 0 0; font-size: var(--text-sm); }
.agent-prompt { display: block; margin-top: 6px; padding: 6px 10px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--surface) 75%, transparent);
  font-size: var(--text-sm); font-style: italic; color: var(--text); border: 1px dashed color-mix(in srgb, var(--agent) 40%, var(--line)); }
.agent-list { margin: 6px 0 0; padding-left: 18px; font-size: var(--text-sm); } .agent-list li { margin: 2px 0; }
.agent-act { flex: none; display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.btn.agent { background: linear-gradient(135deg, var(--agent), color-mix(in srgb, var(--agent) 55%, var(--agent-2))); border-color: transparent; color: #fff;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--agent) 25%, transparent); }
.btn.agent:hover { filter: brightness(1.08); border-color: transparent; }
.grade-btns { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.agent-wait { display: flex; gap: 12px; align-items: flex-start; margin-top: var(--space-3); padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--agent) 35%, var(--line)); background: var(--agent-soft); font-size: var(--text-sm); }
.agent-wait > .icon { flex: none; color: var(--agent); margin-top: 2px; animation: spin-slow 3s linear infinite; }
.agent-wait p { margin: 4px 0 0; } .agent-wait .actions { margin: 8px 0 0; }
.pack-banner { margin-top: var(--space-4); }

/* self-check (grading without AI) */
.self-form { margin-top: var(--space-3); padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.self-form p { margin: 0 0 8px; font-size: var(--text-sm); }
.self-form fieldset { border: 0; margin: 0 0 10px; padding: 0; }
.self-form legend { font-size: var(--text-sm); margin-bottom: 4px; }
.self-dots { display: flex; gap: 6px; }
.self-dots label { position: relative; }
.self-dots input { position: absolute; opacity: 0; inset: 0; }
.self-dots span { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface);
  font-weight: 700; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.self-dots input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-color); }
.self-dots input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.self-note { display: flex; flex-direction: column; gap: 4px; font-size: var(--text-sm); font-weight: 600; }
.self-note textarea { min-height: 0; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); font-size: var(--text-sm); }
.self-card { margin-top: var(--space-3); padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); font-size: var(--text-sm); }
.self-card > b { display: inline-flex; align-items: center; gap: 6px; }
.self-scores { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 4px; color: var(--muted); }
.self-scores b { color: var(--text); }
.self-card p { margin: 6px 0 0; }

/* field packs page */
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.mode { display: flex; flex-direction: column; gap: 6px; padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.mode.on { border-color: color-mix(in srgb, var(--agent) 35%, var(--line)); background: linear-gradient(160deg, var(--agent-soft), var(--surface) 70%); }
.mode p { margin: 0; flex: 1; font-size: var(--text-sm); color: var(--muted); }
.mode .pill { align-self: flex-start; }
.mode-ic { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.mode.on .mode-ic { background: linear-gradient(135deg, var(--agent), var(--agent-2)); color: #fff; }
.pack-list { display: grid; gap: 12px; }
.pack-card { padding: var(--space-4) var(--space-5); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.pack-card.active { border-color: var(--ok); box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 25%, transparent), var(--shadow-sm); }
.pack-card p { margin: 4px 0 0; font-size: var(--text-sm); }
.pack-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pack-top > b { font-size: var(--text-lg); margin-right: 4px; }
.pack-top .level-chip, .lv-pick .level-chip, .rp-idle .level-chip { background: var(--level-gradient); }
.pack-prog { display: flex; align-items: center; gap: 12px; margin-top: 10px; font-size: var(--text-sm); color: var(--muted); }
.pack-prog .bar { flex: 1; max-width: 260px; margin: 0; }
.pack-card .actions { margin-bottom: 0; }
.pack-form { display: grid; gap: var(--space-4); max-width: none; }
.pack-form fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.pack-form legend { font-weight: 700; margin-bottom: 6px; }
.pf-field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.pf-field input, .pf-field textarea { min-height: 46px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-weight: 400; }
.depths { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.depth { position: relative; display: flex; padding: 12px 14px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.depth input { position: absolute; opacity: 0; }
.depth b { display: block; } .depth small { color: var(--muted); font-size: var(--text-sm); }
.depth:has(input:checked) { border-color: var(--agent); background: var(--agent-soft); }
.depth:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--agent) 45%, transparent); outline-offset: 2px; }
.lv-pick { display: flex; flex-wrap: wrap; gap: 10px; }
.lv-pick label { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 12px 4px 8px; border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--surface); cursor: pointer; }
.pack-err { font-size: var(--text-sm); }
.home-agent { margin-top: var(--space-4); }
/* /packs (design/codex-packs-welcome-redesign.md) */
.pack-intro .cando { max-width: 62ch; }
.pack-next { display: flex; align-items: flex-start; gap: var(--space-3); margin-top: var(--space-3); padding: var(--space-3) var(--space-4);
  border: 1px solid color-mix(in srgb, var(--agent) 28%, var(--line)); border-radius: var(--radius); background: linear-gradient(115deg, var(--agent-soft), var(--surface) 80%); }
.pack-next .agent-ic { width: 36px; height: 36px; border-radius: 11px; }
.pack-next-main { flex: 1; min-width: 0; }
.pack-next-main > b { display: block; color: var(--agent-ink); }
.pack-next-main p { margin: 4px 0 0; font-size: var(--text-sm); }
.pack-next-act { flex: none; align-self: center; }
.pack-prompt { margin-top: 8px; font-size: var(--text-sm); }
.pack-prompt summary { cursor: pointer; width: fit-content; color: var(--agent-ink); font-weight: 650; }
.pack-prompt summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--agent) 45%, transparent); outline-offset: 2px; border-radius: 4px; }
.pack-prompt .agent-prompt { user-select: all; }
.pack-done { display: flex; align-items: center; gap: 6px; margin: 10px 0 0 !important; color: var(--ok); font-weight: 650; }
.pack-empty { display: flex; align-items: center; gap: 12px; padding: var(--space-4) var(--space-5); border: 2px dashed var(--line-strong); border-radius: var(--radius-lg);
  color: var(--muted); text-decoration: none; font-size: var(--text-sm); }
.pack-empty:hover { border-color: var(--agent); color: var(--text); }
.pack-empty .icon-sm { flex: none; color: var(--agent); }
.pack-empty b { color: var(--text); }
.pack-access { display: flex; align-items: center; gap: 6px; margin: var(--space-4) 0 0; font-size: var(--text-sm); color: var(--muted); }
.pack-access.ok .icon-sm { color: var(--ok); }
.pack-access-box { margin-top: var(--space-5); }
.pf-intro { margin: 0; }
.pf-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--space-4) var(--space-5); align-items: start; }
.pf-submit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px var(--space-4); }
.pf-submit p { flex: 1 1 260px; margin: 0; font-size: var(--text-sm); }
.pf-submit .pack-err:empty { display: none; }
.pf-submit .pack-err { flex-basis: 100%; }
.modes.compact .mode { padding: var(--space-3) var(--space-4); }
.modes.compact .mode p { font-size: var(--text-xs); }
@media (max-width: 760px) {
  .modes, .depths, .pf-grid { grid-template-columns: 1fr; }
  .pack-card { padding: var(--space-3) var(--space-4); }
  .pack-next { flex-wrap: wrap; }
  .pack-next-main { flex-basis: calc(100% - 52px); }
  .pack-next-act { flex: 1 1 100%; }
  .pack-next-act .btn, .pf-submit .btn { width: 100%; }
}
@media (max-width: 560px) {
  .agent-box { flex-wrap: wrap; padding: var(--space-4); gap: 12px; }
  .agent-main { flex-basis: calc(100% - 56px); }
  .agent-act { flex: 1 1 100%; flex-direction: row; flex-wrap: wrap; }
  .agent-act .btn { flex: 1 1 auto; }
  .grade-btns .btn { flex: 1 1 auto; }
  .sub-head { align-items: stretch; }
}

/* ===== Dark theme ===== */
/* ===== sign in, first-run setup, password (auth.py) ===== */
.auth-wrap { max-width: 460px; min-height: 100vh; display: grid; align-content: center; padding-block: var(--space-6); }
.auth-card { position: relative; padding: var(--space-6); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface);
  box-shadow: 0 24px 60px rgb(40 30 110 / 14%); overflow: hidden; }
.auth-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 5px; background: var(--brand-gradient); }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: var(--text-lg); }
.auth-brand .muted { font-weight: 500; font-size: var(--text-sm); }
.auth-tutors { display: flex; margin: var(--space-4) 0 var(--space-2); }
.auth-tutors .avatar { width: 46px; height: 46px; border: 3px solid var(--surface); box-shadow: var(--shadow-sm); }
.auth-tutors .avatar + .avatar { margin-left: -12px; }
.auth-card h1 { margin: var(--space-3) 0 4px; font-size: clamp(1.5rem, 6vw, 1.9rem); letter-spacing: -.02em; }
.auth-sub { margin: 0 0 var(--space-4); }
.auth-form { display: grid; gap: var(--space-3); }
.auth-field { display: grid; gap: 6px; font-weight: 650; font-size: var(--text-sm); }
.auth-field small { font-weight: 500; }
.auth-field input { min-height: 48px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface);
  color: var(--text); font: 400 var(--text-base)/1.3 var(--font-sans); }
.auth-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent); }
.auth-submit { width: 100%; min-height: 50px; margin-top: 4px; justify-content: center; font-size: var(--text-base); }
.auth-foot { margin: var(--space-4) 0 0; font-size: var(--text-sm); text-align: center; }
.auth-card .notice { margin: 0 0 var(--space-3); }
@media (max-width: 560px) { .auth-wrap { padding-inline: 16px; align-content: start; padding-top: var(--space-5); } .auth-card { padding: var(--space-5) var(--space-4); } }

/* ===== admin: accounts ===== */
.adm-flash { display: flex; gap: var(--space-3); align-items: flex-start; margin: var(--space-4) 0; padding: var(--space-4) var(--space-5);
  border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--line)); border-radius: var(--radius-lg); background: linear-gradient(115deg, var(--ok-soft), var(--surface) 80%); }
.adm-flash .agent-ic { background: var(--ok); }
.adm-flash p { margin: 4px 0 8px; font-size: var(--text-sm); }
.adm-cred { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 10px; font-size: var(--text-sm); }
.adm-cred dt { color: var(--muted); } .adm-cred dd { margin: 0; }
.adm-pw { font-size: var(--text-lg); letter-spacing: .04em; user-select: all; }
.adm-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: var(--space-3) var(--space-4); align-items: end; }
.adm-check { display: flex; align-items: center; gap: 8px; font-size: var(--text-sm); }
.adm-form .btn.primary { justify-self: start; }
.adm-list { display: grid; gap: 10px; }
.adm-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 8px var(--space-4); align-items: center;
  padding: var(--space-3) var(--space-4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.adm-row.off { opacity: .6; }
.adm-who { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.adm-who small { flex-basis: 100%; overflow-wrap: anywhere; }
.adm-meta { display: grid; gap: 2px; font-size: var(--text-xs); }
.adm-act { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.adm-act form { margin: 0; }
.pf-account { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); }
.pf-acc-who { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.pf-account .actions { margin: 0; flex-wrap: wrap; }
.pf-account form { margin: 0; }
.ai-left { font-weight: 500; opacity: .85; }
@media (max-width: 560px) { .sec-head:has(.adm-note) { flex-wrap: wrap; } .adm-note { flex-basis: 100%; } .sec-head:has(.adm-note) .spacer { display: none; } }
.adm-conn { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: var(--space-4) 0 0; font-size: var(--text-sm); overflow-wrap: anywhere; }
@media (max-width: 760px) {
  .adm-form { grid-template-columns: 1fr; }
  .adm-row { grid-template-columns: 1fr; }
  .adm-act { justify-content: flex-start; }
}

/* theme switch: header button (shows the current choice) + Profile → Appearance */
.theme-btn { flex: none; display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--line);
  border-radius: 50%; background: var(--surface); color: var(--muted); cursor: pointer; transition: color .15s, border-color .15s, transform .15s; }
.theme-btn:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.theme-btn:active { transform: scale(.94); }
.theme-btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.theme-btn svg { display: none; }
:root[data-theme-pref="light"] .theme-btn .t-light, :root[data-theme-pref="dark"] .theme-btn .t-dark,
:root[data-theme-pref="auto"] .theme-btn .t-auto { display: block; }
.theme-seg { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: var(--space-3); padding: 4px;
  border: 1px solid var(--line); border-radius: var(--radius-pill); background: var(--surface-2); }
.theme-seg > .muted { padding: 0 8px 0 10px; font-size: var(--text-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.theme-seg button { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border: 0; border-radius: var(--radius-pill);
  background: transparent; color: var(--muted); font: 600 var(--text-sm)/1 var(--font-sans); cursor: pointer; }
.theme-seg button:hover { color: var(--text); }
.theme-seg button[aria-checked="true"] { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.theme-seg button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
@media (max-width: 560px) {
  .theme-seg { display: flex; flex-wrap: nowrap; width: 100%; }
  .theme-seg > .muted { display: none; }   /* the group keeps aria-label="Appearance" */
  .theme-seg button { flex: 1; justify-content: center; padding: 0 8px; }
  .theme-btn { width: 36px; height: 36px; }
}

/* chosen in the header / Profile: light (default), dark, or auto (follows the system; set by a script in <head>) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121220;
  --bg-wash: #141a26;
  --surface: #1b1b2c;
  --surface-2: #242438;
  --surface-3: #2e2e46;
  --text: #e8e8f4;
  --muted: #a5a9bf;
  --subtle: #8b8fa7;
  --line: #303149;
  --line-strong: #46485f;

  --accent: #8d84ff;
  --accent-hover: #a29bff;
  --accent-soft: #29264d;
  --accent-ink: #bab4ff;
  --violet: #b98cf2;
  --violet-soft: #2c2346;
  --teal: #4fc3cf;
  --teal-soft: #15313a;

  --skill-vocabulary: #45c9b5;
  --skill-vocabulary-soft: #143430;
  --skill-grammar: #f0a35e;
  --skill-grammar-soft: #382813;
  --skill-reading: #7fa2ff;
  --skill-reading-soft: #1c2747;
  --skill-listening: #b096f5;
  --skill-listening-soft: #2a2348;
  --skill-writing: #f08ac0;
  --skill-writing-soft: #3a1f30;
  --skill-speaking: #4fc3cf;
  --skill-speaking-soft: #15313a;

  /* level inks lighten for text; the -gradient tokens (chip fills) keep their dark stops */
  --level-b1: #3fbf9f;
  --level-b1-soft: #143229;
  --level-b2: #7d9cff;
  --level-b2-soft: #1b2546;
  --level-c1: #b98cf2;
  --level-c1-soft: #2c2346;
  --level-c2: #f09160;
  --level-c2-soft: #3a2316;

  --ok: #5fd394;
  --ok-soft: #15301f;
  --bad: #ff8590;
  --bad-soft: #3b1b22;
  --warn: #f2bd55;
  --warn-soft: #362a11;
  --highlight: #5b4a10;
  --on-color: #141320;
  --agent: #3cc6d6;
  --agent-ink: #7fdbe6;
  --agent-soft: #12303a;
  --agent-2: #8d84ff;
  --pill-bg: #262539;
  --pill-ink: #b3b6cc;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 12px rgb(0 0 0 / 22%);
  --shadow-card: 0 4px 14px rgb(0 0 0 / 35%), 0 14px 32px rgb(0 0 0 / 28%);
  --shadow-pop: 0 12px 30px rgb(0 0 0 / 50%);
}
:root[data-theme="dark"] body {
  background:
    radial-gradient(ellipse 38rem 28rem at 0% 0%, rgb(101 75 232 / 16%), transparent 72%),
    radial-gradient(ellipse 34rem 26rem at 100% 6%, rgb(38 176 189 / 10%), transparent 70%),
    radial-gradient(ellipse 30rem 24rem at 86% 100%, rgb(242 154 88 / 8%), transparent 72%),
    linear-gradient(145deg, #14131f 0%, #121725 48%, #19141b 100%);
  background-attachment: fixed;
}
:root[data-theme="dark"] .topbar { background: rgb(18 18 32 / 86%); border-bottom-color: var(--line); box-shadow: none; }
:root[data-theme="dark"] .tabs { background: color-mix(in srgb, var(--bg) 90%, transparent); }
:root[data-theme="dark"] .stat { background: color-mix(in srgb, var(--surface) 92%, transparent); border-color: var(--line); }
:root[data-theme="dark"] .hero { border-color: rgb(255 255 255 / 12%); box-shadow: 0 12px 34px rgb(0 0 0 / 35%); }
:root[data-theme="dark"] .bubble, :root[data-theme="dark"] .bubble::before { background: var(--surface-2); border-color: var(--line); }
:root[data-theme="dark"] .hero .bubble, :root[data-theme="dark"] .hero .bubble::before { background: #fff; color: #20213a; border-color: rgb(255 255 255 / 80%); }
:root[data-theme="dark"] .hero-tutor .bubble strong { color: #4033ad; }
:root[data-theme="dark"] .avatar { border-color: var(--surface-3); background: var(--surface-2); }
:root[data-theme="dark"] .bdg img, :root[data-theme="dark"] .bdg > i, :root[data-theme="dark"] .pf-emblem img { background: var(--surface-2); }
:root[data-theme="dark"] .card.empty .num::before { background: linear-gradient(135deg, #5d6178, #44475c); }
:root[data-theme="dark"] .vhead .pos { color: var(--skill-vocabulary); }
:root[data-theme="dark"] .phrases span, :root[data-theme="dark"] .timer.prep { color: var(--skill-speaking); }
:root[data-theme="dark"] .pill.ok { color: var(--ok); }
:root[data-theme="dark"] .pill.warn { color: var(--warn); }
:root[data-theme="dark"] .gl-tip { background: var(--surface-3); color: var(--text); }
:root[data-theme="dark"] .gl { color: var(--text); }
:root[data-theme="dark"] .photo img, :root[data-theme="dark"] .reading-art img { filter: brightness(.92); }
:root[data-theme="dark"] .btn.agent { color: #062a30; }
:root[data-theme="dark"] .agent-ic, :root[data-theme="dark"] .mode.on .mode-ic { color: #062a30; }

