/* ============================================================================
 * plaTTdata — Reusable Open-Data Visualization Stylesheet (Nov 2026)
 * Organized with explicit CSS Cascade Layers (@layer) so individual chart
 * templates can be copied cleanly into future projects without specificity wars.
 * ============================================================================ */

@layer tokens, reset, layout, components, charts, utilities;

/* --------------------------------------------------------------------------
 * 1. Design Tokens
 * -------------------------------------------------------------------------- */
@layer tokens {
  :root {
    --bg-page: #ffffff;
    --surface-gray: #f4f6f8;
    --text: #0f172a;
    --text-secondary: #475569;
    --muted: #64748b;
    --border: #cbd5e1;
    --border-subtle: #e2e8f0;
    --border-dotted: #94a3b8;
    --focus-ring: #334155;
    --font-sans: "National 2", "National", "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  }
}

/* --------------------------------------------------------------------------
 * 2. Reset & Base Typography
 * -------------------------------------------------------------------------- */
@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    font-size: 17.33px; /* 1pt (~1.33px) increase on standard 16px (12pt -> 13pt) base */
  }

  @media (prefers-reduced-motion: no-preference) {
    html {
      scroll-behavior: smooth;
    }
  }

  body {
    font-family: var(--font-sans);
    background-color: var(--bg-page);
    color: var(--text);
    margin: 0;
    padding: 0;
    line-height: 1.6;
    min-height: 100vh;
  }
}

/* --------------------------------------------------------------------------
 * 3. Page Shell (Fixed White Left Rail + Sinusoidal Gray Canvas + Footer)
 * -------------------------------------------------------------------------- */
@layer layout {
  .page-shell {
    display: grid;
    grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
    align-items: start;
    width: 100%;
    background-color: var(--bg-page);
  }

  .left-rail {
    position: sticky;
    inset-block-start: 0;
    min-block-size: 100dvh;
    max-block-size: 100dvh;
    overflow-y: auto;
    scrollbar-gutter: stable;
    overscroll-behavior: contain;
    background-color: var(--bg-page);
    padding-block: 2rem;
    padding-inline: clamp(2.5rem, 4vw, 3.75rem) 2.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    justify-content: safe center;
    align-items: stretch;
    gap: 1.5rem;
  }

  .portfolio-header {
    text-align: start;
    max-inline-size: 100%;
  }

  .portfolio-title {
    font-family: var(--font-sans);
    font-size: clamp(1.35rem, 1.1rem + 0.75vw, 1.68rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: var(--text);
    margin-block: 0 0.65rem;
    text-wrap: balance;
  }

  .portfolio-lead {
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
    text-wrap: pretty;
  }

  /* Main gray chart column with sinusoidal lateral edges (720px wavelength) */
  .container {
    min-inline-size: 0;
    width: 100%;
    min-height: 100vh;
    padding-block: 2.25rem 4rem;
    padding-inline: clamp(2.5rem, 3.8vw, 4.5rem);
    background-image:
      url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2050%20720%22%20width%3D%2250%22%20height%3D%22720%22%3E%3Cpath%20d%3D%22M%2025%2C0%20C%2045%2C108%2045%2C252%2025%2C360%20C%205%2C468%205%2C612%2025%2C720%20L%2050%2C720%20L%2050%2C0%20Z%22%20fill%3D%22%23f4f6f8%22/%3E%3C/svg%3E"),
      url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2050%20720%22%20width%3D%2250%22%20height%3D%22720%22%3E%3Cpath%20d%3D%22M%2025%2C0%20C%2045%2C108%2045%2C252%2025%2C360%20C%205%2C468%205%2C612%2025%2C720%20L%200%2C720%20L%200%2C0%20Z%22%20fill%3D%22%23f4f6f8%22/%3E%3C/svg%3E"),
      linear-gradient(var(--surface-gray), var(--surface-gray));
    background-repeat: repeat-y, repeat-y, no-repeat;
    background-position: left top, right top, center top;
    background-size: 50px 720px, 50px 720px, calc(100% - 98px) 100%;
  }

  .container > main,
  .container > .site-footer {
    max-inline-size: 1300px;
    margin-inline: auto;
  }

  /* Vertical Chart Index in White Left Rail with CSS Scrollspy */
  .index-bar {
    width: 100%;
    padding-block-start: 1.35rem;
    border-block-start: 1px dotted var(--border-dotted);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.7rem;
  }

  .index-brand {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
  }

  .index-heading {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
  }

  .index-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-inline-size: 1.4rem;
    block-size: 1.4rem;
    padding-inline: 0.35rem;
    background-color: var(--surface-gray);
    border: 1px solid var(--border);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text);
  }

  .chart-index-nav {
    scroll-target-group: auto;
    width: 100%;
  }

  .chart-index-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.38rem;
  }

  .chart-index-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    min-block-size: 42px;
    padding-block: 0.4rem;
    padding-inline: 0.75rem;
    border: 1px solid var(--border-subtle);
    background-color: #ffffff;
    color: var(--text);
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  }

  .chart-index-link:hover {
    background-color: #f8fafc;
    border-color: var(--border);
  }

  .chart-index-icon {
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: color 0.15s ease;
  }

  .chart-index-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
  }

  .chart-index-name {
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: -0.01em;
  }

  .chart-index-meta {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--muted);
    margin-block-start: 0.1rem;
  }

  .chart-index-link:is(:target-current, .target-current) {
    background-color: var(--text);
    border-color: var(--text);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.16);
  }

  .chart-index-link:is(:target-current, .target-current) .chart-index-icon,
  .chart-index-link:is(:target-current, .target-current) .chart-index-meta {
    color: rgba(255, 255, 255, 0.78);
  }

  .chart-index-link:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
  }

  .site-footer {
    margin-block-start: 4.5rem;
    padding-block: 2.25rem 0.5rem;
    border-top: 1px solid var(--border-subtle);
    text-align: center;
  }

  .site-footer-copyright {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--muted);
    letter-spacing: 0.01em;
  }

  .site-footer-copyright strong {
    font-weight: 700;
    color: var(--text-secondary);
  }

  .site-footer-link {
    color: var(--text);
    text-decoration: underline;
    text-decoration-color: var(--border);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: color 0.15s ease, text-decoration-color 0.15s ease;
  }

  .site-footer-link:hover {
    color: var(--text);
    text-decoration-color: var(--text);
  }

  .site-footer-link:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 3px;
  }
}

/* --------------------------------------------------------------------------
 * 4. Shared Reusable Chart Components (Copy-Paste Ready Across Projects)
 * -------------------------------------------------------------------------- */
@layer components {
  .chart-section {
    scroll-margin-top: 1rem;
  }

  .chart-section + .chart-section {
    margin-block-start: 5.5rem;
    padding-block-start: 4.5rem;
    border-block-start: 1px solid var(--border-subtle);
  }

  .chart-section:focus {
    outline: none;
  }

  .section-header {
    margin-block-end: 1rem;
    padding-block-end: 0.9rem;
  }

  .page-title {
    font-family: var(--font-sans);
    font-size: clamp(1.55rem, 1.2rem + 1.2vw, 2.2rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-block: 0 0.45rem;
    max-width: 1300px;
    text-wrap: balance;
    color: var(--text);
  }

  .section-question {
    font-size: clamp(1.12rem, 1rem + 0.4vw, 1.32rem);
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.015em;
    color: var(--text);
    margin-block: 0 0.45rem;
    max-width: 68ch;
    text-wrap: balance;
  }

  .page-subtitle {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.96rem;
    line-height: 1.55;
    max-width: 75ch;
    text-wrap: pretty;
  }

  .page-subtitle strong {
    color: var(--text);
    font-weight: 600;
  }

  .dataset-takeaway {
    margin-block: 0.65rem 0;
    padding-block: 0.5rem;
    padding-inline: 0.9rem;
    background: transparent;
    border: 1px dotted var(--border-dotted);
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.52;
    max-width: 76ch;
    text-wrap: pretty;
  }

  .dataset-takeaway strong {
    color: var(--text);
    font-weight: 600;
  }

  /* Controls Bar & Form Primitives */
  .chart-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.85rem 1.5rem;
    margin-block-end: 1rem;
  }

  .control-group {
    border: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
  }

  .control-group[hidden] {
    display: none;
  }

  .control-legend {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    padding: 0;
  }

  .segmented-control {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.25rem;
    background-color: #ffffff;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  }

  .segmented-option {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
  }

  .segmented-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
  }

  .segmented-option span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-block-size: 36px;
    padding: 0.35rem 0.85rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: background-color 0.15s ease, color 0.15s ease;
    user-select: none;
  }

  .segmented-option:hover span {
    background-color: #f1f5f9;
    color: var(--text);
  }

  .segmented-option input[type="radio"]:checked + span {
    background-color: var(--text);
    color: #ffffff;
  }

  .segmented-option input[type="radio"]:focus-visible + span {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
  }

  .chart-select {
    min-block-size: 42px;
    padding: 0.4rem 0.75rem;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    background-color: #ffffff;
    border: 1px solid var(--border);
    cursor: pointer;
  }

  .chart-select:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
  }

  /* Spotlight Search Input */
  .search-spotlight-area {
    flex: 0 1 26rem;
    width: 100%;
  }

  .filter-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .search-input-group {
    position: relative;
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }

  .search-input-group:focus-within {
    border-color: var(--text);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
  }

  .search-icon-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding-left: 0.85rem;
    color: var(--muted);
    pointer-events: none;
  }

  .search-input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    min-height: 44px;
    border: none;
    background: transparent;
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text);
    outline: none;
  }

  .search-input::placeholder {
    color: var(--muted);
    opacity: 0.85;
  }

  .btn-reset {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    margin-right: 0.35rem;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
  }

  .btn-reset:hover {
    background-color: #f1f5f9;
    color: var(--text);
  }

  .search-input:focus-visible,
  .btn-reset:focus-visible,
  a:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
  }

  /* Figure, Canvas, Tooltip & Error Banner */
  .viz-figure {
    margin: 0 0 1.5rem;
  }

  .chart-canvas {
    width: 100%;
    height: clamp(380px, calc(100dvh - 340px), 620px);
  }

  .chart-canvas--beeswarm {
    height: clamp(390px, calc(100dvh - 365px), 580px);
  }

  .viz-caption {
    margin-block-start: 0.75rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.55;
  }

  .chart-tooltip {
    position: absolute;
    pointer-events: none;
    z-index: 20;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid var(--border);
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.1);
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.45;
  }

  .chart-error {
    margin: 1rem 0;
    padding: 0.9rem 1.1rem;
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    font-size: 0.9rem;
  }

  /* Sources Bar & Notion-style Methodology Disclosure */
  .chart-disclosures {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding-block-start: 1.15rem;
  }

  .sources-bar {
    font-size: 0.85rem;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.85rem;
    align-items: center;
  }

  .sources-bar strong {
    color: var(--text-secondary);
    font-weight: 600;
  }

  .sources-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.15rem;
  }

  .sources-list a {
    color: var(--text-secondary);
    text-decoration: underline;
    text-decoration-color: var(--border);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    font-weight: 500;
    transition: color 0.15s ease, text-decoration-color 0.15s ease;
  }

  .sources-list a:hover {
    color: var(--text);
    text-decoration-color: var(--text);
  }

  .notion-toggle {
    width: 100%;
  }

  .notion-toggle::details-content {
    interpolate-size: allow-keywords;
    overflow: clip;
    contain: layout;
  }

  .notion-toggle:not([open])::details-content {
    block-size: 0;
  }

  @media (prefers-reduced-motion: no-preference) {
    .notion-toggle::details-content {
      transition: block-size 0.22s ease-in-out, content-visibility 0.22s ease-in-out;
      transition-behavior: allow-discrete;
    }
  }

  .notion-toggle-summary {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    user-select: none;
    list-style: none;
    padding: 0.25rem 0.5rem;
    margin-inline-start: -0.5rem;
    transition: background-color 0.12s ease;
  }

  .notion-toggle-summary::-webkit-details-marker {
    display: none;
  }

  .notion-toggle-summary:hover {
    background-color: rgba(15, 23, 42, 0.05);
  }

  .notion-toggle-summary:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
  }

  .notion-toggle-triangle {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    color: var(--muted);
    transition: transform 0.15s ease-out, color 0.12s ease;
    transform-origin: center;
  }

  .notion-toggle-summary:hover .notion-toggle-triangle,
  .notion-toggle[open] > .notion-toggle-summary .notion-toggle-triangle {
    color: var(--text);
  }

  .notion-toggle[open] > .notion-toggle-summary .notion-toggle-triangle {
    transform: rotate(90deg);
  }

  .section-heading {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-secondary);
    line-height: 1.3;
  }

  .notion-toggle-summary:hover .section-heading,
  .notion-toggle[open] > .notion-toggle-summary .section-heading {
    color: var(--text);
  }

  .notion-toggle-content {
    padding-inline-start: 1.4rem;
    padding-block-start: 0.65rem;
  }

  .editorial-notes {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-block: 0 1rem;
    max-width: 75ch;
  }

  .editorial-notes p {
    margin: 0;
    font-size: 0.93rem;
    line-height: 1.62;
    color: var(--text-secondary);
    text-wrap: pretty;
  }

  .editorial-notes strong {
    color: var(--text);
    font-weight: 600;
  }
}

/* --------------------------------------------------------------------------
 * 5. Chart-Specific Styles
 * -------------------------------------------------------------------------- */
@layer charts {
  /* Beeswarm inline search refinement */
  .beeswarm-search-group {
    margin-inline-start: auto;
    flex: 0 1 280px;
    min-width: 240px;
    max-width: 320px;
  }

  .beeswarm-search-group .search-input-group {
    min-height: 42px;
    overflow: hidden;
  }

  .beeswarm-search-group .search-input {
    min-height: 40px;
    padding: 0.35rem 0.5rem;
    font-size: 0.88rem;
  }

  .beeswarm-search-group .search-icon-slot {
    padding-left: 0.7rem;
  }

  .beeswarm-search-group .btn-reset {
    min-height: 30px;
    padding: 0.3rem 0.65rem;
    margin-right: 0.3rem;
  }

  /* Streamgraph */
  .streamgraph-canvas,
  .streamgraph-wrapper {
    position: relative;
    width: 100%;
  }

  .streamgraph-svg {
    display: block;
    width: 100%;
    max-inline-size: min(100%, calc(clamp(300px, calc(100dvh - 390px), 430px) * 1120 / 430));
    height: auto;
    margin-inline: auto;
    overflow: visible;
  }

  .stream-axis-label {
    font-size: 13.3px;
    font-weight: 500;
    fill: #64748b;
  }

  .stream-band {
    transition: fill-opacity 0.16s ease;
  }

  .stream-band-label {
    font-size: 14.3px;
    font-weight: 700;
    letter-spacing: -0.01em;
    text-shadow: 0 1px 2px rgba(15, 23, 42, 0.28);
  }

  .stream-callout-group {
    cursor: pointer;
    transition: opacity 0.15s ease;
  }

  .stream-callout-group.is-dimmed {
    opacity: 0.35;
  }

  .stream-callout-label {
    font-size: 13.3px;
    font-weight: 600;
    letter-spacing: -0.01em;
    fill: var(--text-secondary);
  }

  .stream-callout-group.is-active .stream-callout-label,
  .stream-callout-group:hover .stream-callout-label {
    fill: var(--text);
    font-weight: 700;
  }

  .stream-overlay {
    cursor: crosshair;
  }

  .stream-tooltip {
    min-width: 220px;
    padding: 0.65rem 0.85rem;
    color: var(--text);
  }

  .stream-tooltip-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding-bottom: 0.35rem;
    margin-bottom: 0.35rem;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.88rem;
  }

  .stream-tooltip-head span {
    color: var(--text-secondary);
    font-weight: 600;
  }

  .stream-tooltip-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }

  .stream-tooltip-list li {
    display: flex;
    align-items: center;
    gap: 0.45rem;
  }

  .stream-tooltip-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .stream-tooltip-name {
    flex: 1;
    color: var(--text-secondary);
  }

  .stream-tooltip-val {
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
  }

  .stream-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem 0.9rem;
    margin-block-start: 1rem;
    padding-block-start: 0.85rem;
    border-top: 1px solid var(--border-subtle);
  }

  .stream-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.25rem 0.45rem;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: opacity 0.15s ease, color 0.15s ease, background-color 0.15s ease;
  }

  .stream-legend-item:hover,
  .stream-legend-item.is-active {
    color: var(--text);
    background-color: #f1f5f9;
  }

  .stream-legend-item.is-dimmed {
    opacity: 0.4;
  }

  .stream-legend-swatch {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
  }

  /* Ozone Proportional Areas */
  .ozone-canvas {
    width: 100%;
    padding-block: 0.5rem 0.25rem;
  }

  .ozone-svg {
    display: block;
    width: 100%;
    max-inline-size: min(920px, 100%, calc(clamp(320px, calc(100dvh - 375px), 470px) * 920 / 492));
    height: auto;
    margin-inline: auto;
    overflow: visible;
  }

  .ozone-half {
    cursor: pointer;
    transition: filter 0.18s ease;
  }

  .ozone-half:hover {
    filter: brightness(1.06);
  }

  .ozone-half:focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 4px;
  }

  .ozone-svg-period {
    font-size: 33.3px;
    font-weight: 800;
    letter-spacing: -0.03em;
    fill: #0f172a;
  }

  .ozone-svg-area {
    font-size: 23.3px;
    font-weight: 700;
    letter-spacing: -0.02em;
  }

  .ozone-svg-area--left {
    fill: #1d3557;
  }

  .ozone-svg-area--right {
    fill: #2e6280;
  }

  .ozone-svg-du {
    font-size: 14.8px;
    font-weight: 500;
    fill: #64748b;
  }

  .ozone-svg-step-label {
    font-size: 15.3px;
    font-weight: 700;
    fill: #0f172a;
  }

  .ozone-svg-legend-text {
    font-size: 14.3px;
    font-weight: 500;
    fill: #475569;
  }

  /* Waffle Chart */
  .waffle-threshold-note {
    margin: 0 0 0.55rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
  }

  .waffle-canvas {
    width: 100%;
    padding-block: 0.5rem 0.25rem;
  }

  .waffle-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 1.25rem 1.5rem;
    max-width: 960px;
    margin-inline: auto;
  }

  .waffle-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
  }

  .waffle-panel-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
  }

  .waffle-scenario-tag {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
  }

  .waffle-pct {
    font-size: 2.35rem;
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.03em;
  }

  .waffle-detail {
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--text-secondary);
  }

  .waffle-svg {
    display: block;
    width: 100%;
    max-width: 240px;
    height: auto;
  }

  .waffle-cell {
    transition: fill 0.25s ease;
  }

  .waffle-arrow {
    font-size: 1.65rem;
    font-weight: 300;
    color: #94a3b8;
    user-select: none;
    padding-top: 3.5rem;
  }

  .waffle-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.65rem 1.75rem;
    margin-block-start: 1.75rem;
    padding-block-start: 1rem;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.85rem;
    color: var(--text-secondary);
  }

  .waffle-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
  }

  .waffle-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
  }

  .waffle-legend-delta strong {
    color: var(--text);
    font-weight: 700;
  }

  /* 3-Stage Sankey Diagram */
  .sankey-canvas {
    position: relative;
    width: 100%;
    padding-block: 0.25rem 0.5rem;
  }

  .sankey-svg {
    display: block;
    width: 100%;
    max-inline-size: min(100%, calc(clamp(380px, calc(100dvh - 340px), 640px) * 1280 / 760));
    height: auto;
    margin-inline: auto;
    overflow: visible;
  }

  .sankey-col-kicker {
    font-size: 14.3px;
    font-weight: 800;
    letter-spacing: 0.08em;
    fill: #475569;
  }

  .sankey-flow {
    fill-opacity: 0.38;
    cursor: pointer;
    outline: none;
    transition: fill-opacity 0.18s ease;
  }

  .sankey-flow:hover,
  .sankey-flow:focus-visible {
    fill-opacity: 0.8;
  }

  .sankey-node-group,
  .sankey-node-label-wrap {
    cursor: pointer;
    outline: none;
    transition: opacity 0.18s ease;
  }

  .sankey-node-group:focus-visible .sankey-node-rect {
    stroke: var(--focus-ring);
    stroke-width: 2.5;
  }

  .sankey-has-active .sankey-flow {
    fill-opacity: 0.08;
  }

  .sankey-has-active .sankey-flow.is-highlighted {
    fill-opacity: 0.78;
  }

  .sankey-has-active .sankey-node-group,
  .sankey-has-active .sankey-node-label-wrap {
    opacity: 0.28;
  }

  .sankey-has-active .sankey-node-group.is-highlighted,
  .sankey-has-active .sankey-node-label-wrap.is-highlighted {
    opacity: 1;
  }

  .sankey-idmc-title {
    font-size: 16.8px;
    font-weight: 700;
    fill: #0f172a;
  }

  .sankey-idmc-meta {
    font-size: 14.8px;
    font-weight: 500;
    fill: #475569;
  }

  .sankey-idmc-halo {
    paint-order: stroke;
    stroke: rgba(244, 246, 248, 0.94);
    stroke-width: 5px;
    stroke-linejoin: round;
  }

  .sankey-tooltip {
    max-width: 280px;
    padding: 0.55rem 0.75rem;
  }

  .sankey-tooltip-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.15rem;
  }

  .sankey-tooltip-dot {
    width: 9px;
    height: 9px;
    flex-shrink: 0;
  }

  .sankey-tooltip-body strong {
    color: var(--text);
  }

  .sankey-tooltip-sub {
    color: var(--muted);
    font-size: 0.76rem;
  }
}

/* --------------------------------------------------------------------------
 * 6. Utilities, Responsive Breakpoints & Accessibility Media Queries
 * -------------------------------------------------------------------------- */
@layer utilities {
  .visually-hidden {
    position: absolute;
    clip-path: inset(50%);
    overflow: hidden;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    white-space: nowrap;
  }

  @media (max-width: 1024px) {
    .page-shell {
      grid-template-columns: 1fr;
    }

    .left-rail {
      display: contents;
    }

    .portfolio-header {
      background-color: var(--bg-page);
      padding-block: 1.75rem 1.25rem;
      padding-inline: 1.25rem;
      max-inline-size: none;
    }

    .portfolio-title {
      font-size: 1.55rem;
    }

    .portfolio-lead {
      font-size: 0.95rem;
      line-height: 1.55;
      max-width: 65ch;
      margin-inline: 0;
    }

    .index-bar {
      position: sticky;
      inset-block-start: 0;
      z-index: 30;
      max-inline-size: none;
      background-color: rgba(255, 255, 255, 0.96);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      border-block-start: 1px dotted var(--border-dotted);
      border-block-end: 1px solid var(--border);
      padding-block: 0.6rem;
      padding-inline: 1.25rem;
      gap: 0.5rem;
    }

    .chart-index-nav {
      overflow-x: auto;
    }

    .chart-index-list {
      flex-direction: row;
      flex-wrap: nowrap;
      gap: 0.45rem;
    }

    .chart-index-link {
      width: auto;
      white-space: nowrap;
      padding-inline: 0.75rem;
    }

    .chart-index-meta {
      display: none;
    }

    .container {
      padding-inline: 1.25rem;
      padding-block: 1.5rem 3.5rem;
      background-image: none;
      background-color: var(--surface-gray);
    }

    .chart-section {
      scroll-margin-top: 6rem;
    }

    .chart-section + .chart-section {
      margin-block-start: 3.75rem;
    }

    .section-question {
      font-size: 1.2rem;
    }

    .waffle-row {
      grid-template-columns: 1fr;
      gap: 1.5rem;
    }

    .waffle-arrow {
      display: none;
    }

    .waffle-svg {
      max-width: 220px;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .chart-index-link,
    .chart-index-icon,
    .segmented-option span,
    .notion-toggle-triangle,
    .stream-band,
    .stream-legend-item,
    .ozone-half,
    .waffle-cell,
    .sankey-flow,
    .sankey-node-group,
    .sankey-node-label-wrap {
      transition: none;
    }
  }

  @media (forced-colors: active) {
    .chart-index-link:is(:target-current, .target-current) {
      border: 2px solid Highlight;
      outline: 2px solid Highlight;
    }

    .ozone-half--left,
    .ozone-half--right {
      stroke: CanvasText;
      stroke-width: 2;
    }

    .sankey-node-rect {
      stroke: CanvasText;
      stroke-width: 1.5;
    }
  }
}
