@layer reset, base, layout, components, utilities;

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

  html {
    min-width: 320px;
    scroll-behavior: smooth;
  }

  body,
  h1,
  h2,
  h3,
  p,
  ul,
  ol,
  dl,
  dd,
  figure,
  blockquote {
    margin: 0;
  }

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

  button,
  input,
  select,
  textarea {
    font: inherit;
  }
}

@layer base {
  :root {
    color-scheme: light;
    --paper: #f5f0e5;
    --paper-strong: #fffdf7;
    --ink: #13221d;
    --ink-soft: #405049;
    --line: #c9c5b8;
    --line-dark: #829087;
    --yellow: #f4c54d;
    --yellow-soft: #fbe8a9;
    --green: #177455;
    --green-soft: #dceee5;
    --red: #ad3e35;
    --red-soft: #f6dfda;
    --shadow: 0 18px 50px rgb(19 34 29 / 0.11);
    --sans: "Avenir Next", Avenir, "Segoe UI", "Trebuchet MS", sans-serif;
    --serif: Charter, "Iowan Old Style", "Palatino Linotype", Georgia, serif;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  }

  body {
    min-width: 320px;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 1rem;
    line-height: 1.6;
    text-rendering: optimizeLegibility;
  }

  body:has(dialog[open]) {
    overflow: hidden;
  }

  a {
    color: currentColor;
    text-decoration-thickness: 0.09em;
    text-underline-offset: 0.18em;
  }

  a:hover {
    text-decoration-thickness: 0.15em;
  }

  ::selection {
    background: var(--yellow);
    color: var(--ink);
  }

  h1,
  h2,
  h3 {
    font-weight: 750;
    letter-spacing: -0.035em;
    line-height: 1.04;
  }

  h1 {
    font-size: clamp(2.65rem, 7vw, 6.7rem);
  }

  h2 {
    font-size: clamp(2rem, 4vw, 3.8rem);
  }

  h3 {
    font-size: clamp(1.25rem, 2vw, 1.7rem);
  }

  .prose p + p,
  .prose p + ul,
  .prose ul + p,
  .prose h2 + p,
  .prose h3 + p,
  .prose h2 + ul,
  .prose h3 + ul {
    margin-top: 1rem;
  }

  .prose h2 {
    margin-top: 3.5rem;
  }

  .prose h3 {
    margin-top: 2.25rem;
  }

  .prose ul,
  .prose ol {
    padding-left: 1.25rem;
  }
}

@layer layout {
  .shell {
    width: min(100% - 2rem, 1180px);
    margin-inline: auto;
  }

  .narrow {
    width: min(100% - 2rem, 780px);
    margin-inline: auto;
  }

  .site-header {
    border-bottom: 1px solid rgb(19 34 29 / 0.2);
    background: rgb(245 240 229 / 0.94);
  }

  .site-nav {
    min-height: 74px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
  }

  .nav-links {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: clamp(0.8rem, 2.4vw, 2rem);
    font-size: 0.92rem;
    font-weight: 700;
  }

  .hero {
    min-height: calc(100svh - 75px);
    display: grid;
    grid-template-columns: minmax(0, 1.18fr) minmax(300px, 0.82fr);
    align-items: center;
    gap: clamp(3rem, 7vw, 7rem);
    padding-block: clamp(4rem, 9vw, 8rem);
  }

  .section {
    padding-block: clamp(4.5rem, 9vw, 8rem);
  }

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

  .section-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 0.55fr);
    gap: 2rem;
    align-items: end;
    margin-bottom: clamp(2.5rem, 5vw, 4.5rem);
  }

  .state-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1px;
    border-block: 1px solid var(--ink);
    background: var(--ink);
  }

  .trust-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(2rem, 5vw, 5rem);
  }

  .page-hero {
    padding-block: clamp(4rem, 8vw, 7rem);
    border-bottom: 1px solid var(--line);
  }

  .page-hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(270px, 0.52fr);
    gap: clamp(2.5rem, 7vw, 7rem);
    align-items: end;
  }

  .content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(240px, 0.4fr);
    gap: clamp(3rem, 7vw, 7rem);
  }

  .site-footer {
    padding-block: 3rem;
    background: var(--ink);
    color: var(--paper);
  }

  .footer-grid {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 3rem;
    align-items: end;
  }
}

@layer components {
  .quick-start {
    margin-top: 1.5rem;
  }

  .quick-card {
    background: var(--paper-strong);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: var(--shadow);
    padding: clamp(1.5rem, 4vw, 3rem);
    display: grid;
    gap: 1rem;
  }

  .quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
  }

  .quick-note {
    color: var(--ink-soft);
  }

  .skip-link {
    position: fixed;
    z-index: 100;
    top: 0.75rem;
    left: 0.75rem;
    padding: 0.7rem 1rem;
    transform: translateY(-180%);
    background: var(--ink);
    color: var(--paper);
    font-weight: 800;
  }

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

  .brand {
    display: inline-flex;
    align-items: center;
    gap: 0.72rem;
    font-weight: 850;
    letter-spacing: -0.025em;
    text-decoration: none;
  }

  .brand-mark {
    width: 31px;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    rotate: 45deg;
    border: 2px solid var(--ink);
    border-radius: 6px;
    background: var(--yellow);
  }

  .brand-mark::after {
    content: "";
    width: 5px;
    height: 13px;
    border-radius: 999px;
    background: var(--ink);
    rotate: -45deg;
    box-shadow: 5px 5px 0 -1px var(--ink);
  }

  .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 1.35rem;
    font-family: var(--mono);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .eyebrow::before {
    content: "";
    width: 2.2rem;
    height: 0.22rem;
    background: var(--yellow);
  }

  .hero-copy {
    max-width: 760px;
  }

  .hero-copy h1 {
    max-width: 11ch;
  }

  .hero-proof {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem 1.2rem;
    margin-top: 1.5rem;
    padding: 0;
    color: var(--ink-soft);
    font-family: var(--mono);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    list-style: none;
  }

  .hero-proof li + li::before {
    content: "•";
    margin-right: 1.2rem;
    color: var(--green);
  }

  .hero-copy > p,
  .page-lede {
    max-width: 62ch;
    margin-top: 1.6rem;
    color: var(--ink-soft);
    font-family: var(--serif);
    font-size: clamp(1.15rem, 2vw, 1.4rem);
    line-height: 1.55;
  }

  .action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.9rem;
    margin-top: 2rem;
  }

  .button {
    min-height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    border: 2px solid var(--ink);
    border-radius: 7px;
    padding: 0.78rem 1.15rem;
    background: var(--ink);
    color: var(--paper-strong);
    font-weight: 800;
    line-height: 1.1;
    text-decoration: none;
    cursor: pointer;
    transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
  }

  .button:hover {
    transform: translateY(-2px);
    box-shadow: 4px 4px 0 var(--yellow);
  }

  .button-secondary {
    background: transparent;
    color: var(--ink);
  }

  .button-yellow {
    background: var(--yellow);
    color: var(--ink);
  }

  .button[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
  }

  .hero-road {
    position: relative;
    min-height: 520px;
    overflow: hidden;
    border-radius: 50% 50% 0 0 / 18% 18% 0 0;
    background: var(--ink);
    box-shadow: var(--shadow);
  }

  .hero-road::before {
    content: "";
    position: absolute;
    inset: 0 49% 0 auto;
    width: 8px;
    background: repeating-linear-gradient(to bottom, var(--yellow) 0 55px, transparent 55px 95px);
  }

  .hero-road::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 18%;
    width: 3px;
    background: var(--paper);
    box-shadow: calc(clamp(300px, 25vw, 420px) * 0.64) 0 0 var(--paper);
    opacity: 0.78;
  }

  .hero-practice {
    min-height: 620px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    border-radius: 28px;
    padding: clamp(1rem, 2.5vw, 1.7rem);
    padding-bottom: 7.5rem;
  }

  .hero-practice::before,
  .hero-practice::after {
    opacity: 0.28;
  }

  .hero-practice-card {
    position: relative;
    z-index: 2;
    width: min(100%, 560px);
    border: 1px solid rgb(255 253 247 / 0.45);
    border-radius: 14px;
    padding: clamp(1.25rem, 3vw, 2rem);
    background: var(--paper-strong);
    color: var(--ink);
    box-shadow: 0 22px 60px rgb(0 0 0 / 0.24);
  }

  .demo-kicker {
    margin-bottom: 0.75rem;
    color: var(--green);
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 850;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .hero-practice-card h2 {
    font-size: clamp(1.35rem, 2.6vw, 2rem);
    line-height: 1.16;
  }

  .demo-choice-list {
    display: grid;
    gap: 0.65rem;
    margin-top: 1.3rem;
  }

  .demo-choice {
    min-height: 56px;
    grid-template-columns: 2rem minmax(0, 1fr) auto;
    border-width: 1px;
    padding: 0.7rem 0.8rem;
    font-size: 0.93rem;
  }

  .demo-choice .choice-key {
    width: 2rem;
    height: 2rem;
  }

  .demo-feedback {
    margin-top: 1rem;
    font-size: 0.9rem;
  }

  .demo-continue {
    margin-top: 1rem;
    border-top: 1px solid var(--line);
    padding-top: 1rem;
  }

  .demo-state-links {
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem 1rem;
    margin-top: 0.65rem;
    font-weight: 850;
  }

  .demo-noscript {
    margin-top: 1rem;
    border-left: 4px solid var(--yellow);
    padding-left: 0.8rem;
    font-size: 0.9rem;
  }

  .road-sign {
    position: absolute;
    z-index: 1;
    top: 15%;
    left: 50%;
    width: min(58%, 250px);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    translate: -50% 0;
    rotate: 45deg;
    border: 8px solid var(--paper-strong);
    border-radius: 22px;
    background: var(--yellow);
    color: var(--ink);
    box-shadow: 0 12px 0 rgb(0 0 0 / 0.18);
  }

  .road-sign-copy {
    rotate: -45deg;
    text-align: center;
  }

  .road-sign-copy strong {
    display: block;
    font-size: clamp(2.6rem, 5vw, 4.2rem);
    line-height: 0.9;
  }

  .road-sign-copy span {
    display: block;
    margin-top: 0.55rem;
    font-family: var(--mono);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .road-note {
    position: absolute;
    z-index: 2;
    right: 1.25rem;
    bottom: 1.25rem;
    max-width: 220px;
    border-left: 4px solid var(--yellow);
    padding: 0.85rem 1rem;
    background: var(--paper-strong);
    color: var(--ink);
    font-size: 0.86rem;
    font-weight: 700;
  }

  .state-link {
    min-width: 0;
    min-height: 260px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 2rem;
    padding: clamp(1.5rem, 3vw, 2.4rem);
    background: var(--paper);
    text-decoration: none;
    transition: background 150ms ease, color 150ms ease;
  }

  .state-link + .state-link {
    border-left: 0;
  }

  .state-link:hover,
  .state-link:focus-visible {
    background: var(--ink);
    color: var(--paper);
  }

  .state-abbr {
    min-width: 0;
    overflow-wrap: anywhere;
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.1em;
  }

  .state-link h3 {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: clamp(1.7rem, 2vw, 2rem);
  }

  .state-link p {
    min-width: 0;
    max-width: 30ch;
    overflow-wrap: anywhere;
    color: var(--ink-soft);
  }

  .state-link:hover p,
  .state-link:focus-visible p {
    color: inherit;
  }

  .arrow-link {
    min-width: 0;
    overflow-wrap: anywhere;
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 850;
  }

  .arrow-link::after {
    content: "→";
    font-size: 1.3em;
  }

  .trust-item {
    border-top: 5px solid var(--ink);
    padding-top: 1.25rem;
  }

  .trust-item strong {
    display: block;
    margin-bottom: 0.65rem;
    font-size: 1.08rem;
  }

  .trust-item p {
    color: var(--ink-soft);
  }

  .notice {
    border-left: 6px solid var(--yellow);
    padding: 1.25rem 1.4rem;
    background: var(--paper-strong);
  }

  .notice strong {
    display: block;
    margin-bottom: 0.35rem;
  }

  .quotable-answer {
    max-width: 76ch;
    margin-top: 2rem;
    border-top: 1px solid var(--line-dark);
    padding-top: 1.2rem;
    color: var(--ink-soft);
    font-family: var(--serif);
    font-size: 1.08rem;
  }

  .sample-question {
    border-top: 5px solid var(--ink);
    padding-top: 1.25rem;
  }

  .sample-question h2 {
    font-size: clamp(1.45rem, 3vw, 2.2rem);
    line-height: 1.2;
  }

  .sample-question ol {
    display: grid;
    gap: 0.5rem;
    margin-block: 1.25rem;
    padding-left: 1.6rem;
  }

  .sample-question p + p {
    margin-top: 1rem;
  }

  .fact-list {
    display: grid;
    gap: 0;
    border-top: 1px solid var(--ink);
  }

  .fact-list > div {
    display: grid;
    grid-template-columns: minmax(105px, 0.65fr) minmax(0, 1fr);
    gap: 1rem;
    padding-block: 1rem;
    border-bottom: 1px solid var(--line-dark);
  }

  .fact-list dt {
    font-family: var(--mono);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .fact-list dd {
    font-weight: 700;
  }

  .quiz-shell {
    container-type: inline-size;
    padding-block: clamp(3rem, 7vw, 6rem);
  }

  .quiz-intro {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(250px, 0.45fr);
    gap: clamp(2.5rem, 6vw, 6rem);
    align-items: start;
  }

  .learning-aside {
    min-width: 0;
    display: grid;
    gap: 1rem;
  }

  .learning-aside > *,
  .readiness-panel > *,
  .readiness-score-row > * {
    min-width: 0;
  }

  .learning-aside p,
  .readiness-panel p,
  .readiness-panel h3 {
    overflow-wrap: anywhere;
  }

  .learning-status {
    border-top: 3px solid var(--line-dark);
    padding-top: 0.8rem;
    color: var(--ink-soft);
    font-family: var(--mono);
    font-size: 0.76rem;
    font-weight: 800;
    line-height: 1.5;
  }

  .learning-status[data-tone="connected"] {
    border-color: var(--green);
    color: var(--green);
  }

  .learning-status[data-tone="fallback"] {
    border-color: var(--yellow);
  }

  .learning-status[data-tone="warning"] {
    border-color: var(--red);
    color: var(--red);
  }

  .readiness-panel {
    border: 2px solid var(--ink);
    border-radius: 8px;
    padding: 1.15rem;
    background: var(--paper-strong);
  }

  .readiness-score-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
  }

  .readiness-score-row .eyebrow {
    margin-bottom: 0.5rem;
  }

  .readiness-score-row h3 {
    max-width: 13ch;
    font-size: 1.25rem;
    line-height: 1.15;
  }

  .readiness-score-row > strong {
    flex: 0 0 auto;
    font-family: var(--mono);
    font-size: clamp(2rem, 5vw, 3.1rem);
    letter-spacing: -0.07em;
    line-height: 0.95;
  }

  .readiness-panel > p:not(.review-note) {
    margin-top: 1rem;
    color: var(--ink-soft);
  }

  .readiness-panel .review-note {
    margin-top: 1rem;
    border-top: 1px solid var(--line);
    padding-top: 0.8rem;
    font-size: 0.78rem;
  }

  .mode-list {
    display: grid;
    gap: 0.8rem;
    margin-top: 2rem;
  }

  .mode-button {
    width: 100%;
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border: 2px solid var(--ink);
    border-radius: 8px;
    padding: 1rem 1.1rem;
    background: var(--paper-strong);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
  }

  .mode-button:not([disabled]):hover {
    background: var(--yellow-soft);
  }

  .mode-button[disabled] {
    opacity: 0.58;
    cursor: not-allowed;
  }

  .mode-button[data-start-mode="adaptive"] {
    border-color: var(--green);
  }

  .mode-button[data-start-mode="exam"] {
    border-style: dashed;
  }

  .mode-button strong,
  .mode-button span {
    display: block;
  }

  .mode-button span {
    color: var(--ink-soft);
    font-size: 0.88rem;
  }

  .mode-count {
    flex: 0 0 auto;
    font-family: var(--mono);
    font-size: 0.82rem;
    font-weight: 850;
  }

  .topic-drills {
    margin-top: 2.25rem;
    border-top: 1px solid var(--line-dark);
    padding-top: 1.4rem;
  }

  .topic-drills-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
  }

  .topic-drills-heading h3 {
    font-size: 1.25rem;
  }

  .topic-drills-heading span {
    color: var(--ink-soft);
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
  }

  .topic-drill-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
    margin-top: 0.85rem;
  }

  .topic-drill-button {
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    border: 1px solid var(--line-dark);
    border-radius: 6px;
    padding: 0.7rem 0.8rem;
    background: transparent;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
  }

  .topic-drill-button:hover {
    border-color: var(--ink);
    background: var(--yellow-soft);
  }

  .topic-drill-button span:first-child {
    font-weight: 800;
  }

  .topic-drill-button span:last-child {
    flex: 0 0 auto;
    color: var(--ink-soft);
    font-family: var(--mono);
    font-size: 0.7rem;
  }

  .text-button {
    min-height: 44px;
    margin-top: 0.65rem;
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--ink);
    font-weight: 800;
    text-decoration: underline;
    text-decoration-thickness: 0.09em;
    text-underline-offset: 0.18em;
    cursor: pointer;
  }

  .quiz-panel {
    max-width: 780px;
    margin-inline: auto;
  }

  .quiz-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.8rem;
    font-family: var(--mono);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .progress-track {
    height: 8px;
    overflow: hidden;
    border-radius: 99px;
    background: #d7d2c6;
  }

  .progress-fill {
    width: var(--progress, 0%);
    height: 100%;
    border-radius: inherit;
    background: var(--green);
    transition: width 220ms ease;
  }

  .question-block {
    padding-block: clamp(2.2rem, 5vw, 4rem);
  }

  .question-context {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.8rem;
  }

  .question-topic {
    margin: 0;
    color: var(--green);
    font-family: var(--mono);
    font-size: 0.75rem;
    font-weight: 850;
    letter-spacing: 0.07em;
    text-transform: uppercase;
  }

  .engine-label {
    flex: 0 0 auto;
    border: 1px solid var(--line-dark);
    border-radius: 999px;
    padding: 0.25rem 0.55rem;
    color: var(--ink-soft);
    font-family: var(--mono);
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }

  .question-title {
    max-width: 25ch;
    font-size: clamp(1.8rem, 4.3vw, 3rem);
    line-height: 1.12;
  }

  .choice-list {
    display: grid;
    gap: 0.8rem;
    margin-top: 2rem;
  }

  .choice-fieldset {
    min-width: 0;
    margin: 0;
    border: 0;
    padding: 0;
  }

  .choice {
    position: relative;
    width: 100%;
    min-height: 64px;
    display: grid;
    grid-template-columns: 2.25rem minmax(0, 1fr) auto;
    gap: 0.85rem;
    align-items: center;
    border: 2px solid var(--ink);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    background: var(--paper-strong);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    transition: translate 130ms ease, background 130ms ease;
  }

  .choice:not([disabled]):hover {
    translate: 4px 0;
    background: var(--yellow-soft);
  }

  .choice-key {
    width: 2.25rem;
    height: 2.25rem;
    display: grid;
    place-items: center;
    border: 1px solid var(--line-dark);
    border-radius: 5px;
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 850;
  }

  .choice[disabled] {
    cursor: default;
  }

  .choice-state {
    grid-column: 2 / -1;
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 850;
    letter-spacing: 0.02em;
  }

  .choice.is-correct {
    border-color: var(--green);
    background: var(--green-soft);
  }

  .choice.is-incorrect {
    border-color: var(--red);
    background: var(--red-soft);
  }

  .choice.is-muted {
    border-color: var(--line);
    color: var(--ink-soft);
  }

  .choice.is-selected {
    border-color: var(--yellow);
    background: var(--yellow-soft);
  }

  .choice.is-submitting {
    background: var(--yellow-soft);
  }

  .answer-saving {
    margin-top: 1rem;
    color: var(--ink-soft);
    font-family: var(--mono);
    font-size: 0.8rem;
    font-weight: 800;
  }

  .feedback {
    margin-top: 1.4rem;
    border-left: 6px solid var(--green);
    padding: 1.2rem 1.35rem;
    background: var(--green-soft);
    animation: feedback-in 180ms ease both;
  }

  .feedback.is-incorrect {
    border-color: var(--red);
    background: var(--red-soft);
  }

  .feedback.is-deferred {
    border-color: var(--yellow);
    background: var(--yellow-soft);
  }

  .feedback-title {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 1.08rem;
  }

  .feedback p + p {
    margin-top: 0.65rem;
  }

  .correct-answer {
    font-weight: 750;
  }

  .source-link {
    display: inline-flex;
    margin-top: 0.8rem;
    font-size: 0.9rem;
    font-weight: 800;
  }

  .quiz-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.25rem;
  }

  .result-score {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-block: 1rem 1.5rem;
  }

  .result-score strong {
    font-size: clamp(4rem, 12vw, 8rem);
    letter-spacing: -0.08em;
    line-height: 0.9;
  }

  .readiness-result {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem 2rem;
    align-items: start;
    margin-top: 2rem;
    border-block: 1px solid var(--ink);
    padding-block: 1.25rem;
  }

  .readiness-result .eyebrow {
    margin-bottom: 0.5rem;
  }

  .readiness-result h3 {
    font-size: clamp(1.35rem, 3vw, 2rem);
  }

  .readiness-result > strong {
    font-family: var(--mono);
    font-size: clamp(2.6rem, 7vw, 4.5rem);
    letter-spacing: -0.07em;
    line-height: 0.95;
  }

  .readiness-result .review-note {
    grid-column: 1 / -1;
    margin-top: 0;
  }

  .topic-results {
    margin-top: 2rem;
  }

  .topic-results h3 {
    font-size: 1.2rem;
  }

  .topic-results dl {
    margin-top: 0.8rem;
    border-top: 1px solid var(--line-dark);
  }

  .topic-result {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
    padding-block: 0.8rem;
    border-bottom: 1px solid var(--line);
  }

  .missed-summary {
    margin-top: 2rem;
    border-top: 1px solid var(--line-dark);
    padding-top: 1.25rem;
  }

  .missed-summary h3 {
    font-size: 1.2rem;
  }

  .missed-summary ol {
    display: grid;
    gap: 0.9rem;
    margin-top: 0.9rem;
    padding-left: 1.4rem;
  }

  .missed-summary li {
    padding-left: 0.35rem;
  }

  .missed-summary li strong,
  .missed-summary li span,
  .missed-summary li a {
    display: block;
  }

  .missed-summary li span {
    margin-top: 0.25rem;
    color: var(--ink-soft);
  }

  .missed-summary li a {
    margin-top: 0.35rem;
    font-size: 0.86rem;
    font-weight: 800;
  }

  .review-note {
    margin-top: 2rem;
    color: var(--ink-soft);
    font-size: 0.92rem;
  }

  .privacy-controls {
    margin-block: 1.5rem 2rem;
    border-block: 1px solid var(--line-dark);
    padding-block: 1.25rem;
  }

  .privacy-control-status {
    min-height: 1.6em;
    margin-top: 0.75rem;
    color: var(--ink-soft);
    font-size: 0.9rem;
  }

  .loading-state,
  .error-state {
    padding: 2rem;
    border: 1px solid var(--line-dark);
    background: var(--paper-strong);
  }

  .error-state.compact {
    margin-top: 1rem;
    padding: 1rem;
  }

  .legal-heading {
    max-width: 14ch;
  }

  .legal-dialog {
    width: min(100% - 2rem, 980px);
    max-width: none;
    max-height: min(90dvh, 900px);
    margin: auto;
    overflow: hidden;
    border: 2px solid var(--ink);
    border-radius: 10px;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
    box-shadow: 0 28px 90px rgb(0 0 0 / 0.34);
  }

  .legal-dialog::backdrop {
    background: rgb(19 34 29 / 0.74);
  }

  .legal-dialog-bar {
    position: sticky;
    z-index: 2;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 66px;
    border-bottom: 1px solid var(--line-dark);
    padding: 0.75rem 1rem;
    background: var(--paper-strong);
  }

  .legal-dialog-bar h2 {
    overflow: hidden;
    font-size: clamp(1rem, 2vw, 1.25rem);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .dialog-close {
    min-width: 72px;
    min-height: 44px;
    border: 2px solid var(--ink);
    border-radius: 6px;
    padding: 0.45rem 0.8rem;
    background: var(--yellow);
    color: var(--ink);
    font-weight: 850;
    cursor: pointer;
  }

  .legal-dialog-content {
    max-height: calc(min(90dvh, 900px) - 66px);
    overflow: auto;
    overscroll-behavior: contain;
  }

  .legal-dialog-document .page-hero {
    padding-block: clamp(2.5rem, 6vw, 4.5rem);
  }

  .legal-dialog-document .section {
    padding-block: clamp(2.5rem, 6vw, 4.5rem);
  }

  .footer-brand {
    font-size: clamp(1.7rem, 4vw, 3rem);
    font-weight: 850;
    letter-spacing: -0.045em;
  }

  .footer-copy {
    max-width: 64ch;
    margin-top: 1rem;
    color: #c7d0ca;
    font-family: var(--serif);
  }

  .footer-links {
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.75rem 1.4rem;
    font-size: 0.9rem;
    font-weight: 750;
  }

  .footer-links a,
  .demo-state-links a {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  @keyframes feedback-in {
    from {
      opacity: 0;
      transform: translateY(8px);
    }
  }
}

@layer utilities {
  :focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 3px;
    box-shadow: 0 0 0 6px var(--yellow);
  }

  [hidden] {
    display: none !important;
  }

  .visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
  }

  .text-soft {
    color: var(--ink-soft);
  }

  .mt-1 {
    margin-top: 1rem;
  }

  .mt-2 {
    margin-top: 2rem;
  }
}

@container (max-width: 64rem) {
  .quiz-intro {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 840px) {
  .hero,
  .page-hero-grid,
  .content-grid,
  .quiz-intro {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .hero-road {
    min-height: 440px;
  }

  .hero-practice {
    min-height: auto;
  }

  .section-heading {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .state-list {
    grid-template-columns: 1fr;
  }

  .state-link {
    min-height: 210px;
  }

  .state-link + .state-link {
    border-top: 0;
    border-left: 0;
  }

  .trust-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .site-nav {
    min-height: 66px;
  }

  .nav-links a:not(.nav-primary) {
    display: none;
  }

  .nav-primary {
    font-size: 0.84rem;
  }

  .hero-road {
    min-height: 390px;
  }

  .hero-practice {
    min-height: auto;
    padding: 0.75rem;
    padding-bottom: 7.5rem;
  }

  .hero-practice-card {
    padding: 1rem;
  }

  .topic-drill-list {
    grid-template-columns: 1fr;
  }

  .hero-proof li + li::before {
    margin-right: 0.7rem;
  }

  .hero-road::after {
    right: 16%;
    left: 16%;
    width: auto;
    border-inline: 3px solid var(--paper);
    background: none;
    box-shadow: none;
  }

  .road-sign {
    width: 205px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
  }

  .footer-links {
    justify-content: flex-start;
  }

  .action-row .button {
    width: 100%;
  }

  .fact-list > div {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .mode-button {
    align-items: flex-start;
  }

  .mode-count {
    max-width: 7.5rem;
    text-align: right;
  }

  .question-context,
  .readiness-score-row {
    align-items: flex-start;
  }

  .question-context {
    flex-direction: column;
    gap: 0.45rem;
  }

  .readiness-result {
    grid-template-columns: 1fr;
  }

  .readiness-result .review-note {
    grid-column: 1;
  }
}

@layer components {
  .question-media {
    width: min(100%, 640px);
    margin: 1.25rem 0 1.75rem;
    overflow: hidden;
    border: 1px solid var(--line-dark);
    border-radius: 8px;
    background: var(--paper-strong);
  }

  .question-media img {
    width: 100%;
    aspect-ratio: 640 / 420;
    object-fit: contain;
  }

  .question-media figcaption {
    border-top: 1px solid var(--line);
    padding: 0.55rem 0.75rem;
    color: var(--ink-soft);
    font-size: 0.76rem;
  }

  .missed-media {
    width: 160px;
    aspect-ratio: 640 / 420;
    object-fit: contain;
    float: right;
    margin: 0 0 0.5rem 1rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--paper-strong);
  }

  .section-compact {
    padding-block: clamp(3rem, 6vw, 5rem);
  }

  .sync-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
    gap: clamp(2rem, 6vw, 5rem);
    align-items: start;
  }

  .sync-primary,
  .sync-redeem {
    min-width: 0;
  }

  .sync-redeem {
    border-top: 5px solid var(--ink);
    padding-top: 1.25rem;
  }

  .service-status,
  .sync-state,
  .sync-message {
    color: var(--ink-soft);
    font-size: 0.9rem;
  }

  .service-status[data-tone="connected"],
  .sync-message[data-tone="success"] {
    color: var(--green);
  }

  .service-status[data-tone="warning"],
  .sync-message[data-tone="warning"] {
    color: #725500;
  }

  .sync-message[data-tone="error"] {
    color: var(--red);
  }

  .sync-state {
    display: grid;
    gap: 0.2rem;
    margin-top: 1rem;
    border-left: 6px solid var(--yellow);
    padding: 1rem 1.2rem;
    background: var(--paper-strong);
  }

  .sync-state strong {
    color: var(--ink);
    font-size: 1.05rem;
  }

  .sync-form {
    display: grid;
    gap: 0.55rem;
    margin-top: 1.5rem;
  }

  .sync-form input {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--line-dark);
    border-radius: 5px;
    padding: 0.7rem 0.8rem;
    background: var(--paper-strong);
    color: var(--ink);
  }

  .pairing-output {
    margin-top: 1.75rem;
    border: 2px solid var(--ink);
    border-radius: 8px;
    padding: 1.25rem;
    background: var(--yellow-soft);
  }

  .pairing-code {
    display: block;
    margin-block: 0.65rem;
    font-family: var(--mono);
    font-size: clamp(1.7rem, 6vw, 3.2rem);
    font-weight: 900;
    letter-spacing: 0.08em;
    overflow-wrap: anywhere;
  }

  .pairing-code.is-expired {
    opacity: 0.45;
    text-decoration: line-through;
  }

  .device-manager {
    margin-top: 2.5rem;
    border-top: 1px solid var(--line-dark);
    padding-top: 1.25rem;
  }

  .device-row {
    display: grid;
    gap: 0.8rem;
    margin-top: 0.75rem;
    border-bottom: 1px solid var(--line);
    padding-block: 0.9rem;
  }

  .device-row.is-revoked {
    opacity: 0.62;
  }

  .device-row-copy {
    display: grid;
    gap: 0.1rem;
  }

  .device-row-copy span {
    color: var(--ink-soft);
    font-size: 0.8rem;
  }

  .device-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.5rem;
  }

  .device-actions input {
    min-width: 0;
    border: 1px solid var(--line-dark);
    border-radius: 4px;
    padding: 0.55rem 0.65rem;
  }

  .confirmation-row {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    color: var(--red);
  }

  .confirmation-row input {
    width: auto;
    min-height: 24px;
    flex: 0 0 auto;
  }

  .sync-message {
    min-height: 1.6rem;
    margin-top: 1rem;
  }

  .sync-empty {
    color: var(--ink-soft);
    font-size: 0.9rem;
  }
}

@media (max-width: 840px) {
  .sync-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .device-actions {
    grid-template-columns: 1fr;
  }

  .missed-media {
    width: 100%;
    float: none;
    margin: 0 0 0.75rem;
  }
}

@layer components {
  .state-jump {
    max-width: 650px;
    display: grid;
    gap: 0.5rem;
    margin-top: 1.6rem;
  }

  .state-jump > label,
  .state-filter > label {
    font-size: 0.9rem;
  }

  .state-jump-row,
  .state-filter-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
  }

  .state-jump-row input,
  .state-filter-row input {
    min-width: 0;
    min-height: 52px;
    flex: 1 1 auto;
    border: 2px solid var(--ink);
    border-radius: 6px;
    padding: 0.75rem 0.9rem;
    background: var(--paper-strong);
    color: var(--ink);
  }

  .state-jump-row .button {
    flex: 0 0 auto;
  }

  .state-jump-status {
    min-height: 1.45rem;
    color: var(--ink-soft);
    font-size: 0.85rem;
  }

  .recent-state {
    max-width: 650px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    border-left: 6px solid var(--green);
    padding: 0.9rem 1rem;
    background: var(--green-soft);
  }

  .recent-state > div {
    min-width: 0;
    display: grid;
    gap: 0.1rem;
  }

  .recent-state > div > span:last-child {
    color: var(--ink-soft);
    font-size: 0.85rem;
  }

  .recent-state .arrow-link {
    white-space: nowrap;
  }

  .state-filter {
    display: grid;
    gap: 0.55rem;
    margin-bottom: 1.25rem;
    border-top: 1px solid var(--line-dark);
    padding-top: 1.1rem;
  }

  .state-filter-row input {
    max-width: 560px;
    border-width: 1px;
  }

  .state-filter-row output {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 0.78rem;
    font-weight: 800;
    white-space: nowrap;
  }

  .state-filter-empty {
    border-left: 5px solid var(--yellow);
    padding: 0.75rem 0.9rem;
    background: var(--paper-strong);
    color: var(--ink-soft);
  }

  .study-path {
    margin: 2rem 0 1.5rem;
    border-block: 1px solid var(--line-dark);
    padding-block: 1.3rem;
  }

  .study-path-heading,
  .saved-rules-heading,
  .consistency-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
  }

  .study-path-heading .eyebrow,
  .saved-rules-heading .eyebrow {
    margin-bottom: 0.45rem;
  }

  .study-path-heading > span {
    color: var(--ink-soft);
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
  }

  .study-path-list {
    display: grid;
    gap: 0;
    margin-top: 1rem;
    padding: 0;
    list-style: none;
  }

  .study-step {
    border-top: 1px solid var(--line);
  }

  .study-step:last-child {
    border-bottom: 1px solid var(--line);
  }

  .study-step button {
    width: 100%;
    min-height: 78px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.9rem;
    border: 0;
    border-left: 5px solid transparent;
    padding: 0.85rem 0.9rem;
    background: transparent;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
  }

  .study-step button:hover,
  .study-step button:focus-visible {
    background: var(--paper-strong);
  }

  .study-step.is-current button {
    border-left-color: var(--yellow);
    background: var(--yellow-soft);
  }

  .study-step.is-complete button {
    border-left-color: var(--green);
  }

  .study-step-number {
    width: 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
    border: 2px solid currentColor;
    border-radius: 4px;
    font-family: var(--mono);
    font-weight: 900;
  }

  .study-step.is-complete .study-step-number {
    background: var(--green);
    color: var(--paper-strong);
  }

  .study-step button > span:nth-child(2) {
    min-width: 0;
    display: grid;
    gap: 0.15rem;
  }

  .study-step small,
  .study-step-status {
    color: var(--ink-soft);
  }

  .study-step-status {
    max-width: 11rem;
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 800;
    text-align: right;
  }

  .study-shortcuts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 1rem;
    margin-top: 1rem;
    color: var(--ink-soft);
    font-size: 0.88rem;
  }

  .saved-rules-panel {
    display: grid;
    gap: 0.65rem;
    margin-bottom: 1rem;
    border-top: 5px solid var(--yellow);
    padding: 1rem;
    background: var(--paper-strong);
  }

  .saved-rules-heading > strong {
    min-width: 2.3rem;
    text-align: right;
    font-family: var(--mono);
    font-size: 1.65rem;
  }

  .saved-rules-panel > p {
    color: var(--ink-soft);
    font-size: 0.9rem;
  }

  .question-labels {
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.8rem;
  }

  .save-rule-button {
    min-height: 42px;
    flex: 0 0 auto;
    border: 1px solid var(--line-dark);
    border-radius: 5px;
    padding: 0.45rem 0.7rem;
    background: var(--paper-strong);
    color: var(--ink);
    font-weight: 800;
    cursor: pointer;
  }

  .save-rule-button.is-saved,
  .save-rule-button[aria-pressed="true"] {
    border-color: var(--green);
    background: var(--green-soft);
    color: var(--green);
  }

  .consistency-gate {
    display: grid;
    gap: 0.55rem;
    margin-top: 1rem;
    border-top: 1px solid var(--line);
    padding-top: 1rem;
  }

  .consistency-heading {
    align-items: center;
    font-size: 0.88rem;
    font-weight: 800;
  }

  .consistency-heading strong {
    font-family: var(--mono);
    font-size: 1.05rem;
  }

  .consistency-dots {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
  }

  .consistency-dot {
    height: 0.48rem;
    border: 1px solid var(--line-dark);
    background: transparent;
  }

  .consistency-dot.is-complete {
    border-color: var(--green);
    background: var(--green);
  }

  .consistency-gate > p {
    color: var(--ink-soft);
    font-size: 0.82rem;
  }

  .readiness-result .consistency-gate {
    grid-column: 1 / -1;
    width: 100%;
  }

  .missed-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem 1rem;
    margin-top: 0.35rem;
  }
}

@media (max-width: 640px) {
  .state-jump-row,
  .state-filter-row {
    align-items: stretch;
    flex-direction: column;
  }

  .state-jump-row .button,
  .state-filter-row input {
    width: 100%;
    max-width: none;
  }

  .state-filter-row output {
    margin-left: 0;
  }

  .recent-state {
    grid-template-columns: 1fr;
  }

  .recent-state .arrow-link {
    white-space: normal;
  }

  .study-path-heading,
  .saved-rules-heading {
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .study-step button {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .study-step-status {
    grid-column: 2;
    max-width: none;
    text-align: left;
  }

  .question-context {
    align-items: stretch;
  }

  .save-rule-button {
    width: 100%;
  }
}

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

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