/* Snylux. Palette from the Luxembourg flags: Roude Léiw red, the sky blue of
   the national flag and the burelé stripes of the lion flag. */

@font-face {
  font-family: 'Lora';
  src: url('/fonts/lora-var.woff') format('woff');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #1E2B38;
  --ink-2: #4A5B6B;
  --ink-3: #6E7F8F;
  --paper: #F5F8FA;
  --surface: #FFFFFF;
  --surface-2: #EDF2F6;
  --line: #D9E2EA;
  --sky: #00A1DE;
  --sky-soft: #D6EFFA;
  --deep: #0A4F7A;
  --deep-hover: #083F62;
  --on-deep: #FFFFFF;
  --lion: #E03A3E;
  --lion-soft: #FCE4E4;
  --moss: #2F8F5B;
  --moss-soft: #DDF1E5;
  --amber: #A86F00;
  --amber-soft: #FBEFD5;
  --focus: #0A7FBF;

  --font-ui: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-lb: 'Lora', Georgia, 'Times New Roman', serif;

  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5625rem;
  --fs-2xl: 1.953rem;
  --fs-3xl: 2.441rem;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --shadow: 0 1px 2px rgb(30 43 56 / 6%), 0 4px 16px rgb(30 43 56 / 6%);
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #E6EDF3;
    --ink-2: #B5C3D0;
    --ink-3: #8C9CAB;
    --paper: #13202C;
    --surface: #1A2A38;
    --surface-2: #213445;
    --line: #2C4154;
    --sky: #35B6E8;
    --sky-soft: #173D52;
    --deep: #5CC0EC;
    --deep-hover: #7ACDF0;
    --on-deep: #0B1822;
    --lion: #FF6B6E;
    --lion-soft: #4A2328;
    --moss: #5BC48A;
    --moss-soft: #1C3B2B;
    --amber: #E8B04A;
    --amber-soft: #3E3217;
    --focus: #7ACDF0;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { line-height: 1.2; margin: 0; text-wrap: balance; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0; }
a { color: var(--deep); }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
[hidden] { display: none !important; }

.lb { font-family: var(--font-lb); font-weight: 500; letter-spacing: 0.005em; }
.muted { color: var(--ink-2); }
.small { font-size: var(--fs-sm); }
.stack > * + * { margin-top: 1rem; }
.stack-sm > * + * { margin-top: 0.5rem; }
.stack-lg > * + * { margin-top: 2rem; }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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

.skip-link { position: absolute; left: -999px; top: 0.5rem; z-index: 100; background: var(--surface); padding: 0.5rem 1rem; border-radius: var(--r-sm); }
.skip-link:focus { left: 0.5rem; }
.noscript { padding: 2rem; text-align: center; }

/* ---------------------------------------------------------------- boot */
.boot { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 1rem; color: var(--ink-3); }
.boot-mark { width: 56px; height: 56px; border-radius: 14px; background: repeating-linear-gradient(180deg, var(--sky) 0 5.6px, var(--surface) 5.6px 11.2px); box-shadow: var(--shadow); }
.boot p { font-family: var(--font-lb); font-size: var(--fs-lg); }

/* -------------------------------------------------------------- layout */
.shell { min-height: 100dvh; }
.main { max-width: 760px; margin: 0 auto; padding: 1.25rem 1rem calc(var(--nav-h) + var(--safe-b) + 2rem); }
.main-wide { max-width: 1040px; }

.nav {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--ink-3); font-size: 0.75rem; font-weight: 600; position: relative;
}
.nav a svg { width: 24px; height: 24px; }
.nav a[aria-current='page'] { color: var(--deep); }
.nav a[aria-current='page']::before {
  content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--sky);
}
.nav .badge {
  position: absolute; top: 8px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--lion); color: #fff; font-size: 0.6875rem; line-height: 18px; text-align: center;
}
.nav .nav-brand { display: none; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 232px 1fr; }
  .nav {
    position: sticky; top: 0; inset: auto; height: 100dvh; padding: 1.5rem 0.75rem;
    display: flex; flex-direction: column; gap: 0.25rem;
    border-top: 0; border-right: 1px solid var(--line); background: var(--surface); backdrop-filter: none;
  }
  .nav .nav-brand { display: flex; flex-direction: row; justify-content: flex-start; align-items: center; gap: 0.625rem; padding: 0 0.75rem 1.5rem; text-decoration: none; color: var(--ink); font-size: inherit; }
  .nav-brand .mark { width: 32px; height: 32px; border-radius: 8px; }
  .nav-brand span { font-family: var(--font-lb); font-size: var(--fs-lg); font-weight: 600; }
  .nav a:not(.nav-brand) { flex-direction: row; justify-content: flex-start; gap: 0.75rem; padding: 0.625rem 0.75rem; border-radius: var(--r-sm); font-size: var(--fs-md); }
  .nav a:not(.nav-brand):hover { background: var(--surface-2); color: var(--ink); }
  .nav a[aria-current='page'] { background: var(--sky-soft); }
  .nav a[aria-current='page']::before { display: none; }
  .nav .badge { position: static; margin-left: auto; }
  .main { padding: 2.5rem 2rem 4rem; }
  .mobile-only { display: none !important; }
}

.mark { width: 28px; height: 28px; border-radius: 7px; overflow: hidden; flex: none; background: repeating-linear-gradient(180deg, var(--sky) 0 10%, #fff 10% 20%); position: relative; }
.mark::after { content: 'ë'; position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-lb); font-weight: 700; color: var(--lion); font-size: 1.15em; -webkit-text-stroke: 1.5px #fff; paint-order: stroke fill; }

/* ------------------------------------------------------------- topbar */
.topbar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.5rem; }
.topbar .wordmark { display: flex; align-items: center; gap: 0.5rem; font-family: var(--font-lb); font-size: var(--fs-xl); font-weight: 600; }
@media (min-width: 900px) { .topbar .wordmark { display: none; } }
.chip {
  display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.375rem 0.75rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: var(--fs-sm); font-variant-numeric: tabular-nums;
}
.chip svg { width: 18px; height: 18px; }
.chip-streak svg { color: var(--lion); }
.chip-streak.off svg { color: var(--ink-3); }

/* ------------------------------------------------------------ surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.25rem; box-shadow: var(--shadow); }
.card-flat { box-shadow: none; }
.section-title { font-size: var(--fs-lg); font-weight: 700; margin: 2rem 0 0.75rem; }

.page-head { margin-bottom: 1.5rem; }
.page-head .kicker { color: var(--ink-2); font-weight: 600; margin-bottom: 0.25rem; }
.page-head h1.lb { font-size: var(--fs-3xl); font-weight: 600; }
.page-head .sub { color: var(--ink-2); margin-top: 0.375rem; font-size: var(--fs-lg); }
.back { display: inline-flex; align-items: center; gap: 0.25rem; color: var(--ink-2); text-decoration: none; font-weight: 600; margin-bottom: 1rem; }
.back svg { width: 20px; height: 20px; }
.back:hover { color: var(--ink); }

/* ------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 48px; padding: 0.625rem 1.25rem; border-radius: var(--r-md);
  border: 1px solid transparent; font-weight: 700; text-decoration: none; cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, transform 0.08s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { background: var(--deep); color: var(--on-deep); }
.btn-primary:hover:not(:disabled) { background: var(--deep-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--deep); padding-inline: 0.75rem; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--lion); color: #fff; }
.btn-block { width: 100%; }
.btn-google { gap: 0.625rem; }
.google-g {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  font: 700 14px/1 system-ui, sans-serif; color: #fff; background: #4285f4;
}
.or-divider { display: flex; align-items: center; gap: 0.75rem; color: var(--ink-3); font-size: var(--fs-sm); margin: 0; }
.or-divider::before, .or-divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.btn-sm { min-height: 36px; padding: 0.375rem 0.875rem; font-size: var(--fs-sm); }
.btn .count { background: rgb(255 255 255 / 22%); border-radius: 999px; padding: 0 0.5rem; font-variant-numeric: tabular-nums; }
.btn-secondary .count { background: var(--sky-soft); color: var(--deep); }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 24px; height: 24px; }

/* --------------------------------------------------------------- forms */
.field { display: grid; gap: 0.375rem; }
.field label, .field .label { font-weight: 600; }
.field .hint { color: var(--ink-2); font-size: var(--fs-sm); }
.input, select.input {
  width: 100%; min-height: 48px; padding: 0.625rem 0.875rem; border-radius: var(--r-md);
  border: 1.5px solid var(--line); background: var(--surface); transition: border-color 0.15s;
}
.input:hover { border-color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--deep); box-shadow: 0 0 0 3px var(--sky-soft); }
.form-error { color: var(--lion); font-weight: 600; font-size: var(--fs-sm); }
.form-ok { color: var(--moss); font-weight: 600; font-size: var(--fs-sm); }

.segmented { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border-radius: var(--r-md); padding: 4px; gap: 4px; }
.segmented button { min-height: 40px; padding: 0.375rem 1rem; border: 0; border-radius: 9px; background: transparent; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.segmented button[aria-pressed='true'] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.switch { display: flex; align-items: center; gap: 0.75rem; cursor: pointer; }
.switch input { appearance: none; width: 44px; height: 26px; border-radius: 13px; background: var(--line); position: relative; cursor: pointer; transition: background-color 0.15s; flex: none; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.15s var(--ease); box-shadow: 0 1px 2px rgb(0 0 0 / 20%); }
.switch input:checked { background: var(--deep); }
.switch input:checked::after { transform: translateX(18px); }

/* ---------------------------------------------------------- auth pages */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.auth-card { width: 100%; max-width: 420px; }
.auth-brand { display: flex; align-items: center; gap: 0.625rem; justify-content: center; margin-bottom: 1.5rem; text-decoration: none; color: var(--ink); }
.auth-brand .mark { width: 40px; height: 40px; border-radius: 10px; font-size: 1.4rem; }
.auth-brand span { font-family: var(--font-lb); font-size: var(--fs-2xl); font-weight: 600; }
.auth-card h1 { font-size: var(--fs-xl); margin-bottom: 0.25rem; }
.auth-foot { text-align: center; margin-top: 1.25rem; color: var(--ink-2); }

/* ------------------------------------------------------------- landing */
.landing { max-width: 1040px; margin: 0 auto; padding: 1.25rem 1rem 4rem; }
.landing-top { display: flex; align-items: center; gap: 0.75rem; }
.landing-top .segmented { flex-wrap: nowrap; padding: 3px; }
.landing-top .segmented button { min-height: 34px; padding: 0.25rem 0.625rem; }
.landing-top .btn { white-space: nowrap; padding-inline: 0.625rem; }
.landing-top .brand { display: flex; align-items: center; gap: 0.5rem; font-family: var(--font-lb); font-size: var(--fs-xl); font-weight: 600; }
.hero { display: grid; gap: 2.5rem; align-items: center; padding: 3rem 0 3.5rem; }
.hero h1 { font-family: var(--font-lb); font-size: clamp(2.5rem, 8vw, 4.25rem); font-weight: 600; line-height: 1.05; letter-spacing: -0.01em; }
.hero .tr { font-size: var(--fs-xl); color: var(--ink-2); margin-top: 0.75rem; }
.hero .lead { font-size: var(--fs-lg); max-width: 36ch; margin-top: 1.5rem; }
.hero .row { margin-top: 2rem; }
.hero-flag { justify-self: center; width: min(320px, 70vw); aspect-ratio: 5 / 4; border-radius: var(--r-lg); overflow: hidden; display: grid; grid-template-rows: repeat(10, 1fr); box-shadow: var(--shadow); }
.hero-flag span { background: var(--sky); }
.hero-flag span:nth-child(even) { background: var(--surface); }
@media (min-width: 900px) { .hero { grid-template-columns: 1.2fr 1fr; padding: 5rem 0; } }
.features { display: grid; gap: 2rem; border-top: 1px solid var(--line); padding-top: 2.5rem; }
@media (min-width: 900px) { .features { grid-template-columns: repeat(3, 1fr); } }
.feature h2 { font-size: var(--fs-lg); margin-bottom: 0.5rem; }
.feature p { color: var(--ink-2); }
.feature .example { margin-top: 0.75rem; font-family: var(--font-lb); color: var(--ink); }
.level-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.5rem; margin-top: 2.5rem; }
.level-strip div { border-top: 4px solid var(--line); padding-top: 0.5rem; }
.level-strip div.on { border-color: var(--sky); }
.level-strip strong { display: block; }
.level-strip span { font-size: var(--fs-sm); color: var(--ink-2); }
.landing-foot { margin-top: 4rem; color: var(--ink-3); font-size: var(--fs-sm); text-align: center; }

/* ---------------------------------------------------------------- home */
.today { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.today-head { display: flex; align-items: baseline; gap: 0.5rem; }
.today-head h2 { font-size: var(--fs-lg); }
.today-head .xp { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; width: var(--p, 0%); border-radius: inherit; background: var(--sky); transition: width 0.6s var(--ease); }
.bar-fill.done { background: var(--moss); }
.today-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.today-actions .btn { padding-inline: 0.75rem; }
.continue { display: grid; gap: 0.25rem; text-align: left; justify-items: start; justify-content: start; align-content: center; padding: 1rem 1.25rem; min-height: 72px; }
.continue .what { font-weight: 500; opacity: 0.9; }

.level { margin-top: 2.25rem; }
.level-head { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.level-head h2 { font-size: var(--fs-xl); }
.level-head h2 .lb { font-weight: 600; }
.level-head .meta { color: var(--ink-2); font-size: var(--fs-sm); margin-top: 0.125rem; }
.level-desc { color: var(--ink-2); margin: -0.25rem 0 1rem; }
.level.planned .level-head { opacity: 0.65; }

/* Burelé emblem: one stripe per unit, filled when the unit is complete. */
.emblem {
  flex: none; width: 52px; height: 52px; border-radius: 12px; overflow: hidden;
  display: grid; grid-template-rows: repeat(var(--n, 10), 1fr);
  background: var(--surface); border: 1px solid var(--line);
}
.emblem .stripe { background: transparent; }
.emblem .stripe:nth-child(odd) { background: var(--surface-2); }
.emblem .stripe.filled { background: var(--sky); }
.emblem .stripe.filled:nth-child(even) { background: color-mix(in srgb, var(--sky) 70%, var(--surface)); }
.emblem-lg { width: 132px; height: 132px; border-radius: 22px; box-shadow: var(--shadow); }
.emblem.animate .stripe.filled { animation: stripe-in 0.5s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms + 200ms); }
@keyframes stripe-in { from { transform: scaleX(0); transform-origin: left; } to { transform: scaleX(1); transform-origin: left; } }

.units { display: grid; gap: 0.5rem; }
.unit-row {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 0.875rem; align-items: center;
  padding: 0.875rem 1rem; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; color: inherit; transition: border-color 0.15s, background-color 0.15s;
}
a.unit-row:hover { border-color: var(--sky); }
.unit-row.current { border-color: var(--deep); box-shadow: 0 0 0 1px var(--deep); }
.unit-row.locked { background: transparent; color: var(--ink-3); }
.unit-num { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--surface-2); font-variant-numeric: tabular-nums; }
.unit-row.done .unit-num { background: var(--sky); color: #fff; }
.unit-row.current .unit-num { background: var(--deep); color: var(--on-deep); }
.unit-title { display: block; font-family: var(--font-lb); font-size: var(--fs-lg); font-weight: 600; line-height: 1.25; }
.unit-sub { display: block; color: var(--ink-2); font-size: var(--fs-sm); }
.unit-row.locked .unit-sub { color: var(--ink-3); }
.pips { display: flex; gap: 3px; }
.pips i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.pips i.on { background: var(--sky); }
.unit-state svg { width: 22px; height: 22px; color: var(--ink-3); }
.unit-row.done .unit-state svg { color: var(--moss); }
.planned-note { padding: 1rem; border: 1.5px dashed var(--line); border-radius: var(--r-md); color: var(--ink-2); }

/* ---------------------------------------------------------------- unit */
.goal { font-size: var(--fs-lg); color: var(--ink-2); }
.lessons { display: grid; gap: 0.5rem; margin-top: 1.5rem; }
.lesson-row {
  display: flex; gap: 0.875rem; align-items: center; padding: 0.875rem 1rem; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: inherit;
}
.lesson-row:hover { border-color: var(--sky); }
.lesson-row .ico { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--sky-soft); color: var(--deep); flex: none; }
.lesson-row .ico svg { width: 22px; height: 22px; }
.lesson-row.done .ico { background: var(--moss-soft); color: var(--moss); }
.lesson-row .name { display: block; font-weight: 700; }
.lesson-row .info { display: block; color: var(--ink-2); font-size: var(--fs-sm); }
.lesson-row .go { margin-left: auto; color: var(--ink-3); }
.lesson-row .go svg { width: 20px; height: 20px; }
.score { font-weight: 700; font-variant-numeric: tabular-nums; }
.score.good { color: var(--moss); }
.score.meh { color: var(--amber); }

.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); margin: 2.5rem 0 1.25rem; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; padding: 0.75rem 0.625rem; font-weight: 700; color: var(--ink-2); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab[aria-selected='true'] { color: var(--ink); border-color: var(--sky); }

.vocab { display: grid; }
.vocab-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.vocab-row .lb { font-size: var(--fs-lg); }
.vocab-row .note { grid-column: 1 / -1; color: var(--ink-2); font-size: var(--fs-sm); margin-top: -0.5rem; }
.verb-card { margin-top: 1.5rem; }
.verb-card h3 .lb { font-weight: 600; }

.note-block h3 { margin-bottom: 0.75rem; }
.note-block p + p { margin-top: 0.75rem; }
.note-block em, .ex-lb { font-family: var(--font-lb); font-style: normal; font-weight: 600; color: var(--deep); }
.table-wrap { overflow-x: auto; margin-top: 1rem; }
table.gtable { border-collapse: collapse; min-width: 100%; font-size: var(--fs-sm); }
.gtable th, .gtable td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.gtable th { color: var(--ink-2); font-weight: 700; }
.gtable td.lbcell { font-family: var(--font-lb); font-size: var(--fs-md); }

/* Side-by-side conversation reader */
.reader-tools { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.reader-context { color: var(--ink-2); margin-bottom: 1rem; }
.reader { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.reader-head, .reader-line { display: grid; grid-template-columns: 1fr 1fr; }
.reader-head { background: var(--surface-2); font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); }
.reader-head > div { padding: 0.5rem 1rem; }
.reader-line { border-top: 1px solid var(--line); }
.reader-line > div { padding: 0.75rem 1rem; }
.reader-line .speaker { display: block; font-size: 0.75rem; font-weight: 700; color: var(--ink-3); margin-bottom: 0.125rem; font-family: var(--font-ui); }
.reader-line .lbcol { font-family: var(--font-lb); font-size: 1.0625rem; border-right: 1px solid var(--line); }
.reader-line .trcol { color: var(--ink-2); }
.reader-text .reader-line > div { line-height: 1.6; }
.reader-line.alt .lbcol { background: color-mix(in srgb, var(--sky-soft) 40%, transparent); }
.reader.hide-tr .trcol .t { filter: blur(6px); transition: filter 0.2s; cursor: pointer; user-select: none; }
.reader.hide-tr .trcol.revealed .t { filter: none; user-select: auto; }
@media (max-width: 420px) {
  .reader-line .lbcol { font-size: var(--fs-md); }
  .reader-line > div { padding: 0.625rem 0.75rem; }
}
.culture { border-left: 4px solid var(--lion); padding: 0.25rem 0 0.25rem 1rem; font-size: var(--fs-lg); }

/* ------------------------------------------------------------- session */
.session { min-height: 100dvh; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; }
.session-top { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; position: sticky; top: 0; background: var(--paper); z-index: 5; }
.progress-track { flex: 1; height: 14px; border-radius: 7px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; width: var(--p, 0%); background: repeating-linear-gradient(90deg, var(--sky) 0 18px, color-mix(in srgb, var(--sky) 82%, #fff) 18px 36px); border-radius: inherit; transition: width 0.4s var(--ease); }
.session-count { font-size: var(--fs-sm); font-weight: 700; color: var(--ink-3); font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: right; }
.session-body { flex: 1; padding: 1rem 1.25rem 1.5rem; }
.session-foot { position: sticky; bottom: 0; padding: 1rem 1.25rem calc(1rem + var(--safe-b)); background: var(--paper); border-top: 1px solid var(--line); }

.ex { display: grid; gap: 1.25rem; animation: ex-in 0.25s var(--ease); }
@keyframes ex-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.ex-label { font-weight: 700; color: var(--ink-2); }
.prompt { font-size: var(--fs-2xl); font-weight: 600; line-height: 1.25; }
.prompt.lb { font-weight: 600; }
.prompt-sub { color: var(--ink-2); margin-top: -0.75rem; }
.hint-tr { color: var(--ink-2); font-size: var(--fs-md); }

.options { display: grid; gap: 0.625rem; }
@media (min-width: 560px) { .options.two { grid-template-columns: 1fr 1fr; } }
.option {
  display: flex; align-items: center; gap: 0.75rem; min-height: 56px; padding: 0.75rem 1rem; text-align: left;
  border-radius: var(--r-md); border: 1.5px solid var(--line); border-bottom-width: 3px; background: var(--surface); cursor: pointer; font-size: var(--fs-md);
  transition: border-color 0.12s, background-color 0.12s;
}
.option .lb { font-size: 1.125rem; }
.option:hover:not(:disabled) { border-color: var(--sky); }
.option.selected { border-color: var(--deep); background: var(--sky-soft); }
.option.is-correct { border-color: var(--moss); background: var(--moss-soft); }
.option.is-wrong { border-color: var(--lion); background: var(--lion-soft); }
.option:disabled { cursor: default; }
.key { flex: none; width: 26px; height: 26px; border-radius: 7px; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; color: var(--ink-3); }
@media (hover: none) { .key { display: none; } }

.answer-input { font-family: var(--font-lb); font-size: var(--fs-xl); min-height: 60px; }
.accents { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.accents button { min-width: 44px; min-height: 40px; border-radius: var(--r-sm); border: 1.5px solid var(--line); background: var(--surface); font-family: var(--font-lb); font-size: var(--fs-lg); cursor: pointer; }
.accents button:hover { border-color: var(--sky); }

.cloze { font-family: var(--font-lb); font-size: var(--fs-xl); line-height: 2.1; font-weight: 500; }
.gap { display: inline-block; min-width: 4.5em; padding: 0 0.5rem; margin: 0 0.125rem; border-bottom: 3px solid var(--sky); text-align: center; color: var(--deep); line-height: 1.4; }
.gap.empty { color: transparent; }
.gap input { border: 0; background: transparent; font: inherit; color: var(--deep); width: 7em; text-align: center; padding: 0; }
.gap input:focus { outline: none; }
.gap.is-correct { border-color: var(--moss); color: var(--moss); }
.gap.is-wrong { border-color: var(--lion); color: var(--lion); }
.chips { display: flex; flex-wrap: wrap; gap: 0.625rem; }
.chip-opt, .tile {
  min-height: 48px; padding: 0.5rem 1rem; border-radius: var(--r-md); border: 1.5px solid var(--line); border-bottom-width: 3px;
  background: var(--surface); font-family: var(--font-lb); font-size: 1.125rem; cursor: pointer;
}
.chip-opt:hover:not(:disabled), .tile:hover:not(:disabled) { border-color: var(--sky); }
.chip-opt.selected { border-color: var(--deep); background: var(--sky-soft); }
.chip-opt.is-correct { border-color: var(--moss); background: var(--moss-soft); }
.chip-opt.is-wrong { border-color: var(--lion); background: var(--lion-soft); }
.tile.used { visibility: hidden; }
.order-answer { min-height: 116px; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 0.5rem; padding: 0.75rem 0; border-top: 1.5px solid var(--line); border-bottom: 1.5px solid var(--line); background: repeating-linear-gradient(180deg, transparent 0 57px, var(--line) 57px 58px); }
.order-bank { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 0.625rem; }
.match-col { display: grid; gap: 0.625rem; align-content: start; }
.match-card {
  min-height: 56px; padding: 0.625rem 0.75rem; border-radius: var(--r-md); border: 1.5px solid var(--line); border-bottom-width: 3px;
  background: var(--surface); cursor: pointer; text-align: center; font-size: var(--fs-md);
}
.match-card.lb { font-size: 1.125rem; }
.match-card.picked { border-color: var(--deep); background: var(--sky-soft); }
.match-card.matched { border-color: var(--moss); background: var(--moss-soft); color: var(--ink-2); cursor: default; }
.match-card.wrong { border-color: var(--lion); background: var(--lion-soft); animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.intro-card { text-align: center; padding: 2.5rem 1.25rem; display: grid; gap: 0.75rem; justify-items: center; }
.intro-card .new { font-size: var(--fs-sm); font-weight: 700; color: var(--lion); }
.intro-card .word { font-family: var(--font-lb); font-size: clamp(2.25rem, 9vw, 3.25rem); font-weight: 600; line-height: 1.1; }
.intro-card .meaning { font-size: var(--fs-xl); color: var(--ink-2); }
.intro-card .note { max-width: 36ch; color: var(--ink-2); }

.conj { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; font-family: var(--font-lb); font-size: var(--fs-2xl); font-weight: 600; }
.conj .pron { color: var(--ink); }
.conj .slot { min-width: 4em; border-bottom: 3px solid var(--sky); color: var(--deep); padding: 0 0.25rem; }

/* Feedback sheet */
.feedback { padding: 1rem 1.25rem calc(1rem + var(--safe-b)); border-top: 0; animation: sheet-in 0.22s var(--ease); }
.feedback-inner { display: grid; gap: 0.25rem; margin-bottom: 1rem; }
.feedback .title { display: flex; align-items: center; gap: 0.5rem; font-size: var(--fs-lg); font-weight: 800; }
.feedback .title svg { width: 26px; height: 26px; }
.feedback .answer { font-family: var(--font-lb); font-size: var(--fs-lg); font-weight: 600; }
.feedback .extra { font-size: var(--fs-sm); }
.feedback.correct { background: var(--moss-soft); color: var(--moss); }
.feedback.almost { background: var(--amber-soft); color: var(--amber); }
.feedback.wrong { background: var(--lion-soft); color: var(--lion); }
.feedback .answer, .feedback .extra { color: var(--ink); }
.feedback.correct .btn-primary { background: var(--moss); color: #fff; }
.feedback.almost .btn-primary { background: var(--amber); color: #fff; }
.feedback.wrong .btn-primary { background: var(--lion); color: #fff; }
@keyframes sheet-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

.results { text-align: center; display: grid; justify-items: center; gap: 1rem; padding: 2.5rem 1rem; }
.results h1 { font-family: var(--font-lb); font-size: var(--fs-3xl); font-weight: 600; }
.results-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; width: 100%; max-width: 440px; margin-top: 0.5rem; }
.results-stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 0.75rem 0.5rem; }
.results-stats strong { display: block; font-size: var(--fs-xl); font-variant-numeric: tabular-nums; }
.results-stats span { font-size: var(--fs-sm); color: var(--ink-2); }
.results .actions { display: grid; gap: 0.625rem; width: 100%; max-width: 440px; margin-top: 1rem; }

/* ------------------------------------------------------------ progress */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 1rem; }
.stat strong { display: block; font-size: var(--fs-2xl); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { color: var(--ink-2); font-size: var(--fs-sm); }
.heatmap-wrap { overflow-x: auto; padding-bottom: 0.25rem; }
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); grid-auto-columns: 12px; gap: 3px; width: max-content; }
.heat { border-radius: 3px; background: var(--surface-2); }
.heat.l1 { background: color-mix(in srgb, var(--sky) 30%, var(--surface-2)); }
.heat.l2 { background: color-mix(in srgb, var(--sky) 55%, var(--surface-2)); }
.heat.l3 { background: color-mix(in srgb, var(--sky) 80%, var(--surface-2)); }
.heat.l4 { background: var(--deep); }
.heatmap i.future { background: transparent; }
.legend { display: flex; align-items: center; gap: 4px; font-size: 0.75rem; color: var(--ink-3); margin-top: 0.5rem; justify-content: flex-end; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.level-bars { display: grid; gap: 0.875rem; }
.level-bar-row { display: grid; grid-template-columns: 48px 1fr auto; gap: 0.75rem; align-items: center; }
.level-bar-row span:last-child { font-size: var(--fs-sm); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.hard-list { display: grid; }
.hard-row { display: grid; grid-template-columns: 1fr auto; gap: 0.25rem 1rem; padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.hard-row .lb { font-size: var(--fs-lg); }
.hard-row .tr { color: var(--ink-2); font-size: var(--fs-sm); grid-column: 1; }
.hard-row .n { grid-row: 1 / span 2; grid-column: 2; align-self: center; color: var(--lion); font-weight: 700; font-size: var(--fs-sm); }

/* ------------------------------------------------------------- profile */
.settings { display: grid; gap: 1rem; }
.settings .card h2 { font-size: var(--fs-lg); margin-bottom: 1rem; }
.danger-zone { border-color: color-mix(in srgb, var(--lion) 40%, var(--line)); }
.banner svg { width: 22px; height: 22px; flex: none; }
.banner { display: flex; gap: 0.75rem; align-items: center; padding: 0.875rem 1rem; border-radius: var(--r-md); background: var(--amber-soft); margin-bottom: 1.25rem; flex-wrap: wrap; }
.banner p { flex: 1; min-width: 200px; }

/* ------------------------------------------------------ dialogs, toasts */
dialog.modal { border: 0; border-radius: var(--r-lg); padding: 1.5rem; width: min(440px, calc(100vw - 2rem)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgb(0 0 0 / 30%); }
dialog.modal::backdrop { background: rgb(19 32 44 / 55%); }
dialog.modal h2 { font-size: var(--fs-lg); margin-bottom: 0.5rem; }
dialog.modal .row { margin-top: 1.5rem; justify-content: flex-end; }
.toasts { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 1rem); transform: translateX(-50%); z-index: 50; display: grid; gap: 0.5rem; width: min(440px, calc(100vw - 2rem)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; border-radius: var(--r-md); background: var(--ink); color: var(--paper); box-shadow: var(--shadow); animation: sheet-in 0.2s var(--ease); font-weight: 600; }
.toast.error { background: var(--lion); color: #fff; }
.toast button { margin-left: auto; background: transparent; border: 1.5px solid currentColor; color: inherit; border-radius: var(--r-sm); padding: 0.25rem 0.75rem; font-weight: 700; cursor: pointer; }
@media (min-width: 900px) { .toasts { bottom: 1.5rem; } }

.empty { text-align: center; padding: 3rem 1rem; display: grid; gap: 0.75rem; justify-items: center; }
.empty svg { width: 48px; height: 48px; color: var(--sky); }
.offline-pill { display: inline-flex; gap: 0.375rem; align-items: center; font-size: var(--fs-sm); font-weight: 700; color: var(--amber); }

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

/* ------------------------------------------------------------- audio */
.speak {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
  width: 1.75rem; height: 1.75rem; padding: 0; margin: 0 0.125rem;
  border: 1px solid var(--line); border-radius: 50%; background: var(--surface);
  color: var(--ink-2); cursor: pointer; flex-shrink: 0;
  font-size: 1rem; line-height: 1;
}
.speak svg { width: 1rem; height: 1rem; }
.speak:hover, .speak:focus-visible { color: var(--ink); border-color: var(--ink-3); }
.speak.playing { color: var(--ink); background: var(--sky-soft); }
.speak.loading svg { animation: speak-pulse 0.9s ease-in-out infinite; }
.speak.failed { opacity: 0.4; }
@keyframes speak-pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .speak.loading svg { animation: none; } }
.feedback .listen { display: flex; align-items: center; gap: 0.375rem; }

/* ------------------------------------------------------- leaderboard */
.board-tabs { margin: 0.5rem 0 0.75rem; flex-wrap: nowrap; display: flex; }
.board-tabs button { flex: 1; padding: 0.375rem 0.5rem; white-space: nowrap; }
.board-note { display: flex; align-items: center; gap: 0.375rem; margin: 0 0 1rem; }
.board-note svg { width: 1rem; height: 1rem; flex-shrink: 0; }
.board { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.board-row { display: grid; grid-template-columns: 2.75rem 1fr auto; align-items: center; gap: 0.5rem; padding: 0.75rem 1rem; border-top: 1px solid var(--line); }
.board-row:first-child { border-top: 0; }
.board-row .rank { font-weight: 800; color: var(--ink-2); font-variant-numeric: tabular-nums; font-size: 1.125rem; }
.board-row .nick { font-weight: 700; overflow-wrap: anywhere; }
.board-row .nick em { font-style: normal; font-weight: 600; color: var(--ink-3); }
.board-row .xp { font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; }
.board-row.me { background: var(--sky-soft); }
.board-gap { text-align: center; color: var(--ink-3); padding: 0.25rem 0; border-top: 1px solid var(--line); }
.loading { opacity: 0.5; transition: opacity 0.15s; }
