/* Parla: iOS-inspired web UI. The existing semantic token names are shared with app.js. */
:root {
  color-scheme: light;
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-secondary: #eeeef2;
  --surface-elevated: #ffffff;
  --ink: #1c1c1e;
  --muted: #636366;
  --line: #d9d9df;
  --green: #077a57;
  --green-dark: #066447;
  --on-accent: #ffffff;
  --mint: #e8f5ef;
  --mint-ink: #126747;
  --peach: #fff3de;
  --peach-ink: #7c4c00;
  --error: #b52a26;
  --error-bg: #ffedeb;
  --nav-material: rgba(249, 249, 252, .94);
  --shadow: 0 8px 28px rgba(0, 0, 0, .08);
  --sheet-shadow: 0 -12px 60px rgba(0, 0, 0, .18);
  --radius: 16px;
  --control-radius: 12px;
  --page-inset: 20px;
  --content-width: 680px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --bottom-nav-height: calc(max(66px, 4.5rem) + var(--safe-bottom));
  --keyboard-inset: 0px;
  --viewport-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
[data-theme='dark'] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-secondary: #2c2c2e;
  --surface-elevated: #2c2c2e;
  --ink: #f2f2f7;
  --muted: #aeaeb2;
  --line: #3a3a3c;
  --green: #67d8b4;
  --green-dark: #8ae5c6;
  --on-accent: #003d2c;
  --mint: #143d30;
  --mint-ink: #a0e8ca;
  --peach: #372c18;
  --peach-ink: #f0ca88;
  --error: #ff9b95;
  --error-bg: #482421;
  --nav-material: rgba(28, 28, 30, .94);
  --shadow: 0 8px 28px rgba(0, 0, 0, .22);
  --sheet-shadow: 0 -12px 60px rgba(0, 0, 0, .4);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; scroll-padding-top: calc(var(--safe-top) + 12px); }
body { margin: 0; min-height: var(--viewport-height); background: var(--bg); color: var(--ink); font-size: 1.0625rem; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button { min-width: 44px; min-height: 44px; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button, a, input, select, textarea, summary { touch-action: manipulation; }
button, input, select, textarea { transition: background-color .16s ease, border-color .16s ease, opacity .16s ease; }
button:active:not(:disabled) { opacity: .64; }
button:disabled { cursor: default; opacity: .45; }
:where(button, input, select, textarea, a, summary):focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }
/* These are reading targets for screen changes, not interactive controls. */
.app-shell > main[tabindex='-1']:focus, .dialog-header > h2[tabindex='-1']:focus { outline: none; }
a { color: var(--green); text-underline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 2.125rem; line-height: 1.15; letter-spacing: -.9px; font-weight: 750; overflow-wrap: anywhere; }
h2 { font-size: 1.3125rem; line-height: 1.25; letter-spacing: -.35px; font-weight: 700; }
h3 { font-size: 1.0625rem; line-height: 1.3; font-weight: 650; }
p { line-height: 1.55; }
.icon { width: 22px; height: 22px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* App navigation. Material is reserved for the fixed tab bar and reading tools. */
.app-shell { width: 100%; max-width: var(--content-width); margin: auto; padding: calc(12px + var(--safe-top)) var(--page-inset) calc(94px + var(--safe-bottom)); }
.app-shell { padding-left: max(var(--page-inset), var(--safe-left)); padding-right: max(var(--page-inset), var(--safe-right)); }
.conversation-shell { padding-bottom: calc(24px + var(--safe-bottom)); }
.topbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; margin-bottom: 22px; }
.brand { display: inline-flex; gap: 7px; align-items: center; font-size: 1.3125rem; font-weight: 750; letter-spacing: -.7px; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 27px; height: 30px; color: var(--green); }
.brand-mark svg { width: 27px; height: 27px; }
.topbar-actions { display: flex; align-items: center; gap: 5px; min-width: 0; }
.topbar > .topbar-actions:last-child { margin-left: auto; }
.language-tag { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-size: .8125rem; color: var(--green); background: transparent; padding: 8px 4px; min-width: 0; overflow-wrap: normal; }
.topbar:has(.topbar-actions .brand) .language-tag { display: none; }
.icon-button { display: inline-grid; place-items: center; width: 44px; min-width: 44px; height: 44px; padding: 10px; border-radius: 50%; background: var(--surface-secondary); color: var(--green); flex: 0 0 auto; }
.topbar .icon-button { background: transparent; }
.refresh-button { color: var(--muted); }
.refresh-button .icon { width: 20px; height: 20px; }
.bottom-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; z-index: 20; left: 50%; bottom: 0; width: min(100%, var(--content-width)); transform: translateX(-50%); padding: 5px max(4px, var(--safe-right)) calc(5px + var(--safe-bottom)) max(4px, var(--safe-left)); border-top: .5px solid var(--line); background: var(--nav-material); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.nav-button { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 3px; min-width: 0; min-height: 54px; padding: 5px 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: .6875rem; font-weight: 550; line-height: 1.3; overflow-wrap: anywhere; }
.nav-button .icon { width: 24px; height: 24px; }
.nav-button.active { color: var(--green); font-weight: 650; }
[data-keyboard='open'] .bottom-nav { display: none; }
.page-heading { margin: 0 0 24px; }
.page-heading:has(.heading-action) { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 10px; align-items: center; }
.heading-action { background: var(--green); color: var(--on-accent); }
.eyebrow { color: var(--muted); font-size: .8125rem; font-weight: 500; line-height: 1.4; }
.page-heading .eyebrow { margin-bottom: 6px; }
.page-heading .subtext, .page-subtitle { margin-top: 9px; max-width: 54ch; }
.subtext, .page-subtitle { color: var(--muted); font-size: .9375rem; line-height: 1.5; }
.section-title, .section-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; margin: 28px 0 12px; }
.section-title > *, .section-header > * { min-width: 0; overflow-wrap: anywhere; }
.section-title h2, .section-header h2 { font-size: 1.25rem; }
.section-title .subtext { margin-top: 6px; }
.section-title .text-button { font-size: .875rem; }

/* Controls use one accent, quiet secondary fills and explicit interactive states. */
.primary, .secondary, .add-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 50px; padding: 12px 16px; border-radius: var(--control-radius); font-size: 1rem; font-weight: 600; line-height: 1.35; text-align: center; }
.primary { background: var(--green); color: var(--on-accent); }
.secondary { background: var(--surface-secondary); color: var(--green); }
.primary.full, .secondary.full { width: 100%; }
.text-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 9px 4px; background: transparent; color: var(--green); font-size: .9375rem; font-weight: 500; line-height: 1.4; }
.text-button .icon { width: 20px; height: 20px; }
.add-button { width: 100%; margin-top: 16px; background: var(--surface); color: var(--green); }
input:not([type='checkbox']), select, textarea { width: 100%; min-width: 0; min-height: 48px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--control-radius); background: var(--surface); color: var(--ink); font-size: 1rem; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, select:focus, textarea:focus { border-color: var(--green); }
input[type='checkbox'] { accent-color: var(--green); }
textarea { resize: vertical; line-height: 1.5; }
.search-box { position: relative; margin-bottom: 14px; }
.search-box > .icon { position: absolute; top: 13px; left: 13px; width: 21px; height: 21px; color: var(--muted); pointer-events: none; }
.search-box input { min-height: 48px; padding-left: 43px; border-color: transparent; background: var(--surface-secondary); }
.filters { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 4px; border-radius: 12px; background: var(--surface-secondary); margin: 0 0 20px; }
.filters::-webkit-scrollbar { display: none; }
.filter { flex: 1 0 auto; min-height: 44px; padding: 9px 12px; border-radius: 9px; background: transparent; font-size: .8125rem; font-weight: 500; white-space: nowrap; }
.filter.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); font-weight: 650; }
.catalog-suggestions:not(:empty) { margin: 0 0 18px; }
.catalog-suggestions .form-note { margin: 8px 4px 10px; }
.word-search-section, .catalog-search-section { min-width: 0; }
.word-search-section > .section-title { margin-top: 0; }
.word-search-section > .section-title h2, .catalog-search-section > .section-title h2 { font-size: 1rem; }
.catalog-search-section { margin-top: 24px; }
.catalog-search-section > .section-title { margin-bottom: 10px; }
.catalog-search-section > .form-note { margin: 8px 3px 12px; }
.catalog-search-section .catalog-suggestions:not(:empty) { margin-bottom: 0; }
.field-label { display: block; font-size: .9375rem; font-weight: 600; margin-bottom: 9px; }
.form-note { color: var(--muted); font-size: .8125rem; line-height: 1.5; margin: 12px 0 20px; }
.error-message { padding: 14px 16px; border-radius: 12px; background: var(--error-bg); color: var(--error); font-size: .9375rem; line-height: 1.5; margin: 14px 0; overflow-wrap: anywhere; }

/* Words form a grouped list. The word, translation and progress carry hierarchy. */
.word-list, .native-list { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.word-row, .native-row { display: flex; width: 100%; align-items: center; gap: 12px; padding: 16px; text-align: left; background: transparent; }
.word-row + .word-row, .native-row + .native-row { border-top: .5px solid var(--line); }
.word-initial { display: grid; place-items: center; width: 38px; height: 40px; border-radius: 10px; background: var(--surface-secondary); color: var(--muted); font-size: 1.25rem; font-weight: 500; flex: 0 0 auto; }
.word-text { min-width: 0; flex: 1; }
.word-term { font-size: 1.0625rem; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.word-translation { font-size: .875rem; line-height: 1.4; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.word-cefr { display: inline-block; margin-left: 7px; padding: 3px 5px; border-radius: 5px; background: var(--surface-secondary); color: var(--muted); font: 550 .6875rem/1.2 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; vertical-align: middle; white-space: nowrap; }
.word-row > .icon { width: 16px; height: 16px; color: var(--muted); }
.word-progress-summary { display: grid; justify-items: end; gap: 5px; flex: 0 0 auto; max-width: 75px; text-align: right; font-size: .75rem; color: var(--muted); }
.word-progress-summary .goal-line { width: 42px; margin: 0; }
.word-status { display: block; margin-top: 6px; color: var(--green); font-size: .8125rem; }
.goal-line { height: 4px; border-radius: 4px; background: var(--line); margin-top: 12px; overflow: hidden; }
.goal-line > span { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.word-progress { display: grid; gap: 12px; margin-top: 20px; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: left; }
.word-progress .goal-line { margin: 0; }
.word-progress .stage-top strong { white-space: nowrap; }
.recommendation-row { cursor: pointer; }
.recommendation-row > input { width: 22px; height: 22px; min-height: 22px; margin: 0; padding: 0; flex: 0 0 auto; }
.recommendation-row .word-translation { display: block; }
.recommendation-list { max-height: min(48dvh, 480px); overflow-y: auto; overscroll-behavior: contain; }
.recommendation-row:has(input:checked) { background: var(--mint); }
.recommendation-row:has(input:disabled) { cursor: default; opacity: .6; }
.word-summary { display: flex; align-items: center; gap: 16px; }
.word-summary-copy { min-width: 0; flex: 1; }

/* Practice overview and progress: compact data, one clear next action. */
.hero, .practice-overview { padding: 22px; background: var(--surface); border-radius: var(--radius); margin-bottom: 20px; }
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.hero .eyebrow { color: var(--muted); font-size: .9375rem; }
.hero-count { margin: 12px 0 4px; font-size: 2.75rem; letter-spacing: -1.7px; line-height: 1.1; font-weight: 700; font-variant-numeric: tabular-nums; }
.hero-copy { color: var(--muted); font-size: .9375rem; }
.practice-title { font-size: 1.125rem; }
.practice-ready-count { display: flex; align-items: baseline; gap: 10px; }
.hero-illustration { display: none; }
.hero-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.hero-footer .primary { flex: 1 0 160px; }
.hero-footer .text-button { flex: 1 1 120px; font-size: .8125rem; }
.practice-overview .hero-footer { display: grid; gap: 12px; margin-top: 10px; }
.practice-length { justify-content: flex-start; font-size: .875rem !important; }
.session-time { color: var(--muted); font-size: .8125rem; }
.today-study > .subtext { margin-top: 8px; }
.today-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 16px; margin: -7px 2px 20px; color: var(--muted); font-size: .8125rem; line-height: 1.5; }
.today-summary > span { display: inline-flex; align-items: center; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.today-summary strong { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.today-summary .icon { width: 16px; height: 16px; color: var(--green); }
.today-actions { overflow: hidden; margin-top: 20px; border-radius: var(--radius); background: var(--surface); }
.today-action { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 76px; padding: 14px 16px; background: transparent; color: var(--ink); text-align: left; }
.today-action + .today-action { border-top: .5px solid var(--line); }
.today-action:focus-visible { outline-offset: -3px; }
.today-action > .icon:first-child { color: var(--green); }
.today-action > .icon:last-child { width: 16px; height: 18px; color: var(--muted); }
.today-action-copy { display: grid; flex: 1; min-width: 0; gap: 3px; overflow-wrap: anywhere; }
.today-action-copy strong { font-size: 1rem; font-weight: 600; line-height: 1.35; }
.today-action-copy small, .today-action-copy .subtext { font-size: .8125rem; line-height: 1.4; color: var(--muted); }
.today-reading { min-width: 0; }
.today-reading-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin: 24px 0 12px; }
.today-reading-heading h2 { font-size: 1.25rem; }
.today-reading-heading .text-button { font-size: .875rem; }
.today-reading > .book-row { border-radius: var(--radius); background: var(--surface); }
.today-reading .book-position { margin-top: 3px; }
.mini-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); margin-bottom: 24px; border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.metric { min-width: 0; padding: 18px 16px; }
.metric:nth-child(even) { border-left: .5px solid var(--line); }
.metric:nth-last-child(n+3) { border-bottom: .5px solid var(--line); }
.metric-top { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .8125rem; line-height: 1.4; }
.metric-top > span { min-width: 0; overflow-wrap: anywhere; }
.metric-top .icon { width: 17px; height: 17px; color: var(--green); }
.metric-number { margin-top: 9px; font-size: 1.75rem; font-weight: 650; letter-spacing: -.8px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric-number small { margin-left: 5px; font-size: .8125rem; font-weight: 400; color: var(--muted); letter-spacing: 0; }
.insight { display: flex; gap: 10px; padding: 18px 3px; color: var(--muted); font-size: .8125rem; line-height: 1.5; }
.insight .icon { margin-top: 1px; width: 18px; height: 18px; }
.progress-hero { display: flex; align-items: center; gap: 20px; padding: 20px; border-radius: var(--radius); background: var(--surface); margin-bottom: 18px; }
.progress-ring { width: 102px; height: 102px; flex: 0 0 auto; padding: 7px; border-radius: 50%; background: conic-gradient(var(--green) var(--progress, 0%), var(--surface-secondary) 0); }
.progress-ring-inner { width: 100%; height: 100%; border-radius: 50%; background: var(--surface); display: flex; flex-direction: column; justify-content: center; align-items: center; }
.progress-ring strong { font-size: 1.875rem; letter-spacing: -.9px; }
.progress-ring small { margin-top: 2px; font-size: .75rem; color: var(--muted); }
.progress-hero h3 { margin-bottom: 7px; }
.progress-hero .subtext { font-size: .8125rem; }
.progress-today-count { color: var(--green); font-size: 2.375rem; font-weight: 650; letter-spacing: -1px; line-height: 1.15; }
.progress-overview > p { color: var(--muted); font-size: 1rem; max-width: 23ch; }
.progress-stages { display: grid; gap: 21px; padding: 20px; border-radius: var(--radius); background: var(--surface); }
.stage-top { display: flex; justify-content: space-between; gap: 12px; font-size: .9375rem; }
.stage-top strong { font-weight: 600; }
.stage .goal-line { margin-top: 9px; }

/* Profile follows the grouped-summary and calendar conventions of a phone app. */
.profile-greeting { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.profile-avatar { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--mint); color: var(--green); font-size: 1.375rem; font-weight: 600; flex: 0 0 auto; }
.profile-name { font-size: 1.0625rem; font-weight: 600; margin-top: 2px; }
.conversation-metrics { margin-bottom: 12px; }
.honesty-note { color: var(--muted); font-size: .8125rem; line-height: 1.5; margin: 0 3px 24px; }
.profile-empty { margin: 16px 3px; }
.calendar-card { padding: 18px 16px 16px; border-radius: var(--radius); background: var(--surface); }
.calendar-card > .eyebrow { font-size: .9375rem; font-weight: 600; color: var(--ink); }
.calendar-controls { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 8px 0 12px; }
.calendar-controls h3 { text-transform: capitalize; font-size: 1rem; text-align: center; }
.calendar-controls .icon-button { background: transparent; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px 3px; }
.calendar-weekday, .calendar-day, .calendar-blank { display: grid; place-items: center; min-height: 34px; text-align: center; font-size: .875rem; border-radius: 50%; }
.calendar-weekday { color: var(--muted); font-size: .75rem; min-height: 27px; }
.calendar-day { color: var(--muted); }
.calendar-day.active { background: var(--mint); color: var(--green); font-weight: 650; }
.calendar-day.current { outline: 1.5px solid var(--green); outline-offset: -2px; color: var(--green); }
.calendar-note { color: var(--muted); text-align: center; font-size: .75rem; margin: 16px 0; }
.calendar-footer { display: flex; align-items: center; gap: 8px; border-top: .5px solid var(--line); padding-top: 16px; font-size: .8125rem; color: var(--muted); }
.calendar-footer .icon { width: 18px; height: 18px; color: var(--green); }
.calendar-footer strong { margin-left: auto; color: var(--ink); font-weight: 600; white-space: nowrap; }
.saved-words-card { display: flex; align-items: center; gap: 14px; width: 100%; padding: 18px 20px; margin-top: 20px; border-radius: var(--radius); background: var(--surface); text-align: left; }
.saved-words-card > div { flex: 1; min-width: 0; }
.saved-count { display: block; font-size: 1.875rem; font-weight: 650; letter-spacing: -.8px; margin: 6px 0 3px; }
.saved-words-card .subtext { font-size: .8125rem; }
.saved-words-card > .icon { color: var(--green); width: 25px; height: 25px; }
.saved-words-card > .icon:last-child { width: 16px; height: 16px; color: var(--muted); }
.training-link { width: 100%; margin: 8px 0; font-size: .9375rem; }

/* Settings: labelled rows, visible switch state, ordinary system controls. */
.settings-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.settings-form > * { min-width: 0; }
.settings-card { min-width: 0; padding: 20px; border-radius: var(--radius); background: var(--surface); overflow-wrap: anywhere; }
.settings-card > h2 { margin-bottom: 18px; font-size: 1.125rem; }
.settings-field { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 18px; }
.settings-field label { font-size: .9375rem; }
.settings-field select { min-height: 48px; background: var(--surface-secondary); border-color: transparent; padding-right: 28px; }
.settings-toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; margin-top: 18px; padding-top: 18px; border-top: .5px solid var(--line); font-size: .9375rem; cursor: pointer; }
.settings-toggle input { appearance: none; -webkit-appearance: none; position: relative; flex: 0 0 51px; width: 51px; height: 31px; min-height: 31px; border: 0; padding: 0; margin: 7px 0; border-radius: 20px; background: var(--line); cursor: pointer; }
.settings-toggle input::before { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #ffffff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .16s ease; }
.settings-toggle input:checked { background: var(--green); }
.settings-toggle input:checked::before { transform: translateX(20px); }
.settings-card textarea { display: block; min-height: 110px; font-size: 1rem; background: var(--surface-secondary); border-color: transparent; }
.settings-card .form-note { margin-bottom: 0; }
.settings-note { color: var(--muted); font-size: .8125rem; margin: 0 4px; }
.settings-savebar { position: fixed; z-index: 14; left: 50%; bottom: calc(var(--bottom-nav-height) + 8px); transform: translateX(-50%); display: grid; gap: 8px; width: min(calc(100% - 2 * var(--page-inset)), calc(var(--content-width) - 2 * var(--page-inset))); max-height: calc(var(--viewport-height) - var(--bottom-nav-height) - var(--safe-top) - 24px); overflow-y: auto; overscroll-behavior: contain; padding: 12px; border: .5px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.settings-form.has-unsaved-settings { padding-bottom: calc(var(--settings-savebar-height, 8rem) + 16px); }
.settings-save-note { color: var(--muted); font-size: .8125rem; line-height: 1.4; margin: 0 3px; }
.settings-savebar .error-message { margin: 0; padding: 10px 12px; font-size: .8125rem; }
[data-keyboard='open'] .settings-savebar { bottom: calc(var(--keyboard-inset) + 8px); }
.settings-footer { margin-top: 22px; text-align: center; }
.settings-footer .text-button { font-size: .8125rem; color: var(--muted); }
.topic-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.topic-chip { min-height: 44px; padding: 10px 13px; border-radius: 10px; font-size: .875rem; color: var(--green); background: var(--mint); }

/* Modals become bottom sheets on phones, with native dialog focus/escape handling. */
dialog { position: fixed; inset: auto 0 var(--keyboard-inset); width: min(100%, var(--content-width)); max-width: 100%; max-height: calc(var(--viewport-height) - var(--safe-top) - 16px); margin: 0 auto; padding: 24px max(20px, var(--safe-right)) calc(20px + var(--safe-bottom)) max(20px, var(--safe-left)); border: 0; border-radius: 24px 24px 0 0; background: var(--surface-elevated); color: var(--ink); box-shadow: var(--sheet-shadow); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
dialog::backdrop { background: rgba(0, 0, 0, .38); }
.sheet-grabber { width: 34px; height: 5px; margin: -13px auto 18px; border-radius: 8px; background: var(--line); }
.dialog-header, .sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.dialog-header h2 { min-width: 0; font-size: 1.5rem; line-height: 1.2; letter-spacing: -.5px; overflow-wrap: anywhere; }
.dialog-header .icon-button { color: var(--muted); background: var(--surface-secondary); }
.sheet-body { min-width: 0; }
.dialog-translation { font-size: 1.375rem; line-height: 1.35; margin-bottom: 10px; }
.dialog-meaning { color: var(--muted); font-size: .9375rem; margin-bottom: 20px; }
.dialog-translation, .dialog-meaning, .example, .option, .exercise-translation { overflow-wrap: anywhere; }
.example { padding: 16px; margin: 20px 0; background: var(--surface-secondary); border-radius: 12px; }
.example p { font-size: 1.0625rem; line-height: 1.5; }
.example .subtext { margin-top: 8px; font-size: .9375rem; }
.dialog-actions { display: grid; gap: 10px; margin-top: 22px; }
.dialog-actions .text-button { color: var(--muted); }
.save-confirmation .dialog-actions { margin-top: 20px; }
.unsaved-dialog .dialog-actions .danger { color: var(--error); }
.lookup-sheet .dialog-header h2 { font-size: 1.0625rem; font-weight: 500; color: var(--muted); }
.lookup-term-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.lookup-term { font-size: 2rem; line-height: 1.15; letter-spacing: -.7px; overflow-wrap: anywhere; }
.phonetic { color: var(--muted); font-size: .9375rem; }
.lookup-term-line .audio-button { margin: 0 0 0 auto; font-size: .875rem; padding: 10px 12px; }
.lookup-term-line .error-message { flex-basis: 100%; }
.lookup-translation { font-size: 1.375rem; margin-top: 18px; line-height: 1.35; overflow-wrap: anywhere; }
.lookup-meaning { margin-top: 10px; font-size: .9375rem; color: var(--muted); }
.lookup-body .example > .eyebrow { font-size: .8125rem; margin-bottom: 8px; }
.lookup-body > .primary { margin-top: 20px; }
.lookup-note { font-size: .8125rem; color: var(--muted); text-align: center; margin: 12px 8px 0; }

/* The exercise is the focus: readable prompt, large answers, quiet task chrome. */
.session-shell { max-width: var(--content-width); min-height: var(--viewport-height); padding: calc(8px + var(--safe-top)) var(--page-inset) calc(8px + var(--safe-bottom)); margin: auto; display: flex; flex-direction: column; }
.session-shell { padding-left: max(var(--page-inset), var(--safe-left)); padding-right: max(var(--page-inset), var(--safe-right)); }
.session-shell.has-session-actions { padding-bottom: calc(var(--session-actions-height, 5.5rem) + 12px); }
.session-header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.session-header .icon-button { background: transparent; color: var(--muted); }
.session-progress { flex: 1; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.session-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--green); transition: width .2s ease; }
.session-count { font-size: .8125rem; font-weight: 550; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.exercise-heading { margin-bottom: 12px; }
.exercise-title { font-size: 1.375rem; line-height: 1.25; letter-spacing: -.4px; }
.exercise-card { margin: 0 0 12px; padding: 14px; background: var(--surface); border-radius: var(--radius); text-align: center; }
.exercise-term { font-size: 1.875rem; font-weight: 650; letter-spacing: -.7px; line-height: 1.15; overflow-wrap: anywhere; }
.exercise-term-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; min-width: 0; }
.exercise-term-row > .exercise-term, .exercise-term-row > .feedback-answer { min-width: 0; }
.exercise-term-row > .exercise-term { max-width: 100%; }
.exercise-term-row > .feedback-answer { margin: 0; }
.exercise-translation { color: var(--muted); margin-top: 6px; font-size: 1.0625rem; line-height: 1.4; }
.exercise-prompt { font-size: 1.5rem; line-height: 1.35; letter-spacing: -.3px; }
.exercise-details { margin-top: 8px; text-align: left; }
.exercise-details-label { margin: 0 0 6px; color: var(--muted); font-size: .9375rem; font-weight: 500; }
.session-shell .exercise-details .example { margin: 4px 0 0; padding: 12px; text-align: left; }
.session-shell .exercise-details .example p { font-size: 1rem; }
.session-shell .exercise-details .example .subtext { font-size: .9375rem; }
.audio-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 11px 15px; margin-top: 18px; border-radius: 12px; background: var(--mint); color: var(--green); font-size: .9375rem; font-weight: 600; }
.audio-button.large { display: flex; width: 88px; height: 88px; margin: 2px auto 16px; border-radius: 50%; }
.audio-button.large .icon { width: 36px; height: 36px; }
.session-shell .audio-button.compact { flex: 0 0 44px; width: 44px; height: 44px; margin: 0; padding: 10px; }
.session-shell .audio-button.large { width: 64px; height: 64px; margin: 0 auto 8px; }
.session-shell .audio-button.large .icon { width: 29px; height: 29px; }
.listening-note { color: var(--muted); font-size: .875rem; }
.options { display: grid; gap: 6px; }
.option { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 46px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-align: left; font-size: 1.0625rem; line-height: 1.35; }
.option > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.option-index { display: grid; place-items: center; width: 25px; height: 25px; flex: 0 0 auto; border-radius: 50%; background: var(--surface-secondary); color: var(--muted); font-size: .8125rem; font-weight: 500; }
.option.selected { border-color: var(--green); background: var(--mint); }
.option.selected .option-index { background: var(--green); color: var(--on-accent); }
.answer-input { font-size: 1.0625rem !important; min-height: 50px !important; }
.exercise-footer { margin-top: auto; padding-top: 4px; text-align: center; }
.exercise-footer .text-button { color: var(--muted); }
.session-actions { position: fixed; z-index: 18; left: 50%; bottom: 0; transform: translateX(-50%); display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; width: min(100%, var(--content-width)); padding: 10px max(var(--page-inset), var(--safe-right)) calc(8px + var(--safe-bottom)) max(var(--page-inset), var(--safe-left)); border-top: .5px solid var(--line); background: var(--bg); }
.session-actions > .primary { flex: 1 1 9rem; min-width: 0; }
.session-actions > .text-button { flex: 0 1 auto; color: var(--muted); }
[data-keyboard='open'] .session-actions { bottom: var(--keyboard-inset); padding-bottom: 8px; }
.feedback { margin: 0; padding: 16px; border-radius: var(--radius); background: var(--mint); }
.feedback.incorrect { background: var(--peach); }
.feedback.neutral { background: var(--surface); }
.feedback-title { display: flex; gap: 9px; align-items: center; font-size: 1.25rem; font-weight: 650; }
.feedback .feedback-answer { margin: 10px 0 4px; font-size: 1.5rem; line-height: 1.3; font-weight: 600; overflow-wrap: anywhere; }
.feedback .exercise-term-row { justify-content: space-between; margin-top: 12px; }
.feedback .exercise-term-row .feedback-answer { margin: 0; }
.feedback .subtext { color: var(--mint-ink); font-size: .9375rem; }
.feedback.incorrect .subtext { color: var(--peach-ink); }
.feedback.neutral .subtext { color: var(--muted); }
.feedback .example { padding: 0; background: none; margin-bottom: 0; }
.session-shell[data-mode] .word-photo { margin: 10px 0 0; }
.session-shell[data-mode] .word-photo > img { height: 180px; max-height: none; aspect-ratio: auto; object-fit: contain; }
.session-shell[data-mode='image'] .image-exercise { padding: 10px; }
.session-shell[data-mode='image'] .word-photo { margin: 0; }
.session-shell[data-mode] .photo-credit { margin-top: 6px; }
@media (max-height: 760px) {
  .session-shell[data-mode] .word-photo > img { height: 144px; }
}
@media (max-height: 620px) {
  .session-shell { padding-top: calc(4px + var(--safe-top)); }
  .session-header { margin-bottom: 6px; }
  .exercise-heading { margin-bottom: 8px; }
  .exercise-card { padding: 12px; margin-bottom: 8px; }
  .session-shell[data-mode] .word-photo > img { height: 112px; }
  .session-shell[data-mode='image'] .image-exercise { padding: 8px; }
}
.completion { display: flex; align-items: center; justify-content: center; flex: 1; flex-direction: column; padding: 24px 0; text-align: center; }
.completion-art { display: grid; place-items: center; width: 96px; height: 96px; margin-bottom: 26px; border-radius: 50%; background: var(--mint); color: var(--green); }
.completion-art .icon { width: 46px; height: 46px; }
.completion h1 { margin-bottom: 12px; }
.completion .subtext { max-width: 40ch; }
.completion-metrics { display: flex; width: 100%; margin: 28px 0; border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.completion-metrics .metric { flex: 1; }
.completion-metrics .metric-top { justify-content: center; }

/* Conversation: inline words stay naturally sized for uninterrupted reading. */
.conversation-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; margin-bottom: 24px; border-radius: 12px; background: var(--surface-secondary); }
.conversation-tab { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 9px 10px; border-radius: 9px; background: transparent; font-size: .9375rem; font-weight: 500; }
.conversation-tab.active { background: var(--surface); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); font-weight: 600; }
.conversation-tab .icon { width: 19px; height: 19px; }
.reading-card, .explain-card { padding: 20px; border-radius: var(--radius); background: var(--surface); }
.reading-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.reading-meta time { color: var(--muted); font-size: .75rem; }
.conversation-voice { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 6px; align-items: center; margin-bottom: 8px; }
.conversation-voice > .icon-button { background: transparent; color: var(--muted); }
.conversation-voice > .icon-button .icon { width: 18px; height: 18px; }
.voice-time { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.conversation-voice .voice-position { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 44px; min-height: 44px; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; cursor: pointer; }
.voice-position::-webkit-slider-runnable-track { height: 2px; border-radius: 1px; background: var(--line); }
.voice-position::-webkit-slider-thumb { appearance: none; -webkit-appearance: none; width: 10px; height: 10px; margin-top: -4px; border: 0; border-radius: 50%; background: var(--muted); }
.voice-position::-moz-range-track { height: 2px; border-radius: 1px; background: var(--line); }
.voice-position::-moz-range-thumb { width: 10px; height: 10px; border: 0; border-radius: 50%; background: var(--muted); }
.voice-position:disabled { opacity: .45; cursor: default; }
.conversation-voice > .error-message { grid-column: 1 / -1; margin: 0; }
.reply-text { font-size: 1.3125rem; line-height: 1.8; white-space: pre-wrap; overflow-wrap: anywhere; }
.reply-word { display: inline; min-width: 0; min-height: 0; padding: 2px 0; border-radius: 4px; background: none; font: inherit; cursor: pointer; vertical-align: baseline; white-space: normal; user-select: text; }
.reply-word:hover, .reply-word:focus-visible, .reply-word.selected { background: var(--mint); color: var(--green); }
.reply-text.selecting .reply-word { border-bottom: 1px dashed var(--line); }
.reading-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.reading-actions .secondary { min-height: 44px; font-size: .9375rem; }
.reading-actions .text-button { font-size: .875rem; }
.translation-panel { margin-top: 18px; padding: 20px; border-radius: var(--radius); background: var(--surface); }
.translation-panel .eyebrow { margin-bottom: 10px; }
.translation-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1.0625rem; line-height: 1.65; }
.selection-bar { padding: 18px; border-radius: var(--radius); background: var(--surface); margin-top: 16px; }
.selection-bar .subtext { margin-bottom: 12px; }
.explain-card { margin-bottom: 16px; }
.explain-card > .eyebrow { margin-bottom: 14px; }
.learner-text { font-size: 1.1875rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.explain-label { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }
.explain-label .icon { width: 20px; height: 20px; color: var(--green); }
.explain-label h2 { font-size: 1.0625rem; }
.feedback-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1.0625rem; line-height: 1.7; }
.feedback-text + .feedback-text { margin-top: 16px; }
.tip-card { position: relative; padding: 20px; border-radius: var(--radius); background: var(--mint); margin: 16px 0 24px; }
.tip-card > .icon { position: absolute; top: 18px; right: 18px; color: var(--mint-ink); }
.tip-card .eyebrow { margin-right: 28px; margin-bottom: 12px; color: var(--mint-ink); }
.tip-card > p:last-child { font-size: 1rem; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Real photography belongs to the word, not to interface decoration. */
.word-photo { margin: 20px 0; min-width: 0; }
.word-photo > img { display: block; width: 100%; max-height: 300px; aspect-ratio: 4 / 3; object-fit: contain; border-radius: 12px; background: var(--surface-secondary); }
.photo-credit { color: var(--muted); font-size: .75rem; line-height: 1.5; margin-top: 10px; text-align: center; overflow-wrap: anywhere; }
.photo-credit a { display: inline-flex; align-items: center; min-height: 44px; color: inherit; }
.photo-credit summary { min-height: 44px; padding: 10px 0; cursor: pointer; }
.photo-error { padding: 24px 16px; border-radius: 12px; background: var(--surface-secondary); color: var(--muted); font-size: .9375rem; text-align: center; }
.image-exercise { padding: 12px; }
.image-exercise .word-photo { margin: 0; }
.image-exercise .word-photo > img { max-height: 300px; }
.feedback .word-photo > img { max-height: 220px; }
.image-admin-entry { margin-top: 24px; }
.image-admin-entry > .secondary + .secondary { margin-top: 10px; }
.image-setup-note { padding: 16px; margin: 0 0 20px; border-radius: 12px; color: var(--peach-ink); background: var(--peach); font-size: .875rem; overflow-wrap: anywhere; }
.image-pilot { margin-bottom: 24px; }
.image-pilot .form-note { margin: 9px 3px 0; }
.image-pilot .secondary { white-space: normal; }
.image-catalog-summary { color: var(--muted); font-size: .8125rem; margin: 16px 0; }
.image-catalog { display: grid; border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.image-catalog-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 16px; background: transparent; text-align: left; }
.image-catalog-row + .image-catalog-row { border-top: .5px solid var(--line); }
.image-catalog-mark { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 40px; border-radius: 10px; background: var(--surface-secondary); color: var(--muted); }
.image-catalog-mark.approved { color: var(--green); background: var(--mint); }
.image-catalog-text { display: grid; gap: 4px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.image-catalog-text strong { font-size: 1.0625rem; font-weight: 600; }
.image-catalog-text span { font-size: .875rem; color: var(--muted); }
.image-catalog-text small { font-size: .75rem; color: var(--muted); }
.image-catalog-row > .icon { width: 16px; height: 16px; color: var(--muted); }
.image-search-form { margin-top: 24px; }
.image-search-form .form-note { margin-bottom: 14px; }
.image-suggest { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; text-align: left; }
.image-search-form .image-setup-note { margin: 14px 0 0; }
.chosen-image:empty { display: none; }
.chosen-image { border-bottom: .5px solid var(--line); padding-bottom: 16px; }
.chosen-image .word-photo { margin: 12px 0; }
.chosen-image > .text-button { font-size: .875rem; color: var(--muted); }
.image-results { display: grid; gap: 20px; }
.image-results > .form-note { margin-bottom: 0; }
.image-candidate { min-width: 0; }
.image-candidate .word-photo { margin: 0 0 12px; }
.image-candidate .secondary { min-height: 46px; }

/* Library is a compact grouped list. Description and versions live in the detail. */
.book-library { min-width: 0; }
.book-list { overflow: hidden; border-radius: var(--radius); background: var(--surface); }
.book-row { position: relative; display: grid; grid-template-columns: 60px minmax(0, 1fr) 12px; align-items: center; gap: 12px; width: 100%; min-height: 110px; padding: 12px 14px; border-radius: 0; background: transparent; color: var(--ink); text-align: left; }
.book-row + .book-row::before { content: ''; position: absolute; top: 0; left: 86px; right: 0; height: .5px; background: var(--line); }
.book-row:focus-visible { outline-offset: -3px; }
.book-row > .icon { width: 12px; height: 18px; color: var(--muted); }
.book-row-info { display: grid; gap: 4px; min-width: 0; }
.book-row-title { display: block; font-size: 1.0625rem; line-height: 1.25; font-weight: 650; letter-spacing: -.2px; overflow-wrap: anywhere; }
.book-row-author { display: block; color: var(--muted); font-size: .8125rem; line-height: 1.3; overflow-wrap: anywhere; }
.book-row-meta { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 10px; row-gap: 3px; color: var(--muted); font-size: .75rem; line-height: 1.35; margin-top: 3px; }
.book-row-meta:empty { display: none; }
.book-row-levels { font-weight: 600; color: var(--green); }
.book-row-versions { overflow-wrap: anywhere; }
.library-book { display: block; padding: 20px; border-radius: var(--radius); background: var(--surface); }
.library-book-heading { display: flex; gap: 18px; align-items: center; }
.library-book-info { display: block; min-width: 0; }
.library-book-info > span { display: block; }
.library-book-title { display: block; margin: 8px 0; font-size: 1.375rem; line-height: 1.2; letter-spacing: -.5px; font-weight: 650; overflow-wrap: anywhere; }
.book-cover { position: relative; display: block; overflow: hidden; width: 94px; height: 139px; flex: 0 0 94px; background: #285649; color: #fff4d8; border-radius: 2px 5px 5px 2px; box-shadow: inset 3px 0 rgba(255, 255, 255, .18), 1px 2px 4px rgba(0, 0, 0, .12); }
.book-cover-fallback { display: flex; flex-direction: column; justify-content: space-between; height: 100%; padding: 14px 11px 14px 15px; }
.book-cover .icon { width: 24px; height: 24px; }
.book-cover-author { font-size: .625rem; line-height: 1.3; margin: 12px 0 5px; }
.book-cover-fallback strong { font: 1rem/1.2 Georgia, serif; overflow-wrap: anywhere; }
.book-cover-image { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; opacity: 0; }
.book-cover.has-image { background: var(--surface-secondary); }
.book-cover.has-image .book-cover-image { opacity: 1; }
.book-cover.book-cover-compact { width: 60px; height: 86px; min-height: 86px; flex-basis: 60px; padding: 0; }
.book-cover-compact .book-cover-fallback { justify-content: center; align-items: center; padding: 9px 7px 9px 10px; gap: 8px; }
.book-cover-compact .icon { width: 25px; height: 25px; flex-shrink: 0; }
.book-cover-compact .book-cover-fallback strong { font: 600 .625rem/1.2 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
.book-cover-tone-1 { background: #775338; }
.book-cover-tone-2 { background: #3d536e; }
.book-cover-tone-3 { background: #68516a; }
.book-description { display: block; margin: 18px 0; }
.book-versions-title { margin: 28px 0 12px; font-size: 1.25rem; }
.book-versions { display: grid; border-radius: 12px; overflow: hidden; background: var(--surface-secondary); }
.book-version { padding: 18px; }
.book-version + .book-version { border-top: .5px solid var(--line); }
.book-version-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.book-version-heading h3 { font-size: 1rem; }
.book-level { flex: 0 0 auto; padding: 5px 8px; border-radius: 7px; background: var(--mint); color: var(--mint-ink); font-size: .8125rem; font-weight: 600; }
.book-level-note, .book-length, .book-position { color: var(--muted); font-size: .8125rem; line-height: 1.5; margin-top: 10px; }
.book-version .secondary { margin-top: 16px; min-height: 46px; background: var(--surface); }
.book-version .goal-line { margin-top: 9px; }
.book-about { color: var(--muted); font-size: .8125rem; line-height: 1.6; margin-top: 24px; }
.book-about summary { min-height: 44px; padding: 10px 0; cursor: pointer; }
.book-about p { margin: 8px 0; }
.book-about a { display: inline-flex; align-items: center; min-height: 44px; }
.book-about .book-cover-source { display: flex; }

/* Reading retains book typography; surrounding controls follow the app system. */
.book-reader { --book-font-size: 1.3125rem; background: var(--bg); color: var(--ink); overflow-anchor: none; }
.book-reader[data-reader-theme='dark'] { color-scheme: dark; --bg: #000000; --surface: #1c1c1e; --surface-secondary: #2c2c2e; --ink: #f2f2f7; --muted: #aeaeb2; --line: #3a3a3c; --green: #67d8b4; --on-accent: #003d2c; --mint: #143d30; --mint-ink: #a0e8ca; }
.book-reader[data-reader-theme='light'] { color-scheme: light; --bg: #f2f2f7; --surface: #ffffff; --surface-secondary: #eeeef2; --ink: #1c1c1e; --muted: #636366; --line: #d9d9df; --green: #077a57; --on-accent: #ffffff; --mint: #e8f5ef; --mint-ink: #126747; }
.book-reader .page-heading h1 { font-size: 1.75rem; }
.reader-edition-row { display: flex; align-items: center; gap: 10px; }
.reader-version-select { flex: 1; max-width: 100%; font-size: .9375rem; }
.reader-edition-row .text-button { flex: 0 0 auto; }
.reader-dock { position: sticky; top: calc(var(--safe-top) + 6px); z-index: 12; padding: 8px 12px; margin: 20px 0 26px; border: .5px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.reader-tools { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 8px 12px; margin: 20px 0 26px; border: .5px solid var(--line); border-radius: 14px; background: var(--surface); }
.reader-tool { min-width: 44px; min-height: 44px; padding: 8px; border-radius: 10px; background: var(--surface-secondary); font-size: 1rem; }
.reader-parallel-control { display: flex; align-items: center; justify-content: flex-end; gap: 7px; flex: 1; min-height: 44px; font-size: .8125rem; line-height: 1.3; cursor: pointer; }
.reader-parallel-control input { width: 19px; height: 19px; min-height: 19px; padding: 0; margin: 0; flex: 0 0 auto; }
.reader-lookup { max-height: min(33dvh, 280px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.reader-lookup > strong { display: block; font-size: 1rem; }
.reader-lookup-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.reader-lookup-top .eyebrow { font-size: .8125rem; margin-bottom: 4px; }
.reader-lookup-top .icon-button { margin: -6px -4px 0 0; background: transparent; }
.reader-word-meaning { display: block; font-size: 1rem; line-height: 1.4; overflow-wrap: anywhere; }
.reader-sentence-translation { font-size: .9375rem; line-height: 1.5; margin: 10px 0 2px; }
.reader-save-word { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 10px 12px; margin-top: 10px; border-radius: 10px; color: var(--green); background: var(--mint); font-size: .9375rem; font-weight: 550; }
.reader-save-word .icon { width: 18px; height: 18px; }
.reader-save-word:disabled { opacity: 1; color: var(--muted); background: var(--surface-secondary); }
.book-text { font: var(--book-font-size)/1.85 Georgia, 'Times New Roman', serif; }
.book-paragraph { font: inherit; margin-bottom: 1.1em; }
.book-sentence { border-radius: 3px; }
.book-sentence.selected { background: var(--mint); }
.book-word { display: inline; min-width: 0; min-height: 0; border: 0; padding: 2px 0; border-radius: 3px; background: none; font: inherit; line-height: inherit; }
.book-word:hover { background: var(--mint); }
.book-word.selected { background: var(--green); color: var(--on-accent); }
.book-parallel { display: none; font: .9375rem/1.65 -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: var(--muted); margin: 8px 0 18px; }
.has-parallel .book-parallel { display: block; }
.has-parallel .book-sentence { display: block; }
.reader-end { padding: 28px 0 16px; margin-top: 36px; border-top: 1px solid var(--line); text-align: center; }
.reader-end > .icon { width: 28px; height: 28px; margin-bottom: 12px; color: var(--green); }
.reader-end h2 { font-size: 1.5rem; margin-bottom: 9px; }
.reader-end .secondary { margin-top: 20px; }
.reader-status-row { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 6px; }
.reader-position-status { font-size: .8125rem; color: var(--muted); }
.reader-save-error { color: var(--error); }
.reader-status-row .text-button { font-size: .8125rem; }
.book-chunk { display: flow-root; }
.reader-edge { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; padding: 8px 0; color: var(--muted); font-size: .8125rem; }

/* Collections share the word-list language; selecting does not hide progress. */
.collections-entry { display: flex; align-items: center; gap: 13px; width: 100%; padding: 16px; margin: 0 0 20px; border-radius: var(--radius); background: var(--surface); color: var(--ink); text-align: left; }
.collections-entry > span { min-width: 0; flex: 1; }
.collections-entry strong { display: block; font-size: 1.0625rem; font-weight: 600; margin-bottom: 3px; }
.collections-entry .subtext { display: block; font-size: .8125rem; }
.collections-entry > .icon:first-child { color: var(--green); width: 26px; height: 26px; }
.collections-entry > .icon:last-child { width: 16px; height: 16px; color: var(--muted); }
/* Collections: discover a set, choose new words, then save from the thumb zone. */
.collection-group + .collection-group { margin-top: 26px; }
.collection-group-title { margin: 0 4px 10px; font-size: 1.0625rem; }
.collection-grid { overflow: hidden; border-radius: var(--radius); background: var(--surface); }
.collection-card { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 82px; padding: 14px 16px; border-radius: 0; background: transparent; color: var(--ink); text-align: left; }
.collection-card + .collection-card::before { content: ''; position: absolute; top: 0; left: 70px; right: 0; height: .5px; background: var(--line); }
.collection-card:focus-visible { outline-offset: -3px; }
.collection-card-copy { min-width: 0; flex: 1; }
.collection-card-copy > strong { display: block; font-size: 1rem; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.collection-symbol { display: grid; place-items: center; width: 42px; height: 44px; flex: 0 0 auto; border-radius: 11px; background: var(--mint); color: var(--green); }
.collection-symbol .icon { width: 23px; height: 23px; }
.collection-symbol-book { background: var(--surface-secondary); color: var(--muted); }
.collection-summary { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: .8125rem; line-height: 1.5; }
.collection-card .collection-summary { margin-top: 4px; }
.collection-new-count { color: var(--green); }
.collection-card > .icon { width: 16px; height: 16px; color: var(--muted); }
.app-shell:has(.collection-detail) { padding-bottom: 0; }
.collection-detail { padding-bottom: calc(var(--collection-actions-height, 9rem) + var(--collection-nav-height, var(--bottom-nav-height)) + 16px); }
.collection-detail .page-heading { margin-bottom: 20px; }
.collection-detail .page-heading .collection-summary { margin-top: 12px; }
.collection-read { margin-top: 6px; padding-left: 0; }
.collection-word-filters { margin-bottom: 14px; }
.collection-word-filters > button { flex: 1; white-space: normal; min-width: 0; }
.collection-list-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 12px; min-height: 48px; padding: 0 4px; margin-bottom: 4px; }
.collection-list-heading .text-button { font-size: .9375rem; padding-inline: 0; }
.collection-page-feedback:empty { display: none; }
.collection-pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 18px 0 6px; }
.collection-pagination > button { flex: 1; min-width: 0; min-height: 48px; padding-inline: 10px; white-space: normal; overflow-wrap: anywhere; }
.collection-pagination > span { order: -1; flex: 0 0 100%; text-align: center; font-variant-numeric: tabular-nums; }
.collection-pagination[hidden] { display: none; }
.collection-empty { padding: 20px 8px; color: var(--muted); font-size: .9375rem; }
.collection-actions { position: fixed; z-index: 18; left: 50%; bottom: var(--collection-nav-height, var(--bottom-nav-height)); transform: translateX(-50%); width: min(100%, var(--content-width)); display: grid; gap: 8px; padding: 10px max(var(--page-inset), var(--safe-right)) 12px max(var(--page-inset), var(--safe-left)); border-top: .5px solid var(--line); background: var(--bg); }
.collection-action-note { color: var(--muted); font-size: .8125rem; text-align: center; }
.collection-actions .primary { min-height: 50px; min-width: 0; white-space: normal; }
.collection-actions .text-button { padding: 6px 12px; }
.collection-feedback:empty { display: none; }
.collection-feedback .error-message { margin: 0; max-height: 6rem; overflow-y: auto; }
[data-keyboard='open'] .collection-actions { bottom: var(--keyboard-inset); }
.collection-word-row { align-items: center; gap: 12px; min-height: 76px; padding-block: 13px; }
label.collection-word-row { cursor: pointer; }
.collection-word-row .word-term, .collection-word-row .word-translation { display: block; }
.collection-word-row > input { width: 23px; height: 23px; min-height: 23px; padding: 0; margin: 0; flex: 0 0 auto; }
.collection-word-row:has(input:checked) { background: var(--mint); }
.collection-word-row:has(input:focus-visible) { outline: 2px solid var(--green); outline-offset: -3px; }
.collection-word-saved { width: 23px; flex: 0 0 auto; color: var(--green); }
.collection-word-row .word-status { display: block; margin-top: 3px; }


/* Empty, loading and error states have an immediate visible way forward. */
.empty { padding: 28px 20px; border-radius: var(--radius); background: var(--surface); text-align: center; }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 50%; background: var(--surface-secondary); color: var(--green); }
.empty-icon .icon { width: 27px; height: 27px; }
.empty h3 { font-size: 1.1875rem; margin-bottom: 9px; }
.empty .primary { margin-top: 22px; }
.empty > .secondary { margin-top: 10px; }
.empty .text-button { display: flex; margin: 8px auto 0; }
.gate { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: var(--viewport-height); max-width: 460px; padding: calc(28px + var(--safe-top)) 28px calc(28px + var(--safe-bottom)); margin: auto; text-align: center; }
.gate { padding-left: max(28px, var(--safe-left)); padding-right: max(28px, var(--safe-right)); }
.gate .brand { margin-bottom: 36px; }
.gate-visual { display: grid; place-items: center; width: 80px; height: 80px; margin-bottom: 28px; border-radius: 22px; background: var(--mint); color: var(--green); }
.gate-visual .icon { width: 36px; height: 36px; }
.gate h1 { font-size: 1.875rem; margin-bottom: 12px; }
.gate .subtext { margin-bottom: 24px; }
.gate-note { color: var(--muted); font-size: .8125rem; margin-top: 26px; }
.loader { width: 24px; height: 24px; border: 2px solid var(--line); border-top-color: var(--green); border-radius: 50%; margin: 28px auto; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.section-loading { min-height: 170px; padding: 32px 12px; text-align: center; }
.section-loading .loader { margin: 18px auto; }
.section-error { padding: 26px 20px; border-radius: var(--radius); background: var(--surface); text-align: center; }
.section-error > .icon { width: 30px; height: 30px; color: var(--muted); margin-bottom: 14px; }
.section-error h3 { margin-bottom: 10px; }
.section-error .secondary { margin-top: 20px; }
#toast { position: fixed; z-index: 100; left: 50%; bottom: calc(82px + var(--safe-bottom) + var(--keyboard-inset)); transform: translate(-50%, 6px); max-width: min(90%, 460px); width: max-content; padding: 13px 18px; border-radius: 14px; background: var(--ink); color: var(--surface); font-size: .9375rem; line-height: 1.4; text-align: center; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .16s ease, transform .16s ease; }
#toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* Adapt to window size, text scaling, pointing method and accessibility settings. */
@media (hover: hover) and (pointer: fine) {
  .primary:hover:not(:disabled) { background: var(--green-dark); }
  .word-row:hover, .native-row:hover, .image-catalog-row:hover, .today-action:hover { background: var(--surface-secondary); }
  .book-row:hover { background: var(--surface-secondary); }
  .collection-card:hover, .collections-entry:hover, .saved-words-card:hover { background: var(--surface-secondary); }
  .text-button:hover:not(:disabled) { text-decoration: underline; text-underline-offset: 3px; }
}
@media (min-width: 600px) {
  :root { --page-inset: 28px; }
  .app-shell, .session-shell { padding-top: calc(20px + var(--safe-top)); }
}
@media (min-width: 720px) and (min-height: 560px) {
  dialog { inset: 0; width: min(calc(100% - 48px), 520px); max-height: calc(var(--viewport-height) - 48px); margin: auto; border-radius: 22px; padding: 24px; }
  .sheet-grabber { display: none; }
}
@media (max-width: 360px) {
  :root { --page-inset: 16px; }
  .topbar { gap: 8px; }
  .hero, .practice-overview, .settings-card, .library-book { padding: 18px; }
  .word-row { gap: 9px; padding: 14px 12px; }
  .word-initial { width: 32px; height: 36px; }
  .word-progress-summary { max-width: 60px; }
  .progress-hero { gap: 14px; padding: 18px; }
  .progress-ring { width: 86px; height: 86px; }
  .progress-ring strong { font-size: 1.625rem; }
  .library-book-heading { gap: 13px; }
  .book-cover { width: 80px; height: 132px; flex-basis: 80px; }
  .book-cover-fallback { padding: 12px 10px 12px 13px; }
  .library-book-title { font-size: 1.1875rem; }
  .reader-dock { padding: 8px; }
  .reader-tools { gap: 4px; flex-wrap: wrap; }
  .reader-parallel-control { justify-content: flex-start; min-width: 90px; }
}
@media (prefers-contrast: more) {
  :root { --muted: #48484a; --line: #8e8e93; }
  [data-theme='dark'] { --muted: #d1d1d6; --line: #8e8e93; }
  .bottom-nav { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .filter.active, .conversation-tab.active { outline: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
