/* Mobile first. Content stays plain; only navigation uses a translucent material. */
:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  color-scheme: light dark;
  --bg: #f5f5f7;
  --paper: #ffffff;
  --ink: #1d1d1f;
  --muted: #69696f;
  --line: #e3e3e8;
  --fill: #ededf1;
  --blue: #0066cc;
  --blue-hover: #0058b0;
  --tint: #e8f1ff;
  --red: #b63e32;
  --expression: #5242c2;
  --glass: #ffffffed;
  --shadow: 0 8px 32px #20202b06, 0 1px 3px #20202b04;
  --nav-height: 64px;
  --review-height: 100px;
  background: var(--bg);
  color: var(--ink);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
button, a, summary { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
button, a, input, select, summary { -webkit-touch-callout: none; }
a { color: var(--blue); text-underline-offset: 3px; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
p { line-height: 1.55; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -.035em; line-height: 1.2; }
h1 { font-size: 2rem; font-weight: 700; margin-bottom: 10px; }
h2 { font-size: 1.25rem; font-weight: 650; margin-bottom: 16px; }
h3 { font-size: 1.125rem; font-weight: 600; }
strong { font-weight: 600; }
input, select { min-height: 44px; max-width: 100%; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
input[type="checkbox"] { width: 44px; height: 28px; min-height: 28px; flex: none; appearance: none; border-radius: 99px; border: none; padding: 3px; background: #bdbdc5; position: relative; }
input[type="checkbox"]::before { content: ''; display: block; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0003; transition: transform .15s; }
input[type="checkbox"]:checked { background: #248547; }
input[type="checkbox"]:checked::before { transform: translateX(16px); }
input[type="number"] { width: 84px; text-align: center; }
select { padding-right: 24px; }
button .icon { pointer-events: none; }
.icon { width: 22px; height: 22px; flex: none; vertical-align: middle; }
.muted, .help-note { color: var(--muted); }
.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; }
[hidden] { display: none !important; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 200; padding: 12px 18px; background: var(--paper); border-radius: 12px; }
.skip-link:focus { top: 12px; }
.shell { max-width: 1120px; margin: auto; }
.topbar { min-height: 64px; padding: calc(8px + env(safe-area-inset-top)) 24px 8px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { color: var(--ink); display: inline-flex; gap: 8px; align-items: center; min-height: 44px; font-size: 1.125rem; font-weight: 650; text-decoration: none; letter-spacing: -.045em; }
.brand .icon { color: var(--blue); width: 21px; height: 21px; }
.status-pill { color: var(--muted); font-size: .8125rem; }
.desktop-nav { display: none; }
.navigation a { text-decoration: none; color: var(--muted); display: flex; align-items: center; justify-content: center; min-width: 0; font-weight: 500; }
.navigation a[aria-current="page"] { color: var(--blue); background: var(--tint); }
.mobile-nav { position: fixed; z-index: 50; bottom: calc(12px + env(safe-area-inset-bottom)); left: 16px; right: 16px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; padding: 6px; border-radius: 28px; border: 1px solid #ffffff66; background: var(--glass); -webkit-backdrop-filter: blur(24px) saturate(140%); backdrop-filter: blur(24px) saturate(140%); box-shadow: 0 4px 28px #1d1d2912, 0 0 0 1px #1d1d2906; max-width: 460px; margin-inline: auto; }
.mobile-nav a { min-height: 52px; padding: 5px 2px; border-radius: 22px; flex-direction: column; gap: 4px; font-size: .6875rem; text-align: center; line-height: 1.1; overflow-wrap: anywhere; }
.mobile-nav .icon { width: 22px; height: 22px; }
main { padding: 24px 20px calc(116px + env(safe-area-inset-bottom)); outline: none; }
body[data-page="study"] main { max-width: 688px; margin: auto; padding-top: 0; padding-bottom: calc(var(--nav-height) + var(--review-height) + 76px + env(safe-area-inset-bottom)); }
.study-toolbar { display: flex; justify-content: space-between; align-items: center; min-height: 52px; gap: 12px; margin-bottom: 12px; }
.study-toolbar h1 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -.025em; margin: 0; }
.study-meta { display: flex; align-items: center; gap: 10px; }
.session-count { font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.icon-button { width: 44px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: transparent; color: var(--muted); }
.icon-button:hover { background: var(--fill); color: var(--ink); }
.study-meta .icon-button { background: var(--paper); box-shadow: 0 1px 4px #20202b05; }
.flashcard { border: 1px solid var(--line); border-radius: 24px; background: var(--paper); box-shadow: var(--shadow); padding: 20px 24px 28px; overflow-wrap: anywhere; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-top .icon-button { margin-right: -8px; }
.language-label { font-size: .875rem; color: var(--muted); font-weight: 500; }
.prompt-content { padding: 16px 0 24px; }
.card-prompt, .card-answer { font-size: 1.6875rem; letter-spacing: -.035em; line-height: 1.4; font-weight: 500; margin: 0; text-wrap: pretty; }
.card-prompt.long-prompt, .card-answer.long-prompt { font-size: 1.5rem; }
.recall-cue { font-size: .875rem; font-weight: 400; letter-spacing: -.01em; color: var(--muted); margin: 0; align-self: center; justify-self: center; text-align: center; }
.answer-content { border-top: 1px solid var(--line); padding: 24px 0 0; }
/* Target expressions share one emphasis color across study and vocabulary examples. */
.card-prompt strong, .card-answer strong, .example-details strong, .detail-example strong { color: var(--expression); font-weight: 700; }
.expression-gloss { display: flex; flex-wrap: wrap; gap: 5px 10px; font-size: .875rem; color: var(--muted); margin: 22px 0 0; }
.expression-gloss strong { color: var(--ink); }
.example-details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; gap: 10px; color: var(--muted); font-size: .875rem; list-style: none; }
.example-details summary::after { content: '⌄'; font-size: 1.0625rem; margin-left: auto; }
.example-details[open] summary::after { transform: rotate(180deg); }
summary::-webkit-details-marker { display: none; }
.example-details { margin-top: 20px; font-size: .9375rem; }
.example-details p { margin: 12px 0 0; }
.example-details p:last-child { color: var(--muted); }
.primary, .secondary { min-height: 50px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; border: none; border-radius: 16px; padding: 12px 22px; font-size: 1rem; font-weight: 550; text-decoration: none; line-height: 1.3; text-align: center; }
.primary { background: var(--blue); color: #fff; }
.primary:hover { background: var(--blue-hover); }
.secondary { background: var(--fill); color: var(--ink); }
.secondary:hover { background: var(--line); }
.primary .icon, .secondary .icon { width: 19px; height: 19px; }
.subtle-button { border: none; background: transparent; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 6px; font-size: .875rem; text-decoration: none; color: var(--muted); }
.subtle-button:hover { color: var(--blue); }
.subtle-button .icon { width: 17px; height: 17px; }
.review-controls { position: fixed; z-index: 40; left: 20px; right: 20px; max-width: 648px; margin: auto; bottom: calc(var(--nav-height) + 28px + env(safe-area-inset-bottom)); padding-top: 12px; background: var(--bg); box-shadow: 0 -12px 20px 8px var(--bg); }
/* Reserve each card's actual answer and controls, as in the extension. */
.reveal-area, .control-swap { display: grid; }
.reveal-area > *, .control-swap > * { grid-area: 1 / 1; min-width: 0; }
.reveal-area > .is-hidden, .control-swap > .is-hidden { visibility: hidden; pointer-events: none; }
.control-swap > .reveal-button { align-self: center; }
.answer-content:not(.is-hidden), .rating-content:not(.is-hidden) { animation: answer-in 120ms ease-out; }
@keyframes answer-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .answer-content:not(.is-hidden), .rating-content:not(.is-hidden) { animation: none; }
}
.reveal-button { width: 100%; min-height: 54px; border-radius: 18px; }
.rating-question { text-align: center; font-size: .875rem; color: var(--muted); margin: 0 0 12px; }
.ratings { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 3.6rem), 1fr)); gap: 8px; }
.rating { min-height: 70px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: var(--paper); border: 1px solid var(--line); border-radius: 17px; font-size: .9375rem; font-weight: 550; padding: 10px 5px; line-height: 1.2; }
.rating small { font-size: .75rem; color: var(--muted); font-weight: 400; }
.rating-0 { color: var(--red); }
.rating.is-selected { color: #fff; background: var(--blue); border-color: var(--blue); }
.rating.is-selected small { color: #fff; }
.rating:hover { box-shadow: inset 0 0 0 1px currentColor; }
.session-footer { display: flex; justify-content: center; align-items: center; gap: 16px; min-height: 12px; }
.session-footer:has(button) { min-height: 44px; margin-top: 4px; }
.keyboard-tip { display: none; color: var(--muted); font-size: .8125rem; }
.completion-undo { display: flex; margin: 12px auto; }
.complete-card { padding: 60px 24px; text-align: center; }
.completion-art { width: 64px; height: 64px; display: grid; place-items: center; margin: 0 auto 24px; border-radius: 50%; background: var(--tint); color: var(--blue); }
.completion-art .icon { width: 30px; height: 30px; }
.complete-card h2 { font-size: 1.75rem; }
.complete-card>p { max-width: 350px; margin: 0 auto 28px; font-size: .9375rem; color: var(--muted); }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 20px; margin-bottom: 28px; }
.page-heading .secondary { font-size: .875rem; min-height: 44px; }
.page-description { font-size: .9375rem; color: var(--muted); margin: 0; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 20px; }
.library-controls { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; }
.search-box { display: flex; align-items: center; gap: 9px; padding: 0 14px; border-radius: 12px; background: var(--fill); }
.search-box .icon { color: var(--muted); width: 20px; }
.search-box input { width: 100%; min-width: 0; border: 0; background: transparent; font-size: 1rem; padding-left: 0; padding-right: 0; }
.search-box:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }
.search-box input:focus { outline: 0; }
.filter-group { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-button { min-height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); padding: 8px 12px; font-size: .8125rem; }
.filter-button.active { background: var(--tint); color: var(--blue); }
.library-table { overflow: hidden; }
.library-table-head { display: none; }
.library-row { width: 100%; border: 0; border-top: 1px solid var(--line); text-align: left; background: var(--paper); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 18px; }
.library-row:first-child { border-top: 0; }
.library-row:hover { background: var(--bg); }
.word-cell { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.word-cell strong { font-size: 1rem; font-weight: 500; overflow-wrap: anywhere; }
.word-cell>span { font-size: .8125rem; color: var(--muted); line-height: 1.5; }
.mastery-cell, .row-arrow { display: none; }
.due-tag, .paused-tag, .scheduled-tag { display: inline-block; font-size: .75rem; color: var(--muted); border-radius: 8px; padding: 5px 7px; background: var(--fill); max-width: 88px; line-height: 1.3; text-align: center; }
.due-tag { background: var(--tint); color: var(--blue); }
.results-count { font-size: .8125rem; margin: 18px 4px; }
.no-results { padding: 44px 24px; text-align: center; }
.no-results p { font-size: .875rem; color: var(--muted); }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.metric { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.metric .icon { color: var(--blue); width: 20px; }
.metric strong { font-size: 2rem; font-weight: 600; letter-spacing: -.045em; }
.metric>span { font-size: .8125rem; color: var(--muted); line-height: 1.4; }
.progress-layout { display: grid; gap: 20px; margin-bottom: 20px; }
.activity-panel, .vocabulary-panel, .history-panel { padding: 22px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-heading h2 { margin: 0; }
.panel-heading .muted { font-size: .8125rem; }
.activity-chart { display: flex; gap: 7px; height: 180px; margin-top: 24px; }
.chart-column { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; flex: 1; min-width: 0; }
.bar-space { width: 100%; height: 120px; display: flex; align-items: flex-end; }
.activity-bar { width: 100%; background: #a7c8ef; border-radius: 4px 4px 0 0; min-height: 3px; }
.current .activity-bar { background: var(--blue); }
.bar-label { margin-top: 10px; font-size: .6875rem; color: var(--muted); }
.bar-count { font-size: .625rem; color: var(--muted); margin-bottom: 6px; }
.chart-note { font-size: .8125rem; margin: 20px 0 0; }
.vocabulary-panel>p { font-size: .875rem; }
.distribution { display: flex; gap: 2px; height: 12px; border-radius: 8px; overflow: hidden; margin: 24px 0; }
.stage-list { display: flex; flex-direction: column; gap: 16px; font-size: .875rem; }
.stage-list>div { display: flex; justify-content: space-between; gap: 12px; }
.stage-list>div>span { display: flex; align-items: center; gap: 9px; color: var(--muted); }
.stage-list i { width: 8px; height: 8px; border-radius: 50%; }
.recent-list { margin-top: 16px; }
.recent-list>div { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-top: 1px solid var(--line); padding: 16px 0; }
.recent-list>div>span:first-child { display: flex; flex-direction: column; gap: 7px; min-width: 0; overflow-wrap: anywhere; }
.recent-list strong { font-size: .9375rem; font-weight: 500; }
.recent-list small { font-size: .75rem; color: var(--muted); }
.history-rating { font-size: .8125rem; color: var(--muted); background: var(--fill); padding: 6px 9px; border-radius: 8px; }
.history-0 { color: var(--red); }
.history-2, .history-3 { color: var(--blue); background: var(--tint); }
.empty-history { font-size: .9375rem; color: var(--muted); padding: 30px 0 8px; line-height: 1.6; }
.empty-history a { display: inline-block; min-height: 44px; padding: 8px 0; }
.settings-layout, .settings-column { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; align-content: start; }
.settings-column, .settings-panel { min-width: 0; }
.settings-panel { padding: 24px 20px; }
.settings-panel>p { font-size: .9375rem; }
.setting-field { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 20px 0; border-top: 1px solid var(--line); }
.setting-field>span { min-width: 0; }
.setting-field strong { display: block; font-size: .9375rem; font-weight: 500; line-height: 1.4; }
.setting-field small { display: block; font-size: .8125rem; color: var(--muted); line-height: 1.5; margin-top: 5px; }
.setting-field select { font-size: .875rem; max-width: 50%; }
.setting-field:has(input[type="checkbox"]) { min-height: 68px; }
.compact { font-size: .8755rem; min-height: 46px; }
.action-list { margin-top: 20px; }
.action-row { width: 100%; text-align: left; border: 0; border-top: 1px solid var(--line); background: transparent; display: flex; align-items: center; gap: 14px; padding: 20px 0; }
.action-row>.icon { color: var(--blue); width: 20px; }
.action-row>.icon:last-child { width: 16px; margin-left: auto; color: var(--muted); }
.action-row>span { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.action-row strong { font-size: .9375rem; font-weight: 500; }
.action-row small { font-size: .8125rem; line-height: 1.5; color: var(--muted); }
.help-note { font-size: .8125rem !important; line-height: 1.6; margin: 18px 0; }
.section-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--tint); color: var(--blue); margin-bottom: 20px; }
.install-panel>p { color: var(--muted); }
.install-state { font-size: .8125rem !important; margin: 18px 0 4px; }
.small-badge { border-radius: 6px; background: var(--fill); padding: 5px 7px; font-size: .625rem; color: var(--muted); }
.stacked-label { display: flex; flex-direction: column; gap: 10px; font-size: .875rem; margin: 22px 0; }
.stacked-label input { width: 100%; font-size: 1rem; }
.sync-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; }
.setup-details { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 22px; font-size: .8125rem; line-height: 1.6; color: var(--muted); }
.setup-details summary { min-height: 44px; padding: 10px 0; color: var(--blue); cursor: pointer; }
.setup-details ol { padding-left: 20px; }
.setup-details li { margin: 12px 0; }
.setup-details code { overflow-wrap: anywhere; }
.toast { position: fixed; z-index: 100; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); padding: 14px 20px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 6px 30px #0002; font-size: .875rem; line-height: 1.5; }
dialog { width: min(500px, calc(100% - 24px)); max-height: calc(100dvh - 40px); overflow-y: auto; margin: auto; border: 1px solid var(--line); border-radius: 26px; background: var(--paper); color: var(--ink); padding: 30px 24px; box-shadow: 0 28px 100px #0003; }
dialog::backdrop { background: #10101855; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.dialog-close { position: absolute; right: 12px; top: 12px; background: var(--fill); width: 44px; height: 44px; }
dialog h2 { font-size: 1.5rem; padding-right: 38px; margin-bottom: 24px; }
dialog p { font-size: .9375rem; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
#study-options-form .primary { margin-top: 8px; width: 100%; }
.detail-title { overflow-wrap: anywhere; }
.detail-meaning { color: var(--muted); }
.detail-example { padding: 20px; background: var(--bg); border-radius: 16px; margin: 20px 0; }
.detail-example p { margin-bottom: 12px; }
.detail-example p:last-child { color: var(--muted); margin-bottom: 0; }
.detail-stats { display: flex; flex-wrap: wrap; gap: 24px; margin: 24px 0; }
.detail-stats>span { font-size: .75rem; color: var(--muted); }
.detail-stats strong { display: block; font-size: 1.375rem; color: var(--ink); margin-top: 8px; }
.eyebrow { font-size: .75rem; font-weight: 500; color: var(--muted); margin-bottom: 14px; }
.loading, .fatal-error { text-align: center; padding: 72px 20px; }
.loading p { color: var(--muted); }

@media (max-width: 360px) {
  .topbar { padding-inline: 20px; }
  main { padding-inline: 16px; }
  .review-controls { left: 16px; right: 16px; }
  .flashcard { padding: 16px 20px 24px; }
  .card-prompt, .card-answer { font-size: 1.5rem; }
  .card-prompt.long-prompt, .card-answer.long-prompt { font-size: 1.375rem; }
  .setting-field { flex-wrap: wrap; }
  .setting-field select { max-width: 100%; }
  .settings-panel { padding: 22px 18px; }
}
@media (max-height: 680px) and (max-width: 767px) {
  .topbar { min-height: 52px; padding-top: env(safe-area-inset-top); padding-bottom: 0; }
  .study-toolbar { margin-bottom: 8px; min-height: 48px; }
  .prompt-content { padding: 12px 0 20px; }
  .card-prompt, .card-answer { font-size: 1.5rem; }
}
@media (min-width: 768px) {
  .topbar { padding: 18px 36px; min-height: 88px; }
  .brand { font-size: 1.25rem; }
  .desktop-nav { display: flex; gap: 3px; border: 1px solid var(--line); border-radius: 99px; padding: 4px; background: var(--glass); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
  .desktop-nav a { min-height: 40px; border-radius: 99px; padding: 9px 16px; font-size: .8125rem; gap: 7px; }
  .desktop-nav .icon { width: 16px; height: 16px; }
  .mobile-nav { display: none; }
  main { padding: 40px 36px 70px; }
  body[data-page="study"] main { padding-top: 32px; padding-bottom: 48px; }
  .study-toolbar { margin-bottom: 18px; }
  .study-toolbar h1 { font-size: 1.125rem; }
  .flashcard { padding: 24px 36px 32px; border-radius: 28px; }
  .card-prompt, .card-answer { font-size: 2rem; }
  .card-prompt.long-prompt, .card-answer.long-prompt { font-size: 1.75rem; }
  .answer-content { padding: 24px 0 0; }
  .review-controls { position: relative; inset: auto; margin: 26px auto 0; padding: 0; box-shadow: none; }
  .reveal-button { display: flex; max-width: 360px; margin: auto; }
  .ratings { max-width: 520px; margin: auto; }
  .rating { min-height: 76px; }
  .session-footer { min-height: 44px; margin-top: 8px; }
  .keyboard-tip { display: inline; }
  .page-heading { margin-bottom: 32px; }
  .library-controls { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; }
  .search-box { flex: 1; min-width: 280px; }
  .library-table-head, .library-row { display: grid; grid-template-columns: minmax(0,1fr) 112px 115px 20px; align-items: center; gap: 22px; padding: 20px 24px; }
  .library-table-head { color: var(--muted); font-size: .6875rem; font-weight: 500; }
  .mastery-cell { display: flex; align-items: center; gap: 9px; font-size: .8125rem; }
  .mastery-meter { width: 48px; height: 4px; background: var(--fill); overflow: hidden; border-radius: 4px; }
  .mastery-meter>span { display: block; height: 100%; background: var(--blue); }
  .row-arrow { display: block; color: var(--muted); }
  .row-arrow .icon { width: 16px; }
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; margin-bottom: 26px; }
  .metric { padding: 24px; }
  .progress-layout { grid-template-columns: 1.4fr 1fr; gap: 24px; margin-bottom: 26px; }
  .activity-panel, .vocabulary-panel, .history-panel { padding: 28px; }
  .settings-layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; }
  .settings-panel { padding: 28px; }
  .setting-field { flex-wrap: wrap; }
  .setting-field select { max-width: 100%; }
}
/* Landscape gives reading and rating their own space instead of overlapping. */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse), (orientation: landscape) and (max-height: 500px) and (max-width: 950px) {
  .desktop-nav { display: none; }
  .mobile-nav { display: grid; }
  .topbar { min-height: 48px; padding: 0 24px; }
  body[data-page="study"] main { max-width: 940px; padding: 0 24px calc(var(--nav-height) + 36px + env(safe-area-inset-bottom)); }
  .study-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 0 20px; align-items: start; }
  .study-toolbar { grid-column: 1 / -1; min-height: 44px; margin-bottom: 8px; }
  .flashcard { padding: 12px 20px 20px; border-radius: 20px; }
  .prompt-content { padding: 8px 0 16px; }
  .card-prompt, .card-answer, .card-prompt.long-prompt, .card-answer.long-prompt { font-size: 1.375rem; line-height: 1.4; }
  .recall-cue { font-size: .8125rem; }
  .answer-content { padding: 16px 0 0; }
  .expression-gloss { margin-top: 14px; }
  .review-controls { position: sticky; inset: auto; top: 12px; margin: 0; padding: 0; width: 100%; box-shadow: none; background: transparent; }
  .reveal-button { max-width: 100%; min-height: 52px; }
  .ratings { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .rating { min-height: 58px; padding: 8px 5px; }
  .rating-question { margin-bottom: 10px; }
  .keyboard-tip { display: none; }
  .session-footer { min-height: 0; margin-top: 4px; }
  .session-footer:has(button) { min-height: 44px; }
  .completion-undo { grid-column: 2; }
  .complete-card { grid-column: 1 / -1; padding: 24px; }
  main { padding-bottom: 116px; }
}
@media (max-width: 360px) and (max-height: 600px) {
  .flashcard { padding: 10px 18px 18px; }
  .prompt-content { padding: 8px 0 16px; }
  .review-controls { padding-top: 6px; }
  .session-footer { min-height: 4px; }
}
@media (prefers-color-scheme: dark) {
  :root { --expression: #b8b6ff; }
  :root { --bg: #101012; --paper: #1c1c1f; --ink: #f5f5f7; --muted: #ababaf; --line: #35353a; --fill: #2b2b30; --blue: #58a8ff; --blue-hover: #80bdff; --tint: #163351; --red: #ff9b8f; --glass: #252528f2; --shadow: 0 8px 30px #0002; }
  .primary, .rating.is-selected, .rating.is-selected small { color: #081c30; }
  .mobile-nav { border-color: #ffffff0d; }
  input[type="checkbox"] { background: #62626a; }
  .activity-bar { background: #406b96; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  .mobile-nav, .desktop-nav { background: var(--paper); -webkit-backdrop-filter: none; backdrop-filter: none; border-color: var(--muted); }
  dialog::backdrop { -webkit-backdrop-filter: none; backdrop-filter: none; background: #101018aa; }
  .flashcard, .panel, .rating { border-color: var(--muted); }
}
@media (forced-colors: active) {
  .card-prompt strong, .card-answer strong, .example-details strong, .detail-example strong { color: CanvasText; }
  .primary, .rating.is-selected, .navigation a[aria-current="page"] { border: 2px solid ButtonText; }
  input[type="checkbox"] { appearance: auto; }
  input[type="checkbox"]::before { display: none; }
}
