:root {
  color-scheme: light;
  /* Semantic roles keep each color's meaning consistent across screens. */
  --ink: #17253d;
  --muted: #5e6d83;
  --paper: #f5f7fc;
  --surface: #fff;
  --line: #dce4f0;
  --primary: #315bd8;
  --primary-strong: #2448bd;
  --primary-soft: #eaf0ff;
  --on-primary-soft: #203b86;
  --navy: #172b50;
  --gold: #80530b;
  --gold-soft: #fff5df;
  --success: #246c49;
  --success-soft: #e7f4eb;
  --danger: #a43643;
  --danger-soft: #fbeaec;
  --radius: 16px;
  --shadow: 0 12px 32px rgba(22, 49, 58, .07);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { min-width: 320px; margin: 0; background: var(--paper); -webkit-font-smoothing: antialiased; }
button, textarea, select { font: inherit; }
button { color: inherit; touch-action: manipulation; }
button:focus-visible, a:focus-visible, textarea:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}
[hidden] { display: none !important; }

.app-shell {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
.topbar, .main-content, .footer-note {
  width: min(calc(100% - 36px), 960px);
  margin-inline: auto;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(220, 228, 240, .88);
  background: rgba(245, 247, 252, .93);
  backdrop-filter: blur(16px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  border: 1px solid #d5e0ff;
  border-radius: 13px;
  background: var(--primary-soft);
}
.brand-mark svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: var(--primary);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: .93rem; font-weight: 760; }
.brand small { margin-top: 2px; color: var(--muted); font-size: .68rem; }
.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  font-size: .92rem;
  font-weight: 740;
  cursor: pointer;
}
.icon-button span { margin-left: 1px; font-size: .64rem; vertical-align: top; }

.main-content { flex: 1; padding: 26px 0 34px; }
.footer-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 0 16px;
  color: var(--muted);
  font-size: .69rem;
  line-height: 1.55;
}
.footer-contact { flex: 0 0 auto; margin: -4px 0 0 auto; padding: 4px 0 4px 10px; border: 0; color: var(--primary); background: transparent; font-size: .72rem; font-weight: 720; text-decoration: none; cursor: pointer; }
.demo-dot { width: 7px; height: 7px; flex: 0 0 auto; margin-top: 5px; border-radius: 50%; background: #c1934d; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(1.8rem, 4vw, 2.35rem); line-height: 1.3; font-weight: 760; letter-spacing: -.04em; }
h2 { margin-bottom: 9px; font-size: 1.13rem; line-height: 1.4; letter-spacing: -.02em; }
h3 { margin-bottom: 8px; font-size: 1rem; }
p { line-height: 1.7; }
.muted { color: var(--muted); }
.small { font-size: .81rem; }
.eyebrow, .section-kicker {
  margin: 0 0 7px;
  color: var(--primary);
  font-size: .74rem;
  font-weight: 760;
  letter-spacing: .035em;
}

.button-primary, .button-secondary, .button-quiet, .button-danger {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 12px;
  text-decoration: none;
  font-size: .85rem;
  font-weight: 740;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}
.button-primary:active, .button-secondary:active, .button-quiet:active, .button-danger:active { transform: scale(.985); }
.button-primary { color: white; background: var(--primary); }
.button-primary:hover { background: var(--primary-strong); }
.button-secondary { color: var(--on-primary-soft); border-color: #d9e3ff; background: var(--primary-soft); }
.button-secondary:hover { background: #dfe8ff; }
.button-quiet { color: var(--primary-strong); border-color: var(--line); background: var(--surface); }
.button-quiet:hover { border-color: #c6d2e5; background: #f8faff; }
.button-danger { color: var(--danger); border-color: #f0d5d9; background: var(--danger-soft); }
.button-primary:disabled, .button-secondary:disabled, .button-quiet:disabled, .button-danger:disabled { opacity: .48; cursor: not-allowed; }
.action-row { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 16px; }
.text-link, .report-link {
  padding: 4px 0;
  border: 0;
  color: var(--primary);
  background: transparent;
  font-size: .77rem;
  font-weight: 740;
  text-decoration: none;
  cursor: pointer;
}

/* Home dashboard */
.home-heading { margin: 5px 0 17px; }
.home-heading h1 { margin-bottom: 4px; }
.home-heading > p:last-child { margin-bottom: 0; color: var(--muted); font-size: .85rem; }

.demo-note, .notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border: 1px solid #efdfb8;
  border-radius: 12px;
  color: #604a25;
  background: var(--gold-soft);
  font-size: .72rem;
  line-height: 1.6;
}
.demo-note { margin: 0 0 15px; }
.demo-note-mark, .notice-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #704d14;
  background: #f4e5bd;
  font-size: .72rem;
  font-weight: 800;
}
.demo-note strong, .demo-note span:not(.demo-note-mark) { display: block; }
.demo-note strong, .notice strong { margin-bottom: 1px; font-weight: 740; }

.home-primary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr);
  align-items: stretch;
  gap: 16px;
  margin-bottom: 26px;
}
.official-practice-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: -5px 0 27px;
  padding: 17px 19px;
  border: 1px solid #d7e3fb;
  border-radius: 15px;
  background: linear-gradient(105deg, #edf3ff, #f7f9ff 68%, #fff);
}
.official-practice-copy { min-width: 0; }
.official-practice-card .exam-switch { min-width: 0; }
.official-practice-copy .section-kicker { margin-bottom: 4px; }
.official-practice-copy h2 { margin-bottom: 4px; font-size: .96rem; }
.official-practice-copy p:not(.section-kicker) { margin: 0 0 2px; color: #42536e; font-size: .75rem; line-height: 1.5; }
.official-practice-copy small { color: var(--muted); font-size: .67rem; line-height: 1.5; }
.official-practice-card .button-secondary { flex: 0 0 auto; white-space: nowrap; }
.official-practice-actions { display: flex; flex: 0 0 auto; flex-direction: column; gap: 8px; }
.official-practice-actions button { white-space: nowrap; }
.practice-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 20px;
  border: 1px solid #243d6b;
  border-radius: 17px;
  color: #fff;
  background: var(--navy);
  box-shadow: 0 12px 26px rgba(25, 59, 67, .12);
}
.practice-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.practice-card .section-kicker { margin: 0; color: #c3d2ff; }
.practice-open {
  padding: 4px 8px;
  border: 1px solid rgba(220, 230, 255, .28);
  border-radius: 999px;
  color: #e7edff;
  font-size: .65rem;
  white-space: nowrap;
}
.practice-card-main { display: flex; align-items: center; gap: 16px; margin: 19px 0; }
.practice-number {
  min-width: 82px;
  color: #d8e2ff;
  font-size: 2.65rem;
  font-weight: 780;
  line-height: 1;
  letter-spacing: -.07em;
}
.practice-number small { margin-left: 4px; color: #d8e2ff; font-size: .83rem; letter-spacing: 0; }
.practice-copy { min-width: 0; }
.practice-copy h2 { margin: 0 0 5px; color: #fff; font-size: 1.04rem; }
.practice-copy p { margin: 0; color: #d0d9ef; font-size: .73rem; line-height: 1.55; }
.practice-button {
  width: 100%;
  justify-content: space-between;
  min-height: 46px;
  padding-inline: 14px;
  color: #fff;
  background: var(--primary);
}
.practice-button:hover { color: #fff; background: #416be8; }
.practice-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.practice-footnote { display: flex; flex-wrap: wrap; gap: 13px; margin-top: 12px; color: #d0d9ef; font-size: .65rem; }
.practice-footnote span + span::before { content: "•"; margin-right: 7px; color: #a9baff; }

.progress-section { min-width: 0; }
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
}
.section-heading h2 { margin: 0; }
.section-heading .section-kicker { margin-bottom: 3px; }
.section-heading .text-link { flex: 0 0 auto; font-size: .7rem; }
.learning-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}
.overview-item { min-width: 0; padding: 14px 12px; }
.overview-item + .overview-item { border-left: 1px solid var(--line); }
.overview-item span, .record-summary span {
  display: block;
  min-height: 2.2em;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: .66rem;
  line-height: 1.4;
}
.overview-item strong, .record-summary strong {
  display: block;
  font-size: 1.35rem;
  font-weight: 760;
  letter-spacing: -.045em;
}
.overview-item small, .record-summary small {
  margin-left: 3px;
  color: var(--muted);
  font-size: .69rem;
  font-weight: 600;
  letter-spacing: 0;
}
.recent-line { min-height: 2em; margin: 9px 0 0; color: var(--muted); font-size: .69rem; line-height: 1.5; }

.menu-section { margin-top: 26px; }
.menu-list, .settings-card, .record-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}
.menu-item {
  width: 100%;
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  text-align: left;
}
.menu-item + .menu-item { border-top: 1px solid #edf1f2; }
.menu-button { border: 0; color: inherit; background: transparent; text-decoration: none; cursor: pointer; }
.menu-button:hover:not(:disabled) { background: #f7f9ff; }
.menu-button:disabled { color: inherit; opacity: .62; cursor: default; }
.menu-icon {
  width: 39px;
  height: 39px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid #d9e3ff;
  border-radius: 12px;
  color: var(--primary);
  background: #f0f4ff;
}
.menu-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.history-icon { color: #566780; border-color: #dfe6f0; background: #f1f4f9; }
.menu-copy { min-width: 0; flex: 1; }
.menu-copy strong, .menu-copy small { display: block; }
.menu-copy strong { margin-bottom: 3px; font-size: .82rem; }
.menu-copy small { overflow: hidden; color: var(--muted); font-size: .68rem; line-height: 1.45; text-overflow: ellipsis; }
.menu-trailing {
  min-width: 25px;
  display: grid;
  place-items: center;
  color: var(--primary);
  font-size: .95rem;
  font-weight: 740;
}
.settings-section { margin-top: 25px; }
.settings-card { padding-inline: 15px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 13px; padding: 14px 0; }
.settings-row + .settings-row { border-top: 1px solid #edf1f2; }
.settings-row strong { font-size: .82rem; }
.settings-row .small { margin-top: 3px; font-size: .71rem; line-height: 1.5; }
.settings-controls { display: flex; flex: 0 0 auto; gap: 5px; }
.settings-actions { display: flex; flex: 0 0 auto; gap: 6px; }
.settings-actions button { min-height: 38px; padding: 6px 11px; font-size: .72rem; }
.settings-controls button {
  min-width: 37px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: white;
  font-size: .7rem;
  cursor: pointer;
}
.settings-controls button.active { color: white; border-color: var(--primary); background: var(--primary); }

/* Question flow */
.quiz-top {
  width: min(100%, 740px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 auto 15px;
}
.quiz-top .button-quiet { min-height: 39px; padding: 7px 11px; font-size: .76rem; }
.quiz-top > .pill { flex: 0 0 auto; }
.progress-wrap { display: flex; flex: 1; align-items: center; justify-content: flex-end; gap: 10px; }
.progress-track { width: min(34vw, 220px); height: 6px; overflow: hidden; border-radius: 999px; background: #e2e8f3; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--primary); transition: width .25s ease; }
.progress-count { color: var(--muted); font-size: .73rem; white-space: nowrap; }
.session-meter {
  width: min(100%, 740px);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 0 auto 12px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface);
  font-size: .71rem;
}
.session-meter strong { color: var(--ink); }
.mock-timer { color: var(--primary-dark); font-weight: 800; }
.exam-switch { margin: 0 0 12px; }
.mock-timer.is-low { color: #b3261e; }
.card { padding: 18px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); }
.quiz-card {
  scroll-margin-top: 84px;
  width: min(100%, 740px);
  margin-inline: auto;
  padding: clamp(17px, 4vw, 28px);
  box-shadow: 0 7px 22px rgba(22, 49, 58, .035);
}
.row-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.question-title { margin: 16px 0 18px; font-size: clamp(1.15rem, 3.8vw, 1.42rem); line-height: 1.65; letter-spacing: -.02em; }
.answer-hint { margin: -10px 0 14px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.content-origin { display: grid; gap: 3px; margin: 14px 0 12px; padding: 10px 12px; border-left: 3px solid var(--primary); border-radius: 0 10px 10px 0; color: #42536e; background: #f1f5ff; font-size: .7rem; line-height: 1.55; }
.content-origin strong { color: #2448bd; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #54666d;
  background: #eef3f4;
  font-size: .67rem;
  font-weight: 700;
  white-space: nowrap;
}
.pill.demo { color: var(--gold); background: var(--gold-soft); }
.pill.official { color: #2448bd; background: #eaf0ff; }
.pill.correct { color: var(--success); background: var(--success-soft); }
.pill.wrong { color: var(--danger); background: var(--danger-soft); }
.choices { display: grid; gap: 9px; }
.choice {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  background: white;
  text-align: left;
  line-height: 1.65;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.choice:hover { border-color: #9aafea; background: #fcfdff; }
.choice.selected { border-color: var(--primary); background: #f0f4ff; box-shadow: 0 0 0 2px rgba(49, 91, 216, .11); }
.choice-number {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: #53647d;
  background: #edf1f8;
  font-size: .73rem;
  font-weight: 760;
}
.choice.selected .choice-number { color: white; background: var(--primary); }
.choice-check { margin-left: auto; padding-left: 8px; color: var(--primary); font-size: 1.05rem; font-weight: 800; }
.answer-status { margin: 13px 0 0; color: var(--muted); font-size: .74rem; line-height: 1.55; }
.quiz-actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; }
.quiz-actions .button-primary { flex: 1; }
.quiz-actions .button-quiet, .quiz-actions .button-secondary { min-width: 72px; }
.text-link { margin-top: 10px; }

/* Results and source details */
.result-score {
  width: min(100%, 740px);
  margin: 8px auto 15px;
  padding: 20px;
  border: 1px solid #dce5fb;
  border-radius: 17px;
  color: var(--ink);
  background: #edf2ff;
}
.result-score .eyebrow { color: var(--primary); }
.result-score h1 { font-size: 1.35rem !important; }
.notice { width: min(100%, 740px); margin: 14px auto; }
.score-number { display: flex; align-items: baseline; gap: 7px; margin: 6px 0; color: var(--primary-strong); font-size: 2.55rem; font-weight: 780; letter-spacing: -.06em; }
.score-number small { color: var(--muted); font-size: .88rem; font-weight: 600; letter-spacing: 0; }
.score-details { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.result-score + .notice + .action-row, .result-score ~ .section-heading, .result-item { width: min(100%, 740px); margin-inline: auto; }
.result-score ~ .section-heading { margin-top: 22px; }
.result-item { margin-top: 11px; padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.result-item-head { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-bottom: 10px; }
.result-question { margin-bottom: 10px; font-weight: 740; line-height: 1.65; }
.answer-line { margin: 5px 0; color: var(--muted); font-size: .79rem; line-height: 1.6; }
.answer-line strong { color: var(--ink); }
.explanation { margin: 12px 0; padding: 12px 13px; border: 1px solid #dfe7f5; border-radius: 12px; color: #354963; background: #f5f7fc; font-size: .81rem; line-height: 1.75; }
.source-meta { padding-top: 10px; border-top: 1px solid #edf1f2; color: var(--muted); font-size: .72rem; line-height: 1.8; }
.source-meta strong { color: #3f5069; }
.choice-explanations, .source-links { margin-top: 12px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 12px; color: #42536e; background: #fbfcff; font-size: .76rem; line-height: 1.65; }
.choice-explanations > strong, .source-links > strong { display: block; margin-bottom: 7px; color: var(--ink); }
.choice-explanation { margin: 7px 0 0; }
.choice-explanation strong { margin-right: 3px; color: var(--on-primary-soft); }
.source-links ul { display: grid; gap: 5px; margin: 0; padding-left: 18px; }
.source-links a { color: var(--primary-strong); text-decoration-thickness: 1px; text-underline-offset: 2px; overflow-wrap: anywhere; }
.report-link { margin-top: 10px; }

/* Official question list */
.official-list-tools, .official-list { width: min(100%, 740px); margin-inline: auto; }
.official-search { display: grid; gap: 6px; margin-bottom: 11px; }
.official-search span { color: var(--muted); font-size: .72rem; font-weight: 720; }
.official-search input {
  width: 100%;
  min-height: 48px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: .92rem;
}
.official-search input::placeholder { color: #93a1b5; }
.official-field-filters { display: flex; flex-wrap: wrap; gap: 7px; }
.official-field-filters button {
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: .74rem;
  font-weight: 720;
  cursor: pointer;
}
.official-field-filters button.active { color: white; border-color: var(--primary); background: var(--primary); }
.official-list-count { margin: 10px 0 0; color: var(--muted); font-size: .72rem; }
.official-list { display: grid; gap: 10px; margin-top: 12px; }
.official-list-item { padding: 14px 15px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.official-list-head { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-bottom: 7px; }
.official-qnumber { color: var(--primary-strong); font-size: 1.02rem; font-weight: 780; letter-spacing: -.02em; }
.official-list-topic { margin: 0 0 4px; font-size: .86rem; font-weight: 740; }
.official-list-prompt {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.official-list-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 11px; }
.official-list-foot > span { color: var(--muted); font-size: .7rem; font-weight: 700; white-space: nowrap; }
.official-list-foot .button-secondary { min-height: 40px; padding: 7px 12px; font-size: .76rem; white-space: nowrap; }

/* Field-by-field results */
.field-stats { width: min(100%, 740px); margin: 14px auto 0; padding: 15px 16px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.field-stats h2 { margin-bottom: 11px; font-size: .95rem; }
.field-stat-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px auto 44px auto; align-items: center; gap: 10px; padding: 7px 0; }
.field-review-button { min-height: 34px; padding: 5px 10px; font-size: .68rem; white-space: nowrap; }
.field-stat-row + .field-stat-row { border-top: 1px solid #edf1f2; }
.field-stat-name { overflow: hidden; font-size: .78rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.field-stat-track { height: 8px; overflow: hidden; border-radius: 999px; background: #e2e8f3; }
.field-stat-fill { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.field-stat-row strong { font-size: .8rem; white-space: nowrap; }
.field-stat-rate { color: var(--muted); font-size: .76rem; font-weight: 700; text-align: right; }

/* Learning history */
.page-heading { width: min(100%, 740px); margin: 8px auto 18px; }
.page-heading h1 { margin-bottom: 6px; font-size: clamp(1.75rem, 4vw, 2.2rem); }
.page-heading p:last-child { margin-bottom: 0; font-size: .82rem; }
.record-summary {
  width: min(100%, 740px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0 auto 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}
.record-summary > div { padding: 15px 17px; }
.record-summary > div + div { border-left: 1px solid var(--line); }
.page-heading ~ .section-heading, .record-list { width: min(100%, 740px); margin-inline: auto; }
.page-heading ~ .section-heading { margin-top: 20px; }
.record-list { padding: 3px 16px; }
.history-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 11px; padding: 13px 0; border-bottom: 1px solid #edf1f2; }
.history-item:last-child { border-bottom: 0; }
.history-item strong { display: block; margin-bottom: 3px; font-size: .83rem; }
.history-item small { color: var(--muted); font-size: .7rem; line-height: 1.5; }
.history-score { color: var(--primary); font-size: .88rem; font-weight: 760; }
.empty-state { padding: 24px 12px; text-align: center; }
.empty-state p { margin-bottom: 15px; }

/* App navigation */
.bottom-nav {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: calc(9px + env(safe-area-inset-bottom));
  width: min(calc(100% - 26px), 420px);
  display: flex;
  justify-content: stretch;
  padding: 5px;
  transform: translateX(-50%);
  border: 1px solid rgba(218, 227, 241, .96);
  border-radius: 17px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 8px 24px rgba(23, 43, 80, .13);
  backdrop-filter: blur(18px);
}
.bottom-nav button {
  position: relative;
  min-height: 51px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  border-radius: 12px;
  color: #66758b;
  background: transparent;
  font-size: .65rem;
  font-weight: 680;
  cursor: pointer;
}
.bottom-nav button[aria-current="page"] { color: var(--on-primary-soft); background: var(--primary-soft); }
.bottom-nav button:disabled { color: #a2adbd; cursor: default; }
.bottom-nav svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-count { position: absolute; top: 4px; left: calc(50% + 10px); min-width: 15px; height: 15px; display: grid; place-items: center; padding: 0 4px; border-radius: 999px; color: white; background: var(--primary); font-size: .55rem; font-weight: 740; }

@media (min-width: 700px) {
  .topbar, .main-content, .footer-note { width: min(calc(100% - 56px), 960px); }
  .topbar { min-height: 76px; }
  .main-content { padding-top: 30px; }
  .home-heading { margin-bottom: 20px; }
  .practice-card { padding: 23px; }
  .bottom-nav { width: 360px; }
}

@media (max-width: 699px) {
  .home-primary-grid { grid-template-columns: 1fr; gap: 19px; }
  .practice-card { padding: 18px; }
  .practice-card-main { margin: 15px 0; }
  .progress-section .overview-item { padding: 12px 9px; }
  .bottom-nav {
    left: 0;
    bottom: 0;
    width: 100%;
    padding: 6px max(13px, calc((100vw - 420px) / 2)) calc(6px + env(safe-area-inset-bottom));
    transform: none;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 -5px 18px rgba(23, 43, 80, .08);
  }
  .bottom-nav button { min-height: 52px; }
}
@media (max-width: 900px) {
  .official-practice-card { flex-direction: column; align-items: stretch; gap: 11px; }
  .official-practice-actions { flex-direction: row; flex-wrap: wrap; }
  .official-practice-actions button { flex: 1 1 150px; }
}
@media (max-width: 860px) {
  .home-primary-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .topbar, .main-content, .footer-note { width: min(calc(100% - 28px), 960px); }
  .topbar { min-height: 65px; }
  .main-content { padding-top: 20px; }
  .home-heading { margin-top: 0; }
  .home-heading h1 { font-size: 1.72rem; }
  .home-heading > p:last-child { font-size: .78rem; }
  .demo-note { padding: 9px 10px; font-size: .67rem; }
  .practice-number { min-width: 72px; font-size: 2.35rem; }
  .practice-copy h2 { font-size: .96rem; }
  .practice-copy p { font-size: .7rem; }
  .official-practice-card { flex-direction: column; align-items: stretch; gap: 11px; margin-bottom: 23px; padding: 14px; }
  .official-practice-actions { flex-direction: row; flex-wrap: wrap; }
  .official-practice-actions button { flex: 1 1 150px; }
  .official-practice-card .button-secondary { align-self: center; min-height: 40px; padding-inline: 10px; font-size: .68rem; }
  .official-practice-copy p:not(.section-kicker) { font-size: .69rem; }
  .official-practice-copy small { font-size: .62rem; }
  .practice-footnote { gap: 7px; font-size: .61rem; }
  .section-heading { gap: 7px; }
  .section-heading .text-link { font-size: .66rem; }
  .overview-item { padding-inline: 8px; }
  .overview-item span { font-size: .61rem; }
  .overview-item strong { font-size: 1.2rem; }
  .menu-item { min-height: 68px; gap: 9px; padding-inline: 11px; }
  .menu-icon { width: 35px; height: 35px; }
  .menu-copy strong { font-size: .78rem; }
  .menu-copy small { font-size: .65rem; }
  .settings-card { padding-inline: 11px; }
  .settings-row { align-items: flex-start; gap: 8px; padding: 12px 0; }
  .settings-row .button-danger { min-height: 36px; padding: 6px 8px; font-size: .67rem; }
  .settings-actions { gap: 4px; }
  .settings-actions button { min-height: 36px; padding: 5px 8px; font-size: .67rem; }
  .settings-controls { gap: 3px; }
  .settings-controls button { min-width: 33px; height: 34px; padding-inline: 5px; font-size: .65rem; }
  .session-meter { font-size: .66rem; }
  .quiz-card { padding: 15px; }
  .choice { padding: 11px; }
  .quiz-actions { gap: 5px; }
  .quiz-actions .button-quiet, .quiz-actions .button-secondary { min-width: 62px; padding-inline: 8px; }
  .quiz-actions .button-primary { padding-inline: 10px; font-size: .77rem; }
  .result-score { padding: 17px; }
  .result-item { padding: 13px; }
  .record-summary > div { padding: 13px; }
  .record-list { padding-inline: 12px; }
  .footer-note { font-size: .64rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* Dark theme: semantic variables are redefined; component rules keep working. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e9effc;
  --muted: #a7b4cc;
  --paper: #0d1524;
  --surface: #17223a;
  --line: #2d3c5f;
  --primary: #84a5ff;
  --primary-strong: #aec4ff;
  --primary-soft: #233560;
  --on-primary-soft: #d3e0ff;
  --navy: #dbe7ff;
  --gold: #ecbb5f;
  --gold-soft: #3b3016;
  --success: #62cf96;
  --success-soft: #173527;
  --danger: #ff97a4;
  --danger-soft: #40202a;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
}

/* Header actions stay visible on narrow screens. */
.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.topbar .brand { min-width: 0; }
.label-button {
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  font-size: .92rem;
  font-weight: 740;
  cursor: pointer;
  flex-shrink: 0;
}
@media (max-width: 560px) {
  .brand small { display: none; }
  .brand strong { font-size: .95rem; white-space: nowrap; }
  .icon-button { flex-shrink: 0; }
}

/* Resume card and study trend chart. */
.resume-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  padding: 18px;
  margin-bottom: 16px;
  display: grid;
  gap: 12px;
}
.trend-section { margin-bottom: 8px; }
.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 12px 10px 8px;
}
.trend-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  min-width: 0;
}
.trend-bar {
  width: 100%;
  max-width: 22px;
  background: var(--primary);
  border-radius: 4px 4px 0 0;
}
.trend-count { font-size: .68rem; font-weight: 700; color: var(--ink); min-height: .8rem; }
.trend-day { font-size: .6rem; color: var(--muted); white-space: nowrap; }
.trend-rate { font-size: .6rem; color: var(--muted); min-height: .75rem; }
.check-list { display: grid; gap: 10px; }
.check-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.goal-card, .daily-card { border: 1px solid var(--line); border-radius: 20px; background: var(--surface); padding: 18px; margin-bottom: 16px; }
.goal-card h2, .daily-card h2 { margin: 2px 0 4px; font-size: 1.3rem; }
.goal-today { display: flex; align-items: baseline; gap: 8px; margin-top: 12px; }
.goal-today strong { font-size: 1.15rem; }
.goal-track { display: block; margin: 8px 0; }
.accuracy-chart { width: 100%; height: auto; display: block; }
.heat-grid { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; margin: 8px 0; }
.heat-cell { aspect-ratio: 1; border-radius: 3px; background: var(--line); display: block; }
.heat-1 { background: color-mix(in srgb, var(--primary) 30%, var(--surface)); }
.heat-2 { background: color-mix(in srgb, var(--primary) 55%, var(--surface)); }
.heat-3 { background: color-mix(in srgb, var(--primary) 80%, var(--surface)); }
.heat-4 { background: var(--primary); }
.back-to-top { position: fixed; right: 14px; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 35; padding: 10px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: 0 4px 16px rgba(23, 37, 61, .18); cursor: pointer; }
.back-to-top[hidden] { display: none; }

.chip-scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip-scroll::-webkit-scrollbar { display: none; }
.chip-scroll > * { flex: 0 0 auto; }
.field-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Dark theme fixes: keep designed cards readable. */
:root[data-theme="dark"] { --navy: #1e3465; }
:root[data-theme="dark"] .official-practice-card { background: var(--surface); border-color: var(--line); }
:root[data-theme="dark"] .official-practice-copy p:not(.section-kicker) { color: var(--muted); }
