:root {
  color-scheme: light;
  --navy: #10294c;
  --navy-2: #193b67;
  --blue: #155eef;
  --blue-dark: #0e49c7;
  --sky: #eaf2ff;
  --paper: #ffffff;
  --canvas: #eef3f8;
  --ink: #15263d;
  --muted: #53657a;
  --line: #c8d4e2;
  --line-strong: #94a9c0;
  --green: #07856f;
  --green-soft: #daf5eb;
  --red: #c4433b;
  --red-soft: #fde8e6;
  --amber: #f5b941;
  --shadow: 0 24px 60px rgba(25, 50, 82, .16), 0 4px 12px rgba(25, 50, 82, .09);
  --font: Bahnschrift, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background-color: var(--canvas);
  background-image:
    linear-gradient(rgba(16, 41, 76, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 41, 76, .035) 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }
::selection { color: white; background: var(--blue); }
* { scrollbar-color: var(--line-strong) var(--canvas); scrollbar-width: thin; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 218px minmax(0, 1fr); }
.legend {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 30px 20px 24px;
  color: #f7fbff;
  background: var(--navy);
  overflow: hidden;
}
.legend::after {
  content: "";
  position: absolute;
  inset: auto -72px -72px auto;
  width: 190px;
  aspect-ratio: 1;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 50%;
  box-shadow: 0 0 0 26px rgba(255,255,255,.025), 0 0 0 52px rgba(255,255,255,.02);
  pointer-events: none;
}
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark { display: grid; width: 44px; height: 44px; place-items: center; color: var(--navy); background: white; }
.brand-mark svg { width: 28px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.brand strong { display: block; font-size: 18px; letter-spacing: .16em; }
.brand small { display: block; margin-top: 2px; color: #a7bdd7; font-size: 11px; letter-spacing: .13em; text-transform: uppercase; }
.primary-nav { display: grid; gap: 8px; margin-top: 54px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid transparent;
  color: #aabbd0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}
.nav-item svg, .icon-text-button svg, .primary-button svg, .dialog-close svg { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-item:hover { color: white; border-color: rgba(255,255,255,.15); }
.nav-item.is-active { color: white; border-color: rgba(255,255,255,.28); background: rgba(255,255,255,.09); }
.nav-badge { display: grid; min-width: 22px; height: 22px; margin-left: auto; padding: 0 6px; place-items: center; color: var(--navy); background: white; font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
.nav-badge[hidden] { display: none; }
.legend-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: auto; border: 1px solid rgba(255,255,255,.16); background: rgba(255,255,255,.16); }
.legend-stats div { padding: 15px 12px; background: var(--navy); }
.legend-stats span { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.legend-stats small { color: #9fb3cc; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.source-note { margin: 18px 0 0; color: #7f9ab9; font-size: 11px; line-height: 1.55; letter-spacing: .08em; text-transform: uppercase; }

.workspace { min-width: 0; padding: 48px clamp(24px, 5vw, 76px) 56px; }
.screen { display: none; width: min(1160px, 100%); margin: 0 auto; animation: screen-in .38s cubic-bezier(.2,.8,.2,1) both; }
.screen.is-active { display: block; }
@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.screen-heading { display: flex; justify-content: space-between; gap: 40px; align-items: flex-end; margin-bottom: 42px; }
.screen-heading h1, .results-heading h1 { max-width: 720px; margin: 0; color: var(--navy); font-size: clamp(30px, 4vw, 52px); line-height: 1; letter-spacing: -.035em; font-weight: 650; }
.screen-heading p, .results-heading p { max-width: 650px; margin: 14px 0 0; color: var(--muted); font-size: 16px; line-height: 1.55; }
.formula-sketch { position: relative; width: 260px; flex: 0 0 260px; color: var(--blue); }
.formula-sketch svg { display: block; width: 100%; height: 90px; overflow: visible; }
.formula-sketch .grid-line { fill: none; stroke: var(--line); stroke-width: 1; }
.formula-sketch .curve { fill: none; stroke: currentColor; stroke-width: 2.4; vector-effect: non-scaling-stroke; }
.formula-sketch span { position: absolute; right: 0; bottom: -7px; padding-left: 8px; color: var(--blue); background: var(--canvas); font-family: Cambria, Georgia, serif; font-style: italic; }

.setup-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .8fr); gap: 24px; align-items: start; }
.config-column { display: grid; gap: 24px; }
.config-section { position: relative; padding: 24px; border: 1px solid var(--line); background: rgba(255,255,255,.78); box-shadow: 0 8px 28px rgba(32,55,86,.05); }
.config-section::before { content: ""; position: absolute; left: -1px; top: -1px; width: 24px; height: 24px; border-left: 2px solid var(--blue); border-top: 2px solid var(--blue); pointer-events: none; }
.compact-section { padding-bottom: 22px; }
.section-heading-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading-row > div:first-child { display: flex; align-items: center; gap: 10px; }
.section-heading-row h2 { margin: 0; color: var(--navy); font-size: 18px; font-weight: 650; }
.step-index { display: grid; width: 25px; height: 25px; place-items: center; color: white; background: var(--blue); font-size: 12px; }
.inline-actions { display: flex; gap: 12px; }
.text-button { padding: 4px 0; border: 0; color: var(--blue); background: transparent; cursor: pointer; font-size: 12px; border-bottom: 1px solid currentColor; }
.text-button:hover { color: var(--blue-dark); }

.topic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.topic-option { position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 11px; align-items: center; min-height: 58px; padding: 10px 12px; border: 1px solid var(--line); color: var(--ink); background: var(--paper); cursor: pointer; text-align: left; transition: border-color .16s ease, background .16s ease, transform .16s ease; }
.topic-option:hover { border-color: var(--blue); transform: translateY(-1px); }
.topic-option.is-selected { border-color: var(--blue); background: var(--sky); }
.topic-check { display: grid; width: 20px; height: 20px; place-items: center; border: 1px solid var(--line-strong); color: white; background: white; }
.is-selected .topic-check { border-color: var(--blue); background: var(--blue); }
.topic-check svg { width: 13px; fill: none; stroke: currentColor; stroke-width: 2.4; opacity: 0; }
.is-selected .topic-check svg { opacity: 1; }
.topic-name { font-size: 13px; line-height: 1.25; }
.topic-count { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }

.difficulty-grid { display: grid; gap: 8px; }
.difficulty-option { display: grid; grid-template-columns: 76px 1fr 20px; align-items: center; gap: 8px; min-height: 45px; padding: 7px 10px; border: 1px solid var(--line); background: white; cursor: pointer; text-align: left; transition: border-color .16s, background .16s; }
.difficulty-option:hover { border-color: var(--blue); }
.difficulty-option.is-selected { border-color: var(--blue); background: var(--sky); }
.difficulty-symbol { color: var(--blue); font-size: 14px; letter-spacing: .08em; white-space: nowrap; }
.difficulty-label { color: var(--muted); font-size: 11px; line-height: 1.25; }
.mini-check { display: grid; width: 18px; height: 18px; place-items: center; border: 1px solid var(--line-strong); color: white; }
.is-selected .mini-check { border-color: var(--blue); background: var(--blue); }
.mini-check::after { content: ""; width: 7px; height: 4px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg) translateY(-1px); }

.segment-control { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line); background: white; }
.segment-control button { min-height: 42px; padding: 0 10px; border: 0; border-right: 1px solid var(--line); color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; }
.segment-control button:last-child { border-right: 0; }
.segment-control button:hover { color: var(--blue); }
.segment-control button.is-active { color: white; background: var(--navy); }

.launch-bar { position: sticky; bottom: 18px; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-top: 24px; padding: 18px 18px 18px 22px; color: white; background: var(--navy); box-shadow: 0 18px 44px rgba(16,41,76,.24); }
.launch-bar strong, .launch-bar span { display: block; }
.launch-bar strong { font-size: 15px; }
.launch-bar > div > span { margin-top: 4px; color: #a9bdd5; font-size: 11px; }
.primary-button, .secondary-button { min-height: 50px; padding: 0 21px; border: 1px solid transparent; cursor: pointer; font-weight: 650; transition: transform .16s, background .16s, opacity .16s; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 18px; color: white; background: var(--blue); }
.primary-button:hover { background: #3475f6; transform: translateY(-2px); }
.primary-button:active { transform: translateY(0); }
.primary-button:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.secondary-button { color: var(--navy); border-color: var(--line-strong); background: white; }
.secondary-button:hover { border-color: var(--blue); color: var(--blue); }

/* Study */
#studyScreen { max-width: 940px; }
.study-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.icon-text-button { display: inline-flex; gap: 8px; align-items: center; min-height: 38px; padding: 0; border: 0; color: var(--muted); background: transparent; cursor: pointer; }
.icon-text-button:hover { color: var(--blue); }
.study-progress-copy { display: flex; align-items: baseline; gap: 12px; font-variant-numeric: tabular-nums; }
.study-progress-copy strong { color: var(--navy); font-size: 15px; }
.study-progress-copy span { color: var(--muted); font-size: 11px; }
.progress-track { height: 4px; margin-top: 17px; background: #d9e2ec; overflow: hidden; }
.progress-fill { width: 100%; height: 100%; background: var(--blue); transform: scaleX(0); transform-origin: left; transition: transform .45s cubic-bezier(.2,.8,.2,1); }
.study-meta { display: flex; align-items: center; gap: 10px; margin: 26px 0 13px; min-height: 24px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .065em; }
.study-meta span { padding-right: 10px; border-right: 1px solid var(--line); }
.study-meta span:last-child { padding-right: 0; border-right: 0; }
.difficulty-mark { color: var(--blue); letter-spacing: .09em; }
.flashcard { position: relative; display: block; width: min(100%, 860px); margin: 0 auto; padding: 0; border: 0; background: transparent; perspective: 1600px; cursor: pointer; }
.flashcard-inner { position: relative; display: grid; width: 100%; aspect-ratio: 1.43; transform-style: preserve-3d; transition: transform .58s cubic-bezier(.2,.76,.25,1); }
.flashcard.is-flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face { grid-area: 1 / 1; position: relative; display: grid; place-items: center; padding: 28px; border: 1px solid #b9c7d6; background: white; box-shadow: var(--shadow); backface-visibility: hidden; overflow: hidden; }
.flashcard-face::after { content: ""; position: absolute; inset: 13px; border: 1px solid rgba(21,94,239,.12); pointer-events: none; }
.flashcard-back { transform: rotateY(180deg); }
.flashcard img { display: block; width: 100%; height: 100%; object-fit: contain; }
.paper-stack { position: absolute; inset: 12px -10px -10px 10px; border: 1px solid #c7d4e1; background: #dfe8f2; transform: rotate(.65deg); box-shadow: 0 14px 40px rgba(25,50,82,.12); }
.face-label { position: absolute; top: 18px; left: -1px; padding: 6px 11px 5px; color: white; background: var(--blue); font-size: 9px; letter-spacing: .13em; }
.answer-label { background: var(--green); }
.card-instruction { margin: 20px 0 0; color: var(--muted); text-align: center; font-size: 12px; }
kbd { display: inline-grid; min-width: 23px; height: 22px; padding: 0 5px; place-items: center; border: 1px solid #aebdcd; border-bottom-width: 2px; color: var(--navy); background: white; font: 11px var(--font); }
.rating-panel { margin-top: 22px; opacity: 0; transform: translateY(-8px); transition: opacity .24s ease .12s, transform .36s cubic-bezier(.2,.8,.2,1); }
.rating-panel.is-visible { opacity: 1; transform: translateY(0); }
.rating-panel > p { margin: 0 0 10px; color: var(--muted); text-align: center; font-size: 12px; }
.rating-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rate-button { display: flex; justify-content: space-between; align-items: center; min-height: 58px; padding: 8px 16px; border: 1px solid; cursor: pointer; text-align: left; transition: transform .16s, background .16s; }
.rate-button:hover { transform: translateY(-2px); }
.rate-button span { display: flex; align-items: center; gap: 9px; font-weight: 650; }
.rate-button small { opacity: .75; font-size: 10px; }
.rate-button.repeat { color: var(--red); border-color: #e5aaa6; background: var(--red-soft); }
.rate-button.know { color: var(--green); border-color: #8fd1c3; background: var(--green-soft); }

/* Results */
#resultsScreen { max-width: 840px; padding-top: 6vh; }
.results-heading { display: flex; gap: 22px; align-items: flex-start; padding-bottom: 34px; border-bottom: 1px solid var(--line); }
.result-symbol { display: grid; width: 70px; height: 70px; flex: 0 0 70px; place-items: center; color: white; background: var(--blue); font-family: Cambria, serif; font-size: 38px; }
.result-summary { display: flex; justify-content: space-between; gap: 40px; align-items: flex-end; margin-top: 42px; }
.result-primary strong { display: block; color: var(--navy); font-size: clamp(64px, 11vw, 116px); line-height: .8; letter-spacing: -.065em; font-variant-numeric: tabular-nums; }
.result-primary span { display: block; margin-top: 18px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }
.result-breakdown { display: flex; gap: 38px; }
.result-breakdown > div { display: grid; grid-template-columns: auto auto; align-items: center; gap: 2px 9px; }
.result-breakdown strong { font-size: 30px; font-variant-numeric: tabular-nums; }
.result-breakdown small { grid-column: 2; color: var(--muted); font-size: 11px; }
.dot { width: 9px; height: 30px; grid-row: span 2; background: var(--green); }
.dot.repeat { background: var(--red); }
.result-bar { height: 10px; margin-top: 34px; background: var(--red-soft); }
.result-bar span { display: block; width: 100%; height: 100%; background: var(--green); transform: scaleX(0); transform-origin: left; transition: transform .8s cubic-bezier(.2,.8,.2,1); }
.result-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 32px; }

.mistakes-section { margin-top: 42px; padding-top: 30px; border-top: 1px solid var(--line); }
.mistakes-heading h2 { margin: 0; color: var(--navy); font-size: 22px; }
.mistakes-heading p { margin: 7px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.mistakes-list { display: grid; gap: 8px; margin-top: 20px; }
.mistake-item { border: 1px solid var(--line); background: rgba(255,255,255,.82); }
.mistake-item[open] { border-color: var(--line-strong); background: white; }
.mistake-item summary { display: grid; grid-template-columns: 38px minmax(0, 1fr) 22px; gap: 13px; align-items: center; min-height: 66px; padding: 10px 14px; cursor: pointer; list-style: none; }
.mistake-item summary::-webkit-details-marker { display: none; }
.mistake-item summary:hover { background: var(--red-soft); }
.mistake-number { color: var(--red); font-size: 11px; font-variant-numeric: tabular-nums; }
.mistake-item summary span:nth-child(2) { min-width: 0; }
.mistake-item summary small, .mistake-item summary strong { display: block; }
.mistake-item summary small { margin-bottom: 3px; color: var(--muted); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
.mistake-item summary strong { overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.mistake-item summary svg { width: 20px; fill: none; stroke: var(--muted); stroke-width: 1.8; transition: transform .18s ease; }
.mistake-item[open] summary svg { transform: rotate(180deg); }
.mistake-faces { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; padding: 1px; border-top: 1px solid var(--line); background: var(--line); }
.mistake-faces figure { position: relative; margin: 0; padding: 14px; background: white; }
.mistake-faces img { display: block; width: 100%; aspect-ratio: 1.43; object-fit: contain; }
.mistake-faces figcaption { position: absolute; top: 10px; left: 0; padding: 5px 8px; color: white; background: var(--navy); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.mistake-faces figure:last-child figcaption { background: var(--green); }

/* Review queue */
.review-heading { align-items: flex-start; }
.review-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.review-toolbar strong { color: var(--navy); font-size: 14px; }
.danger-text { color: var(--red); }
.danger-text:hover { color: #9e302a; }
.review-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.review-card { display: grid; grid-template-columns: 142px minmax(0, 1fr); min-width: 0; border: 1px solid var(--line); background: rgba(255,255,255,.82); }
.review-card img { display: block; width: 142px; height: 100%; min-height: 112px; border-right: 1px solid var(--line); background: white; object-fit: contain; }
.review-card-copy { min-width: 0; padding: 16px; }
.review-card-copy span { display: block; overflow: hidden; color: var(--muted); font-size: 9px; letter-spacing: .06em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.review-card-copy h2 { display: -webkit-box; margin: 9px 0 16px; overflow: hidden; color: var(--ink); font-size: 14px; line-height: 1.35; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.review-card-copy small { color: var(--blue); font-size: 10px; letter-spacing: .05em; }
.review-empty { max-width: 620px; padding: 54px 36px; border: 1px solid var(--line); background: rgba(255,255,255,.78); text-align: center; }
.review-empty > span { display: grid; width: 64px; height: 64px; margin: 0 auto 22px; place-items: center; color: var(--green); border: 1px solid #8fd1c3; background: var(--green-soft); }
.review-empty svg { width: 38px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.review-empty h2 { margin: 0; color: var(--navy); font-size: 24px; }
.review-empty p { max-width: 440px; margin: 10px auto 24px; color: var(--muted); font-size: 14px; line-height: 1.55; }

/* Tables */
.tables-heading { align-items: flex-start; }
.tables-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.table-sheet { padding: 0; border: 1px solid var(--line); color: var(--ink); background: white; box-shadow: 0 10px 28px rgba(25,50,82,.08); cursor: zoom-in; text-align: left; transition: transform .2s, box-shadow .2s, border-color .2s; }
.table-sheet:hover { border-color: var(--blue); transform: translateY(-4px); box-shadow: 0 18px 38px rgba(25,50,82,.14); }
.table-sheet img { display: block; width: 100%; aspect-ratio: 1.43; object-fit: contain; border-bottom: 1px solid var(--line); }
.table-sheet > span { display: flex; gap: 12px; align-items: center; min-height: 50px; padding: 9px 14px; font-size: 13px; }
.table-sheet b { color: var(--blue); font-variant-numeric: tabular-nums; }
.table-dialog { width: min(96vw, 1500px); height: min(94vh, 1100px); max-width: none; max-height: 94vh; padding: 0; border: 0; overflow: hidden; background: #d9e3ee; box-shadow: 0 30px 90px rgba(5,20,40,.35); }
.table-dialog::backdrop { background: rgba(7,23,43,.78); backdrop-filter: blur(5px); }
.table-viewport { width: 100%; height: 100%; overflow: auto; overscroll-behavior: contain; }
.table-dialog img { display: block; width: 100%; max-width: none; height: auto; margin: 0 auto; }
.dialog-close { position: fixed; z-index: 2; top: 18px; right: 18px; display: grid; width: 44px; height: 44px; place-items: center; border: 1px solid rgba(255,255,255,.5); color: white; background: var(--navy); cursor: pointer; }
.table-zoom { position: fixed; z-index: 2; left: 50%; bottom: 18px; display: grid; grid-template-columns: 42px 62px 42px; align-items: center; color: white; background: var(--navy); box-shadow: 0 8px 30px rgba(5,20,40,.3); transform: translateX(-50%); }
.table-zoom button { width: 42px; height: 42px; border: 0; color: white; background: transparent; cursor: pointer; font-size: 22px; }
.table-zoom button:hover { background: var(--blue); }
.table-zoom output { text-align: center; font-size: 11px; font-variant-numeric: tabular-nums; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 30; padding: 11px 16px; color: white; background: var(--navy); box-shadow: 0 10px 30px rgba(16,41,76,.28); opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: opacity .2s, transform .2s; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.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; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 84px minmax(0, 1fr); }
  .legend { padding-inline: 14px; align-items: center; }
  .brand > span:last-child, .nav-item span, .legend-stats small, .source-note { display: none; }
  .primary-nav { width: 100%; }
  .nav-item { justify-content: center; padding: 0; }
  .nav-badge { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 4px; color: white; background: var(--red); }
  .nav-item { position: relative; }
  .legend-stats { grid-template-columns: 1fr; width: 100%; }
  .legend-stats div { text-align: center; }
  .setup-grid { grid-template-columns: 1fr; }
  .config-column { grid-template-columns: 1fr 1fr; }
  .config-column .config-section:first-child { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
  .app-shell { display: block; }
  .legend { position: sticky; z-index: 20; width: 100%; height: 68px; padding: 10px 14px; flex-direction: row; align-items: center; box-shadow: 0 4px 20px rgba(16,41,76,.18); }
  .brand-mark { width: 40px; height: 40px; }
  .primary-nav { display: flex; width: auto; margin: 0 0 0 auto; gap: 5px; }
  .nav-item { width: 44px; min-height: 42px; }
  .legend-stats { display: none; }
  .workspace { padding: 30px 14px 38px; }
  .table-dialog { width: 96vw; height: 92vh; }
  .screen-heading { align-items: flex-start; margin-bottom: 27px; }
  .screen-heading h1, .results-heading h1 { font-size: clamp(29px, 9vw, 40px); }
  .screen-heading p { font-size: 14px; }
  .formula-sketch { display: none; }
  .topic-grid { grid-template-columns: 1fr; }
  .config-column { display: grid; grid-template-columns: 1fr; }
  .config-column .config-section:first-child { grid-column: auto; }
  .config-section { padding: 18px; }
  .launch-bar { bottom: 8px; align-items: stretch; flex-direction: column; gap: 13px; padding: 15px; }
  .launch-bar .primary-button { width: 100%; }
  .study-meta { flex-wrap: wrap; margin-top: 20px; }
  .flashcard-inner { aspect-ratio: 1.18; }
  .flashcard-face { padding: 14px; }
  .flashcard-face::after { inset: 7px; }
  .flashcard img { object-fit: contain; }
  .face-label { top: 8px; padding: 5px 8px; }
  .card-instruction { line-height: 1.6; }
  .rating-actions { grid-template-columns: 1fr; }
  .rating-panel.is-visible { max-height: 230px; }
  .rate-button { min-height: 54px; }
  .result-summary { align-items: flex-start; flex-direction: column; }
  .result-breakdown { width: 100%; justify-content: space-between; }
  .result-actions { flex-direction: column-reverse; }
  .result-actions button { width: 100%; }
  .mistake-faces { grid-template-columns: 1fr; }
  .review-heading { flex-direction: column; gap: 24px; }
  .review-heading .primary-button { width: 100%; }
  .review-list { grid-template-columns: 1fr; }
  .review-card { grid-template-columns: 104px minmax(0, 1fr); }
  .review-card img { width: 104px; }
  .review-empty { padding: 40px 20px; }
  .tables-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
