:root[data-theme="light"] {
  color-scheme: light;
  --ink: #10233f;
  --muted: #5e6d80;
  --paper: #fffdf8;
  --surface: #ffffff;
  --line: #dce2e9;
  --coral: #b83c32;
  --coral-soft: #ffe1dd;
  --yellow: #ffd66b;
  --mint: #9de2cb;
  --blue: #95c7f6;
  --green: #17875f;
  --red: #b83636;
  --shadow: 0 18px 60px rgba(16, 35, 63, .10);
  --topbar: rgba(255, 253, 248, .92);
  --glass: rgba(255,255,255,.96);
  --soft-surface: rgba(255,255,255,.65);
  --input: #fff;
  --success-soft: #ddf7eb;
  --success-text: #075f41;
  --error-soft: #ffe4e1;
  --error-text: #8d2626;
  --deck-one: #fff3d2;
  --deck-two: #e2f7f0;
  --deck-three: #e5f2ff;
  --phase-0: #fff0ed;
  --phase-1: #fff3d2;
  --phase-2: #fff8df;
  --phase-3: #edf7ff;
  --phase-4: #e5f2ff;
  --phase-5: #e4f8f1;
  --phase-6: #d8f3e9;
  --phase-7: #c8ecdf;
  --edge: #10233f;
  --primary-bg: #10233f;
  --primary-text: #fff;
  --progress-track: rgba(255,255,255,.75);
}

:root {
  color-scheme: dark;
  --ink: #edf4ff; --muted: #a8b7ca; --paper: #0c1422; --surface: #121d2d; --line: #314158;
  --coral: #ff8177; --coral-soft: #40242a; --yellow: #6b5522; --mint: #245f52; --blue: #264f75;
  --green: #66d6aa; --red: #ff8c8c; --shadow: 0 18px 60px rgba(0,0,0,.34);
  --topbar: rgba(12,20,34,.92); --glass: rgba(18,29,45,.97); --soft-surface: rgba(18,29,45,.72); --input: #18263a;
  --success-soft: #16372e; --success-text: #8de7c4; --error-soft: #402329; --error-text: #ffaaaa;
  --deck-one: #332d20; --deck-two: #18352f; --deck-three: #1b3045;
  --phase-0: #3b2529; --phase-1: #3a3221; --phase-2: #332f20; --phase-3: #1b3042;
  --phase-4: #1c354b; --phase-5: #19372f; --phase-6: #1b4035; --phase-7: #205044;
  --edge: #050912; --primary-bg: #dceaff; --primary-text: #0c1422; --progress-track: #24344a;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body { margin: 0; min-height: 100vh; font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", system-ui, sans-serif; color: var(--ink); background: radial-gradient(circle at 3% 5%, rgba(255, 214, 107, .32), transparent 22rem), var(--paper); }
.learning-rotate-hint[hidden] { display: none; }
.learning-rotate-hint { position: fixed; inset: 0; z-index: 10000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; padding: 1rem max(1.5rem, env(safe-area-inset-left)) 1rem max(1.5rem, env(safe-area-inset-right)); overflow: auto; background: var(--paper); color: var(--ink); text-align: center; }
.learning-rotate-hint > span { font-size: 2.5rem; }
.learning-rotate-hint h1 { max-width: 32rem; margin: 0; font-size: clamp(1.2rem, 4vw, 1.8rem); }
.learning-rotate-hint p { margin: 0; }
body.learning-rotation-blocked { overflow: hidden; }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
button, .button { touch-action: manipulation; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); line-height: 1.6; }
.eyebrow { margin: 0 0 .6rem; color: var(--coral); font-size: .78rem; font-weight: 850; letter-spacing: .15em; text-transform: uppercase; }

.topbar { position: sticky; top: 0; z-index: 10; min-height: 4.6rem; display: flex; align-items: center; gap: 1.6rem; padding: .7rem clamp(1rem, 4vw, 3rem); border-bottom: 1px solid var(--line); background: var(--topbar); backdrop-filter: blur(18px); }
.brand { display: inline-flex; align-items: center; gap: .65rem; margin-right: auto; text-decoration: none; font-weight: 850; }
.brand-mini { display: grid; place-items: center; width: 2.4rem; height: 2.4rem; border-radius: .75rem; background: var(--mint); border: 2px solid var(--ink); box-shadow: .16rem .16rem 0 var(--edge); transform: rotate(-3deg); }
.topbar nav { display: flex; gap: .3rem; }
.topbar nav a { padding: .65rem .8rem; border-radius: .8rem; text-decoration: none; color: var(--muted); font-weight: 700; }
.topbar nav a:hover, .topbar nav a[aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: 0 2px 12px rgba(0,0,0,.12); }
.logout-form { margin: 0; }
.theme-toggle { position: fixed; right: 1rem; bottom: 1rem; z-index: 20; width: 3rem; height: 3rem; display: grid; place-items: center; border: 2px solid var(--ink); border-radius: 50%; color: var(--ink); background: var(--surface); box-shadow: .18rem .18rem 0 var(--edge); cursor: pointer; font-size: 1.15rem; }
.theme-toggle:hover, .theme-toggle:focus-visible { width: 9rem; border-radius: 999px; }
.theme-toggle .theme-toggle-label { display: none; margin-left: .35rem; font-size: .78rem; font-weight: 800; }
.theme-toggle:hover .theme-toggle-label, .theme-toggle:focus-visible .theme-toggle-label { display: inline; }
.theme-toggle:hover, .theme-toggle:focus-visible { display: flex; justify-content: center; }
.page-learn:has(.learn-card, .feedback-card) .theme-toggle { display: none; }
.pull-refresh { --pull-distance: 0px; position: fixed; top: max(.55rem, env(safe-area-inset-top)); left: 50%; z-index: 40; display: flex; align-items: center; gap: .45rem; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--glass); box-shadow: 0 .35rem 1.2rem rgba(0,0,0,.2); opacity: 0; pointer-events: none; transform: translate(-50%, calc(-4rem + var(--pull-distance))); transition: opacity .12s ease, border-color .12s ease; white-space: nowrap; }
.pull-refresh span { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; color: var(--primary-text); background: var(--primary-bg); font-size: 1rem; font-weight: 900; }
.pull-refresh strong { font-size: .78rem; }
.pull-refresh.is-visible, .pull-refresh.is-refreshing { opacity: 1; }
.pull-refresh.is-ready { border-color: var(--ink); color: var(--ink); }
.pull-refresh.is-refreshing { --pull-distance: 72px; }
.pull-refresh.is-refreshing span { animation: pull-refresh-spin .8s linear infinite; }
@keyframes pull-refresh-spin { to { transform: rotate(360deg); } }

.app-shell { width: min(72rem, calc(100% - 2rem)); margin: 0 auto; padding: clamp(2rem, 5vw, 4.5rem) 0; }
.legal-page { width: min(48rem, calc(100% - 2rem)); }
.legal-page > .brand { width: max-content; margin-bottom: 1.5rem; }
.legal-page h1 { margin: .2rem 0 1.5rem; font-size: clamp(2.2rem, 7vw, 4rem); line-height: 1; letter-spacing: -.05em; }
.legal-page h2 { margin-top: 2rem; }
.legal-page p, .legal-page li { line-height: 1.65; }
.legal-page li + li { margin-top: .55rem; }
.site-footer { padding: 1rem 1rem 3rem; text-align: center; color: var(--muted); font-size: .84rem; }
.site-footer a { font-weight: 800; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 1.5rem; margin-bottom: 2rem; }
.page-heading h1 { margin: 0; font-size: clamp(2.2rem, 6vw, 4.5rem); letter-spacing: -.055em; line-height: 1; }
.admin-navigation { display: flex; gap: .45rem; margin: 0 0 2rem; padding: .4rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); box-shadow: var(--shadow); }
.admin-navigation a { flex: 1; padding: .75rem 1rem; border-radius: .75rem; color: var(--muted); text-align: center; text-decoration: none; font-weight: 850; }
.admin-navigation a:hover, .admin-navigation a[aria-current="page"] { color: var(--primary-text); background: var(--primary-bg); }
.scope-badge { display: inline-flex; width: max-content; align-items: center; gap: .35rem; padding: .42rem .65rem; border: 1px solid currentColor; border-radius: 999px; font-size: .72rem; font-weight: 850; white-space: nowrap; }
.scope-personal { color: var(--green); background: color-mix(in srgb, var(--green) 10%, var(--surface)); }
.scope-profile { color: var(--coral); background: var(--coral-soft); }
.scope-global { color: color-mix(in srgb, var(--ink) 78%, var(--blue)); background: color-mix(in srgb, var(--blue) 25%, var(--surface)); }
.scope-admin { color: var(--muted); background: var(--paper); }
.settings-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.settings-heading h2, .settings-heading .eyebrow { margin-bottom: 0; }
.profile-edit-context { display: flex; align-items: center; gap: .45rem; margin: 0 1rem 1rem; padding: .75rem 1rem; border-radius: .85rem; background: var(--paper); color: var(--muted); font-size: .84rem; }
.profile-edit-context strong { color: var(--ink); }
.profile-edit-context .scope-badge { margin-left: auto; }

.freeze-protection-card { position: relative; isolation: isolate; margin-bottom: 2.2rem; padding: clamp(1.6rem, 5vw, 3rem); overflow: hidden; border: 2px solid var(--ink); border-radius: 2rem; background: linear-gradient(135deg, color-mix(in srgb, var(--blue) 42%, var(--surface)), var(--surface) 62%, color-mix(in srgb, var(--coral-soft) 60%, var(--surface))); box-shadow: .55rem .55rem 0 var(--edge); text-align: center; }
.freeze-protection-card::before { content: ''; position: absolute; z-index: -1; width: 16rem; height: 16rem; top: -10rem; left: 50%; border-radius: 50%; background: color-mix(in srgb, var(--blue) 42%, transparent); transform: translateX(-50%); filter: blur(1rem); }
.freeze-protection-card h1 { margin: .15rem 0 .75rem; font-size: clamp(2rem, 6vw, 4rem); line-height: 1; letter-spacing: -.05em; }
.freeze-protection-card > p:not(.eyebrow) { max-width: 42rem; margin: .7rem auto; color: var(--muted); font-size: clamp(1rem, 2.4vw, 1.2rem); line-height: 1.5; }
.freeze-protection-card .freeze-protection-status { color: var(--ink); font-weight: 850; }
.freeze-protection-translation { display: grid; gap: .3rem; max-width: 42rem; margin: 1.1rem auto 0; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--muted); }
.freeze-protection-translation strong { color: var(--ink); font-size: 1.05rem; }
.freeze-protection-translation span { line-height: 1.45; }
.freeze-protection-speech { margin: 1rem auto 0; }
.freeze-protection-card form { margin-top: 1.4rem; }
.freeze-protection-symbols { display: flex; justify-content: center; align-items: center; gap: .7rem; margin-bottom: .8rem; font-size: clamp(2.2rem, 7vw, 4rem); line-height: 1; }
.freeze-protection-symbols span:first-child { animation: freeze-crystal-used .9s ease-out both; }
.freeze-protection-symbols span:last-child { animation: freeze-flame-protected .75s .5s cubic-bezier(.2,.9,.25,1.3) both; }
@keyframes freeze-crystal-used { 0% { opacity: 0; transform: scale(1.4) rotate(-12deg); filter: drop-shadow(0 0 1.2rem var(--blue)); } 55% { opacity: 1; transform: scale(1) rotate(4deg); } 100% { opacity: .72; transform: scale(.88) rotate(0); } }
@keyframes freeze-flame-protected { 0% { opacity: .2; transform: scale(.45); filter: saturate(.25); } 70% { opacity: 1; transform: scale(1.2); filter: drop-shadow(0 0 1rem var(--coral)); } 100% { opacity: 1; transform: scale(1); filter: none; } }

.hero { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 2rem; padding: clamp(1.5rem, 5vw, 3.5rem); border: 2px solid var(--ink); border-radius: 2rem; background: var(--surface); box-shadow: .55rem .55rem 0 var(--edge); }
.hero h1 { max-width: 13ch; margin: 0; font-size: clamp(2.7rem, 7vw, 5.5rem); line-height: .95; letter-spacing: -.06em; }
.hero p:not(.eyebrow) { max-width: 38rem; color: var(--muted); font-size: 1.08rem; line-height: 1.6; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin: 2.2rem 0; }
.stat-card { min-height: 10rem; display: flex; flex-direction: column; justify-content: space-between; padding: 1.4rem; border: 2px solid var(--ink); border-radius: 1.4rem; box-shadow: .3rem .3rem 0 var(--edge); }
.stat-card strong { font-size: clamp(2.3rem, 5vw, 4rem); letter-spacing: -.06em; }
.stat-card span { font-weight: 750; }
.coral { background: var(--coral-soft); } .mint { background: var(--mint); } .blue { background: var(--blue); } .yellow { background: var(--yellow); }
.streak-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 0 0 2.2rem; }
.streak-card { position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1rem; min-height: 7.5rem; padding: 1.2rem 1.3rem 1.65rem; overflow: hidden; border: 2px solid var(--ink); border-radius: 1.4rem; background: var(--surface); box-shadow: .28rem .28rem 0 var(--edge); }
.streak-card .streak-flag { font-size: 2.6rem; line-height: 1; }
a.streak-card { color: inherit; text-decoration: none; }
a.streak-card:hover, a.streak-card:focus-visible { border-color: var(--coral); }
a.streak-card:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; }
.streak-card strong, .streak-card div span { display: block; }
.streak-card strong { font-size: 1.7rem; letter-spacing: -.03em; }
.streak-card div span, .streak-freezes { color: var(--muted); font-size: .82rem; font-weight: 800; }
.streak-card progress { appearance: none; position: absolute; right: 1rem; bottom: .65rem; left: 1rem; width: auto; height: .42rem; overflow: hidden; border: 0; border-radius: 999px; background: var(--progress-track); }
.streak-card progress::-webkit-progress-bar { border-radius: 999px; background: var(--progress-track); }
.streak-card progress::-webkit-progress-value { border-radius: 999px; background: var(--coral); }
.streak-card progress::-moz-progress-bar { border-radius: 999px; background: var(--coral); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; background: radial-gradient(circle at 10% 10%, rgba(255,214,107,.65) 0 8rem, transparent 8.2rem), radial-gradient(circle at 90% 85%, rgba(149,199,246,.6) 0 12rem, transparent 12.2rem), var(--paper); }
.login-card { width: min(100%, 30rem); padding: clamp(1.7rem, 6vw, 3.4rem); border: 2px solid var(--ink); border-radius: 2rem; background: var(--glass); box-shadow: .65rem .65rem 0 var(--edge); }
.login-card h1 { margin: 0; font-size: clamp(2.5rem, 10vw, 4.3rem); line-height: .95; letter-spacing: -.06em; }
.brand-mark { width: 5rem; height: 5rem; display: grid; place-items: center; margin-bottom: 1.8rem; border: 2px solid var(--ink); border-radius: 1.4rem; background: var(--mint); box-shadow: .4rem .4rem 0 var(--edge); font-size: 2.25rem; font-weight: 850; transform: rotate(-4deg); }

.stack { display: grid; gap: 1rem; margin-top: 1.6rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.span-two { grid-column: span 2; }
label { display: grid; gap: .45rem; color: var(--muted); font-size: .86rem; font-weight: 750; }
input, textarea, select { width: 100%; min-height: 3.2rem; padding: .75rem .9rem; border: 2px solid var(--line); border-radius: .85rem; color: var(--ink); background: var(--input); outline: none; }
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--ink); box-shadow: 0 0 0 4px rgba(149,199,246,.35); }

.button { display: inline-flex; min-height: 3rem; align-items: center; justify-content: center; padding: .7rem 1.05rem; border: 2px solid var(--ink); border-radius: .85rem; text-decoration: none; font-weight: 820; cursor: pointer; }
.button-primary { color: var(--primary-text); background: var(--primary-bg); box-shadow: .2rem .2rem 0 var(--coral); }
.button-secondary { color: var(--ink); background: var(--surface); box-shadow: .18rem .18rem 0 var(--edge); }
.button-language-switch { background: color-mix(in srgb, var(--blue) 24%, var(--surface)); box-shadow: 0 .35rem .8rem color-mix(in srgb, var(--blue) 65%, transparent); }
.button-quiet { min-height: auto; border-color: transparent; background: transparent; color: var(--muted); box-shadow: none; }
.button-large { min-height: 3.7rem; padding: .9rem 1.25rem; }
.button-small { min-height: 2.5rem; padding: .5rem .75rem; font-size: .82rem; }
.button-danger { color: #fff; border-color: #8d2626; background: var(--red); box-shadow: .18rem .18rem 0 #6e2020; }
.button:hover { transform: translateY(-1px); }

.notice { margin-bottom: 1.5rem; padding: 1rem 1.15rem; border: 2px solid; border-radius: 1rem; font-weight: 700; }
.notice-success { color: var(--success-text); border-color: var(--green); background: var(--success-soft); }
.notice-error { color: var(--error-text); border-color: var(--red); background: var(--error-soft); }
.notice-info { color: var(--ink); border-color: var(--line); background: var(--surface); }
.panel { margin-top: 2rem; padding: clamp(1.25rem, 4vw, 2rem); border: 1px solid var(--line); border-radius: 1.3rem; background: var(--surface); box-shadow: var(--shadow); }
.panel h2 { margin-top: 0; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.panel-heading h2 { margin-bottom: 0; }
.panel-heading > a { color: var(--muted); font-weight: 750; }

.learn-card, .feedback-card { width: min(100%, 50rem); margin: 2rem auto; padding: clamp(1.5rem, 6vw, 4rem); text-align: center; border: 2px solid var(--ink); border-radius: 2rem; background: var(--surface); box-shadow: .6rem .6rem 0 var(--edge); }
.learn-meta { display: flex; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: .85rem; font-weight: 750; }
.prompt-label { margin-top: 4rem; color: var(--muted); }
.learn-card h1 { margin: .5rem 0 3rem; font-size: clamp(3rem, 12vw, 7rem); line-height: .9; letter-spacing: -.06em; }
.learn-card h1.term-medium { font-size: clamp(2.6rem, 8vw, 5rem); line-height: .96; }
.learn-card h1.term-long { font-size: clamp(2.1rem, 5.5vw, 3.7rem); line-height: 1.02; }
.learn-card h1.term-very-long { font-size: clamp(1.7rem, 4vw, 2.8rem); line-height: 1.08; letter-spacing: -.035em; }
.tts-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .65rem; margin: -1.4rem 0 1.4rem; }
.tts-button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 2.8rem; padding: .55rem .85rem; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); color: var(--ink); font: inherit; font-weight: 850; cursor: pointer; }
.tts-button:hover, .tts-button:focus-visible, .tts-button.is-playing { background: var(--blue-soft); transform: translateY(-1px); }
.tts-button.is-loading { opacity: .68; cursor: wait; }
.tts-button.is-loading span:first-child { animation: tts-pulse .85s ease-in-out infinite alternate; }
@keyframes tts-pulse { to { transform: scale(1.16); opacity: .55; } }
.answer-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .7rem; }
.answer-form input { min-width: 0; width: 100%; }
/* Keep Safari's rotation text inflation from defeating the learning sizes;
   pinch zoom remains available. */
body.page-learn { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.answer-form input { min-height: 4rem; font-size: 1.25rem; text-align: center; }
.answer-empty-hint { grid-column: 1 / -1; color: var(--muted); text-align: center; }
.hint { color: var(--muted); }
.feedback-card.is-correct { background: var(--success-soft); }
.feedback-card.is-wrong { background: var(--phase-0); }
.goal-celebration { display: flex; align-items: center; justify-content: center; gap: .65rem; margin: -1rem 0 1.1rem; padding: .75rem 1rem; border: 2px solid var(--ink); border-radius: 1rem; color: var(--success-text); background: color-mix(in srgb, var(--mint) 72%, var(--surface)); box-shadow: .18rem .18rem 0 var(--edge); }
.goal-celebration > span { font-size: 1.35rem; }
.goal-celebration strong { font-size: 1.05rem; }
.goal-celebration small { color: var(--muted); font-weight: 750; }
.feedback-heading { display: flex; align-items: flex-start; justify-content: center; gap: .8rem; margin-bottom: 1rem; text-align: center; }
.feedback-result { display: flex; align-items: center; gap: .55rem; flex: 0 0 auto; }
.feedback-result .eyebrow { margin: 0; }
.feedback-icon { width: 3rem; height: 3rem; display: grid; flex: 0 0 auto; place-items: center; border: 2px solid var(--ink); border-radius: 50%; background: var(--surface); font-size: 1.4rem; font-weight: 900; }
.feedback-card h1 { font-size: clamp(3rem, 12vw, 7rem); line-height: .9; letter-spacing: -.06em; }
.feedback-card h1.term-medium { font-size: clamp(2.6rem, 8vw, 5rem); line-height: .96; }
.feedback-card h1.term-long { font-size: clamp(2.1rem, 5.5vw, 3.7rem); line-height: 1.02; }
.feedback-card h1.term-very-long { font-size: clamp(1.7rem, 4vw, 2.8rem); line-height: 1.08; letter-spacing: -.035em; }
.feedback-card h1 span { color: var(--coral); }
.daily-progress { appearance: none; display: block; width: 100%; height: .85rem; margin: 1.4rem 0 .8rem; overflow: hidden; padding: 0; border: 2px solid var(--ink); border-radius: 999px; background: var(--progress-track); }
.daily-progress::-webkit-progress-bar { border-radius: 999px; background: var(--progress-track); }
.daily-progress::-webkit-progress-value { border-radius: 999px; background: var(--coral); }
.daily-progress::-moz-progress-bar { border-radius: 999px; background: var(--coral); }
.streak-inline { color: var(--muted); font-size: .9rem; font-weight: 800; }
.confetti-canvas { position: fixed; inset: 0; z-index: 10000; width: 100%; height: 100%; pointer-events: none; }
.feedback-actions, .welcome-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .8rem; margin-top: 1.4rem; }
.feedback-actions .feedback-sound-button { flex: 0 0 4.5rem; width: 4.5rem; padding-inline: 0; font-size: 1.35rem; }
.feedback-actions [data-next-card] { flex: 1 1 18rem; }
.answer-card-keeper { position: fixed !important; top: 0; left: 0; width: 1px !important; height: 1px !important; margin: 0 !important; padding: 0 !important; overflow: hidden; opacity: .001; pointer-events: none; clip-path: inset(50%); }

.language-picker { width: min(100%, 62rem); margin: 0 auto; }
.language-unit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.language-unit-card { position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1rem; min-height: 8rem; padding: 1.25rem; overflow: hidden; border: 2px solid var(--ink); border-radius: 1.4rem; background: var(--surface); box-shadow: .28rem .28rem 0 var(--edge); text-decoration: none; }
.language-unit-card:hover { transform: translateY(-2px); }
.language-unit-flag { font-size: 3.2rem; line-height: 1; }
.language-unit-card strong, .language-unit-card small { display: block; }
.language-unit-card strong { font-size: 1.25rem; }
.language-unit-card small { margin-top: .3rem; color: var(--muted); font-weight: 750; }
.language-unit-count { color: var(--muted); font-size: .84rem; font-weight: 800; }
.language-unit-streak { position: absolute; right: 1rem; top: .65rem; color: var(--muted); font-size: .75rem; font-weight: 850; }
.language-unit-progress { appearance: none; position: absolute; right: 1rem; bottom: .65rem; left: 1rem; width: auto; height: .35rem; overflow: hidden; padding: 0; border: 0; border-radius: 999px; background: var(--progress-track); }
.language-unit-progress::-webkit-progress-bar { border-radius: 999px; background: var(--progress-track); }
.language-unit-progress::-webkit-progress-value { border-radius: 999px; background: var(--coral); }
.language-unit-progress::-moz-progress-bar { border-radius: 999px; background: var(--coral); }

.language-welcome { width: min(100%, 48rem); margin: 1rem auto; padding: clamp(2rem, 7vw, 4.5rem); text-align: center; border: 2px solid var(--ink); border-radius: 2rem; background: var(--surface); box-shadow: .6rem .6rem 0 var(--edge); }
.welcome-flag { display: block; margin-bottom: 1rem; font-size: clamp(6rem, 20vw, 10rem); line-height: 1; filter: drop-shadow(.2rem .25rem 0 rgba(16,35,63,.18)); }
.language-welcome h1 { margin: .2rem 0 1rem; font-size: clamp(2.5rem, 8vw, 5rem); line-height: .98; letter-spacing: -.055em; }
.welcome-greeting { display: flex; flex-direction: column; align-items: center; }
.welcome-greeting h1 { text-wrap: balance; }
.welcome-translation { max-width: 38rem; margin: -.25rem 0 1rem; color: var(--muted); font-size: clamp(1rem, 2.5vw, 1.25rem); font-weight: 750; line-height: 1.35; text-wrap: balance; }
.welcome-speech-button { width: 3.5rem; min-height: 3.5rem; padding: 0; font-size: 1.25rem; }
.welcome-goal { margin: 1.4rem 0 .4rem; font-size: 1.15rem; }

.learning-complete { width: min(100%, 64rem); margin: 1rem auto; padding: clamp(1.5rem, 5vw, 3.5rem); text-align: center; border: 2px solid var(--ink); border-radius: 2rem; background: var(--surface); box-shadow: .6rem .6rem 0 var(--edge); }
.learning-complete h1 { margin: .25rem 0 1.4rem; font-size: clamp(2.5rem, 7vw, 5rem); line-height: 1; letter-spacing: -.05em; text-wrap: balance; }
.completion-farewell { display: flex; flex-direction: column; align-items: center; gap: .55rem; margin: 0 auto 1.75rem; }
.completion-farewell > strong { font-size: clamp(1.6rem, 4vw, 2.65rem); line-height: 1.1; text-wrap: balance; }
.completion-farewell > span { color: var(--muted); font-size: clamp(1rem, 2.5vw, 1.25rem); font-weight: 750; text-wrap: balance; }
.completion-speech-button { width: 3.5rem; min-height: 3.5rem; padding: 0; font-size: 1.25rem; }
.completion-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; margin: 1.5rem 0; }
.completion-stats article { display: flex; min-width: 0; min-height: 7rem; flex-direction: column; justify-content: center; padding: 1rem .7rem; border: 1px solid var(--line); border-radius: 1.15rem; background: var(--soft-surface); }
.completion-stats strong { color: var(--ink); font-size: clamp(1.45rem, 3vw, 2.2rem); line-height: 1; }
.completion-stats span { margin-top: .45rem; color: var(--muted); font-size: .82rem; font-weight: 800; }
.completion-achievements { margin: 1.75rem 0; }
.completion-achievements h2 { font-size: 1.25rem; }
.completion-achievements > div { display: flex; flex-wrap: wrap; justify-content: center; gap: .7rem; }
.completion-achievements a { display: grid; grid-template-columns: auto 1fr; gap: .15rem .6rem; min-width: min(100%, 15rem); padding: .75rem 1rem; text-align: left; text-decoration: none; border: 1px solid var(--line); border-radius: 1rem; background: var(--paper); color: var(--ink); }
.completion-achievements a > span { grid-row: 1 / 3; align-self: center; font-size: 1.65rem; }
.completion-achievements small { color: var(--muted); }
.completion-achievements article { display: grid; grid-template-columns: auto 1fr; gap: .15rem .6rem; min-width: min(100%, 15rem); padding: .75rem 1rem; text-align: left; border: 1px solid var(--line); border-radius: 1rem; background: var(--paper); color: var(--ink); }
.completion-achievements article > span { grid-row: 1 / 3; align-self: center; font-size: 1.65rem; }
.completion-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .7rem; margin-top: 1.5rem; }
.completion-actions .button-primary { flex: 1 1 100%; }

.empty-state { margin: 2rem 0; padding: 3rem 1.5rem; text-align: center; border: 2px dashed var(--line); border-radius: 1.5rem; background: var(--soft-surface); }
.empty-state.compact { grid-column: 1 / -1; margin: 0; padding: 1.5rem; }
.empty-state h1, .empty-state h2 { margin-top: 0; }
.celebration-mark { width: 5rem; height: 5rem; display: grid; place-items: center; margin: 0 auto 1rem; border-radius: 1.4rem; background: var(--yellow); border: 2px solid var(--ink); box-shadow: .3rem .3rem 0 var(--edge); font-size: 2.4rem; }

.deck-language-tabs { display: flex; gap: .65rem; margin: 0 0 1.2rem; overflow-x: auto; padding: .2rem .2rem .55rem; }
.deck-language-tab { width: 3.4rem; height: 3.1rem; display: grid; place-items: center; flex: 0 0 auto; border: 2px solid var(--line); border-radius: .9rem; background: var(--surface); box-shadow: .18rem .18rem 0 var(--edge); font-size: 1.55rem; text-decoration: none; }
.deck-language-tab-all { font-size: 1.4rem; }
.deck-language-tab.active { border-color: var(--ink); background: var(--primary-bg); transform: translateY(-.08rem); }
.deck-list { display: grid; gap: .55rem; }
.deck-row { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 1rem; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); text-decoration: none; transition: border-color .15s ease, transform .15s ease, background .15s ease; }
.deck-row:nth-child(3n+1) { background: var(--deck-one); } .deck-row:nth-child(3n+2) { background: var(--deck-two); } .deck-row:nth-child(3n) { background: var(--deck-three); }
.deck-row:hover, .deck-row:focus-visible { border-color: var(--ink); transform: translateX(.18rem); }
.deck-row-copy { min-width: 0; display: grid; gap: .22rem; }
.deck-class-label { width: fit-content; color: var(--muted); font-size: .7rem; font-weight: 900; letter-spacing: .055em; text-transform: uppercase; }
.deck-row h2 { min-width: 0; display: flex; align-items: center; gap: .6rem; margin: 0; overflow: hidden; font-size: 1rem; letter-spacing: -.02em; white-space: nowrap; }
.deck-row h2 > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.deck-title-flag { flex: 0 0 auto; font-size: 1.2rem; line-height: 1; }
.deck-word-count { color: var(--muted); font-size: .82rem; font-weight: 800; white-space: nowrap; }
.language-chip { padding: .35rem .55rem; border-radius: .5rem; color: var(--primary-text); background: var(--primary-bg); font-size: .72rem; font-weight: 850; letter-spacing: .06em; }
.word-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.word-list article { min-width: 0; overflow-wrap: anywhere; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); }
.word-list article > *, .word-list input, .word-list select, .word-list textarea { min-width: 0; max-width: 100%; }
.word-list small { grid-column: 1 / -1; color: var(--muted); }
.completion-details { margin-top: 1.25rem; text-align: left; }
.completion-details > summary { cursor: pointer; padding: .8rem 0; font-weight: 800; }
.completion-overview { margin: 1rem 0; }
.completion-primary-actions { margin-bottom: 1rem; }
.learning-settings-details { padding: 1rem 0; border-top: 1px solid var(--line); scroll-margin-top: 6rem; }
.learning-settings-details > summary { cursor: pointer; font-weight: 750; }
.learning-settings-details .form-grid { margin-top: 1rem; }
.device-usage-orientation { display: block; margin-top: .3rem; color: var(--muted); }
.device-usage-table { width: 100%; overflow-wrap: anywhere; }
@media (max-width: 1100px) {
  .device-usage-table thead { display: none; }
  .device-usage-table, .device-usage-table tbody, .device-usage-table tr, .device-usage-table td { display: block; width: 100%; }
  .device-usage-table tr { padding: .7rem 0; border-bottom: 1px solid var(--line); }
  .device-usage-table td { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; text-align: right; border: 0; }
  .device-usage-table td::before { content: attr(data-label); text-align: left; color: var(--muted); }
  .device-usage-table td small { grid-column: 2; }
}
@media (min-width: 801px) and (max-width: 1100px) {
  .workspace-content .word-list { grid-template-columns: minmax(0, 1fr); }
}
.heading-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .6rem; }
.vocabulary-library { display: grid; gap: .8rem; }
.vocabulary-book, .vocabulary-group { overflow: clip; border: 1px solid var(--line); border-radius: 1.15rem; background: var(--surface); }
.vocabulary-book > summary, .vocabulary-group > summary, .vocabulary-audio > summary { display: flex; align-items: center; gap: .8rem; padding: 1rem 1.15rem; cursor: pointer; list-style: none; }
.vocabulary-book > summary::-webkit-details-marker, .vocabulary-group > summary::-webkit-details-marker, .vocabulary-audio > summary::-webkit-details-marker { display: none; }
.vocabulary-book > summary::before, .vocabulary-group > summary::before, .vocabulary-audio > summary::before { content: '›'; flex: 0 0 auto; color: var(--coral); font-size: 1.45rem; font-weight: 900; line-height: 1; transition: transform .18s ease; }
.vocabulary-book[open] > summary::before, .vocabulary-group[open] > summary::before, .vocabulary-audio[open] > summary::before { transform: rotate(90deg); }
.vocabulary-book > summary span, .vocabulary-group > summary span { display: grid; gap: .2rem; min-width: 0; }
.vocabulary-book > summary strong { font-size: 1.25rem; }
.vocabulary-book > summary small, .vocabulary-group > summary small { color: var(--muted); }
.vocabulary-book-groups { display: grid; gap: .55rem; padding: 0 .75rem .75rem 2rem; }
.vocabulary-group { background: var(--page); }
.vocabulary-group > summary strong { font-size: 1.05rem; }
.vocabulary-group-content { display: grid; gap: .7rem; padding: 0 .85rem .85rem; }
.vocabulary-group-content > .button { justify-self: end; }
.vocabulary-catalog { display: grid; gap: .55rem; }
.vocabulary-catalog-item { display: grid; gap: .7rem; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); }
.vocabulary-catalog-copy { display: grid; gap: .25rem; }
.vocabulary-catalog-copy strong { font-size: 1.02rem; }
.vocabulary-catalog-copy strong span, .vocabulary-catalog-copy small span { color: var(--coral); }
.vocabulary-catalog-copy small { color: var(--muted); }
.vocabulary-audio { border-top: 1px solid var(--line); }
.vocabulary-audio > summary { padding: .65rem 0 0; font-weight: 800; }
.vocabulary-audio-list { display: grid; gap: .5rem; padding-top: .65rem; }
.vocabulary-audio-list > article { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: .65rem; padding: .65rem; border-radius: .75rem; background: var(--page); }
.vocabulary-audio-list > article > div { display: grid; gap: .12rem; }
.vocabulary-audio-list small { color: var(--muted); }
.vocabulary-audio-all { display: flex; justify-content: flex-end; padding-top: .25rem; }
.learning-context { display: flex; justify-content: center; flex-wrap: wrap; gap: .35rem; margin: 0 0 .35rem; color: var(--muted); font-size: .9rem; }
.deck-settings { margin-bottom: 1rem; }
.deck-settings > summary, .danger-zone > summary { cursor: pointer; font-weight: 850; }
.deck-settings-form { margin-top: 1.2rem; }
.word-editor { grid-column: 1 / -1; padding-top: .2rem; border-top: 1px dashed var(--line); }
.word-editor > summary { width: fit-content; cursor: pointer; color: var(--muted); font-size: .78rem; font-weight: 800; }
.word-edit-form { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-top: .8rem; }
.word-edit-form > p { grid-column: 1 / -1; }
.vocabulary-admin-panel details { margin-top: 1rem; }
.vocabulary-admin-panel pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 24rem; overflow: auto; }
.word-edit-form input { min-height: 2.7rem; padding: .55rem .7rem; }
.word-hint-field, .word-edit-actions { grid-column: 1 / -1; }
.word-edit-actions { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.danger-zone { border: 2px solid var(--red); background: var(--error-soft); }
.danger-zone[open] > summary { color: var(--red); }
.danger-zone-content { display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, .7fr); gap: 2rem; margin-top: 1.2rem; padding-top: 1.2rem; border-top: 1px solid #edcccc; }
.danger-zone-content h2 { margin-bottom: .35rem; }
.danger-form { margin-top: 0; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.anki-panel code { padding: .12rem .35rem; border-radius: .35rem; background: var(--input); }
.anki-upload-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: .8rem; margin-top: 1.2rem; }
.anki-notice { margin: 1.2rem 0 0; }
.anki-preview { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }
.anki-preview > h3 { margin: 0; font-size: 1.35rem; }
.anki-model-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; align-items: end; gap: .8rem; margin-top: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--paper); }
.anki-model-title { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.anki-model-title span { color: var(--muted); font-size: .85rem; font-weight: 750; }
.anki-sample-preview { grid-column: 1 / -1; margin-top: .35rem; padding-top: 1rem; border-top: 1px dashed var(--line); }
.anki-sample-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .65rem; }
.anki-sample-heading span { color: var(--muted); font-size: .82rem; }
.anki-sample-table { overflow: hidden; border: 1px solid var(--line); border-radius: .8rem; background: var(--surface); }
.anki-sample-labels, .anki-sample-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.anki-sample-labels { color: var(--muted); background: var(--input); font-size: .75rem; font-weight: 850; text-transform: uppercase; letter-spacing: .04em; }
.anki-sample-labels span, .anki-sample-row span { min-width: 0; padding: .55rem .7rem; overflow-wrap: anywhere; }
.anki-sample-labels span + span, .anki-sample-row span + span { border-left: 1px solid var(--line); }
.anki-sample-row + .anki-sample-row { border-top: 1px solid var(--line); }
.anki-close-form { display: flex; justify-content: flex-end; margin-top: 1rem; }
.profile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; }
.profile-card { display: flex; align-items: center; gap: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); }
.profile-card h2, .profile-card p { margin: 0; }
.profile-card p { margin-top: .2rem; color: var(--muted); }
.avatar { width: 3.4rem; height: 3.4rem; display: grid; place-items: center; flex: 0 0 auto; border: 2px solid var(--ink); border-radius: 1rem; background: var(--blue); font-size: 1.4rem; font-weight: 850; }
.profile-editor-grid { display: grid; gap: .8rem; }
.profile-editor { overflow: hidden; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); }
.profile-editor > summary { display: flex; align-items: center; gap: 1rem; padding: 1rem; cursor: pointer; list-style: none; }
.profile-editor > summary::-webkit-details-marker { display: none; }
.profile-editor > summary strong, .profile-editor > summary small { display: block; }
.profile-editor > summary small { margin-top: .2rem; color: var(--muted); }
.profile-edit-form { padding: 1rem; border-top: 1px solid var(--line); background: var(--paper); }
.profile-active { display: flex; align-items: center; align-self: center; grid-template-columns: auto 1fr; }
.profile-active input { width: 1.2rem; min-height: 1.2rem; }
.profile-sound-settings { border-top: 1px solid var(--line); background: var(--paper); }
.profile-reminder-settings { border-top: 1px solid var(--line); background: var(--paper); }
.profile-reminder-settings > summary { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 1rem; cursor: pointer; font-weight: 850; list-style: none; }
.profile-reminder-settings > summary::-webkit-details-marker { display: none; }
.profile-reminder-settings > summary small { color: var(--muted); font-weight: 700; text-align: right; }
.profile-reminder-settings > form { padding: 0 1rem 1rem; }
.profile-sound-settings > summary { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 1rem; cursor: pointer; font-weight: 850; }
.profile-sound-settings > summary small { color: var(--muted); font-weight: 700; }
.profile-sound-settings > form { padding: 0 1rem 1rem; }
.tts-status { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1rem; margin: 1rem 0; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--paper); }
.tts-status.is-online strong { color: var(--green); }
.tts-status.is-offline strong { color: var(--red); }
.tts-progress-summary { display: grid; grid-template-columns: auto minmax(12rem, 1fr); align-items: center; gap: .6rem 1rem; margin: 1rem 0; padding: 1rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--paper); }
.tts-progress-summary > div { display: grid; }
.tts-progress-summary > div strong { font-size: 1.8rem; line-height: 1; color: var(--accent); }
.tts-progress-summary > div span { color: var(--muted); font-size: .85rem; font-weight: 800; }
.tts-progress-summary progress { width: 100%; }
.tts-progress-summary p { grid-column: 1 / -1; margin: 0; }
.tts-language-table td:nth-child(n+3) { text-align: center; }
.tts-language-table td:nth-child(2) { min-width: 10rem; }
.tts-language-table td:nth-child(2) progress { display: block; width: 100%; margin-top: .25rem; }
.tts-voice-list { display: grid; gap: .75rem; margin: 1rem 0; }
.tts-voice-row { display: grid; grid-template-columns: minmax(16rem, .8fr) minmax(20rem, 1.2fr); align-items: center; gap: 1rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--paper); }
.tts-voice-row > label { display: flex; align-items: center; gap: .8rem; cursor: pointer; }
.tts-voice-row > label span { display: grid; gap: .15rem; }
.tts-voice-row small { color: var(--muted); overflow-wrap: anywhere; }
.tts-preview-button { justify-content: flex-start; text-align: left; font-size: .9rem; }
.tts-cache-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: .75rem; }
.tts-failures { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.tts-failures-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.tts-failures-heading h3, .tts-failures-heading p { margin-top: 0; }
.tts-no-failures { padding: .8rem 1rem; border-radius: .8rem; background: color-mix(in srgb, var(--green) 13%, var(--paper)); color: var(--green); font-weight: 850; }
.profile-problem-settings { border-top: 1px solid var(--line); background: var(--paper); }
.profile-problem-settings > summary { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 1rem; cursor: pointer; font-weight: 850; }
.profile-problem-settings > summary small { color: var(--muted); font-weight: 700; }
.profile-problem-settings > form { padding: 0 1rem 1rem; }
.profile-learning-settings { border-top: 1px solid var(--line); background: var(--paper); }
.profile-learning-settings > summary { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 1rem; cursor: pointer; font-weight: 850; }
.profile-learning-settings > summary small { color: var(--muted); font-weight: 700; }
.profile-learning-content { padding: 0 1rem 1rem; }
.profile-learning-content > p { margin-top: 0; }
.achievements-heading h1 { max-width: 18ch; }
.achievement-summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, .7fr); align-items: center; gap: 1.5rem; }
.achievement-summary > div { display: flex; align-items: center; gap: 1rem; }
.achievement-summary-icon { display: grid; width: 4rem; height: 4rem; flex: 0 0 auto; place-items: center; border: 2px solid var(--ink); border-radius: 1.2rem; background: var(--yellow); font-size: 2rem; box-shadow: .18rem .18rem 0 var(--edge); }
.achievement-summary strong, .achievement-summary span { display: block; }
.achievement-summary strong { font-size: 1.65rem; }
.achievement-summary div span { color: var(--muted); }
.achievement-summary progress { width: 100%; height: 1rem; accent-color: var(--coral); }
.reward-ladder { background: linear-gradient(135deg, var(--surface), color-mix(in srgb, var(--blue) 18%, var(--surface))); }
.reward-ladder-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .7rem; }
.reward-ladder-grid article { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: .2rem .65rem; min-width: 0; padding: .85rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--paper); }
.reward-ladder-grid article > span { grid-row: 1 / 3; font-size: 2rem; }
.reward-ladder-grid strong { font-size: 1.55rem; }
.reward-ladder-grid small { color: var(--muted); line-height: 1.35; }
.achievement-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; margin: 1rem 0; }
.achievement-card { min-height: 17rem; position: relative; overflow: hidden; display: flex; flex-direction: column; padding: 1.2rem; border: 1px solid var(--line); border-radius: 1.2rem; background: var(--surface); }
.achievement-card.is-unlocked { border: 2px solid var(--ink); box-shadow: .2rem .2rem 0 var(--edge); }
.achievement-card.is-locked { justify-content: center; color: var(--muted); background: var(--input); border-style: dashed; filter: saturate(.25); }
.achievement-card .achievement-icon { display: grid; width: 3.4rem; height: 3.4rem; place-items: center; margin-bottom: .8rem; border-radius: 1rem; background: var(--paper); font-size: 1.75rem; }
.achievement-card h2 { margin: .1rem 0 .45rem; font-size: 1.35rem; }
.achievement-card > p:not(.eyebrow) { margin: 0; color: var(--muted); line-height: 1.5; }
.achievement-card dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; margin: auto 0 0; padding-top: 1rem; border-top: 1px solid var(--line); }
.achievement-card dl div { min-width: 0; }
.achievement-card dt { color: var(--muted); font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.achievement-card dd { margin: .18rem 0 0; font-size: .82rem; font-weight: 800; }
.achievement-empty { margin: 1rem 0; }
.achievement-empty > span { display: block; margin-bottom: .5rem; font-size: 2.5rem; }
.achievement-locked-count { margin: .75rem 0 1.5rem; color: var(--muted); font-size: .9rem; }
.rarity-gold, .rarity-diamant { background: linear-gradient(145deg, var(--surface), var(--yellow)); }
.logbook-panel { margin-top: 1rem; }
.logbook-list { margin: 1.2rem 0 0; padding: 0; list-style: none; }
.logbook-list li { display: grid; grid-template-columns: 6rem 2.8rem minmax(0, 1fr); gap: .8rem; align-items: start; padding: 1rem 0; border-top: 1px solid var(--line); }
.logbook-list time strong, .logbook-list time span { display: block; }
.logbook-list time span { margin-top: .15rem; color: var(--muted); font-size: .76rem; }
.logbook-icon { display: grid; width: 2.5rem; height: 2.5rem; place-items: center; border-radius: .8rem; background: var(--input); font-size: 1.2rem; }
.logbook-list h3, .logbook-list p { margin: 0; }
.logbook-list p { margin-top: .25rem; color: var(--muted); line-height: 1.45; }
.achievement-toast { max-width: 70%; margin: 0; padding: .55rem; border: 1px solid var(--line); border-radius: .9rem; background: color-mix(in srgb, var(--yellow) 42%, var(--surface)); text-align: left; }
.achievement-toast > p { margin: 0 0 .5rem; text-align: center; }
.achievement-toast > div { display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem; }
.achievement-toast-item { display: flex; align-items: center; gap: .4rem; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: .7rem; color: var(--ink); background: var(--surface); text-decoration: none; }
.achievement-toast-item.is-new { border: 2px solid var(--ink); }
.achievement-toast-item > span:first-child { font-size: 1.25rem; }
.achievement-toast-item strong, .achievement-toast-item small { display: block; }
.achievement-toast-item strong { font-size: .78rem; }
.achievement-toast-item small { color: var(--muted); font-size: .65rem; }
.language-toggles { margin: 0; padding: 1rem; border: 1px solid var(--line); border-radius: .85rem; background: var(--surface); }
.language-toggles legend { padding: 0 .35rem; color: var(--ink); font-weight: 850; }
.language-toggles > p { margin: 0 0 .8rem; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.language-toggles > div { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; }
.language-toggles label { display: flex; align-items: center; gap: .45rem; padding: .65rem; border: 1px solid var(--line); border-radius: .7rem; color: var(--ink); background: var(--paper); }
.language-toggles input { width: 1.1rem; min-height: 1.1rem; }
.home-assistant-panel { border-top: 1px solid var(--line); background: var(--paper); }
.home-assistant-panel > summary { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding: 1rem; cursor: pointer; font-weight: 850; }
.home-assistant-panel > summary small { color: var(--muted); font-weight: 700; }
.home-assistant-content { display: grid; gap: 1.2rem; padding: 0 1rem 1rem; }
.home-assistant-status { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: .85rem; background: var(--surface); }
.home-assistant-status p { margin: 0; }
.api-code-block { min-width: 0; }
.api-code-block > div { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .55rem; }
.api-code-block h3 { margin: 0; }
.api-code-block textarea { min-height: 0; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: .78rem; line-height: 1.5; white-space: pre; }
.api-code-block .notice { margin: 0 0 .65rem; }
.api-rotate-form { display: flex; justify-content: flex-end; margin: 0; }

.inline-filter { display: flex; align-items: end; gap: .7rem; }
.inline-filter label { min-width: 12rem; }
.statistics-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.statistics-heading > div { min-width: 0; }
.statistics-heading h1 { max-width: 16ch; font-size: clamp(2.3rem, 5vw, 3.8rem); }
.phase-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin-top: 1.2rem; }
.phase-card { min-height: 9rem; padding: 1rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--surface); }
.phase-card > span { color: var(--muted); font-size: .76rem; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.phase-card > strong { display: block; margin: .35rem 0; font-size: 2rem; }
.phase-card h3, .phase-card h2, .phase-card p { margin: .2rem 0 0; }
.phase-card p { color: var(--muted); font-size: .86rem; }
.phase-0 { background: var(--phase-0); } .phase-1 { background: var(--phase-1); } .phase-2 { background: var(--phase-2); }
.phase-3 { background: var(--phase-3); } .phase-4 { background: var(--phase-4); } .phase-5 { background: var(--phase-5); }
.phase-6 { background: var(--phase-6); } .phase-7 { background: var(--phase-7); } .phase-8 { background: var(--mint); }
.language-stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-top: 1rem; }
.language-stat { display: grid; gap: .35rem; padding: 1rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--paper); text-decoration: none; }
.language-stat:hover { border-color: var(--ink); }
.language-stat span { color: var(--muted); font-size: .86rem; }
.table-scroll { margin-top: 1rem; overflow-x: auto; }
.page-statistics .panel { min-width: 0; }
.page-statistics .table-scroll { max-width: 100%; }
.progress-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.progress-table th, .progress-table td { padding: .85rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
.progress-table th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
.progress-table th a { color: inherit; text-decoration: none; }
.progress-table th a:hover { color: var(--ink); text-decoration: underline; }
.progress-table td:first-child { min-width: 14rem; white-space: normal; }
.progress-table td small { display: block; margin-top: .25rem; color: var(--muted); }
.progress-table .is-due { color: var(--red); font-weight: 800; }
@media (max-width: 760px) {
  .page-statistics .responsive-stat-scroll { overflow-x: visible; }
  .responsive-stat-table, .responsive-stat-table tbody, .responsive-stat-table tr, .responsive-stat-table td { display: block; width: 100%; }
  .responsive-stat-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .responsive-stat-table tbody { display: grid; gap: .75rem; }
  .responsive-stat-table tbody tr { padding: .45rem .85rem; border: 1px solid var(--line); border-radius: .85rem; background: var(--paper); }
  .responsive-stat-table td, .responsive-stat-table td:first-child { min-width: 0; padding: .5rem 0; border-bottom: 1px solid var(--line); white-space: normal; overflow-wrap: anywhere; }
  .responsive-stat-table td:last-child { border-bottom: 0; }
  .responsive-stat-table td::before { content: attr(data-label); display: block; margin-bottom: .15rem; color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
  .responsive-stat-table td:first-child { font-size: 1rem; }
}
.phase-badge { display: inline-flex; padding: .28rem .5rem; border: 1px solid rgba(16,35,63,.25); border-radius: .55rem; font-size: .78rem; font-weight: 850; }
.phase-waiting { color: var(--muted); background: var(--input); }
.phase-active { color: var(--ink); background: var(--mint); }
.phase-disabled { color: var(--ink); background: var(--yellow); }
.word-stat-filters { display: flex; flex-wrap: wrap; align-items: end; justify-content: flex-end; gap: .55rem; }
.word-stat-filters label { min-width: 9rem; }
.word-stat-filters select { min-height: 2.7rem; padding: .5rem .7rem; }
.reactivate-word-form { margin-top: .5rem; }
.auto-disabled-notice { margin: 1rem 0; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: .8rem; background: var(--yellow); color: var(--ink); }
.track-grid { display: grid; gap: .8rem; margin-top: 1.2rem; }
.track-card { padding: 1rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--paper); }
.track-title { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.track-title span, .track-meta { color: var(--muted); font-size: .84rem; }
.track-form { --track-control-height: 3.2rem; display: grid; grid-template-columns: repeat(3, minmax(8rem, 1fr)) auto; align-items: end; gap: .7rem; }
.track-form > label { grid-template-rows: auto var(--track-control-height); align-self: end; }
.track-form > label > input,
.track-form > label > select,
.track-form > .button { height: var(--track-control-height); min-height: var(--track-control-height); max-height: var(--track-control-height); }
.track-form [hidden] { display: none; }
.track-meta { margin: .8rem 0 0; }
.sequence-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1.5rem; }
.sequence-heading .eyebrow, .sequence-heading .muted { margin: 0; }
.sequence-heading .muted { max-width: 46rem; font-size: .9rem; text-align: right; }
.sequence-flow { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.15fr) auto minmax(0, 1fr); align-items: stretch; gap: .65rem; margin-top: 1.15rem; }
.sequence-step { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: .3rem; padding: .85rem 1rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--soft-surface); }
.sequence-step small { color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.sequence-step strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sequence-current { border-color: var(--ink); background: var(--deck-two); }
.sequence-endpoint { border-style: dashed; }
.sequence-endpoint strong { color: var(--coral); }
.sequence-arrow { display: grid; place-items: center; color: var(--coral); font-size: 1.45rem; font-weight: 900; }
.sequence-form { display: grid; grid-template-columns: minmax(16rem, 1fr) auto; align-items: end; gap: .7rem; max-width: 42rem; margin: 1.2rem 0 0 auto; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.phase-timeline { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; margin: 2rem 0; }
.phase-timeline .phase-card { min-height: 10rem; display: flex; flex-direction: column; justify-content: space-between; border: 2px solid var(--ink); box-shadow: .18rem .18rem 0 var(--edge); }
.phase-timeline .phase-card strong { font-size: 1rem; }
.help-intro { font-size: 1.08rem; line-height: 1.65; }
.faq-list details { padding: 1rem 0; border-top: 1px solid var(--line); }
.faq-list summary { cursor: pointer; font-weight: 820; }
.faq-list details p { max-width: 52rem; color: var(--muted); line-height: 1.65; }
.app-device-overview { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.app-device-overview h2 { margin: .2rem 0; }
.device-version-pills { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }
.device-version-pills span { padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 99rem; background: var(--input); font-size: .82rem; font-weight: 800; }
.profile-devices { grid-column: 1 / -1; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.profile-devices h3 { display: flex; align-items: center; gap: .5rem; }
.profile-devices h3 small { display: inline-grid; min-width: 1.7rem; height: 1.7rem; place-items: center; border-radius: 99rem; background: var(--input); }
.app-device-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .8rem; padding: .8rem 0; border-top: 1px solid var(--line); }
.app-device-card p, .app-device-card small { display: block; margin: .15rem 0 0; color: var(--muted); }
.app-device-icon { display: grid; width: 2.7rem; height: 2.7rem; place-items: center; border: 2px solid var(--ink); border-radius: .8rem; background: var(--mint); font-size: 1.4rem; }

@media (max-width: 800px) {
  /* The account menu remains the single reachable mobile theme control. */
  .theme-toggle { display: none !important; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .admin-navigation { position: sticky; top: 5.2rem; z-index: 8; overflow-x: auto; }
  .admin-navigation a { flex: 1 0 auto; }
  .settings-heading { align-items: flex-start; flex-direction: column; }
  .profile-edit-context { align-items: flex-start; flex-direction: column; }
  .profile-edit-context .scope-badge { margin-left: 0; }
  .tts-voice-row { grid-template-columns: 1fr; }
  .tts-progress-summary { grid-template-columns: 1fr; }
  .tts-progress-summary p { grid-column: 1; }
  .tts-failures-heading { display: grid; }
  .tts-preview-button { width: 100%; }
  .topbar { flex-wrap: wrap; gap: .5rem; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; }
  .topbar nav a { flex: 1 0 auto; text-align: center; }
  .brand > span:last-child { display: none; }
  .hero { grid-template-columns: 1fr; align-items: start; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .streak-grid { grid-template-columns: 1fr; }
  .deck-row { grid-template-columns: minmax(0, 1fr) auto; }
  .word-list, .two-columns { grid-template-columns: 1fr; }
  .anki-model-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .anki-model-title { grid-column: 1 / -1; }
  .anki-sample-preview { grid-column: 1 / -1; }
  .phase-grid, .phase-timeline { grid-template-columns: repeat(2, 1fr); }
  .language-stat-grid { grid-template-columns: 1fr; }
  .track-form, .sequence-form, .danger-zone-content { grid-template-columns: 1fr; }
  .sequence-heading { align-items: flex-start; flex-direction: column; gap: .45rem; }
  .sequence-heading .muted { text-align: left; }
  .sequence-flow { grid-template-columns: 1fr; }
  .sequence-arrow { min-height: 1.2rem; transform: rotate(90deg); }
  .language-toggles > div { grid-template-columns: repeat(2, 1fr); }
  .language-unit-grid { grid-template-columns: 1fr; }
  .achievement-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .achievement-summary { grid-template-columns: 1fr; }
  .reward-ladder-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-assistant-status { align-items: flex-start; flex-direction: column; }
  .app-device-overview { align-items: flex-start; flex-direction: column; }
  .device-version-pills { justify-content: flex-start; }
}

@media (max-width: 520px) {
  .app-shell { width: min(100% - 1rem, 72rem); padding-top: 1.2rem; }
  .topbar { padding-inline: .7rem; }
  .logout-form .button { padding-inline: .4rem; }
  .hero { border-radius: 1.4rem; box-shadow: .35rem .35rem 0 var(--edge); }
  .stat-card { min-height: 8rem; padding: 1rem; }
  .form-grid, .profile-grid { grid-template-columns: 1fr; }
  .span-two { grid-column: auto; }
  .reward-ladder-grid { grid-template-columns: 1fr; }
  .deck-row { gap: .45rem .7rem; padding: .75rem .8rem; }
  .deck-row h2 { font-size: .92rem; }
  .answer-form { grid-template-columns: 1fr; }
  .panel-heading { flex-direction: column; }
  .anki-upload-form, .anki-model-form { grid-template-columns: 1fr; }
  .anki-model-title { grid-column: auto; align-items: start; flex-direction: column; gap: .2rem; }
  .anki-sample-preview { grid-column: auto; }
  .anki-sample-heading { align-items: start; flex-direction: column; gap: .2rem; }
  .anki-sample-table { overflow-x: auto; }
  .anki-sample-labels, .anki-sample-row { min-width: 34rem; }
  .learn-card, .feedback-card { margin-top: 0; border-radius: 1.4rem; box-shadow: .35rem .35rem 0 var(--edge); }
  .page-heading { align-items: start; flex-direction: column; }
  .inline-filter { width: 100%; align-items: stretch; flex-direction: column; }
  .statistics-heading { display: flex; }
  .phase-grid, .phase-timeline { grid-template-columns: 1fr; }
  .word-edit-form { grid-template-columns: 1fr; }
  .word-hint-field, .word-edit-actions { grid-column: auto; }
  .word-edit-actions { align-items: stretch; flex-direction: column; }
  .heading-actions { width: 100%; justify-content: stretch; }
  .heading-actions .button { flex: 1; }
  .vocabulary-book-groups { padding-left: .65rem; }
  .vocabulary-audio-list > article { grid-template-columns: 1fr auto; }
  .vocabulary-audio-list > article form { grid-column: 1 / -1; }
  .vocabulary-audio-list > article form .button { width: 100%; }
  .language-toggles > div { grid-template-columns: 1fr; }
  .home-assistant-panel > summary { align-items: flex-start; flex-direction: column; }
  .app-device-card { grid-template-columns: auto minmax(0, 1fr); }
  .app-device-card form { grid-column: 1 / -1; }
  .language-unit-card { min-height: 7rem; padding: 1rem; }
  .language-unit-flag { font-size: 2.7rem; }
  .language-welcome { margin-top: 0; border-radius: 1.4rem; box-shadow: .35rem .35rem 0 var(--edge); }
  .welcome-flag { font-size: 6.5rem; }
  .feedback-actions, .welcome-actions { align-items: stretch; }
  .feedback-actions { flex-direction: row; flex-wrap: nowrap; }
  .feedback-actions .feedback-sound-button { flex: 0 0 4.25rem; width: 4.25rem; }
  .feedback-actions [data-next-card] { flex: 1 1 auto; width: auto; }
  .welcome-actions { flex-direction: column; }
  .welcome-actions .button { width: 100%; }
  .learning-complete { margin-top: 0; border-radius: 1.4rem; box-shadow: .35rem .35rem 0 var(--edge); }
  .completion-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .completion-actions { flex-direction: column; align-items: stretch; }
  .completion-actions .button { width: 100%; }
  .achievement-grid { grid-template-columns: 1fr; }
  .achievement-card { min-height: 14rem; }
  .logbook-list li { grid-template-columns: 4.7rem 2.5rem minmax(0, 1fr); gap: .55rem; }

}

/* Touch keyboards also reduce the usable height on wide tablets and landscape phones. */
@media (max-width: 680px), (hover: none) and (pointer: coarse) {
  body.keyboard-active .topbar,
  body.keyboard-active .site-footer,
  body.keyboard-active .theme-toggle { display: none; }
  body.keyboard-active .app-shell { width: 100%; padding: .75rem .5rem; }
  body.page-learn.keyboard-active:has(.learn-card:not(.answer-card-keeper)) .app-shell {
    position: fixed;
    top: var(--learning-visible-top, 0px);
    left: 0;
    right: 0;
    height: var(--learning-visible-height, 100dvh);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
  }
  body.keyboard-active .learn-card,
  body.keyboard-active .feedback-card { width: 100%; margin: 0; padding: 1rem; border-radius: 1.2rem; box-shadow: none; }
  body.keyboard-active .learn-meta { align-items: center; gap: .45rem; font-size: .76rem; }
  body.keyboard-active .prompt-label { margin: 1.15rem 0 .3rem; font-size: .9rem; }
  body.keyboard-active .learn-card h1 { margin: .2rem 0 1.2rem; font-size: clamp(2.8rem, 15vw, 4.5rem); }
  body.keyboard-active .learn-card h1.term-medium { font-size: clamp(1.55rem, 6.8vw, 2.35rem); line-height: 1; overflow-wrap: anywhere; }
  body.keyboard-active .learn-card h1.term-long { font-size: clamp(1.35rem, 5.6vw, 1.95rem); line-height: 1.04; overflow-wrap: anywhere; }
  body.keyboard-active .learn-card h1.term-very-long { font-size: clamp(1.15rem, 4.8vw, 1.55rem); line-height: 1.1; letter-spacing: -.025em; overflow-wrap: anywhere; }
  body.keyboard-active .hint { margin: .45rem 0; font-size: .84rem; }
  body.keyboard-active .answer-form { gap: .5rem; }
  body.keyboard-active .answer-form input { min-height: 3.7rem; padding-block: .55rem; font-size: 1.08rem; }
  body.keyboard-active .answer-form .button { min-height: 3.25rem; padding-block: .55rem; }
  body.keyboard-active .goal-celebration { justify-content: flex-start; gap: .35rem; margin: 0 0 .45rem; padding: .35rem .55rem; border-radius: .7rem; }
  body.keyboard-active .goal-celebration > span { font-size: .95rem; }
  body.keyboard-active .goal-celebration strong { font-size: .76rem; }
  body.keyboard-active .goal-celebration small { margin-left: auto; font-size: .63rem; }
  body.keyboard-active .feedback-heading { gap: .45rem; margin-bottom: .4rem; }
  body.keyboard-active .feedback-result { gap: .35rem; }
  body.keyboard-active .feedback-icon { width: 2.25rem; height: 2.25rem; font-size: 1rem; }
  body.keyboard-active .feedback-result .eyebrow { font-size: .72rem; }
  body.keyboard-active .feedback-card h1 { margin: .2rem 0 .55rem; font-size: clamp(2.8rem, 15vw, 4.5rem); }
  body.keyboard-active .feedback-card h1.term-medium { font-size: clamp(1.55rem, 6.8vw, 2.35rem); line-height: 1; overflow-wrap: anywhere; }
  body.keyboard-active .feedback-card h1.term-long { font-size: clamp(1.35rem, 5.6vw, 1.95rem); line-height: 1.04; overflow-wrap: anywhere; }
  body.keyboard-active .feedback-card h1.term-very-long { font-size: clamp(1.15rem, 4.8vw, 1.55rem); line-height: 1.1; letter-spacing: -.025em; overflow-wrap: anywhere; }
  body.keyboard-active .feedback-card .muted { margin: .35rem 0; line-height: 1.35; }
  body.keyboard-active .feedback-card .daily-progress { margin: .75rem 0 .45rem; }
  body.keyboard-active .achievement-toast { max-width: 68%; padding: .3rem; }
  body.keyboard-active .achievement-toast > p { margin-bottom: .2rem; font-size: .66rem; text-align: left; }
  body.keyboard-active .achievement-toast > div { justify-content: flex-start; gap: .25rem; }
  body.keyboard-active .achievement-toast-item { padding: .22rem .3rem; }
  body.keyboard-active .achievement-toast-item > span:first-child { font-size: .95rem; }
  body.keyboard-active .achievement-toast-item strong { font-size: .7rem; }
  body.keyboard-active .achievement-toast-item small { font-size: .58rem; }
  body.keyboard-active .feedback-card .feedback-actions { margin-top: .75rem; }
  body.keyboard-active .feedback-card .button { min-height: 3.25rem; }
  body.keyboard-active .learning-context { margin: 0 0 .25rem; font-size: .76rem; }
  body.keyboard-active .feedback-card > p { margin: .4rem 0; }
}

@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
  body.keyboard-active .app-shell { padding: .35rem; }
  body.keyboard-active .feedback-card { padding-block: .55rem; }
  body.keyboard-active .feedback-card .feedback-heading { margin-bottom: .15rem; }
  body.keyboard-active .feedback-card .feedback-actions { margin-top: .35rem; }
  body.keyboard-active .feedback-card .daily-progress { margin: .35rem 0; }
  body.keyboard-active .feedback-card .button { min-height: 2.75rem; padding-block: .45rem; }
  body.keyboard-active .learn-card { padding: .5rem .7rem; }
  body.keyboard-active .learn-card .prompt-label { margin: .3rem 0 .15rem; }
  body.keyboard-active .learn-card h1.term-long,
  body.keyboard-active .learn-card h1.term-very-long { font-size: 1rem; margin: .2rem 0 .4rem; line-height: 1.1; }
  body.keyboard-active .answer-form input { min-height: 2.75rem; font-size: 1rem; }
  body.keyboard-active .answer-form .button { min-height: 2.75rem; }
  body.page-learn.keyboard-active .feedback-card h1.term-long,
  body.page-learn.keyboard-active .feedback-card h1.term-very-long { font-size: 1rem; line-height: 1.1; }
  body.keyboard-active .feedback-card .learning-context { font-size: .65rem; }
  body.keyboard-active .feedback-card > p { margin: .15rem 0; font-size: .75rem; }
  body.page-learn.keyboard-active:has(.feedback-card) .app-shell {
    position: fixed;
    top: var(--learning-visible-top, 0px);
    left: 0;
    right: 0;
    height: var(--learning-visible-height, 100dvh);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
  }
}

/* A phone remains short in landscape after the software keyboard closes. */
@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
  .page-learn:has(.learn-card, .feedback-card) .topbar,
  .page-learn:has(.learn-card, .feedback-card) .site-footer { display: none; }
  .page-learn:has(.learn-card, .feedback-card) .app-shell { width: 100%; padding: .5rem; }
  .page-learn .learn-card, .page-learn .feedback-card { width: 100%; margin: 0; padding: .7rem 1rem; box-shadow: none; }
  .page-learn .feedback-card h1 { margin: .3rem 0; font-size: 2rem; line-height: 1.1; }
  .page-learn .feedback-card h1.term-long,
  .page-learn .feedback-card h1.term-very-long { font-size: 1.3rem; }
  .page-learn .feedback-card > p { margin: .3rem 0; font-size: .85rem; }
  .page-learn .feedback-card > .notice { padding: .35rem .6rem; }
  .page-learn .feedback-actions, .page-learn .daily-progress { margin-block: .4rem; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }

/* Long learning text uses the available width instead of a narrow desktop card. */
.page-learn:has(.learning-term.term-long, .learning-term.term-very-long) .app-shell {
  width: calc(100% - 2rem);
}
.page-learn .learn-card:has(.learning-term.term-long, .learning-term.term-very-long),
.page-learn .feedback-card:has(.learning-term.term-long, .learning-term.term-very-long) {
  width: 100%;
  padding-inline: clamp(1rem, 2vw, 2rem);
  text-align: center;
}
/* Tablet learning controls stay centered; text can still use the full card. */
@media (hover: none) and (pointer: coarse) and (min-width: 681px) {
  .page-learn .answer-form { grid-template-columns: minmax(0, 1fr); }
  .page-learn .answer-form > button[type="submit"] {
    width: 50%;
    min-width: min(100%, 12rem);
    justify-self: center;
  }
  .page-learn .feedback-card .feedback-actions {
    width: 50%;
    min-width: min(100%, 22rem);
    margin-inline: auto;
    flex-wrap: nowrap;
  }
  .page-learn .feedback-card .feedback-actions [data-next-card] { min-width: 0; flex: 1 1 auto; }
}
@media (max-width: 680px), (hover: none) and (pointer: coarse) {
  .page-learn.keyboard-active:has(.learning-term.term-long, .learning-term.term-very-long) .app-shell {
    width: 100%;
  }
}

.account-shell { max-width: 1100px; }
.account-shell h1 { font-size: clamp(2rem, 5vw, 3.8rem); overflow-wrap: anywhere; }
.account-shell .button-row { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem; }
.account-shell details { padding: 1rem 0; }
.account-shell summary { cursor: pointer; font-weight: 700; }
.account-shell details form { margin-top: 1rem; }
.account-profile { padding: 1.4rem 0; border-bottom: 1px solid var(--line); }
.wizard-books { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1.2rem; }
.wizard-book { display: flex; flex-direction: column; align-items: flex-start; gap: .6rem; padding: 1rem; border: 2px solid var(--line); border-radius: 1rem; cursor: pointer; }
.wizard-book:has(input:checked) { border-color: var(--coral, #ff8177); background: var(--surface); outline: 2px solid var(--coral, #ff8177); }
.wizard-book input { width: auto; }
.book-cover { width: 100%; height: 230px; object-fit: contain; border-radius: .5rem; }
.wizard-book strong, .wizard-book small { overflow-wrap: anywhere; }
.account-shell input[type=checkbox] { width: auto; margin-right: .5rem; }

/* Shared application shell. Learning cards retain their larger, playful controls. */
body { background: var(--paper); }
.unified-header { gap: 2rem; padding-block: 1rem; position: relative; z-index: 30; }
.unified-header .brand-mini { box-shadow: none; border-width: 1px; }
.unified-header .primary-navigation { margin-left: auto; }
.unified-header a { text-decoration: none; }
.account-menu { position: relative; margin: 0; padding: 0; }
.account-menu > summary { cursor: pointer; list-style: none; border: 1px solid var(--line); border-radius: .7rem; padding: .65rem .9rem; font-size: .9rem; font-weight: 600; }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu-content { position: absolute; right: 0; top: calc(100% + .5rem); width: 240px; padding: .5rem; background: var(--surface); border: 1px solid var(--line); border-radius: .85rem; box-shadow: var(--shadow); }
.account-menu-content a, .account-menu-content button { display: block; width: 100%; padding: .75rem; text-align: left; background: none; border: 0; border-radius: .45rem; color: var(--ink); font: inherit; cursor: pointer; }
.account-menu-content a:hover, .account-menu-content button:hover { background: var(--input); }
.account-menu-content form { margin: .3rem 0 0; border-top: 1px solid var(--line); }
.section-tabs { display: flex; gap: 1.5rem; border-bottom: 1px solid var(--line); margin-bottom: 2rem; }
.section-tabs a { padding: .8rem .2rem; text-decoration: none; color: var(--muted); }
.section-tabs [aria-current] { border-bottom: 3px solid var(--coral); color: var(--ink); }
.workspace-layout.app-shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 2.5rem; max-width: 1320px; padding-top: 2.25rem; }
.workspace-sidebar { align-self: start; position: sticky; top: 1.5rem; }
.workspace-sidebar .eyebrow { margin: 0 0 1rem; font-size: .7rem; }
.workspace-sidebar nav { display: grid; gap: .3rem; }
.workspace-sidebar nav a { padding: .75rem .85rem; border-radius: .65rem; color: var(--muted); text-decoration: none; font-weight: 550; font-size: .95rem; }
.workspace-sidebar nav a:hover { background: var(--surface); color: var(--ink); }
.workspace-sidebar nav a[aria-current] { color: var(--ink); background: var(--surface); box-shadow: inset 3px 0 var(--coral); }
.workspace-test-badge { display: inline-block; margin-left: .3rem; padding: .12rem .35rem; border: 1px solid var(--line); border-radius: .4rem; color: var(--muted); font-size: .67rem; font-weight: 750; vertical-align: middle; }
.workspace-back { display: block; margin-top: 1.5rem; padding: .5rem .85rem; color: var(--muted); font-size: .85rem; text-decoration: none; }
.workspace-content { min-width: 0; }
.workspace-mobile-nav { display: none; }
.wizard-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: .8rem; }
.wizard-choice { display: grid; grid-template-columns: auto 1fr; gap: .5rem .75rem; border: 1px solid var(--line); border-radius: 12px; padding: 1rem; background: var(--surface); cursor: pointer; }
.wizard-choice input { width: auto; align-self: start; margin-top: .2rem; }
.wizard-choice small { grid-column: 2; color: var(--muted); }
.wizard-choice:has(input:checked), .wizard-book:has(input:checked) { outline: 2px solid var(--accent, #ff8275); outline-offset: 2px; }
.wizard-choice:focus-within { outline: 3px solid var(--accent, #ff8275); }
.wizard-chapter-sections { display: grid; gap: .7rem; min-width: 0; }
.account-shell .wizard-chapter-section { padding: 0; border: 1px solid var(--line); border-radius: .85rem; background: var(--surface); overflow: hidden; }
.account-shell .wizard-chapter-section > summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .35rem 1rem; padding: 1rem 1.15rem; list-style: none; }
.account-shell .wizard-chapter-section > summary::-webkit-details-marker { display: none; }
.account-shell .wizard-chapter-section > summary::before { content: '▸'; color: var(--muted); }
.account-shell .wizard-chapter-section[open] > summary::before { content: '▾'; }
.account-shell .wizard-chapter-section > summary strong { flex: 1; }
.account-shell .wizard-chapter-section > summary small { color: var(--muted); text-align: right; }
.wizard-chapter-section > .wizard-choices { padding: 0 1.15rem 1.15rem; }
.deck-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 1rem; margin: 1.5rem 0 2rem; }
.deck-card { display: flex; flex-direction: column; gap: .65rem; min-width: 0; padding: 1.25rem; border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); text-decoration: none; overflow-wrap: anywhere; }
.deck-card h2, .deck-card p { margin: 0; }
.deck-card p, .deck-grade { color: var(--muted); font-size: .85rem; line-height: 1.5; }
.deck-card:hover, .chapter-row:hover { border-color: var(--coral); background: var(--input); }
.book-catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.book-language-section { margin: 1.75rem 0 2.5rem; }
.book-language-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding-bottom: .7rem; border-bottom: 1px solid var(--line); }
.book-language-heading h2 { margin: 0; font-size: 1.2rem; }
.book-language-heading > span { color: var(--muted); font-size: .85rem; }
.book-catalog-card { flex-direction: row; align-items: flex-start; gap: 1.1rem; }
.catalog-cover { flex: 0 0 76px; width: 76px; height: 108px; object-fit: contain; border-radius: .35rem; background: var(--paper); }
.catalog-copy { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; gap: .55rem; }
.catalog-copy h2 { font-size: 1.15rem; line-height: 1.35; }
.catalog-copy .deck-word-count { white-space: normal; font-size: .8rem; }
.catalog-open { font-size: .85rem; font-weight: 600; margin-top: .25rem; }
.chapter-list-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem; margin: 2rem 0 1rem; }
.chapter-list-heading h2 { margin: 0; }
.chapter-list-heading > span { color: var(--muted); font-size: .85rem; }
.chapter-list { display: grid; gap: .55rem; margin-bottom: 2rem; }
.chapter-section { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: .9rem; background: var(--surface); }
.chapter-section > summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.15rem; cursor: pointer; list-style: none; }
.chapter-section > summary::-webkit-details-marker { display: none; }
.chapter-section > summary::after { content: '⌄'; color: var(--muted); font-size: 1.2rem; transform: rotate(-90deg); }
.chapter-section[open] > summary::after { transform: none; }
.chapter-section > summary > span:first-child { display: grid; min-width: 0; gap: .2rem; }
.chapter-section > summary strong { font-size: .95rem; }
.chapter-section > summary small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.chapter-section-count { margin-left: auto; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.chapter-section-rows { display: grid; gap: .4rem; padding: .2rem .65rem .7rem; }
.chapter-row { display: grid; grid-template-columns: 2.25rem minmax(0, 1fr) auto auto; align-items: center; gap: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: .7rem; background: var(--surface); color: var(--ink); text-decoration: none; }
.chapter-number { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: .55rem; background: var(--input); font-size: .85rem; color: var(--muted); }
.chapter-row .chapter-copy h2 { font-size: 1rem; line-height: 1.4; margin: 0; overflow-wrap: anywhere; }
.chapter-copy small, .chapter-count { color: var(--muted); font-size: .8rem; }
.chapter-count { white-space: nowrap; }
.page-books .page-heading, .page-book .page-heading { align-items: flex-start; flex-wrap: wrap; }
.page-books .page-heading > div:first-child, .page-book .page-heading > div:first-child { min-width: 0; flex: 1 1 auto; }
.page-books .heading-actions { flex-wrap: wrap; }
@media (max-width: 1100px) { .book-catalog { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 520px) {
  .chapter-section-count { display: none; }
  .book-catalog-card { padding: 1rem; gap: .85rem; }
  .catalog-cover { flex-basis: 60px; width: 60px; height: 86px; }
  .chapter-row { grid-template-columns: 1.75rem minmax(0, 1fr) auto; gap: .65rem; padding: .85rem; }
  .chapter-number { width: 1.75rem; height: 1.75rem; }
  .chapter-count { grid-column: 2; }
  .chapter-row > span:last-child { grid-column: 3; grid-row: 1 / 3; }
}
.workspace-page { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
.workspace-page h1, .workspace-page h2, .workspace-page h3 { font-family: ui-rounded, 'SF Pro Rounded', 'Avenir Next', system-ui, sans-serif; }
.workspace-page h1 { font-size: clamp(1.8rem, 3vw, 2.6rem); line-height: 1.2; letter-spacing: -.035em; margin: .35rem 0 1rem; }
.workspace-page h2 { font-size: 1.2rem; line-height: 1.4; margin: 0 0 1rem; }
.workspace-page h3 { font-size: 1rem; }
.workspace-page .page-heading { margin-bottom: 1.5rem; }
.workspace-page .panel { border: 1px solid var(--line); border-radius: 1rem; padding: 1.5rem; box-shadow: none; margin-bottom: 1.25rem; }
.workspace-page .settings-heading .eyebrow, .workspace-page .scope-personal { display: none; }
.workspace-page .form-grid { gap: 1.25rem; align-items: start; }
.workspace-page label { font-size: .875rem; font-weight: 550; gap: .5rem; }
.workspace-page label small { font-size: .78rem; font-weight: 400; line-height: 1.4; }
.workspace-page input:not([type=checkbox]):not([type=radio]), .workspace-page select, .workspace-page textarea { border: 1px solid var(--line); border-radius: .6rem; min-height: 44px; padding: .65rem .8rem; font-size: .95rem; font-weight: 400; margin: 0; width: 100%; }
.workspace-page input[type=checkbox], .workspace-page input[type=radio] { width: 1.15rem; height: 1.15rem; flex-shrink: 0; accent-color: var(--green); }
.workspace-page label > span:has(> input[type=checkbox]) { display: flex; align-items: flex-start; gap: .65rem; line-height: 1.5; }
.workspace-page label > span > input[type=checkbox] { margin: .1rem 0 0; }
.workspace-page .button { border-radius: .6rem; border-width: 1px; min-height: 44px; padding: .65rem 1rem; box-shadow: none; font-size: .9rem; font-weight: 600; width: fit-content; max-width: 100%; justify-self: start; transform: none; }
.workspace-page .form-grid > .button { grid-column: 1 / -1; }
.workspace-page .button-secondary { border-color: var(--line); background: transparent; color: var(--ink); }
.workspace-page .button-primary { border-color: transparent; }
.workspace-page p { line-height: 1.6; }
.workspace-page .profile-editor-grid { display: block; }
.workspace-page .profile-editor { border: 1px solid var(--line); box-shadow: none; border-radius: 1rem; }
.workspace-page .profile-editor > summary { padding: 1.25rem; }
.workspace-page details > summary { cursor: pointer; }
.workspace-page .language-toggles { border: 1px solid var(--line); }
.workspace-page .language-toggles label { border: 0; background: transparent; padding: .5rem; }
.workspace-page .inline-filter { margin-bottom: 1.5rem; align-items: end; }
.workspace-page .button-row { display: flex; flex-wrap: wrap; gap: .75rem; }
.workspace-page .account-profile { padding: 1.25rem 0; }
.workspace-page .account-profile details { padding: 1rem 0; }
.workspace-page .account-profile details form { margin-top: 1rem; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.setting-row p { margin: .4rem 0; }
.user-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; margin-top: 1rem; }
.user-picker a { border: 1px solid var(--line); border-radius: .65rem; padding: .85rem; text-decoration: none; }
.user-picker small { display: block; color: var(--muted); margin-top: .3rem; }
.user-picker [aria-current] { border-color: var(--coral); background: var(--input); }
.workspace-page .user-search { display: flex; align-items: end; flex-wrap: wrap; }
.user-search label { flex: 1 1 220px; }
.workspace-page [hidden] { display: none !important; }
:where(a, button, input, select, summary, textarea):focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
body:not(.page-learn) .stat-card { background: var(--surface); border: 1px solid var(--line); box-shadow: none; border-radius: 1rem; }
body:not(.page-learn) .stat-card strong { font-size: clamp(2rem, 4vw, 3.25rem); }
body:not(.page-learn) .stat-card span { color: var(--muted); }
body:not(.page-learn) .page-heading h1 { font-size: clamp(1.9rem, 3.5vw, 2.8rem); line-height: 1.2; }
body:not(.page-learn) .button-secondary { box-shadow: none; border: 1px solid var(--line); }
body:not(.page-learn) .panel, body:not(.page-learn) .deck-card { border: 1px solid var(--line); box-shadow: none; }
.workspace-page .profile-editor > .profile-edit-context { padding-block: .65rem; font-size: .9rem; }
.workspace-page .profile-editor details { margin: 0; }
.workspace-page details.panel > form { margin-top: 1.25rem; }
@media (max-width: 760px) {
  body:has(.unified-header) { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .unified-header { padding: .75rem 1rem; flex-wrap: wrap; gap: .7rem; backdrop-filter: none; }
  .unified-header .brand { font-size: .85rem; }
  .unified-header .account-menu { margin-left: auto; }
  .unified-header .primary-navigation { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); padding: .5rem .5rem calc(.5rem + env(safe-area-inset-bottom)); display: flex; justify-content: space-around; margin: 0; gap: .25rem; }
  .unified-header .primary-navigation a { font-size: .8rem; padding: .65rem .35rem; }
  .workspace-layout.app-shell { display: block; width: 100%; padding: 1rem; }
  .workspace-sidebar { position: static; margin-bottom: 1.5rem; }
  .workspace-desktop-nav { display: none; }
  .workspace-mobile-nav { display: block; padding: 0 !important; border: 1px solid var(--line); border-radius: .7rem; background: var(--surface); }
  .workspace-mobile-nav > summary { padding: .8rem; list-style: none; display: flex; justify-content: space-between; }
  .workspace-mobile-nav > summary::-webkit-details-marker { display: none; }
  .workspace-sidebar nav { display: grid; gap: .25rem; padding: .25rem; }
  .workspace-sidebar nav a { white-space: nowrap; flex-shrink: 0; font-size: .85rem; }
  .workspace-sidebar nav a[aria-current] { box-shadow: inset 0 -3px var(--coral); }
  .workspace-back { margin-top: .25rem; padding-left: 0; }
  .workspace-page .panel { padding: 1.1rem; }
  .workspace-page .form-grid { grid-template-columns: minmax(0, 1fr); }
  .workspace-page .span-two { grid-column: 1; }
  .workspace-page .button { min-height: 44px; }
  .setting-row { align-items: flex-start; flex-direction: column; }
  .workspace-page .inline-filter { align-items: stretch; }
  .workspace-page .inline-filter label { width: 100%; }
}
