:root {
      color-scheme: light;
      --font-primary: "Open Sans", Arial, sans-serif;
      --font-icons: "Material Symbols Rounded";
      --brand-primary: #9e1b32;
      --brand-neutral: #333e48;
      --ink: #333e48;
      --muted: #696969;
      --line: #cfcfcf;
      --line-soft: #e7e7e7;
      --gray-700: #4f4f4f;
      --surface: #ffffff;
      --page: #f7f7f7;
      --red: #9e1b32;
      --red-hover: #6d1222;
      --orange: #e77204;
      --yellow: #f1c319;
      --green: #45842a;
      --blue: #007298;
      --purple: #652f6c;
      --focus: #cfcfcf;
      --blue-hover: #004d66;
      --blue-highlight: #cdf3ff;
      --red-highlight: #ffccd5;
      --accent: var(--blue);
      --accent-hover: var(--blue-hover);
      --accent-highlight: var(--blue-highlight);
      --accent-ring: rgba(0, 114, 152, .24);
    }

    * {
      box-sizing: border-box;
    }

    body {
      margin: 0;
      min-width: 320px;
      background: var(--page);
      color: var(--ink);
      font-family: var(--font-primary);
      line-height: 1.45;
    }

    body[data-style-version="cs1"],
    body[data-color-set="colorset1"] {
      --accent: var(--red);
      --accent-hover: var(--red-hover);
      --accent-highlight: var(--line-soft);
      --accent-ring: rgba(158, 27, 50, .24);
    }

    .page-shell {
      width: min(1760px, calc(100% - 32px));
      margin: 0 auto;
      padding: 16px 0 24px;
    }

    header {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 12px;
      align-items: end;
      padding: 0 0 12px;
      border: 0;
    }

    h1 {
      margin: 0;
      color: var(--brand-primary);
      font-size: 30px;
      font-weight: 760;
      line-height: 1.08;
      letter-spacing: 0;
    }

    .intro {
      margin: 6px 0 0;
      max-width: 940px;
      color: var(--muted);
      font-size: 15px;
    }

    .header-actions {
      display: grid;
      gap: 12px;
      justify-items: end;
      align-items: center;
    }

    .nav-links {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      justify-content: flex-end;
    }

    .nav-link,
    .card-replay-button {
      min-height: 30px;
      border: 0;
      border-radius: 8px;
      background: var(--surface);
      color: var(--accent-hover);
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 0 10px;
      text-decoration: none;
      font: inherit;
      font-size: 12px;
      font-weight: 800;
      line-height: 1;
    }

    .card-replay-button {
      appearance: none;
      color: var(--ink);
      cursor: pointer;
      font-weight: 700;
    }

    .nav-link:hover,
    .card-replay-button:hover {
      border-color: var(--accent);
      background: var(--accent-highlight);
      color: var(--accent-hover);
    }

    .card-replay-button:focus-visible {
      outline: 3px solid var(--focus);
      outline-offset: 2px;
    }

    .material-symbols-rounded {
      font-family: var(--font-icons);
      font-size: 16px;
      font-variation-settings: "FILL" 0, "wght" 700, "GRAD" 0, "opsz" 20;
      line-height: 1;
    }

    .summary {
      display: grid;
      grid-auto-flow: column;
      gap: 12px;
      align-items: center;
      color: var(--muted);
      font-size: 13px;
      white-space: nowrap;
    }

    .summary strong {
      display: block;
      color: var(--ink);
      font-size: 22px;
      line-height: 1.05;
    }

    .gallery {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      grid-auto-flow: dense;
      gap: 12px;
      padding-top: 18px;
    }

    .example-card {
      min-width: 0;
      border: 0;
      border-radius: 8px;
      background: var(--surface);
      overflow: hidden;
      box-shadow: none;
    }

    .example-card--wide {
      grid-column: span 2;
      overflow-x: auto;
      border-color: var(--line-soft);
    }

    .example-card--wide .viz-frame {
      min-width: 880px;
      aspect-ratio: 1.956;
    }

    .example-card--full {
      grid-column: 1 / -1;
    }

    .example-card--full .viz-frame {
      aspect-ratio: 1.956;
    }

    .example-header {
      min-height: 0;
      padding: 10px 12px;
      border: 0;
    }

    .example-header-top {
      display: flex;
      gap: 10px;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 6px;
    }

    .example-kicker {
      min-width: 0;
      margin: 0;
      color: var(--brand-primary);
      font-size: 12px;
      font-weight: 700;
      text-transform: uppercase;
    }

    h2 {
      margin: 0;
      font-size: 18px;
      line-height: 1.15;
      letter-spacing: 0;
    }

    .example-copy {
      margin: 8px 0 0;
      color: var(--muted);
      font-size: 13px;
    }

    .example-pattern-id {
      margin: 5px 0 0;
      color: var(--gray-700);
      font-family: Consolas, "Liberation Mono", "Courier New", monospace;
      font-size: 10.5px;
      font-weight: 700;
      line-height: 1.25;
      letter-spacing: 0;
      overflow-wrap: anywhere;
    }

    .viz-frame {
      aspect-ratio: 1.34;
      background: var(--surface);
    }

    svg {
      display: block;
      width: 100%;
      height: 100%;
    }

    .axis path,
    .axis line {
      stroke: #9c9c9c;
    }

    .axis text,
    .caption,
    .label {
      fill: #4f4f4f;
      font-size: 12px;
    }

    .grid line {
      stroke: #e7e7e7;
      stroke-dasharray: 3 5;
    }

    .caption,
    .label,
    .mark-label {
      paint-order: stroke;
      stroke: #ffffff;
      stroke-width: 3px;
      stroke-linejoin: round;
    }

    .mark-label {
      fill: #333e48;
      font-size: 12px;
      font-weight: 650;
    }

    .example-card[data-replay-state="running"] .card-replay-button {
      border-color: var(--accent);
      background: var(--accent-highlight);
      color: var(--accent-hover);
    }

    .example-card[data-replay-state="running"] .viz-frame {
      box-shadow: inset 0 0 0 2px var(--accent-ring);
    }

    @media (max-width: 1320px) {
      .gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }
    }

    @media (max-width: 820px) {
      .gallery {
        grid-template-columns: 1fr;
      }
    }

    @media (max-width: 680px) {
      .page-shell {
        width: min(100% - 20px, 720px);
        padding-top: 16px;
      }

      header {
        grid-template-columns: 1fr;
        gap: 12px;
      }

      h1 {
        font-size: 25px;
      }

      .header-actions {
        justify-items: start;
      }

      .summary {
        grid-auto-flow: row;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        white-space: normal;
      }

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

      .example-card--wide {
        grid-column: span 1;
      }

      .example-card--full {
        grid-column: span 1;
        overflow-x: auto;
      }

      .example-card--full .viz-frame {
        min-width: 880px;
      }

      .example-header {
        min-height: 0;
      }
    }

@media (pointer: coarse) { :root button, :root select, :root input:not([type="checkbox"]):not([type="radio"]) { min-height: 44px; } }

.card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.example-header-top { flex-wrap: wrap; }
.viz-frame.is-expanded { min-width: 0; aspect-ratio: auto; max-height: 70vh; overflow: auto; }
.viz-frame.is-expanded svg { max-width: none; }

/* Keep the dense CS1 overview inside its card; Expand retains readable detail. */
body[data-style-version="cs1"] article[data-example-id="task-overlap-dense"] .viz-frame:not(.is-expanded) {
  min-width: 0;
  aspect-ratio: 880 / 489.85;
}

body[data-style-version="cs1"] article[data-example-id="task-overlap-dense"] .viz-frame.is-expanded svg {
  width: 2200px !important;
  height: auto !important;
  aspect-ratio: 880 / 489.85;
}
