/* ==========================================================================
   Hibba's Revision — stylesheet
   iPad-first, touch-optimised, theme-able via CSS custom properties.
   Sections: 1 Tokens & themes · 2 Base · 3 Layout & nav · 4 Components
             5 Home · 6 Subject hub · 7 Flashcards · 8 Quiz · 9 Exam
             10 Explainers · 11 Drawer · 12 Accessibility modes · 13 Responsive
   ========================================================================== */

/* 1. Tokens & themes ------------------------------------------------------ */
:root {
  --font-scale: 1;
  --font-body: "Lexend", "Atkinson Hyperlegible", -apple-system, BlinkMacSystemFont, "Segoe UI", Verdana, sans-serif;
  --radius: 18px;
  --radius-sm: 12px;
  --tap: 48px;
  --nav-h: 72px;
  --rail-w: 96px;
  --ease: cubic-bezier(.2, .75, .25, 1);
  --dur: .32s;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --accent: #4f6bed;
}

html[data-theme="light"] {
  --bg: #f6f7fb; --surface: #ffffff; --surface-2: #eff1f7; --surface-3: #e4e8f1;
  --text: #1c2333; --muted: #586176; --border: #dce0ea;
  --ok: #1d7340; --ok-bg: #e2f4e8; --gentle: #7c5300; --gentle-bg: #fff3d6;
  --focus: #2848e0; --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 8px 24px rgba(20, 30, 60, .08);
  --svg-ink: #1c2333; --svg-grid: #d9deea; --svg-plane: #ffffff; --svg-side: #dfe4f0; --svg-side-2: #c9d0e0;
  color-scheme: light;
}
html[data-theme="cream"] {
  --bg: #f8f0dc; --surface: #fffaf0; --surface-2: #f3e8cf; --surface-3: #eadcbc;
  --text: #2a251d; --muted: #5d5444; --border: #e2d4b3;
  --ok: #2b6b36; --ok-bg: #e5efd5; --gentle: #7a4f05; --gentle-bg: #fbe7bf;
  --focus: #6b3fd1; --shadow: 0 1px 2px rgba(70, 50, 10, .07), 0 8px 24px rgba(70, 50, 10, .08);
  --svg-ink: #2a251d; --svg-grid: #e6d8b8; --svg-plane: #fffaf0; --svg-side: #eadcbc; --svg-side-2: #dccaa2;
  color-scheme: light;
}
html[data-theme="mint"] {
  --bg: #e6f4ec; --surface: #f5fbf7; --surface-2: #dcefe3; --surface-3: #cbe5d5;
  --text: #19291f; --muted: #46594c; --border: #c3dfcd;
  --ok: #1a6b3a; --ok-bg: #d3eedc; --gentle: #6f4d00; --gentle-bg: #f8ebc6;
  --focus: #1f5fd1; --shadow: 0 1px 2px rgba(10, 60, 30, .06), 0 8px 24px rgba(10, 60, 30, .08);
  --svg-ink: #19291f; --svg-grid: #c9e3d3; --svg-plane: #f5fbf7; --svg-side: #cbe5d5; --svg-side-2: #b3d6c1;
  color-scheme: light;
}
html[data-theme="blue"] {
  --bg: #e6eef9; --surface: #f6f9fe; --surface-2: #dce6f6; --surface-3: #cad8ef;
  --text: #17223a; --muted: #48566f; --border: #c4d3ec;
  --ok: #1b6a3d; --ok-bg: #d8efe1; --gentle: #714f00; --gentle-bg: #f9ecc8;
  --focus: #2747c9; --shadow: 0 1px 2px rgba(15, 35, 80, .06), 0 8px 24px rgba(15, 35, 80, .08);
  --svg-ink: #17223a; --svg-grid: #cad8ef; --svg-plane: #f6f9fe; --svg-side: #cad8ef; --svg-side-2: #b2c5e6;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0a0c10; --surface: #14171d; --surface-2: #1d2129; --surface-3: #2a303b;
  --text: #f6f8fb; --muted: #c5ccd8; --border: #4b5465;
  --ok: #8be3aa; --ok-bg: #123321; --gentle: #ffd77a; --gentle-bg: #3a2c06;
  --focus: #ffd400; --shadow: 0 0 0 1px #343b48;
  --svg-ink: #f6f8fb; --svg-grid: #313847; --svg-plane: #14171d; --svg-side: #262c37; --svg-side-2: #1b2029;
  color-scheme: dark;
}

/* Derived accent tokens (colour-mix with fallbacks) */
body {
  --accent-soft: #eef1fd;
  --accent-ink: var(--accent);
  --accent-soft: color-mix(in srgb, var(--accent) 13%, var(--surface));
  --accent-line: color-mix(in srgb, var(--accent) 45%, var(--border));
}
html[data-theme="dark"] body {
  --accent-ink: color-mix(in srgb, var(--accent) 45%, #ffffff);
  --accent-soft: color-mix(in srgb, var(--accent) 22%, var(--surface));
}

/* 2. Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  font-size: calc(100% * var(--font-scale));
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--bg);
}
/* Kill double-tap zoom while keeping pinch-zoom (accessibility) */
html, body, body * { touch-action: manipulation; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
html[data-font="atkinson"] { --font-body: "Atkinson Hyperlegible", Verdana, sans-serif; }
html[data-font="system"]   { --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Verdana, sans-serif; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1rem; }
a { color: var(--accent-ink); }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
input, textarea { font-size: max(16px, 1rem); } /* >=16px stops iOS zoom-on-focus */
.icon { flex: none; display: block; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 10px; }
.skip-link {
  position: absolute; left: 1rem; top: -100px; z-index: 100; padding: .75rem 1rem;
  background: var(--surface); color: var(--text); border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.skip-link:focus { top: 1rem; }
.math { font-family: "Cambria Math", "STIX Two Math", Georgia, serif; font-size: 1.05em; white-space: nowrap; }

/* 3. Layout & navigation -------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.app-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
}
.page {
  flex: 1; width: 100%; max-width: 1080px; margin: 0 auto;
  padding: 1rem max(1.25rem, var(--safe-r)) 2rem max(1.25rem, var(--safe-l));
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .6rem max(1.25rem, var(--safe-r)) .6rem max(1.25rem, var(--safe-l));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--text); font-weight: 600; min-height: var(--tap); }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--accent); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent);
}
.site-footer { padding: 1.5rem; text-align: center; color: var(--muted); font-size: .85rem; }
.site-footer p { margin: 0; }

/* Bottom tab bar (portrait default) */
.tabbar {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar-list {
  list-style: none; margin: 0 auto; padding: 0 .25rem; height: var(--nav-h); max-width: 980px;
  display: flex; align-items: stretch; overflow-x: auto; scrollbar-width: none;
}
.tabbar-list::-webkit-scrollbar { display: none; }
.tabbar-list > li { flex: 1 0 auto; min-width: 72px; display: flex; }
.tab {
  --tab-accent: var(--accent);
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-width: var(--tap); min-height: var(--tap); padding: 6px 4px;
  color: var(--muted); text-decoration: none; background: none; border: 0; cursor: pointer;
  font-size: .72rem; font-weight: 500; border-radius: 14px; position: relative;
  -webkit-user-select: none; user-select: none;
}
.tab .icon { transition: transform var(--dur) var(--ease); }
.tab:active .icon { transform: translate3d(0, 1px, 0) scale(.94); }
.tab.is-active { color: var(--text); }
.tab.is-active::before {
  content: ""; position: absolute; top: 6px; width: 44px; height: 30px; border-radius: 15px; z-index: -1;
  background: color-mix(in srgb, var(--tab-accent) 20%, transparent);
}
.tab.is-active .icon { color: var(--tab-accent); }
html[data-theme="dark"] .tab.is-active .icon { color: color-mix(in srgb, var(--tab-accent) 45%, #fff); }
.tab-label { white-space: nowrap; font-size: .72rem; }

/* 4. Components ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--tap); min-width: var(--tap); padding: .7rem 1.15rem;
  border-radius: 14px; border: 2px solid transparent; cursor: pointer;
  font-weight: 600; font-size: 1rem; line-height: 1.2; text-decoration: none;
  background: var(--surface-2); color: var(--text);
  transition: transform .15s var(--ease), background-color var(--dur), border-color var(--dur);
  -webkit-user-select: none; user-select: none;
}
.btn:active { transform: translate3d(0, 1px, 0) scale(.98); }
.btn[disabled] { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
html[data-theme="dark"] .btn-primary { background: var(--accent-ink); color: #0a0c10; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-soft { background: var(--accent-soft); color: var(--text); border-color: var(--accent-line); }
.btn-icon { padding: .5rem; width: var(--tap); }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; padding: .9rem 1.4rem; font-size: 1.05rem; }
.btn-icon-text span { font-size: .95rem; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent-ink); text-decoration: underline; cursor: pointer; font: inherit; min-height: 0; }

.pill {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: .55rem 1.1rem;
  border-radius: 999px; border: 2px solid var(--border); background: var(--surface);
  color: var(--text); font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color var(--dur), border-color var(--dur);
  -webkit-user-select: none; user-select: none;
}
.pill[aria-pressed="true"], .pill.is-active { background: var(--accent-soft); border-color: var(--accent); }
.pill-row { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .6rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem;
}
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 600; color: var(--accent-ink); margin: 0 0 .25rem; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 60ch; }
.section-h { margin: 2rem 0 1rem; }
.muted { color: var(--muted); }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .7rem; border-radius: 999px;
  font-size: .8rem; font-weight: 600; background: var(--accent-soft); color: var(--text);
}
.bar { height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; border-radius: 5px; background: var(--accent); transition: width .6s var(--ease); }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty-state h1, .empty-state h2 { color: var(--text); }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 16px; background: var(--surface-2); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented > label > span, .segmented > button {
  display: flex; align-items: center; justify-content: center; min-height: 44px; padding: .4rem .9rem;
  border-radius: 12px; font-weight: 500; font-size: .95rem; background: none; border: 0; cursor: pointer;
}
.segmented input:checked + span, .segmented > [aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }

.toast {
  position: fixed; left: 50%; z-index: 60; bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  transform: translate3d(-50%, 0, 0); padding: .75rem 1.2rem; border-radius: 14px;
  background: var(--text); color: var(--bg); font-weight: 500; box-shadow: var(--shadow);
  max-width: calc(100vw - 2rem);
}
.toast.is-in { animation: toast-in .3s var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translate3d(-50%, 12px, 0); } to { opacity: 1; transform: translate3d(-50%, 0, 0); } }

.calm-dialog {
  border: 0; padding: 0; border-radius: var(--radius); background: var(--surface); color: var(--text);
  width: min(460px, calc(100vw - 2rem)); box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.calm-dialog::backdrop { background: rgba(10, 15, 30, .45); }
.calm-dialog-inner { padding: 1.5rem; }
.calm-dialog-actions { display: flex; gap: .75rem; justify-content: flex-end; flex-wrap: wrap; }

.module-loading { display: flex; gap: 8px; justify-content: center; padding: 3rem; }
.module-loading span { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); opacity: .3; animation: pulse 1.2s infinite; }
.module-loading span:nth-child(2) { animation-delay: .2s; }
.module-loading span:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 50% { opacity: 1; } }

/* 5. Home ------------------------------------------------------------------ */
.hero { display: grid; gap: 1.25rem; align-items: end; padding: 1rem 0 .5rem; }
.continue-card {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .25rem 1rem;
  padding: 1rem 1.25rem; border-radius: var(--radius); text-decoration: none; color: var(--text);
  background: var(--accent-soft); border: 2px solid var(--accent-line); min-height: 72px;
}
.continue-label { font-size: .85rem; color: var(--muted); grid-column: 1; }
.continue-title { grid-column: 1; font-size: 1.1rem; }
.continue-go { grid-column: 2; grid-row: 1 / span 2; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; }

.subject-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.subject-card {
  position: relative; display: flex; align-items: center; gap: 1rem; padding: 1.15rem 1.2rem; min-height: 112px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; overflow: hidden;
  transition: transform var(--dur) var(--ease), border-color var(--dur);
  transform: translate3d(0, 0, 0);
}
.subject-card::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 6px; background: var(--accent); }
.subject-card:active { transform: translate3d(0, 2px, 0) scale(.99); }
@media (hover: hover) { .subject-card:hover { border-color: var(--accent); transform: translate3d(0, -2px, 0); } }
.subject-icon {
  width: 56px; height: 56px; border-radius: 16px; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink);
}
.subject-icon.big { width: 68px; height: 68px; border-radius: 20px; }
.subject-body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; flex: 1; }
.subject-name { font-size: 1.2rem; }
.subject-blurb { color: var(--muted); font-size: .95rem; }
.subject-meta { color: var(--muted); font-size: .8rem; margin-top: .25rem; }
.ring { position: relative; width: 58px; height: 58px; flex: none; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4.5; }
.ring-track { stroke: var(--surface-3); }
.ring-fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dasharray .8s var(--ease); }
.ring-text { font-size: .78rem; font-weight: 700; }

.how-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.how-grid .section-h { grid-column: 1 / -1; margin-bottom: 0; }
.how-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; }
.how-card p { margin: 0; color: var(--muted); font-size: .95rem; }
.how-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); margin-bottom: .6rem; flex: none; }
.tip-card { display: flex; gap: 1rem; align-items: flex-start; margin-top: 2rem; padding: 1.2rem; border-radius: var(--radius); background: var(--surface-2); }
.tip-card p { margin: 0; }
.tip-h { font-size: 1.1rem; }

/* 6. Subject hub ------------------------------------------------------------ */
.subject-head { display: flex; gap: 1rem; align-items: center; padding: .5rem 0 1rem; }
.subject-head h1 { margin: 0; }
.subject-head .lead { margin: .35rem 0 0; }
.mode-name { color: var(--muted); font-weight: 500; }
.mode-tabs {
  position: sticky; top: 64px; z-index: 15; display: flex; gap: 4px; padding: 5px; margin: 0 0 1rem;
  background: var(--surface-2); border-radius: 18px; overflow-x: auto; scrollbar-width: none;
}
.mode-tabs::-webkit-scrollbar { display: none; }
.mode-tab {
  flex: 1 0 auto; display: flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: var(--tap); padding: .5rem 1rem; border-radius: 14px; color: var(--muted);
  text-decoration: none; font-weight: 600; white-space: nowrap;
}
.mode-tab.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.mode-tab.is-active .icon { color: var(--accent-ink); }
.topic-filter { display: flex; gap: .5rem; overflow-x: auto; padding: .25rem .1rem 1rem; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.topic-filter::-webkit-scrollbar { display: none; }

.stat-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-bottom: 1.5rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat-num { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .9rem; }
.mode-launch { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-bottom: 1.5rem; }
.mode-launch a {
  display: flex; gap: .9rem; align-items: center; padding: 1rem 1.1rem; min-height: 76px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text); box-shadow: var(--shadow);
}
.mode-launch small { display: block; color: var(--muted); font-size: .85rem; }
.topic-table { width: 100%; border-collapse: separate; border-spacing: 0 .5rem; }
.topic-table th { text-align: left; font-size: .85rem; color: var(--muted); font-weight: 600; padding: 0 .75rem; }
.topic-table td { background: var(--surface); padding: .8rem .75rem; vertical-align: middle; }
.topic-table td:first-child { border-radius: 14px 0 0 14px; font-weight: 600; }
.topic-table td:last-child { border-radius: 0 14px 14px 0; }
.topic-table .bar { min-width: 90px; }
.small { font-size: .85rem; }

/* 7. Flashcards ------------------------------------------------------------ */
.fc-toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.fc-counter { font-weight: 600; color: var(--muted); }
.fc-stage { perspective: 1600px; -webkit-perspective: 1600px; touch-action: pan-y; position: relative; }
.fc-slide { transform: translate3d(0, 0, 0); transition: transform .3s var(--ease), opacity .3s var(--ease); will-change: transform; }
.fc-slide.out-left  { transform: translate3d(-40%, 0, 0) rotate(-3deg); opacity: 0; }
.fc-slide.out-right { transform: translate3d(40%, 0, 0) rotate(3deg); opacity: 0; }
.fc-slide.in-from-right { transform: translate3d(40%, 0, 0); opacity: 0; transition: none; }
.fc-slide.in-from-left  { transform: translate3d(-40%, 0, 0); opacity: 0; transition: none; }
.flashcard {
  position: relative; width: 100%; height: clamp(260px, 46vh, 440px);
  transform-style: preserve-3d; -webkit-transform-style: preserve-3d;
  transition: transform .6s var(--ease); cursor: pointer; border-radius: 26px;
  -webkit-user-select: none; user-select: none;
}
.flashcard.is-flipped { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .8rem; padding: 2rem 1.75rem; text-align: center; border-radius: 26px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--surface); border: 2px solid var(--border); box-shadow: var(--shadow);
  transform: translateZ(0.1px);
}
.fc-face.back { transform: rotateY(180deg) translateZ(0.1px); background: var(--accent-soft); border-color: var(--accent-line); }
.fc-face .chip { position: absolute; top: 1rem; left: 1rem; }
.fc-text { font-size: clamp(1.25rem, 1rem + 1.2vw, 1.8rem); font-weight: 500; line-height: 1.45; max-width: 30ch; overflow-wrap: anywhere; }
.fc-face.back .fc-text { font-size: clamp(1.1rem, .95rem + .9vw, 1.45rem); font-weight: 400; max-width: 38ch; }
.fc-hint { color: var(--muted); font-size: .9rem; position: absolute; bottom: 1rem; }
.fc-status { position: absolute; top: 1rem; right: 1rem; }
.fc-controls { display: grid; grid-template-columns: auto 1fr auto; gap: .75rem; margin-top: 1rem; }
.fc-rate { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: .75rem; }
.fc-rate .btn { min-height: 60px; }
.btn-review { background: var(--gentle-bg); color: var(--text); border-color: color-mix(in srgb, var(--gentle) 40%, transparent); }
.btn-confident { background: var(--ok-bg); color: var(--text); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.btn-review[aria-pressed="true"] { border-color: var(--gentle); }
.btn-confident[aria-pressed="true"] { border-color: var(--ok); }
.fc-done { text-align: center; padding: 2.5rem 1.25rem; }
.fc-done .btn { margin: .3rem; }
.fc-swipe-hint { text-align: center; color: var(--muted); font-size: .85rem; margin-top: .75rem; }

/* 8. Quiz -------------------------------------------------------------------- */
.q-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .5rem; }
.q-progress { margin-bottom: 1.25rem; }
.q-text { font-size: clamp(1.2rem, 1rem + .8vw, 1.5rem); font-weight: 500; margin: .75rem 0 1.25rem; }
.q-options { display: grid; gap: .75rem; list-style: none; padding: 0; margin: 0; }
@media (min-width: 900px) { .q-options.two-col { grid-template-columns: 1fr 1fr; } }
.opt {
  display: flex; align-items: center; gap: .9rem; width: 100%; min-height: 64px; padding: .8rem 1rem;
  border-radius: 16px; border: 2px solid var(--border); background: var(--surface); text-align: left;
  font-size: 1.05rem; cursor: pointer; color: var(--text);
  transition: border-color var(--dur), background-color var(--dur), transform .15s var(--ease);
  -webkit-user-select: none; user-select: none;
}
.opt:active { transform: translate3d(0, 1px, 0) scale(.99); }
.opt-key {
  flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-2); font-weight: 700; font-size: .95rem;
}
.opt-mark { margin-left: auto; flex: none; }
.opt.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.opt.is-correct { border-color: var(--ok); background: var(--ok-bg); }
.opt.is-correct .opt-key { background: var(--ok); color: var(--surface); }
.opt.is-gentle { border-color: var(--gentle); background: var(--gentle-bg); border-style: dashed; }
.opt[disabled] { cursor: default; }
.opt[disabled]:not(.is-correct):not(.is-gentle) { opacity: .6; }
.feedback {
  margin-top: 1.25rem; padding: 1.15rem 1.25rem; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--border); animation: rise .35s var(--ease);
}
.feedback.is-correct { border-color: var(--ok); }
.feedback.is-gentle { border-color: var(--gentle); }
.feedback-h { display: flex; gap: .6rem; align-items: center; font-size: 1.15rem; margin: 0 0 .5rem; }
.feedback-h .icon { color: var(--ok); }
.feedback.is-gentle .feedback-h .icon { color: var(--gentle); }
.steps { margin: .5rem 0 0; padding-left: 0; list-style: none; counter-reset: step; display: grid; gap: .5rem; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 32px 1fr; gap: .6rem; align-items: start; }
.steps li::before {
  content: counter(step); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); font-weight: 700; font-size: .85rem;
}
.q-actions { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: space-between; margin-top: 1.25rem; }
@keyframes rise { from { opacity: 0; transform: translate3d(0, 8px, 0); } to { opacity: 1; transform: translate3d(0, 0, 0); } }
.summary-list { list-style: none; padding: 0; display: grid; gap: .6rem; }
.summary-list li { display: grid; grid-template-columns: 1fr 120px auto; gap: .75rem; align-items: center; padding: .7rem .9rem; background: var(--surface); border-radius: 14px; border: 1px solid var(--border); }

/* 9. Exam ------------------------------------------------------------------- */
.exam-list { display: grid; gap: 1rem; }
.exam-item { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.exam-start .opt-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: 1rem 0; }
.exam-layout { display: grid; gap: 1rem; }
.exam-bar {
  position: sticky; top: 132px; z-index: 12; display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  padding: .6rem .8rem; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.calm-timer { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.calm-timer-text { font-weight: 600; white-space: nowrap; }
.calm-timer .bar { width: 120px; height: 8px; }
.calm-timer .bar > span { background: color-mix(in srgb, var(--accent) 60%, var(--surface-3)); transition: width 1s linear; }
.calm-timer.is-hidden .calm-timer-text, .calm-timer.is-hidden .bar { display: none; }
.time-note { padding: .8rem 1rem; border-radius: 14px; background: var(--gentle-bg); margin-bottom: 1rem; }
.navgrid-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem; }
.navgrid-wrap summary { cursor: pointer; font-weight: 600; min-height: var(--tap); display: flex; align-items: center; gap: .5rem; list-style: none; }
.navgrid-wrap summary::-webkit-details-marker { display: none; }
.navgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: .5rem; margin-top: .5rem; }
.navgrid button {
  position: relative; min-height: 52px; min-width: 52px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface); font-weight: 700; cursor: pointer;
}
.navgrid button.is-answered { background: var(--accent-soft); border-color: var(--accent-line); }
.navgrid button.is-current { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.navgrid button.is-flagged::after { content: ""; position: absolute; top: 4px; right: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--gentle); }
.nav-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-top: .75rem; }
.nav-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; vertical-align: -1px; margin-right: 4px; border: 2px solid var(--border); }
.nav-legend .l-ans { background: var(--accent-soft); border-color: var(--accent-line); }
.nav-legend .l-flag { background: var(--gentle); border-color: var(--gentle); border-radius: 50%; }
.exam-q { padding: 1.4rem; }
.exam-q-meta { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .9rem; }
.text-answer {
  width: 100%; min-height: 56px; padding: .8rem 1rem; border-radius: 14px; border: 2px solid var(--border);
  background: var(--surface); color: var(--text);
}
.text-answer:focus { border-color: var(--accent); }
.unit-row { display: flex; align-items: center; gap: .6rem; }
.unit-row .text-answer { max-width: 260px; }
.result-hero { text-align: center; padding: 1.75rem 1.25rem; }
.result-score { font-size: 3rem; font-weight: 700; line-height: 1; margin: .5rem 0; }
.topic-break { list-style: none; padding: 0; display: grid; gap: .75rem; }
.topic-break li { display: grid; gap: .35rem; }
.topic-break .tb-row { display: flex; justify-content: space-between; gap: 1rem; font-weight: 600; }
.review-item { border-top: 1px solid var(--border); padding: 1rem 0; }
.review-item summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; gap: .6rem; font-weight: 600; }
.badge { flex: none; display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 .4rem; border-radius: 10px; font-size: .85rem; font-weight: 700; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.gentle { background: var(--gentle-bg); color: var(--gentle); }

/* 10. Explainers -------------------------------------------------------------- */
.ex-list { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.ex-card { display: flex; flex-direction: column; gap: .5rem; text-align: left; cursor: pointer; border: 1px solid var(--border); color: var(--text); font: inherit; }
.ex-card .ex-thumb { height: 120px; border-radius: 14px; background: linear-gradient(135deg, var(--accent-soft), var(--surface-2)); display: grid; place-items: center; color: var(--accent-ink); }
.ex-card .ex-thumb svg { width: 100%; height: 100%; }
.ex-card-meta { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.ex-player { padding: 1rem; }
.ex-stage { position: relative; border-radius: 20px; overflow: hidden; background: radial-gradient(120% 90% at 30% 10%, var(--surface), var(--surface-2)); border: 1px solid var(--border); }
.ex-stage svg { display: block; width: 100%; height: auto; max-height: 62vh; }
.ex-caption { min-height: 4.5em; margin: 1rem .25rem; font-size: 1.1rem; }
.ex-step-label { font-weight: 700; color: var(--accent-ink); display: block; font-size: .9rem; margin-bottom: .2rem; }
.ex-controls { display: grid; grid-template-columns: auto auto auto 1fr; gap: .6rem; align-items: center; }
.ex-scrub { width: 100%; }
.ex-dots { display: flex; gap: .4rem; justify-content: center; flex-wrap: wrap; margin-top: .75rem; }
.ex-dots button { min-width: 44px; min-height: 44px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface); font-weight: 600; cursor: pointer; }
.ex-dots button[aria-current="step"] { border-color: var(--accent); background: var(--accent-soft); }
.ex-svg-text { font-family: var(--font-body); fill: var(--svg-ink); }

/* Range inputs: large thumb for touch */
input[type="range"] { -webkit-appearance: none; appearance: none; height: var(--tap); background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 10px; border-radius: 5px; background: var(--surface-3); }
input[type="range"]::-moz-range-track { height: 10px; border-radius: 5px; background: var(--surface-3); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 32px; height: 32px; margin-top: -11px; border-radius: 50%; background: var(--accent); border: 4px solid var(--surface); box-shadow: 0 1px 4px rgba(0,0,0,.25); }
input[type="range"]::-moz-range-thumb { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); border: 4px solid var(--surface); }


/* Study tools menu + subject search (topbar) ------------------------------- */
.topbar { justify-content: flex-start; }
.topbar-actions { margin-left: auto; }
.tools-menu { position: relative; }
.tools-toggle {
  display: inline-flex; align-items: center; gap: .35rem; min-height: var(--tap); padding: .4rem .8rem;
  border: 0; background: none; border-radius: 12px; color: var(--accent-ink); font-weight: 600; font-size: 1.02rem; cursor: pointer;
}
.tools-toggle .icon { transition: transform var(--dur) var(--ease); }
.tools-toggle[aria-expanded="true"] { background: var(--accent-soft); }
.tools-toggle[aria-expanded="true"] .icon { transform: rotate(180deg); }
.tools-panel {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 40; width: min(720px, calc(100vw - 2rem));
  padding: .75rem; border-radius: 20px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 18px 50px rgba(15, 25, 50, .18); animation: rise .22s var(--ease);
}
.tools-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.tool-link {
  display: flex; align-items: center; gap: .85rem; min-height: 60px; padding: .55rem .75rem; border-radius: 14px;
  color: var(--text); text-decoration: none;
}
.tool-link:hover, .tool-link:focus-visible { background: var(--surface-2); }
.tool-icon { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); }
.tool-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.tool-label { font-weight: 600; font-size: 1.02rem; }
.tool-text small { color: var(--muted); font-size: .82rem; }
.new-badge { margin-left: auto; flex: none; padding: .15rem .6rem; border-radius: 999px; background: #e9574f; color: #fff; font-size: .78rem; font-weight: 700; }
.tools-section-h { margin: .6rem .75rem .25rem; padding-top: .75rem; border-top: 1px solid var(--border); font-weight: 700; font-size: .92rem; }
.tools-note { margin: .5rem .75rem .25rem; font-size: .82rem; color: var(--muted); }
.subject-search { position: relative; flex: 1 1 260px; max-width: 420px; display: flex; align-items: center; }
.subject-search input {
  width: 100%; min-height: var(--tap); padding: .55rem 3.2rem .55rem 1.2rem; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  -webkit-appearance: none; appearance: none;
}
.subject-search input:focus { border-color: var(--accent); }
.subject-search input::-webkit-search-cancel-button { display: none; }
.search-btn { position: absolute; right: 4px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: none; color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 40; list-style: none; margin: 0; padding: .4rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 18px 50px rgba(15, 25, 50, .18);
  max-height: 60vh; overflow-y: auto;
}
.search-results a { display: flex; flex-direction: column; min-height: 52px; justify-content: center; padding: .45rem .8rem; border-radius: 12px; color: var(--text); text-decoration: none; }
.search-results a small { color: var(--muted); font-size: .8rem; }
.search-results [aria-selected="true"] a, .search-results a:hover { background: var(--surface-2); }
@media (max-width: 1100px) { .topbar .btn-icon-text span { display: none; } .topbar .btn-icon-text { padding: .5rem; } }
@media (max-width: 820px) { .brand-text { display: none; } }
@media (max-width: 560px) {
  .mode-tabs { top: 120px; }
  .topbar { flex-wrap: wrap; gap: .5rem; }
  .subject-search { order: 5; flex-basis: 100%; max-width: none; }
  .tools-grid { grid-template-columns: 1fr; }
  .tools-panel { position: fixed; left: 1rem; right: 1rem; top: 64px; width: auto; max-height: 75vh; overflow-y: auto; }
}

/* Revision notes ------------------------------------------------------------ */
.notes-topic { margin-bottom: 1.75rem; scroll-margin-top: 140px; }
.note-card { margin-bottom: 1rem; }
.note-card h3 { font-size: 1.2rem; display: flex; align-items: center; gap: .6rem; }
.note-points { margin: .5rem 0 1rem; padding-left: 1.2rem; display: grid; gap: .5rem; }
.note-points li { padding-left: .25rem; }
.note-remember { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem 1rem; border-radius: 14px; background: var(--accent-soft); margin-bottom: 1rem; }
.note-remember .icon { color: var(--accent-ink); margin-top: 2px; }
.note-example { margin: 0 0 1rem; border: 2px solid var(--accent-line); border-radius: 14px; padding: .25rem 1rem .75rem; }
.note-example summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; font-weight: 600; padding-top: .5rem; }
.note-example[open] summary { margin-bottom: .5rem; }
.note-tag { display: inline-flex; padding: .15rem .65rem; border-radius: 999px; background: var(--accent); color: #fff; font-size: .78rem; font-weight: 700; }
html[data-theme="dark"] .note-tag { color: #0a0c10; background: var(--accent-ink); }
.note-mistake { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem 1rem; border-radius: 14px; background: var(--gentle-bg); margin-bottom: 1rem; }
.note-mistake .icon { color: var(--gentle); margin-top: 2px; }
.note-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

/* Tools pages ----------------------------------------------------------------- */
.picker-grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.sw-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.sw-item { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(70px, 1fr) auto; gap: .9rem; align-items: center; padding: .8rem 1rem; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.sw-item small { display: block; color: var(--muted); font-size: .82rem; }
.sw-cols { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.planner-week { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.plan-day { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: .8rem; min-height: 140px; display: flex; flex-direction: column; gap: .5rem; }
.plan-day.is-today { border: 2px solid var(--accent); }
.plan-day h3 { font-size: 1rem; margin: 0; display: flex; justify-content: space-between; }
.plan-item { display: flex; align-items: center; gap: .5rem; padding: .45rem .55rem; border-radius: 12px; background: var(--surface-2); font-size: .9rem; min-height: 48px; }
.plan-item.is-done { opacity: .6; text-decoration: line-through; }
.plan-item input[type="checkbox"] { width: 24px; height: 24px; flex: none; accent-color: var(--accent); }
.plan-item .plan-del { margin-left: auto; width: 40px; height: 40px; border: 0; background: none; color: var(--muted); border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.plan-item a { color: inherit; }
.form-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
.field { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; }
.field select, .field input[type="number"] {
  min-height: var(--tap); padding: .5rem .8rem; border-radius: 12px; border: 2px solid var(--border); background: var(--surface); color: var(--text); font-size: max(16px, 1rem);
}
.check-pills { display: flex; flex-wrap: wrap; gap: .5rem; }
.check-pills label { position: relative; }
.check-pills input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.check-pills > label > span { display: inline-flex; align-items: center; min-height: var(--tap); padding: .5rem 1rem; border-radius: 999px; border: 2px solid var(--border); background: var(--surface); font-weight: 500; }
.check-pills input:checked + span { background: var(--accent-soft); border-color: var(--accent); }
.check-pills input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.custom-banner { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: .8rem 1rem; margin-bottom: 1rem; border-radius: 14px; background: var(--accent-soft); border: 1px solid var(--accent-line); }

/* 11. Accessibility drawer ------------------------------------------------------ */
.drawer-backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(10, 15, 30, .4); opacity: 0; transition: opacity var(--dur); }
.drawer-backdrop.is-open { opacity: 1; }
.drawer {
  position: fixed; z-index: 80; top: 0; right: 0; bottom: 0; width: min(420px, 100vw);
  display: flex; flex-direction: column; background: var(--surface); color: var(--text);
  box-shadow: -12px 0 40px rgba(0, 0, 0, .18); border-left: 1px solid var(--border);
  transform: translate3d(105%, 0, 0); transition: transform .38s var(--ease); visibility: hidden;
  padding-right: var(--safe-r); padding-bottom: var(--safe-b);
}
.drawer.is-open { transform: translate3d(0, 0, 0); visibility: visible; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 1.2rem; }
.drawer-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 1rem 1.25rem 2rem; overscroll-behavior: contain; }
.drawer-section { padding: .5rem 0 1.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.drawer-h { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .75rem; }
.theme-grid { display: grid; gap: .5rem; }
.theme-option { position: relative; display: flex; align-items: center; gap: .8rem; padding: .5rem; min-height: 60px; border-radius: 14px; border: 2px solid var(--border); cursor: pointer; }
.theme-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.theme-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.theme-option input:focus-visible ~ .theme-swatch { outline: 3px solid var(--focus); outline-offset: 2px; }
.theme-swatch { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; border: 1px solid rgba(0,0,0,.12); flex: none; }
.theme-text { display: flex; flex-direction: column; line-height: 1.3; }
.theme-text small, .switch-text small { color: var(--muted); font-size: .85rem; }
[data-swatch="light"] .theme-swatch { background: #fff; color: #1c2333; }
[data-swatch="cream"] .theme-swatch { background: #f8f0dc; color: #2a251d; }
[data-swatch="mint"]  .theme-swatch { background: #e0f2e7; color: #19291f; }
[data-swatch="blue"]  .theme-swatch { background: #dfe9f8; color: #17223a; }
[data-swatch="dark"]  .theme-swatch { background: #0a0c10; color: #fff; }
.switch-row, .field-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 60px; padding: .4rem 0; cursor: pointer; }
.field-row { flex-wrap: wrap; cursor: default; }
.switch-text { display: flex; flex-direction: column; line-height: 1.35; }
.switch {
  -webkit-appearance: none; appearance: none; flex: none; position: relative; width: 58px; height: 34px; margin: 0;
  border-radius: 17px; background: var(--surface-3); border: 2px solid var(--border); cursor: pointer; transition: background-color var(--dur);
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform var(--dur) var(--ease);
}
.switch:checked { background: var(--accent); border-color: var(--accent); }
.switch:checked::after { transform: translate3d(24px, 0, 0); }
.size-control { display: flex; align-items: center; gap: .5rem; width: 100%; }
.size-control input { flex: 1; }
.preview-box p { margin: 0; padding: 1rem; border-radius: 14px; background: var(--surface-2); }

/* 12. Accessibility modes --------------------------------------------------------- */
/* Bionic reading */
.bionic b { font-weight: 700; }
.bionic-vis { font-weight: 400; }
html[data-theme="dark"] .bionic b { color: #ffffff; }

/* Dyslexia-friendly spacing */
html[data-spacing="wide"] body { letter-spacing: .05em; word-spacing: .16em; line-height: 1.85; }
html[data-spacing="wide"] p, html[data-spacing="wide"] li { max-width: 68ch; }
html[data-spacing="wide"] .fc-text, html[data-spacing="wide"] .q-text { line-height: 1.75; }
html[data-spacing="wide"] h1, html[data-spacing="wide"] h2, html[data-spacing="wide"] h3 { letter-spacing: .02em; line-height: 1.45; }

/* Reduce motion: pause CSS animations and remove transitions */
html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after {
  animation-play-state: paused !important;
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
  scroll-behavior: auto !important;
}

/* 13. Responsive: iPad landscape & desktop get a side rail -------------------------- */
@media (orientation: landscape) and (min-width: 900px), (min-width: 1200px) {
  .app-main { padding-bottom: 0; }
  .tabbar {
    position: sticky; top: 0; bottom: auto; right: auto; order: -1; flex: none;
    width: calc(var(--rail-w) + var(--safe-l)); height: 100vh; height: 100dvh;
    padding: max(.75rem, env(safe-area-inset-top)) 0 calc(.75rem + var(--safe-b)) var(--safe-l);
    border-top: 0; border-right: 1px solid var(--border);
  }
  .tabbar-list { flex-direction: column; height: 100%; overflow-y: auto; overflow-x: hidden; gap: 2px; padding: 0 .4rem; justify-content: center; }
  .tabbar-list > li { flex: 0 0 auto; min-width: 0; }
  .tabbar-list > li:last-child { margin-top: auto; }
  .tab { min-height: 64px; }
  .toast { bottom: calc(24px + var(--safe-b)); }
  .exam-layout.has-nav { grid-template-columns: minmax(0, 1fr) 260px; align-items: start; }
  .exam-layout.has-nav .navgrid-wrap { position: sticky; top: 200px; order: 2; }
  .fc-text { max-width: 36ch; }
}
@media (min-width: 700px) {
  .hero { grid-template-columns: 1fr minmax(260px, 340px); }
}
@media (max-width: 600px) {
  .topbar-actions .btn-icon-text span { display: none; }
  .tabbar-list > li { min-width: 64px; }
  .summary-list li { grid-template-columns: 1fr auto; }
  .summary-list li .bar { display: none; }
  .ex-controls { grid-template-columns: auto auto auto; }
  .ex-controls .ex-scrub { grid-column: 1 / -1; }
  .exam-bar { top: 128px; }
}
@media print {
  .tabbar, .topbar, .drawer, .drawer-backdrop, .mode-tabs, .site-footer { display: none !important; }
  .app-main { padding: 0; }
}
