:root {
  --brand: #14235c;
  --brand-deep: #0d1740;
  --brand-mid: #435098;
  --brand-soft: #dfe3ff;
  --brand-wash: #f1f3ff;
  --page: #f3f5fb;
  --surface: #ffffff;
  --surface-muted: #f8f9fd;
  --ink: #1d2749;
  --muted: #59627f;
  --line: #cbd1e5;
  --line-strong: #929bb9;
  --cta-gold: #f2c94c;
  --cta-ink: #14235c;
  --good: #176a46;
  --good-soft: #e2f4ea;
  --bad: #982f3b;
  --bad-soft: #fae6e8;
  --radius-card: 16px;
  --radius-control: 12px;
  --shadow: 0 18px 46px rgba(20, 35, 92, 0.09);
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

body {
  min-width: 320px;
  margin: 0;
  overflow-x: clip;
  background: var(--page);
  color: var(--ink);
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

p,
h1,
h2,
h3,
h4,
h5,
dl,
dd,
ol {
  margin-top: 0;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--brand-soft);
  color: var(--brand-deep);
}

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px var(--brand-soft);
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--brand);
  color: #f8f9ff;
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header,
.topic-overview,
.reader-tools,
.guide-shell,
.no-results,
.site-footer {
  width: calc(100% - 40px);
  max-width: 1280px;
  margin-inline: auto;
}

.site-header {
  margin-top: 20px;
  padding: 24px 32px 34px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.site-header__brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-width: 0;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.site-logo {
  width: auto;
  height: 52px;
  flex: 0 0 auto;
  object-fit: contain;
}

.site-brand {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
  text-align: right;
}

.part-switch {
  display: inline-flex;
  gap: 6px;
  margin-top: 18px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
}

.part-switch a {
  min-width: 92px;
  padding: 8px 18px;
  border-radius: 999px;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
}

.part-switch a[aria-current="page"] {
  background: var(--brand);
  color: #fff;
}

.source-table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: 0 10px 26px rgba(20, 35, 92, 0.05);
}

.source-table {
  width: 100%;
  min-width: 620px;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--ink);
  line-height: 1.62;
}

.source-table th,
.source-table td {
  min-width: 0;
  padding: 15px 17px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
  text-align: left;
  vertical-align: middle;
}

.source-table tr > :last-child {
  border-right: 0;
}

.source-table tbody tr:last-child > * {
  border-bottom: 0;
}

.source-table thead th {
  background: var(--brand-mid);
  color: #fff;
  font-weight: 900;
  text-align: center;
}

.source-table tbody th {
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 900;
}

.source-table tbody td {
  background: var(--brand-wash);
  font-weight: 650;
}

.source-table tbody tr:nth-child(even) td {
  background: #f8f9ff;
}

.source-table__headline {
  background: var(--brand) !important;
  font-size: 1.04rem;
  letter-spacing: 0.02em;
}

.source-table--single {
  min-width: 0;
}

.source-table--single td {
  padding: 22px 24px;
  font-size: 1rem;
  text-align: center;
}

/* Part 1 follows the teacher's original comparison-table layout. */
.source-table-title {
  margin: 22px 0 9px;
  color: var(--brand);
  font-size: 1rem;
  font-weight: 900;
}

.source-label + .source-table-scroll + .source-table-title {
  margin-top: 22px;
}

.source-table--part1 {
  min-width: 720px;
}

.source-table--part1 th,
.source-table--part1 td {
  white-space: pre-line;
  text-align: center;
}

.source-table--part1 tbody th {
  min-width: 108px;
}

.source-table--part1 td[colspan] {
  padding-inline: 22px;
}

.source-table--part1 td:has(.source-correction) {
  text-align: left;
}

.source-table--matrix {
  min-width: 760px;
}

.source-table--matrix th,
.source-table--matrix td {
  border-right: 2px solid var(--surface);
  border-bottom: 2px solid var(--surface);
}

.source-table--matrix tr > :last-child {
  border-right: 0;
}

.source-table--profit th,
.source-table--vacancy th {
  text-align: center;
}

.source-table--profit td,
.source-table--vacancy td,
.source-table--bond-total td {
  text-align: center;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(340px, 0.82fr);
  gap: clamp(34px, 5vw, 68px);
  align-items: center;
  padding-top: 38px;
}

.hero-copy {
  min-width: 0;
  padding-block: 8px 14px;
}

.hero-kicker,
.overview-label {
  margin: 0 0 10px;
  color: var(--brand-mid);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.hero-copy h1 {
  max-width: 760px;
  margin: 0;
  color: var(--brand);
  font-size: clamp(2.7rem, 6.2vw, 4.9rem);
  font-weight: 950;
  letter-spacing: -0.065em;
  line-height: 1.04;
  text-wrap: balance;
}

.hero-summary {
  max-width: 650px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.13rem);
  line-height: 1.75;
}

.hero-cta,
.mcq-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  max-width: 100%;
  border: 2px solid var(--brand);
  border-radius: 999px;
  background: var(--cta-gold);
  color: var(--cta-ink);
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 5px 0 rgba(20, 35, 92, 0.18);
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  align-items: center;
  margin-top: 26px;
}

.hero-cta {
  padding: 0 24px;
}

.hero-jump {
  padding: 7px 0;
  background: transparent;
  color: var(--brand);
  font-size: 0.9rem;
  font-weight: 850;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.hero-jump:hover {
  color: var(--brand-mid);
}

.hero-cta:hover,
.mcq-cta:hover {
  background: #f7d66f;
  transform: translateY(-1px);
  box-shadow: 0 7px 0 rgba(20, 35, 92, 0.16);
}

.hero-cta:active,
.mcq-cta:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(20, 35, 92, 0.2);
}

.overview-panel {
  min-width: 0;
  padding: 26px;
  border: 1px solid var(--brand);
  border-radius: 16px;
  background: var(--brand);
  color: #f6f7ff;
}

.overview-heading {
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(223, 227, 255, 0.26);
}

.overview-label {
  color: #cbd2ff;
}

.overview-panel h2 {
  margin: 0;
  color: #f8f9ff;
  font-size: clamp(1.45rem, 2.8vw, 2rem);
  line-height: 1.25;
}

.overview-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 22px 0 0;
}

.overview-metric {
  min-width: 0;
  padding: 0 14px;
  border-left: 1px solid rgba(223, 227, 255, 0.24);
}

.overview-metric:first-child {
  padding-left: 0;
  border-left: 0;
}

.overview-metric:last-child {
  padding-right: 0;
}

.overview-metric dt {
  margin-bottom: 8px;
  color: #cbd2ff;
  font-size: 0.76rem;
  font-weight: 750;
}

.overview-metric dd {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin: 0;
}

.overview-metric strong {
  color: #ffffff;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.overview-metric span {
  color: #cbd2ff;
  font-size: 0.78rem;
}

.overview-note {
  margin: 22px 0 0;
  color: rgba(248, 249, 255, 0.78);
  font-size: 0.85rem;
  line-height: 1.65;
}

.topic-overview {
  margin-top: 24px;
  padding: 30px 32px 34px;
  scroll-margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.topic-overview__heading {
  max-width: 760px;
}

.topic-overview__heading h2 {
  margin: 0;
  color: var(--brand);
  font-size: clamp(1.9rem, 3.5vw, 2.7rem);
  font-weight: 950;
  letter-spacing: -0.045em;
  line-height: 1.18;
}

.topic-overview__heading p {
  max-width: 62ch;
  margin: 9px 0 0;
  color: var(--muted);
}

.counting-rule {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin: 22px 0 0;
  padding: 12px 15px;
  border-left: 4px solid var(--brand);
  background: var(--brand-wash);
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.counting-rule strong {
  flex: 0 0 auto;
  color: var(--brand);
}

.overview-groups {
  margin-top: 24px;
  border-top: 2px solid var(--brand);
  border-bottom: 1px solid var(--line);
}

.overview-group {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
}

.overview-group + .overview-group {
  border-top: 2px solid var(--brand);
}

.overview-group__heading {
  min-width: 0;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--brand-wash);
}

.overview-group__heading h3 {
  margin: 0;
  color: var(--brand);
  font-size: 1rem;
  line-height: 1.45;
}

.overview-group__heading span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 750;
}

.overview-group ol {
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.overview-row + .overview-row {
  border-top: 1px solid var(--line);
}

.overview-row__link {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 130px 68px;
  gap: 14px;
  align-items: center;
  min-width: 0;
  padding: 13px 16px;
  color: inherit;
  text-decoration: none;
}

.overview-row__link:hover {
  background: #f6f7ff;
}

.overview-row__number {
  color: var(--brand-mid);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.overview-row__copy,
.overview-row__stats {
  display: grid;
  min-width: 0;
}

.overview-row__title {
  color: var(--brand);
  font-size: 0.9rem;
  line-height: 1.4;
}

.overview-row__summary {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-row__stats {
  justify-items: end;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
  text-align: right;
}

.overview-row__stats strong {
  color: var(--brand);
  font-size: 0.76rem;
}

.overview-row__action {
  color: var(--brand-mid);
  font-size: 0.73rem;
  font-weight: 850;
  text-align: right;
  white-space: nowrap;
}

.reader-tools {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1.8fr) auto;
  gap: 18px;
  align-items: end;
  margin-top: 24px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 30px rgba(20, 35, 92, 0.08);
  backdrop-filter: blur(14px);
}

.search-control,
.filter-control {
  min-width: 0;
}

.search-control label,
.filter-control > span {
  display: block;
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.search-control input {
  width: 100%;
  min-height: 46px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
}

.search-control input::placeholder {
  color: #69718c;
  opacity: 1;
}

.filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.filter-buttons button,
.toc-toggle {
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--brand);
  border-radius: 999px;
  background: var(--surface);
  color: var(--brand);
  font-size: 0.84rem;
  font-weight: 850;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease, color 140ms ease;
}

.filter-buttons button:hover,
.filter-buttons button[aria-pressed="true"] {
  background: var(--brand-soft);
}

.filter-buttons button:active,
.toc-toggle:active,
.practice-option:active {
  transform: translateY(1px);
}

.filter-status {
  min-width: 92px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  text-align: right;
  white-space: nowrap;
}

.no-results {
  margin-top: 24px;
  padding: 22px;
  border: 1px dashed var(--brand-mid);
  border-radius: 16px;
  background: var(--surface);
  color: var(--brand);
  font-weight: 750;
  text-align: center;
}

.guide-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 30px;
  align-items: start;
  margin-top: 30px;
  padding-bottom: 84px;
}

.guide-sidebar {
  position: sticky;
  top: 112px;
  max-height: calc(100dvh - 136px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 12px 28px rgba(20, 35, 92, 0.07);
}

.sidebar-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.sidebar-heading p {
  margin: 0;
  color: var(--brand);
  font-weight: 900;
}

.sidebar-heading span {
  color: var(--muted);
  font-size: 0.72rem;
}

[data-guide-toc] {
  padding: 10px;
}

.toc-fallback {
  margin: 0;
  padding: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.toc-group {
  margin: 0;
  padding: 8px 0;
}

.toc-group + .toc-group {
  border-top: 1px solid var(--line);
}

.toc-group h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
}

.toc-group h3 span {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.toc-group ol {
  display: grid;
  gap: 2px;
  margin-bottom: 0;
  padding: 0;
  list-style: none;
}

.toc-group a {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 9px 10px;
  border-radius: var(--radius-control);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  text-decoration: none;
}

.toc-group a:hover,
.toc-group a[aria-current="true"] {
  background: var(--brand-soft);
  color: var(--brand);
}

.toc-index {
  color: var(--brand-mid);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.topic-list {
  min-width: 0;
}

.topic-section {
  min-width: 0;
  margin: 0 0 30px;
  padding: 30px;
  scroll-margin-top: 112px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 15px 38px rgba(20, 35, 92, 0.07);
}

.topic-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 22px;
  padding-bottom: 24px;
  border-bottom: 2px solid var(--brand);
}

.topic-kicker {
  align-self: start;
  justify-self: start;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.75rem;
  font-weight: 850;
}

.topic-header h2 {
  grid-column: 1;
  margin: 0;
  color: var(--brand);
  font-size: clamp(1.65rem, 3vw, 2.3rem);
  font-weight: 950;
  letter-spacing: -0.04em;
  line-height: 1.22;
  text-wrap: balance;
}

.topic-summary {
  grid-column: 1;
  max-width: 680px;
  margin: 2px 0 0;
  color: var(--muted);
}

.topic-stat {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: start;
  min-width: 176px;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--brand-wash);
  color: var(--brand);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
  text-align: center;
}

.teacher-source,
.law-supplements,
.question-area {
  margin-top: 28px;
}

.source-label {
  margin: 0 0 10px;
  color: var(--brand);
  font-size: 0.83rem;
  font-weight: 900;
}

.comparison-list {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.comparison-row {
  --source-columns: 1;
  display: grid;
  grid-template-columns: repeat(var(--source-columns), minmax(0, 1fr));
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.comparison-row:first-child {
  background: var(--brand-wash);
}

.comparison-row:last-child {
  border-bottom: 0;
}

.comparison-row:hover {
  background: #f6f7ff;
}

.comparison-cell {
  min-width: 0;
  padding: 12px 14px 13px;
  border-left: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.comparison-cell:first-child {
  border-left: 0;
}

.comparison-cell dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 800;
  line-height: 1.35;
}

.comparison-cell dd {
  margin: 0;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.62;
}

.source-correction {
  display: grid;
  gap: 6px;
}

.source-correction__label {
  justify-self: start;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.69rem;
  font-weight: 900;
}

.source-correction__links {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
}

.source-correction__links a {
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 850;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.comparison-cell[data-merged-duplicate="true"] {
  display: none;
}

.comparison-cell[data-merged-span="2"] {
  grid-column: span 2;
}

.comparison-cell[data-merged-span="3"] {
  grid-column: span 3;
}

.comparison-cell[data-merged-span="4"] {
  grid-column: span 4;
}

.comparison-cell[data-merged-span="5"] {
  grid-column: span 5;
}

.comparison-cell[data-merged-span="6"] {
  grid-column: span 6;
}

.comparison-cell[data-merged-span="7"] {
  grid-column: span 7;
}

.law-supplements {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 12px;
}

.law-note {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line-strong);
  border-left: 5px solid var(--brand-mid);
  border-radius: 16px;
  background: var(--brand-wash);
}

.law-note--teacher {
  border-left-color: var(--brand);
  background: var(--surface-muted);
}

.law-note p {
  margin: 0;
}

.law-note p + p,
.law-note p + a {
  margin-top: 8px;
}

.law-note__label {
  color: var(--brand);
  font-size: 0.75rem;
  font-weight: 900;
}

.law-note a {
  display: inline-block;
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 850;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.question-context-note,
.question-fallback {
  padding: 16px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: var(--brand-wash);
  color: var(--brand);
}

.question-context-note {
  margin: 0 0 12px;
  font-size: 0.86rem;
  font-weight: 750;
}

.question-fallback {
  margin: 0;
  text-align: center;
}

.practice-card {
  overflow: hidden;
  border: 1px solid var(--brand);
  border-radius: 16px;
  background: var(--brand);
  color: #f7f8ff;
}

.practice-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  padding: 24px 24px 18px;
  border-bottom: 1px solid rgba(223, 227, 255, 0.22);
}

.practice-label {
  display: inline-flex;
  margin: 0 0 7px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 900;
}

.practice-header h3 {
  margin: 0;
  color: #ffffff;
  font-size: 1.25rem;
  line-height: 1.35;
}

.practice-source {
  margin: 4px 0 0;
  color: #cbd2ff;
  font-size: 0.75rem;
  white-space: nowrap;
}

.practice-paper,
.practice-key,
.practice-stem,
.practice-options,
.question-result,
.question-analysis {
  margin-inline: 24px;
}

.practice-paper {
  margin-top: 18px;
  margin-bottom: 4px;
  color: #cbd2ff;
  font-size: 0.76rem;
}

.practice-key {
  display: flex;
  gap: 9px;
  margin-top: 0;
  margin-bottom: 16px;
  color: #dfe3ff;
  font-size: 0.82rem;
}

.practice-key strong {
  flex: 0 0 auto;
  color: #ffffff;
}

.practice-stem {
  margin-top: 0;
  margin-bottom: 20px;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.78;
  white-space: pre-line;
}

.practice-options {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}

.practice-option {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid rgba(223, 227, 255, 0.42);
  border-radius: 16px;
  background: #26366f;
  color: #f8f9ff;
  text-align: left;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.practice-option:hover:not(:disabled) {
  border-color: #ffffff;
  background: #304482;
}

.practice-option:disabled {
  cursor: default;
  opacity: 0.72;
}

.option-key {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-weight: 900;
}

.option-text {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
  line-height: 1.6;
}

.option-state {
  min-width: 0;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 900;
  line-height: 1.35;
}

.option-state:empty {
  display: none;
}

.practice-option.is-selected {
  opacity: 1;
}

.practice-option.is-correct {
  border-color: #71cda0;
  background: var(--good-soft);
  color: #104b34;
  opacity: 1;
}

.practice-option.is-incorrect {
  border-color: #e18b95;
  background: var(--bad-soft);
  color: #751f2a;
  opacity: 1;
}

.practice-option.is-correct .option-state,
.practice-option.is-incorrect .option-state {
  background: rgba(255, 255, 255, 0.7);
}

.question-result {
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin-top: 0;
  margin-bottom: 22px;
  padding: 13px 15px;
  border-radius: 16px;
}

.question-result strong {
  flex: 0 0 auto;
  white-space: nowrap;
}

.question-result.is-correct {
  background: var(--good-soft);
  color: #104b34;
}

.question-result.is-incorrect {
  background: var(--bad-soft);
  color: #751f2a;
}

.question-analysis {
  margin-top: 0;
  margin-bottom: 0;
  padding: 22px 0 10px;
  border-top: 1px solid rgba(223, 227, 255, 0.22);
}

.question-analysis > h4 {
  margin: 0 0 8px;
  color: #ffffff;
  font-size: 1.08rem;
}

.analysis-item {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 16px;
  padding: 15px 0;
  border-bottom: 1px solid rgba(223, 227, 255, 0.16);
}

.analysis-item:last-child {
  border-bottom: 0;
}

.analysis-item h5 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: #dfe3ff;
  font-size: 0.78rem;
  line-height: 1.45;
}

.analysis-item h5 span {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 900;
}

.analysis-item p {
  min-width: 0;
  margin: 0;
  color: rgba(248, 249, 255, 0.88);
  font-size: 0.9rem;
  line-height: 1.72;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.analysis-item--fallback {
  display: block;
}

.analysis-item--fallback h5 {
  margin-bottom: 8px;
}

.mcq-cta {
  margin-top: 24px;
  padding: 0 22px;
}

.toc-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: none;
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(20, 35, 92, 0.25);
}

.site-footer {
  margin-top: -44px;
  padding: 24px 0 34px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  text-align: center;
}

.course-campaign {
  position: relative;
  z-index: 0;
  display: block;
  width: 100%;
  max-width: 1462px;
  aspect-ratio: 1462 / 444;
  margin: 0 auto 22px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: center / 100% 100% no-repeat url("courses-cta-background.png");
  color: var(--brand-deep);
  text-decoration: none;
  box-shadow: 0 14px 32px rgba(20, 35, 92, 0.1);
}

.course-campaign__code {
  position: absolute;
  left: 49%;
  bottom: 8%;
  z-index: 1;
  margin: 0;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  font-size: clamp(0.72rem, 1.2vw, 0.95rem);
  font-weight: 900;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.88);
}

.course-campaign__code b {
  display: inline-block;
  margin-left: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--cta-gold);
  color: #050f28;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  box-shadow: inset 0 0 0 1px rgba(13, 23, 64, 0.16);
}

.course-campaign:focus-visible {
  outline-offset: 5px;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 1100px) {
  .guide-is-ready body {
    padding-bottom: 72px;
  }

  .reader-tools {
    grid-template-columns: minmax(240px, 0.8fr) minmax(0, 1.2fr);
  }

  .filter-status {
    grid-column: 1 / -1;
    margin: -6px 0 0;
    text-align: left;
  }

  .guide-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .guide-is-ready .guide-sidebar {
    position: fixed;
    top: 16px;
    bottom: 82px;
    left: 16px;
    z-index: 45;
    width: min(360px, calc(100vw - 32px));
    max-height: none;
    transform: translateX(calc(-100% - 28px));
    transition: transform 180ms ease;
  }

  .guide-is-ready .guide-sidebar[data-toc-open="true"] {
    transform: translateX(0);
  }

  .guide-is-ready .toc-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

@media (max-width: 860px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .overview-panel {
    max-width: none;
  }

  .reader-tools {
    position: static;
    grid-template-columns: minmax(0, 1fr);
  }

  .filter-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-buttons button {
    white-space: normal;
  }

  .filter-status {
    grid-column: auto;
  }

  .overview-group {
    grid-template-columns: minmax(0, 1fr);
  }

  .overview-group__heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .overview-group__heading span {
    margin-top: 0;
  }

  .topic-section {
    scroll-margin-top: 20px;
  }
}

@media (max-width: 767px) {
  body {
    font-size: 15.5px;
  }

  .site-header,
  .topic-overview,
  .reader-tools,
  .guide-shell,
  .no-results,
  .site-footer {
    width: calc(100% - 24px);
  }

  .site-header {
    margin-top: 12px;
    padding: 20px;
  }

  .site-header__brand {
    align-items: flex-start;
    padding-bottom: 16px;
  }

  .site-logo {
    height: 46px;
  }

  .site-brand {
    max-width: 150px;
    font-size: 0.78rem;
  }

  .hero-grid {
    gap: 24px;
    padding-top: 26px;
  }

  .hero-copy {
    padding: 0;
  }

  .hero-copy h1 {
    font-size: clamp(2.35rem, 13vw, 3.4rem);
  }

  .hero-summary {
    margin-top: 14px;
  }

  .hero-cta {
    min-height: 46px;
  }

  .hero-actions {
    margin-top: 20px;
  }

  .overview-panel {
    padding: 22px 18px;
  }

  .overview-metric {
    padding-inline: 9px;
  }

  .overview-metric strong {
    font-size: clamp(1.55rem, 8vw, 2rem);
  }

  .reader-tools {
    margin-top: 16px;
    padding: 14px;
  }

  .topic-overview {
    margin-top: 16px;
    padding: 22px 20px 24px;
  }

  .counting-rule {
    display: grid;
    gap: 3px;
  }

  .overview-row__link {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 8px 12px;
    padding: 13px 12px;
  }

  .overview-row__summary {
    white-space: normal;
  }

  .overview-row__stats {
    grid-column: 2;
    grid-template-columns: repeat(2, max-content);
    gap: 10px;
    justify-content: start;
    justify-items: start;
    text-align: left;
  }

  .overview-row__action {
    display: none;
  }

  .guide-shell {
    gap: 0;
    margin-top: 18px;
  }

  .topic-section {
    margin-bottom: 18px;
    padding: 20px;
  }

  /* Keep teacher tables readable on phones without dropping source columns. */
  .source-table-scroll {
    overflow-x: hidden;
  }

  .source-table,
  .source-table--part1,
  .source-table--matrix {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
  }

  .source-table th,
  .source-table td {
    min-width: 0;
    padding: 8px 5px;
    font-size: 0.78rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .source-table--part1 tbody th {
    min-width: 0;
  }

  .source-table--part1 th,
  .source-table--part1 td {
    padding: 8px 4px;
    font-size: 0.75rem;
  }

  .source-table--part1 td[colspan] {
    padding-inline: 6px;
  }

  .source-table--matrix th,
  .source-table--matrix td {
    padding: 6px 3px;
    font-size: 0.68rem;
    line-height: 1.35;
  }

  .topic-header {
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
    padding-bottom: 20px;
  }

  .topic-header h2,
  .topic-summary,
  .topic-stat {
    grid-column: 1;
  }

  .topic-stat {
    grid-row: auto;
    justify-self: start;
    min-width: 0;
    margin-top: 8px;
    text-align: left;
  }

  .comparison-row {
    display: block;
  }

  .comparison-cell,
  .comparison-cell[data-merged-span] {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    grid-column: auto;
    padding: 11px 13px;
    border-bottom: 1px solid var(--line);
    border-left: 0;
  }

  .comparison-cell:last-child,
  .comparison-cell[data-merged-span]:last-child {
    border-bottom: 0;
  }

  .comparison-cell[data-merged-duplicate="true"] {
    display: none;
  }

  .comparison-cell dt {
    margin-bottom: 2px;
  }

  .law-supplements {
    grid-template-columns: minmax(0, 1fr);
  }

  .practice-header {
    display: block;
    padding: 20px 18px 16px;
  }

  .practice-source {
    margin-top: 8px;
    white-space: normal;
  }

  .practice-paper,
  .practice-key,
  .practice-stem,
  .practice-options,
  .question-result,
  .question-analysis {
    margin-inline: 18px;
  }

  .practice-option {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .option-state {
    grid-column: 2;
    justify-self: start;
  }

  .question-result {
    display: grid;
    gap: 2px;
  }

  .analysis-item {
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
  }

  .mcq-cta {
    min-height: 46px;
    padding-inline: 18px;
    font-size: 0.9rem;
  }

  .course-campaign {
    border-radius: 12px;
  }

  .course-campaign__code {
    bottom: 7%;
    left: 48%;
  }
}

@media (max-width: 900px) {
  body {
    min-width: 0;
    overflow-x: hidden;
  }

  /* Keep the cover/header and every content page on the same mobile canvas. */
  .site-header,
  .topic-overview,
  .reader-tools,
  .guide-shell,
  .no-results,
  .site-footer {
    width: calc(100vw - 24px);
    max-width: none;
  }

  .topic-list,
  .topic-section {
    width: 100%;
    max-width: none;
    min-width: 0;
    box-sizing: border-box;
  }

  .source-table-scroll {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .source-table,
  .source-table--part1,
  .source-table--matrix {
    display: table;
    width: 100% !important;
    max-width: 100%;
    min-width: 0 !important;
    table-layout: fixed;
  }

  .source-table th,
  .source-table td {
    min-width: 0 !important;
    padding: 6px 3px;
    font-size: clamp(0.58rem, 1.9vw, 0.72rem);
    line-height: 1.38;
    overflow-wrap: anywhere;
    word-break: break-all;
  }

  .source-table--part1 tbody th {
    min-width: 0 !important;
  }

  .source-table--part1 td[colspan] {
    padding-inline: 4px;
  }

  .source-table--matrix th,
  .source-table--matrix td {
    padding: 5px 2px;
    font-size: clamp(0.54rem, 1.75vw, 0.68rem);
    line-height: 1.3;
  }
}

@media (max-width: 430px) {
  .overview-metric dt {
    min-height: 2.7em;
  }

  .overview-metric dd {
    display: block;
  }

  .filter-buttons {
    grid-template-columns: minmax(0, 1fr);
  }

  .filter-buttons button {
    width: 100%;
  }

  .topic-section {
    padding: 18px 14px;
  }

  .practice-key {
    display: block;
  }

  .practice-key strong {
    display: block;
    margin-bottom: 3px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  body {
    padding: 0;
    background: #ffffff;
  }

  .skip-link,
  .reader-tools,
  .guide-sidebar,
  .toc-toggle,
  .hero-cta,
  .mcq-cta {
    display: none !important;
  }

  .site-header,
  .guide-shell {
    width: 100%;
    max-width: none;
  }

  .site-header,
  .topic-section {
    box-shadow: none;
    break-inside: avoid;
  }

  .guide-shell {
    display: block;
  }

  .practice-card {
    background: #ffffff;
    color: var(--ink);
  }

  .practice-header h3,
  .practice-stem,
  .question-analysis > h4,
  .analysis-item p {
    color: var(--ink);
  }
}
