  :root {
    --paper: #F1F3F0;
    --panel: #FFFFFF;
    --ink: #1E2B2E;
    --muted: #5F6E72;
    --line: #D9DFDC;
    --soft: #E6EAE7;
    --focus: #2F6FB3;
    --display: "Fraunces", Georgia, "Times New Roman", serif;
    --body: "Archivo", "Helvetica Neue", Arial, sans-serif;
    --header-h: 64px;
    --footer-h: 36px;
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; }
  body {
    font-family: var(--body);
    color: var(--ink);
    background: var(--paper);
    line-height: 1.5;
    font-size: 15px;
  }
  button { font: inherit; color: inherit; cursor: pointer; }
  button:focus-visible, [tabindex]:focus-visible, input:focus-visible {
    outline: 3px solid var(--focus); outline-offset: 2px;
  }

  /* ---------- header ---------- */
  header {
    height: var(--header-h);
    display: flex; align-items: center; gap: 24px;
    padding: 0 20px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
  }
  .brand { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
  .brand h1 {
    margin: 0; font-family: var(--display); font-weight: 700;
    font-size: 22px; letter-spacing: -0.01em; white-space: nowrap;
  }
  .brand span { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
  nav[role=tablist] {
    display: flex; gap: 4px; margin-left: auto;
    background: var(--soft); padding: 4px; border-radius: 999px;
  }
  nav [role=tab] {
    border: 0; background: transparent; border-radius: 999px;
    padding: 7px 14px; font-weight: 600; font-size: 14px; color: var(--muted);
    white-space: nowrap;
  }
  nav [role=tab][aria-selected=true] { background: var(--ink); color: #fff; }
  nav [role=tab] small { display: block; font-weight: 400; font-size: 11px; opacity: .8; line-height: 1; margin-top: 2px; }

  /* ---------- layout ---------- */
  main {
    display: grid;
    grid-template-columns: minmax(340px, 460px) 1fr;
    height: calc(100vh - var(--header-h) - var(--footer-h));
  }
  .lesson { overflow-y: auto; padding: 24px 22px 48px; border-right: 1px solid var(--line); }
  .mapwrap { position: relative; background: #0d1a22; }
  #map { position: absolute; inset: 0; }
  .map-ui {
    position: absolute; top: 14px; right: 14px; z-index: 5;
    display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  }
  .map-card {
    background: rgba(255,255,255,.94); backdrop-filter: blur(4px);
    border-radius: 10px; padding: 10px 12px; font-size: 13px;
    box-shadow: 0 2px 10px rgba(0,0,0,.25); max-width: 300px;
  }
  .map-card label { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
  .map-card button {
    border: 1px solid var(--line); background: #fff; border-radius: 8px;
    padding: 5px 10px; font-size: 13px; font-weight: 600; margin-top: 6px; width: 100%;
  }
  .map-card .where { font-family: var(--display); font-weight: 700; font-size: 16px; margin: 0 0 2px; }
  .map-card .where + p { margin: 0; color: var(--muted); }
  .map-status {
    position: absolute; left: 14px; bottom: 34px; z-index: 5;
    background: rgba(30,43,46,.92); color: #fff; padding: 8px 12px;
    border-radius: 8px; font-size: 13px; max-width: 360px; display: flex; gap: 10px; align-items: center;
  }
  .map-status .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; background: #fff; }
  .map-fallback {
    position: absolute; inset: 0; display: none; place-items: center; text-align: center;
    color: #cfd8dc; padding: 40px; z-index: 6; background: #0d1a22;
  }
  .map-fallback.show { display: grid; }
  .map-fallback h3 { font-family: var(--display); color: #fff; margin: 0 0 8px; }
  .map-fallback p { max-width: 420px; margin: 0; }

  /* ---------- footer ---------- */
  footer {
    height: var(--footer-h);
    display: flex; align-items: center; justify-content: center;
    background: var(--panel); border-top: 1px solid var(--line);
    font-size: 13px; color: var(--muted);
  }
  footer a { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

  /* ---------- lesson content ---------- */
  .lesson h2 {
    font-family: var(--display); font-weight: 700; font-size: 30px;
    letter-spacing: -0.015em; margin: 0; line-height: 1.1;
  }
  .byline { color: var(--muted); margin: 6px 0 14px; font-size: 14px; }
  .tagline { font-size: 17px; margin: 0 0 20px; }
  .lesson h3 {
    font-family: var(--display); font-weight: 700; font-size: 18px; margin: 26px 0 8px;
  }
  .lesson p { margin: 0 0 10px; }
  .diagram { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
  .diagram svg { display: block; width: 100%; max-width: 380px; margin: 0 auto; height: auto; }
  .diagram .hint { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); text-align: center; }
  .zone { cursor: pointer; transition: opacity .15s; }
  .zone-shape { stroke: #fff; stroke-width: 1.5; }
  .zone-num { font-family: var(--body); font-weight: 700; font-size: 15px; fill: #fff; pointer-events: none; }
  svg.has-active .zone:not(.active) { opacity: .45; }
  svg .zone.active .zone-shape { stroke: var(--ink); stroke-width: 3; }
  @media (prefers-reduced-motion: reduce) { .zone { transition: none; } }

  .zones { list-style: none; margin: 14px 0 0; padding: 0; }
  .zones li {
    display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 9px 10px;
    border-radius: 8px; cursor: pointer; border: 1px solid transparent;
  }
  .zones li:hover { background: var(--panel); }
  .zones li.active { background: var(--panel); border-color: var(--line); }
  .zones .sw {
    width: 22px; height: 22px; border-radius: 6px; color: #fff; font-weight: 700; font-size: 12px;
    display: grid; place-items: center; margin-top: 1px;
  }
  .zones b { display: block; font-weight: 600; }
  .zones span { color: var(--muted); font-size: 13.5px; }

  .ground {
    border-left: 4px solid var(--ink); background: var(--panel);
    padding: 12px 14px; border-radius: 0 10px 10px 0; margin-top: 8px;
  }
  .ground ul, .limits ul { margin: 6px 0 0; padding-left: 18px; }
  .ground li, .limits li { margin-bottom: 5px; }
  .idea { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }

  /* ---------- quiz ---------- */
  .q { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
  .q p.prompt { font-weight: 600; margin-bottom: 10px; }
  .q .opts { display: grid; gap: 6px; }
  .q .opts button {
    text-align: left; border: 1px solid var(--line); background: var(--paper);
    border-radius: 8px; padding: 8px 12px;
  }
  .q .opts button:hover { border-color: var(--ink); }
  .q .opts button.right { background: #E3F1DF; border-color: #5E9B4E; }
  .q .opts button.wrong { background: #F8E3E2; border-color: #B8322F; }
  .q .opts button:disabled { cursor: default; }
  .q .fb { margin: 10px 0 0; font-size: 14px; }
  .score { font-family: var(--display); font-size: 22px; font-weight: 700; margin-top: 16px; }
  .reset-quiz { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 12px; font-weight: 600; margin-top: 6px; }

  /* ---------- compare table ---------- */
  table { border-collapse: collapse; width: 100%; font-size: 13.5px; margin-top: 10px; }
  th, td { text-align: left; vertical-align: top; padding: 8px 8px; border-top: 1px solid var(--line); }
  th { font-weight: 600; }
  thead th { border-top: 0; color: var(--muted); font-weight: 600; }

  @media (max-width: 860px) {
    header { flex-wrap: wrap; height: auto; padding: 12px 14px; gap: 10px; }
    nav[role=tablist] { margin-left: 0; width: 100%; overflow-x: auto; }
    main { grid-template-columns: 1fr; height: auto; }
    .mapwrap { order: -1; position: sticky; top: 0; height: 46vh; z-index: 10; }
    .lesson { border-right: 0; height: auto; overflow: visible; }
    .map-card { max-width: 220px; }
    .map-status { bottom: 24px; font-size: 12px; max-width: 60%; }
  }
