/* =========================================================================
   ModiLearn — calm, focused, content first.
   Tokens first, then layout, components, the lesson player, and widgets.
   ========================================================================= */
:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --surface-2: #f3f3f0;
  --text: #1b1b1f;
  --muted: #6b6b73;
  --border: #e4e4df;
  --border-strong: #cfcfc8;
  --ink: #1b1b1f; /* primary buttons */
  --ink-text: #ffffff;
  --accent: #2f5bea; /* overridden per course */
  --good: #1f8a4c;
  --good-bg: #ecf7f0;
  --ok: #9a6b00;
  --ok-bg: #fdf6e3;
  --bad: #c2412d;
  --bad-bg: #fcefec;
  --radius: 16px;
  --radius-sm: 11px;
  --radius-lg: 20px;
  /* The three parts of the name: Mod (modern, modules) · i (you, yourself) · Learn */
  --brand-mod: #2f5bea;
  --brand-i: #e46a1c;
  --brand-learn: #0f8a6b;
  --glass: color-mix(in srgb, var(--surface) 80%, transparent);
  --shadow-lg: 0 1px 2px rgb(20 20 30 / 5%), 0 18px 40px -16px rgb(20 20 30 / 22%);
  --shadow: 0 1px 2px rgb(20 20 30 / 4%), 0 8px 24px rgb(20 20 30 / 5%);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416;
    --surface: #1c1c1f;
    --surface-2: #242428;
    --text: #ececef;
    --muted: #9b9ba4;
    --border: #2e2e33;
    --border-strong: #44444b;
    --ink: #ececef;
    --ink-text: #141416;
    --good: #5cc98a;
    --good-bg: #17291f;
    --ok: #e0b54f;
    --ok-bg: #2c2615;
    --bad: #f08a76;
    --bad-bg: #321d19;
    --accent: #7c9bff;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
    --shadow-lg: 0 1px 2px rgb(0 0 0 / 35%), 0 22px 44px -16px rgb(0 0 0 / 55%);
    --brand-mod: #7c9bff;
    --brand-i: #f59a52;
    --brand-learn: #4fcfa6;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; font-weight: 700; letter-spacing: -.02em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.25rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; letter-spacing: -.01em; }
p { margin: 0 0 .75em; }
a { color: inherit; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.input:focus-visible, .cloze-input:focus-visible, .code-gap:focus-visible { outline: none; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.lead { font-size: 1.125rem; color: var(--muted); max-width: 60ch; }
.display { font-size: clamp(2.2rem, 7vw, 3.4rem); letter-spacing: -.035em; }
.eyebrow { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
.accent-text { color: var(--accent); font-weight: 600; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.center { justify-content: center; }
.row.between { justify-content: space-between; }
.icon { flex-shrink: 0; vertical-align: middle; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 500; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ------------------------------------------------------------- layout */
.page { max-width: 880px; margin: 0 auto; padding: 40px 16px 96px; }
.page-narrow { max-width: 600px; }
.page-head { margin-bottom: 28px; }
.section-title { margin: 48px 0 16px; font-size: 1.15rem; }
.back-link { display: inline-block; margin-bottom: 20px; color: var(--muted); text-decoration: none; font-size: .9rem; }
.back-link:hover { color: var(--text); }

/* Soft colour fields behind every page, in the three brand colours. */
.backdrop { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.backdrop::after { /* faint dot grid */
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--text) 9%, transparent) 1px, transparent 0);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent 70%);
  mask-image: linear-gradient(to bottom, #000, transparent 70%);
}
.blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .28; animation: drift 18s ease-in-out infinite alternate; }
.blob-1 { width: 380px; height: 380px; background: var(--brand-mod); top: -120px; left: -80px; }
.blob-2 { width: 300px; height: 300px; background: var(--brand-i); top: 40%; left: 38%; animation-delay: -6s; opacity: .18; }
.blob-3 { width: 340px; height: 340px; background: var(--brand-learn); bottom: -140px; right: -60px; animation-delay: -12s; }
.backdrop .blob { opacity: .13; }
.backdrop .blob-2 { opacity: .08; }
.focus-mode .backdrop .blob { opacity: .07; } /* calmer during lessons */
@keyframes drift { to { transform: translate(60px, 40px) scale(1.15); } }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 60px; padding: 0 20px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
}
.focus-mode .topbar { display: none; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; letter-spacing: -.01em; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; background: var(--ink); position: relative; transition: transform .35s cubic-bezier(.3, 1.6, .5, 1); }
.brand:hover .brand-mark { transform: rotate(90deg); }
.brand-name > span { transition: color .25s; }
.brand-i { color: var(--brand-i); }
.brand:hover .brand-mod { color: var(--brand-mod); }
.brand:hover .brand-learn { color: var(--brand-learn); }
.brand-mark::after { content: ''; position: absolute; inset: 6px; border-radius: 50%; border: 2px solid var(--ink-text); }
.topnav { display: flex; align-items: center; gap: 18px; font-size: .9rem; }
.topnav a { text-decoration: none; color: var(--muted); }
.topnav a:hover { color: var(--text); }
.topnav a[data-nav] { padding: 6px 12px; border-radius: 999px; transition: background .2s, color .2s; }
.topnav a[data-nav]:hover { background: var(--surface-2); }
.streak { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; color: var(--muted); font-weight: 600; }
.streak-active { color: var(--brand-i); background: color-mix(in srgb, var(--brand-i) 12%, transparent); }
.profile-link { display: inline-flex; border-radius: 50%; transition: transform .2s, box-shadow .2s; }
.profile-link:hover { transform: scale(1.06); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-mod) 25%, transparent); }

/* --------------------------------------------------------- primitives */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: .95rem; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s, transform .15s, box-shadow .2s;
}
.btn:hover { border-color: var(--text); }
.btn:not(:disabled):active { transform: scale(.97); }
.btn .icon { transition: transform .2s; }
.btn:hover .icon-arrow { transform: translateX(3px); }
.btn:disabled, .btn.disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
.btn-primary:hover { opacity: .9; border-color: var(--ink); box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--accent) 70%, transparent); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: .875rem; }
.btn-wide { min-width: 160px; }
.icon-btn { display: inline-grid; place-items: center; background: none; border: 0; cursor: pointer; padding: 6px; border-radius: 8px; color: var(--muted); text-decoration: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.chip-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: .875rem; font-variant-numeric: tabular-nums; }
.chip-btn:hover { border-color: var(--text); }

.input {
  width: 100%; height: 48px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.input-lg { height: 56px; font-size: 1.15rem; }
.input.correct, .cloze-input.correct { border-color: var(--good); background: var(--good-bg); }
.input.wrong, .cloze-input.wrong { border-color: var(--bad); background: var(--bad-bg); }

.bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 10px 0; }
.bar-fill { height: 100%; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 65%, var(--surface)), var(--accent)); border-radius: 999px; transition: width .5s cubic-bezier(.3, 1.2, .5, 1); }

.initials {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; font-size: .85rem; color: var(--text);
}
.initials-lg .initials { width: 64px; height: 64px; font-size: 1.5rem; }

.list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; box-shadow: var(--shadow); }
.list-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; width: 100%; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--border); cursor: pointer; text-decoration: none;
}
.list-row:last-child { border-bottom: 0; }
.list-row { transition: background .15s; }
.list-row:hover { background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.list-row .icon { color: var(--muted); }

.loading { display: grid; place-items: center; padding: 96px 0; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--text); animation: spin .8s linear infinite; }
.empty { text-align: center; padding: 64px 16px; }

/* ------------------------------------------------------------ welcome */
.welcome { --mod-c: var(--brand-mod); --i-c: var(--brand-i); --learn-c: var(--brand-learn); overflow-x: clip; }

.hero { position: relative; isolation: isolate; padding: 64px 16px 72px; border-bottom: 1px solid var(--border); overflow: hidden; }
.hero::before { /* dot grid, brightest around the pointer */
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--text) 16%, transparent) 1px, transparent 0);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(420px circle at var(--mx, 30%) var(--my, 40%), #000 0%, rgb(0 0 0 / 25%) 60%, rgb(0 0 0 / 12%) 100%);
  mask-image: radial-gradient(420px circle at var(--mx, 30%) var(--my, 40%), #000 0%, rgb(0 0 0 / 25%) 60%, rgb(0 0 0 / 12%) 100%);
}
.hero-bg { position: absolute; inset: 0; z-index: -2; pointer-events: none; }

.hero-inner { max-width: 1040px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 56px; align-items: center; }
@media (max-width: 860px) { .hero-inner { grid-template-columns: 1fr; gap: 40px; } .hero { padding-top: 40px; } }
.hero-eyebrow { display: inline-flex; align-items: center; gap: 6px; color: var(--i-c); }
.hero .lead { margin: 20px 0 0; }

/* The interactive "Mod · i · Learn" wordmark */
.wordmark { display: flex; flex-wrap: wrap; align-items: baseline; margin: 0 0 18px; font-size: clamp(3rem, 11vw, 5.4rem); letter-spacing: -.05em; line-height: 1; }
.name-part {
  --c: var(--mod-c);
  position: relative; background: none; border: 0; padding: 0 .02em .12em; margin: 0; cursor: pointer;
  font: inherit; letter-spacing: inherit; color: color-mix(in srgb, var(--text) 32%, transparent);
  transition: color .3s, transform .3s cubic-bezier(.3, 1.6, .5, 1);
}
.name-part-i { --c: var(--i-c); }
.name-part-learn { --c: var(--learn-c); }
.name-part::after { content: ''; position: absolute; left: 6%; right: 6%; bottom: 0; height: 6px; border-radius: 999px; background: var(--c); transform: scaleX(0); transform-origin: left; transition: transform .35s ease; }
.name-part:hover, .name-part.active { color: var(--c); }
.name-part.active { transform: translateY(-4px); }
.name-part.active::after { transform: scaleX(1); }
.name-part:focus-visible { outline-offset: 4px; border-radius: 8px; }

.name-panel { --c: var(--mod-c); min-height: 150px; padding: 16px 18px; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--c) 30%, var(--border)); background: color-mix(in srgb, var(--c) 6%, var(--surface)); transition: border-color .3s, background .3s; }
.name-panel[data-part="i"] { --c: var(--i-c); }
.name-panel[data-part="learn"] { --c: var(--learn-c); }
.name-panel-title { margin: 0 0 10px; font-weight: 700; color: var(--c); }
.name-meanings { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .name-meanings { grid-template-columns: 1fr; } }
.name-meaning { display: grid; align-content: start; gap: 2px; font-size: .9rem; color: var(--muted); animation: fade-in .4s ease both; animation-delay: var(--delay); }
.name-meaning strong { color: var(--text); font-size: 1rem; }

/* Auth card */
.auth-card { padding: 28px; border-radius: 20px; border: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 82%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: var(--shadow), 0 30px 60px -30px rgb(20 20 30 / 25%); }
@media (max-width: 520px) { .auth-card { padding: 20px; } }
.auth-switch { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 22px; border-radius: 12px; background: var(--surface-2); }
.auth-switch-thumb { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 9px; background: var(--surface); box-shadow: 0 1px 3px rgb(20 20 30 / 12%); transition: transform .3s cubic-bezier(.3, 1.3, .5, 1); }
.auth-switch.signup .auth-switch-thumb { transform: translateX(100%); }
.auth-switch-btn { position: relative; z-index: 1; height: 36px; border: 0; background: none; cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--muted); transition: color .2s; }
.auth-switch-btn[aria-pressed="true"] { color: var(--text); }
.auth-title { margin: 0 0 16px; }
.auth-form { display: grid; gap: 14px; }
.auth-form .btn-primary { width: 100%; min-height: 46px; }
.auth-form > p { margin: 0; text-align: center; }
.field { display: grid; gap: 4px; }
.form-error { color: var(--bad); margin: 0; }
.account-section { display: grid; gap: 18px; }
.account-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* Bands below the hero */
.welcome-band { max-width: 1040px; margin: 0 auto; padding: 72px 16px 0; }
.band-head { margin-bottom: 24px; }
.band-head h2 { font-size: clamp(1.4rem, 3.5vw, 1.9rem); }

/* Try it */
.try-card { border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.try-tabs { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); overflow-x: auto; }
.try-tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid transparent; border-radius: 999px; background: none; cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--muted); white-space: nowrap; transition: background .2s, color .2s; }
.try-tab:hover { color: var(--text); }
.try-tab.active { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: 0 1px 3px rgb(20 20 30 / 8%); }
.try-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--mod); transition: transform .3s; }
.try-tab.done .try-dot { box-shadow: 0 0 0 3px color-mix(in srgb, var(--mod) 25%, transparent); }
.try-tab.active .try-dot { transform: scale(1.25); }
.try-body { --mod: var(--accent); padding: 28px; min-height: 290px; }
.try-body .eyebrow { color: var(--mod); }
.try-prompt { font-size: 1.3rem; font-weight: 700; letter-spacing: -.01em; margin-bottom: 18px; }
.try-options { display: grid; gap: 10px; }
.try-option {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; text-align: left;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-weight: 500;
  transition: border-color .15s, transform .15s, background .15s;
}
.try-option:not(:disabled):hover { border-color: var(--mod); transform: translateX(4px); }
.try-option:disabled { cursor: default; color: var(--text); }
.try-option.correct { border-color: var(--good); background: var(--good-bg); animation: pop .35s; }
.try-option.wrong { border-color: var(--bad); background: var(--bad-bg); animation: shake .4s; }
.try-key { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--surface-2); font-size: .8rem; font-weight: 700; color: var(--muted); }
.try-feedback:empty { display: none; }
.try-feedback { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius-sm); }
.try-feedback.good { background: var(--good-bg); }
.try-feedback.good > strong { color: var(--good); }
.try-feedback.bad { background: var(--bad-bg); }
.try-feedback.bad > strong { color: var(--bad); }
.try-next { margin-top: 10px; }
.try-progress { margin: 0; padding: 12px 28px; border-top: 1px solid var(--border); }
@media (max-width: 520px) { .try-body { padding: 20px; } .try-progress { padding: 12px 20px; } }

/* How it works */
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 760px) { .how-grid { grid-template-columns: 1fr; } }
.how-step { padding: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: transform .25s, box-shadow .25s, border-color .25s; }
.how-step:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.how-step h3 { margin-top: 18px; }
.how-step p { margin: 0; }
.how-visual { height: 72px; display: flex; align-items: center; }
.how-modules { --c: var(--mod-c); }
.how-practice { --c: var(--i-c); }
.how-repeat { --c: var(--learn-c); }
.blocks { display: grid; grid-template-columns: repeat(2, 28px); gap: 6px; }
.blocks span { height: 28px; border-radius: 7px; background: color-mix(in srgb, var(--c) calc(35% + var(--i) * 20%), var(--surface)); animation: snap 3.2s ease-in-out infinite; animation-delay: calc(var(--i) * .15s); }
@keyframes snap { 0%, 100% { transform: none; } 40% { transform: translate(calc((var(--i) - 1.5) * 6px), -6px) rotate(calc((var(--i) - 1.5) * 6deg)); } }
.how-step:hover .blocks span { animation-duration: 1.2s; }
.practice { display: grid; grid-template-columns: 90px auto; gap: 8px 14px; align-items: center; }
.practice-line { grid-column: 1; height: 9px; border-radius: 99px; background: var(--surface-2); }
.practice-line.short { width: 60%; }
.practice-check { grid-row: 1 / span 2; grid-column: 2; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--c); color: #fff; animation: check-pop 3.2s ease-in-out infinite; }
@keyframes check-pop { 0%, 30% { transform: scale(.4); opacity: 0; } 45% { transform: scale(1.12); opacity: 1; } 55%, 100% { transform: scale(1); opacity: 1; } }
.spacing { display: flex; align-items: center; }
.spacing span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; font-size: .72rem; font-weight: 700; color: var(--c); border: 2px solid var(--c); background: var(--surface); margin-right: calc(var(--i) * 10px + 4px); animation: pulse-ring 3.2s ease-out infinite; animation-delay: calc(var(--i) * .5s); }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--c) 35%, transparent); } 40%, 100% { box-shadow: 0 0 0 10px transparent; } }

.welcome-cta { text-align: center; padding-bottom: 96px; }
.welcome-cta h2 { margin-bottom: 18px; }

/* --------------------------------------------------------------- home */
.course-art { display: block; width: 100%; height: 100%; }
.home-head h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); letter-spacing: -.03em; }
.name-highlight { background: linear-gradient(100deg, var(--brand-mod), var(--brand-learn)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.home-head .eyebrow { display: inline-flex; align-items: center; gap: 6px; color: var(--brand-i); }

.continue-card {
  display: grid; grid-template-columns: 220px 1fr; overflow: hidden; text-decoration: none;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--glass);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: var(--shadow-lg);
  transition: border-color .2s, transform .25s, box-shadow .25s;
}
.continue-card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); transform: translateY(-3px); box-shadow: var(--shadow-lg), 0 0 0 4px color-mix(in srgb, var(--accent) 10%, transparent); }
.continue-art { min-height: 200px; overflow: hidden; }
.continue-art .course-art, .course-card-art .course-art { transition: transform .6s cubic-bezier(.2, .8, .2, 1); }
.continue-card:hover .course-art, .course-card:hover .course-art { transform: scale(1.08) rotate(-1deg); }
.continue-body { padding: 28px; display: flex; flex-direction: column; justify-content: center; }
.continue-body h2 { margin-bottom: 4px; }
@media (max-width: 600px) {
  .continue-card { grid-template-columns: 1fr; }
  .continue-art { min-height: 0; height: 110px; }
  .continue-body { padding: 20px; }
}
.review-strip {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 16px; padding: 16px 20px;
  border: 1px solid color-mix(in srgb, var(--brand-learn) 30%, var(--border)); border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--brand-learn) 7%, var(--surface));
}
.review-strip > .icon { color: var(--brand-learn); animation: spin-slow 6s linear infinite; }
@keyframes spin-slow { to { transform: rotate(360deg); } }
.review-strip > .grow { flex: 1 1 240px; }
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.course-card {
  display: flex; flex-direction: column; overflow: hidden; text-decoration: none;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
  transition: border-color .2s, transform .25s, box-shadow .25s;
}
.course-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.course-card { animation: fade-in .45s ease both; }
.course-card:nth-child(2) { animation-delay: .06s; }
.course-card:nth-child(3) { animation-delay: .12s; }
.course-card:nth-child(n+4) { animation-delay: .18s; }
.course-card h3 { transition: color .2s; }
.course-card:hover h3 { color: var(--accent); }
.course-card-art { height: 120px; overflow: hidden; }
.course-card-body { padding: 18px 20px 20px; flex: 1; display: flex; flex-direction: column; }
.course-card-body p { margin-bottom: 12px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; }
.course-card-body .course-meta { margin-top: auto; }
.course-meta { display: flex; gap: 14px; color: var(--muted); flex-wrap: wrap; }

/* ------------------------------------------------------------- course */
.course-hero { position: relative; isolation: isolate; }
.course-hero::before { /* a glow in the course colour */
  content: ''; position: absolute; z-index: -1; width: 420px; height: 300px; top: 40px; left: -120px; border-radius: 50%;
  background: var(--accent); opacity: .14; filter: blur(80px); pointer-events: none;
}
.course-hero h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); letter-spacing: -.03em; }
.course-hero-art { height: 140px; border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 28px; box-shadow: var(--shadow); border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border)); }
.course-stats { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.course-stats > div { display: flex; flex-direction: column; min-width: 110px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--glass); transition: transform .2s, border-color .2s; }
.course-stats > div:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.course-stats strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; color: var(--accent); }
.proficiency { margin-top: 32px; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--glass); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: var(--shadow); }
.proficiency .bar { height: 10px; }
.proficiency p { margin: 0; }

.path { list-style: none; margin: 0; padding: 0; position: relative; }
.path-step { display: flex; gap: 20px; position: relative; padding-bottom: 28px; }
.path-step:not(:last-child)::before {
  content: ''; position: absolute; left: 19px; top: 44px; bottom: 4px; width: 2px; background: var(--border);
}
.path-done:not(:last-child)::before { background: linear-gradient(var(--accent), color-mix(in srgb, var(--accent) 50%, var(--border))); }
.path-marker {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--border-strong); background: var(--surface); color: var(--muted); font-weight: 600; font-size: .9rem;
  transition: transform .25s cubic-bezier(.3, 1.6, .5, 1);
}
.path-step:not(.path-locked):hover .path-marker { transform: scale(1.1); }
.path-done .path-marker { background: var(--accent); border-color: var(--accent); color: #fff; }
.path-current .path-marker { border-color: var(--accent); color: var(--accent); animation: marker-pulse 2.4s ease-out infinite; }
@keyframes marker-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 35%, transparent); } 70%, 100% { box-shadow: 0 0 0 12px transparent; } }
.path-locked { opacity: .55; }
.path-body { flex: 1; min-width: 0; padding-top: 8px; }
.path-body h3 { margin: 0 0 4px; }
.path-body p { margin-bottom: 10px; max-width: 56ch; }
.path-resume { align-items: center; gap: 12px; }
.path-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.path-current .path-body { padding: 18px 20px; margin-top: -8px; border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); box-shadow: var(--shadow-lg); }

.practice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 16px; }
.practice-card {
  display: flex; flex-direction: column; gap: 6px; padding: 20px; text-decoration: none;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
  transition: border-color .2s, transform .25s, box-shadow .25s;
}
.practice-card > .icon { box-sizing: content-box; padding: 9px; margin-bottom: 8px; border-radius: 12px; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); transition: transform .3s cubic-bezier(.3, 1.6, .5, 1); }
.practice-card:hover > .icon { transform: rotate(-8deg) scale(1.08); }
.practice-card h3 { margin: 0; }
.practice-card p { margin: 0; }
.practice-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.practice-card.disabled { opacity: .55; pointer-events: none; }

/* ------------------------------------------------------------ profile */
.profile-head {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-bottom: 20px; padding: 24px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--glass); box-shadow: var(--shadow);
}
.profile-head::before { content: ''; position: absolute; inset: 0; z-index: -1; opacity: .12; background: linear-gradient(110deg, var(--brand-mod), var(--brand-i) 50%, var(--brand-learn)); }
.initials-lg .initials { border: 0; color: #fff; background: linear-gradient(135deg, var(--brand-mod), var(--brand-learn)); box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px color-mix(in srgb, var(--brand-mod) 35%, transparent); }
.profile-head h1 { margin: 0; }
.profile-head p { margin: 0; }
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { --c: var(--brand-mod); display: flex; flex-direction: column; gap: 2px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); transition: transform .2s, border-color .2s; }
.stat:nth-child(2) { --c: var(--brand-i); }
.stat:nth-child(3) { --c: var(--brand-learn); }
.stat:nth-child(4) { --c: var(--brand-i); }
.stat:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--c) 45%, var(--border)); }
.stat strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; color: var(--c); letter-spacing: -.02em; }
.course-progress .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex-shrink: 0; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.course-progress .bar { margin: 8px 0 4px; }

/* ------------------------------------------------------------- player */
.player { min-height: 100vh; display: flex; flex-direction: column; }
.player-top {
  display: flex; align-items: center; gap: 16px; padding: 14px 20px;
  max-width: 880px; width: 100%; margin: 0 auto;
}
.player-top .bar { flex: 1; margin: 0; height: 10px; }
.endless-status { flex: 1; display: flex; align-items: center; gap: 14px; min-width: 0; }
.elo-live { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.elo-live strong { font-variant-numeric: tabular-nums; }
.elo-change { font-size: .85em; font-variant-numeric: tabular-nums; color: var(--muted); }
.elo-change.up { color: var(--good); }
.elo-change.down { color: var(--bad); }
.elo-figure { text-align: right; }
.elo-figure strong { font-variant-numeric: tabular-nums; }
.player-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30%; }
@media (max-width: 560px) { .player-title { display: none; } }
.stage { flex: 1; width: 100%; max-width: 680px; margin: 0 auto; padding: 24px 16px 180px; }
.step { display: flex; flex-direction: column; gap: 20px; }
.step-body { display: flex; flex-direction: column; gap: 20px; }
.context-btn {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 8px 14px 8px 10px;
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--muted);
  font-size: .875rem; font-weight: 500; text-align: left; cursor: pointer;
}
.context-btn:hover { border-color: var(--text); color: var(--text); }
.context-dialog {
  width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 48px); padding: 8px 24px 28px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); color: var(--text); box-shadow: var(--shadow);
}
.context-dialog::backdrop { background: rgb(0 0 0 / .5); }
.context-dialog-top { position: sticky; top: 0; display: flex; justify-content: flex-end; margin: 0 -16px; background: var(--bg); }
@media (max-width: 520px) { .context-dialog { padding: 4px 16px 24px; } }

.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  border-top: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  transition: background .2s, border-color .2s;
}
.action-inner { max-width: 680px; margin: 0 auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.verdict { flex: 1; min-width: 200px; }
.verdict:empty { min-height: 0; }
.verdict-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem; }
.verdict:not(:empty) { animation: fade-in .3s ease both; }
.action-buttons { display: flex; gap: 10px; margin-left: auto; }
.tone-good { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.tone-good .verdict-title { color: var(--good); }
.tone-ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.tone-ok .verdict-title { color: var(--ok); }
.tone-bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.tone-bad .verdict-title { color: var(--bad); }

.solution { border-left: 3px solid var(--accent); padding: 4px 0 4px 18px; display: flex; flex-direction: column; gap: 14px; }
.solution .prose p:last-child { margin-bottom: 0; }
.solution-answer strong { font-size: 1.1rem; }

.summary { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 40px; }
.summary-mark { width: 80px; height: 80px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--brand-learn))); color: #fff; margin-bottom: 8px; animation: summary-pop .6s cubic-bezier(.3, 1.6, .5, 1) both, marker-pulse 2.4s ease-out .6s infinite; }
@keyframes summary-pop { from { transform: scale(.3) rotate(-30deg); opacity: 0; } }
.summary h1 { margin: 0; }
.summary-facts { display: flex; gap: 0; margin: 20px 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--glass); box-shadow: var(--shadow); }
.summary-facts > div { padding: 14px 24px; border-right: 1px solid var(--border); }
.summary-facts > div:last-child { border-right: 0; }
.summary-facts dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.summary-facts dd { margin: 4px 0 0; font-weight: 600; }
.summary > p { max-width: 46ch; }
@media (max-width: 640px) { .summary-facts { flex-direction: column; align-self: stretch; } .summary-facts > div { border-right: 0; border-bottom: 1px solid var(--border); } .summary-facts > div:last-child { border-bottom: 0; } }

/* --------------------------------------------------------- explain */
.explain-title { font-size: clamp(1.6rem, 4.5vw, 2rem); margin: 0; }
.prose { font-size: 1.075rem; line-height: 1.7; }
.prose p { margin: 0 0 1em; }
.prose strong { font-weight: 600; }
.examples { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.examples li { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.examples li:last-child { border-bottom: 0; }
.example-text { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 1.05rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .975rem; }
.table th, .table td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table td:nth-child(2) { font-weight: 600; }
.note { padding: 14px 18px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); font-size: .95rem; }
.explain-image { border-radius: var(--radius); border: 1px solid var(--border); }

/* ---------------------------------------------------------- widgets */
.prompt { display: flex; flex-direction: column; gap: 6px; }
.prompt-ask { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.prompt-main { font-size: clamp(1.45rem, 4vw, 1.85rem); margin: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.read-question { flex-shrink: 0; text-transform: none; letter-spacing: normal; vertical-align: middle; }
.accent-note { margin: 0; }
.accent-letter { color: var(--text); text-decoration: underline dotted var(--muted); text-underline-offset: 3px; }
.prompt-sub { font-size: 1rem; font-weight: 400; letter-spacing: 0; }
.prompt-image { border-radius: var(--radius); max-height: 260px; }

.options { display: grid; gap: 10px; }
.listen-controls { display: flex; align-items: center; gap: 18px; margin: 6px 0 22px; }
.listen-play { width: 72px; height: 72px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; background: var(--accent); color: #fff; box-shadow: var(--shadow); transition: transform .12s; }
.listen-play:hover { transform: scale(1.04); }
.listen-play.playing { animation: listen-pulse 1s ease-in-out infinite; }
.listen-side { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.listen-keys { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: -12px 0 18px; }
.listen-keys kbd { font: inherit; font-size: .8em; padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); }
@media (hover: none), (pointer: coarse) { .listen-keys { display: none; } } /* no keyboard on phones */
@keyframes listen-pulse { 50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 20%, transparent); } }
.option {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  padding: 14px 16px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); font-size: 1.025rem;
  transition: border-color .12s, background .12s, box-shadow .12s, transform .15s;
}
.option:hover:not(:disabled) { border-color: var(--accent); transform: translateX(4px); }
.option:disabled { cursor: default; }
.option-key {
  flex-shrink: 0; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px;
  border: 0; background: var(--surface-2); font-size: .75rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums;
  transition: background .15s, color .15s;
}
.option.selected .option-key { background: var(--accent); color: #fff; }
.option.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.option.correct { border-color: var(--good); box-shadow: 0 0 0 1px var(--good); background: var(--good-bg); animation: pop .35s; }
.option.wrong { border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad); background: var(--bad-bg); }

.char-bar { display: flex; flex-wrap: wrap; gap: 6px; }
.char-btn { min-width: 36px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
.char-btn:hover { border-color: var(--text); }
.hint { font-size: .9rem; }
.hint-text { color: var(--muted); }

/* flashcard */
.flashcard { perspective: 1200px; background: none; border: 0; padding: 0; cursor: pointer; width: 100%; }
.flashcard-inner { position: relative; width: 100%; min-height: 240px; transition: transform .5s cubic-bezier(.4, .2, .2, 1); transform-style: preserve-3d; }
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px;
  border-radius: var(--radius-lg); border: 1px solid var(--border-strong); background: var(--surface); box-shadow: var(--shadow-lg);
}
.flashcard-face.back { transform: rotateY(180deg); border-color: var(--accent); }
.face-text { font-size: clamp(1.7rem, 5vw, 2.3rem); font-weight: 700; letter-spacing: -.02em; text-align: center; }
.face-example { font-style: italic; color: var(--muted); }
.grade-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 480px) { .grade-row { grid-template-columns: repeat(2, 1fr); } }

/* cloze */
.cloze-sentence { font-size: 1.35rem; line-height: 2.3; margin: 0; }
.cloze-input {
  width: 5ch; min-width: 4ch; margin: 0 4px; padding: 0 6px; text-align: center;
  font: inherit; color: var(--accent); font-weight: 600; background: transparent;
  border: 0; border-bottom: 2px solid var(--accent); border-radius: 4px 4px 0 0; outline: none;
}
.cloze-input:focus { background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* tiles (order, cloze word bank) */
.tile-row, .tile-zone { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tile {
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-size: 1.025rem;
  border: 1px solid var(--border-strong); background: var(--surface); box-shadow: 0 1px 0 var(--border-strong);
}
.tile { transition: border-color .12s, transform .15s; }
.tile:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-2px); }
.tile:disabled { cursor: default; }
.tile.used { opacity: .25; }
.answer-zone { min-height: 64px; padding: 10px; border-radius: var(--radius); border: 1px dashed var(--border-strong); }
.answer-zone.correct { border: 1px solid var(--good); background: var(--good-bg); }
.answer-zone.wrong { border: 1px solid var(--bad); background: var(--bad-bg); }

/* match */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* Subgrid rows keep each left item level with the right item beside it, even when one wraps. */
.match-column { display: grid; grid-template-rows: subgrid; grid-row: span var(--match-rows, 1); gap: 10px; }
.match-item {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 13px 12px; border-radius: var(--radius-sm); cursor: pointer; font-size: 1rem;
  border: 1px solid var(--border-strong); background: var(--surface); transition: border-color .12s, opacity .3s;
}
.match-item:hover:not(:disabled) { border-color: var(--accent); }
.match-item.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.match-item.matched { border-color: var(--good); background: var(--good-bg); color: var(--good); opacity: .7; cursor: default; }

/* scenario */
.dialogue { display: flex; flex-direction: column; gap: 10px; }
.translated-word { position: relative; display: inline-block; cursor: help; text-decoration: underline dotted var(--muted); text-underline-offset: 4px; }
.word-translation { display: none; position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 10; width: max-content; max-width: min(240px, 65vw); padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-size: .875rem; font-weight: 400; line-height: 1.4; text-align: left; pointer-events: none; }
.translated-word:hover > .word-translation, .translated-word:focus > .word-translation { display: block; }
.line { max-width: 85%; padding: 12px 16px; border-radius: var(--radius); }
.line-them { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); }
.line-me { align-self: flex-end; background: color-mix(in srgb, var(--accent) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.line-me.tone-bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.line-me.tone-good { background: var(--good-bg); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.line-speaker { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.line-text { display: flex; align-items: center; gap: 4px; font-weight: 500; }
.line-feedback { margin-top: 4px; color: var(--muted); }
.options-stack .option.wrong { opacity: .6; }

/* estimate */
.estimate-value { font-size: 2.2rem; font-weight: 700; text-align: center; letter-spacing: -.02em; font-variant-numeric: tabular-nums; border-radius: var(--radius-sm); padding: 4px; }
.estimate-value.correct { color: var(--good); background: var(--good-bg); }
.estimate-value.wrong { color: var(--bad); background: var(--bad-bg); }
.slider { width: 100%; accent-color: var(--accent); height: 28px; cursor: pointer; }

/* conjugation (French course) */
.conj-table { display: grid; grid-template-columns: auto 1fr auto; gap: 10px 14px; align-items: center; }
.conj-person { text-align: right; color: var(--muted); font-weight: 500; }
.conj-mark { color: var(--bad); font-weight: 600; min-width: 4ch; }

/* number explorer (French course) */
.nx-panel { padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; gap: 12px; }
.nx-head { display: flex; align-items: center; gap: 8px; }
.nx-number { font-size: 3rem; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.nx-word { font-size: 1.5rem; font-weight: 600; color: var(--accent); min-height: 1.5em; }
.nx-strip { display: flex; gap: 3px; height: 56px; }
.nx-block {
  min-width: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; overflow: hidden;
  border-radius: 6px; background: color-mix(in srgb, var(--accent) 22%, var(--surface)); transition: flex-grow .2s;
}
.nx-twenty { background: color-mix(in srgb, var(--accent) 45%, var(--surface)); }
.nx-rest { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border: 1px dashed color-mix(in srgb, var(--accent) 40%, transparent); }
.nx-value { font-weight: 700; font-size: .9rem; }
.nx-label { font-size: .7rem; color: var(--muted); white-space: nowrap; }
.nx-formula { font-variant-numeric: tabular-nums; font-size: 1.05rem; }

/* ------------------------------------------------------------- toasts */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: var(--radius-sm); background: var(--ink); color: var(--ink-text); font-size: .9rem; box-shadow: var(--shadow); animation: fade-in .2s ease; transition: opacity .4s; }
.toast-bad { background: var(--bad); color: #fff; }
.toast-out { opacity: 0; }

/* --------------------------------------------------------- animation */
.fade-in { animation: fade-in .35s ease both; }
.shake { animation: shake .4s; border-color: var(--bad) !important; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* voice settings (profile) */
.voice-setting { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-bottom: 1px solid var(--border); }
.voice-setting:last-child { border-bottom: 0; }
.voice-setting select.input { flex: 1; min-width: 0; }
.voice-setting p { margin: 0; }
.voice-help { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }

code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* placement test */
.placement-offer {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap; margin-top: 32px; padding: 24px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
}
.placement-offer h2 { margin-bottom: 6px; }
.placement-offer p { margin: 0; max-width: 56ch; }
.placement-actions { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 560px) { .placement-actions { width: 100%; } }
.section-title.row h2 { margin: 0; font-size: inherit; }
.placed-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.placed-list li { display: flex; align-items: center; gap: 8px; }
.placed-list .icon { color: var(--accent); }

/* selection feedback */
.pop { animation: pop .22s ease-out; }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.035); } 100% { transform: scale(1); } }
.option-sound { color: var(--muted); display: inline-flex; opacity: .55; }
.option.selected .option-sound { color: var(--accent); opacity: 1; }
.read-aloud { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.read-aloud input { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; }

/* speech volume */
.volume-control { display: flex; align-items: center; gap: 10px; }
.volume-range { flex: 1; min-width: 120px; height: 24px; }
.volume-value { min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; }
.volume-wrap { position: relative; display: flex; }
.volume-popover {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 20; width: 260px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow);
}

/* writing exercises */
.write-input { font-size: 1.15rem; }
.write-open { height: auto; min-height: 120px; padding: 12px 14px; resize: vertical; line-height: 1.6; }
.write-output:empty { display: none; }
.write-output { display: flex; flex-direction: column; gap: 8px; }
.word-diff { font-size: 1.15rem; line-height: 2.1; margin: 0; }
.word-diff del { text-decoration: line-through; text-decoration-thickness: 2px; }
.word-diff ins { text-decoration: none; }
.w-fix { display: inline-flex; gap: 4px; align-items: baseline; }
.w-fix del, .w-extra { color: var(--bad); opacity: .8; }
.w-fix ins, .w-missing { color: var(--good); font-weight: 600; border-bottom: 2px solid var(--good); }
.w-slip del { color: var(--ok); }
.w-missing::before { content: '+'; font-weight: 400; margin-right: 1px; }
.write-examples, .write-mistakes { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.write-mistakes del { color: var(--bad); }
.write-mistakes ins { color: var(--good); text-decoration: none; font-weight: 600; }
.grade-row-3 { grid-template-columns: repeat(3, 1fr); }
.w-hint { background: none; color: inherit; border-bottom: 2px wavy var(--bad); padding: 0 1px; }
.w-hint.w-slip { border-bottom-color: var(--ok); }
.w-gap { color: var(--bad); letter-spacing: 2px; }

/* FIAE course: code listings, desk checks, sorting and number explorables */
.code-block { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .9rem; line-height: 1.65; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 0; overflow-x: auto;
  /* Edge shadows appear only while more code is hidden on that side, so a cut-off line reads as scrollable. */
  background:
    linear-gradient(to right, var(--surface) 40%, transparent) left / 28px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 40%, transparent) right / 28px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, color-mix(in srgb, var(--text) 35%, transparent), transparent) left / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, color-mix(in srgb, var(--text) 35%, transparent), transparent) right / 14px 100% no-repeat scroll,
    var(--surface);
}
.code-line { display: flex; padding: 0 14px 0 0; white-space: pre; min-width: max-content; }
.code-line.active { background: color-mix(in srgb, var(--accent) 14%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
.code-no { flex: 0 0 3.2ch; text-align: right; padding-right: 1.4ch; color: var(--muted); opacity: .6; user-select: none; }
.code-text { white-space: pre; }
.tok-keyword { color: var(--accent); font-weight: 600; }
.tok-type { color: #a0570c; }
.tok-number { color: #1f7a6d; }
.tok-string { color: #9b3b8a; }
.tok-comment { color: var(--muted); font-style: italic; }
.tok-op { font-weight: 600; }
@media (prefers-color-scheme: dark) {
  .tok-type { color: #e8a65b; }
  .tok-number { color: #6fd3c2; }
  .tok-string { color: #e391d2; }
}
.code-gap { font: inherit; height: 1.6em; padding: 0 4px; margin: 0 1px; border: 0; border-bottom: 2px solid var(--border-strong); border-radius: 4px 4px 0 0; background: var(--surface-2); color: var(--text); text-align: center; }
.code-gap:focus { outline: none; border-bottom-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.code-gap.correct { border-bottom-color: var(--good); background: var(--good-bg); }
.code-gap.wrong { border-bottom-color: var(--bad); background: var(--bad-bg); text-decoration: line-through; }
.code-gap-bank { cursor: pointer; caret-color: transparent; }
.code-gap-bank:not(:disabled):hover { text-decoration: line-through; text-decoration-color: var(--muted); }
.code-fix { margin-left: 4px; padding: 0 4px; border-radius: 4px; color: var(--good); background: var(--good-bg); font-weight: 600; }
.tile-code, .option-code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.trace-panel { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.trace-controls { justify-content: space-between; }
.trace-note { margin: 0; min-height: 3em; }
.trace-vars td, .trace-vars th, .trace-table td, .trace-table th { text-align: center; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.trace-vars th, .trace-table th { text-transform: none; letter-spacing: 0; }
.trace-value.changed { background: color-mix(in srgb, var(--accent) 16%, transparent); font-weight: 700; }
.trace-gap .code-gap { font-size: .95rem; }
.bs-panel, .bc-panel { display: flex; flex-direction: column; gap: 14px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.bs-bars { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding-top: 8px; }
.bs-bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; min-width: 0; }
.bs-fill { width: 100%; border-radius: 6px 6px 0 0; background: color-mix(in srgb, var(--accent) 35%, var(--surface)); transition: height .25s; }
.bs-bar.sorted .bs-fill { background: var(--border-strong); }
.bs-bar.compared .bs-fill { background: var(--accent); }
.bs-bar.swapped .bs-fill { background: #e07b24; }
.bs-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.bs-index { font-size: .75rem; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.bs-log { margin: 0; min-height: 3em; font-weight: 500; }
.bs-own { align-items: center; }
.bs-input { flex: 1; min-width: 160px; height: 40px; }
.bc-bits { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.bc-bit { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 0; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; }
.bc-bit.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.bc-digit { font-size: 1.5rem; font-weight: 700; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.bc-place { font-size: .75rem; opacity: .8; }
.bc-sum { margin: 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--muted); }
.bc-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; align-items: center; margin: 0; }
.bc-grid dt { color: var(--muted); font-weight: 500; }
.bc-grid dd { margin: 0; }
.bc-decimal { width: 120px; height: 40px; }
.bc-out { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 1.15rem; font-weight: 600; }
.bc-details summary { cursor: pointer; color: var(--accent); font-weight: 500; margin-bottom: 8px; }
.bc-rest { font-weight: 600; }
@media (max-width: 520px) {
  .bc-digit { font-size: 1.1rem; }
  .bc-bit { padding: 8px 0; }
  .bs-bars { gap: 4px; }
}

/* Touch screens: keyboard hints don't apply, and inputs under 16px make iOS zoom in on focus. */
@media (hover: none) and (pointer: coarse) {
  .key-hint { display: none; }
  .code-gap, .trace-gap .code-gap { font-size: 16px; height: 1.9em; }
  .icon-btn { min-width: 40px; min-height: 40px; }
  .link { padding: 9px 0; }
}
