/* ==================================================================
   ericbranch.dev -- "The Operating Document" design system
   Ground-up rebuild. One sheet for the four main pages.
   #050A12 canvas | #C9A84C gold | #0ED4A8 teal | #E8E0D0 warm cream
   No external fonts. No frameworks. No build step.
   ================================================================== */

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

:root {
    --bg0: #02050C;
    --bg: #050A12;
    --surface: #0A1120;
    --surface-2: #0F1830;
    --surface-3: #141E38;
    --gold: #C9A84C;
    --gold-bright: #E3C36A;
    --gold-dim: #A68A3A;
    --gold-glow: rgba(201, 168, 76, 0.15);
    --gold-soft: rgba(201, 168, 76, 0.08);
    --teal: #0ED4A8;
    --teal-dim: #0AAE8A;
    --teal-glow: rgba(14, 212, 168, 0.1);
    --warm: #E8E0D0;
    --warm-bright: #F4EEDF;
    --warm-dim: rgba(232, 224, 208, 0.72);
    --warm-muted: rgba(232, 224, 208, 0.58);
    --warm-faint: rgba(232, 224, 208, 0.38);
    --border: rgba(232, 224, 208, 0.08);
    --border-hover: rgba(232, 224, 208, 0.16);
    --hairline: rgba(232, 224, 208, 0.1);
    --radius: 6px;
    --radius-lg: 10px;
    --max-w: 1100px;
    --max-w-narrow: 760px;
    --nav-h: 64px;
    --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI Variable Display', 'Segoe UI', Roboto, sans-serif;
    --mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    /* tokens some legacy inline styles reference */
    --aoif-ingestion: #E8C547;
    --aoif-storage: #47B5E8;
    --aoif-intelligence: #E85C47;
    --aoif-synthesis: #9B59E8;
    --aoif-feedback: #9B7FDD;
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--sans);
    font-weight: 300;
    background: var(--bg);
    color: var(--warm);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Cursor-reactive dot field (dotfield.js), sits behind everything.
   When it is active it replaces the static line grid below. */
.dotfield-canvas {
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
}
body.has-dotfield::before { display: none; }

/* The drafting field: an ultra-faint fixed grid + corner vignette that
   makes every page feel like one continuous technical document. */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -2;
    background-image:
        linear-gradient(rgba(232, 224, 208, 0.022) 1px, transparent 1px),
        linear-gradient(90deg, rgba(232, 224, 208, 0.022) 1px, transparent 1px);
    background-size: 56px 56px;
    pointer-events: none;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse 120% 90% at 50% 0%, transparent 55%, rgba(2, 5, 12, 0.85) 100%),
        radial-gradient(ellipse 90% 70% at 50% 105%, rgba(2, 5, 12, 0.6), transparent 60%);
    pointer-events: none;
}

::selection {
    background: rgba(201, 168, 76, 0.3);
    color: #FFF6DE;
}

:focus-visible {
    outline: 1.5px solid var(--gold);
    outline-offset: 3px;
    border-radius: 2px;
}

.skip-link {
    position: absolute;
    top: -48px;
    left: 1rem;
    z-index: 300;
    background: var(--surface-2);
    border: 1px solid var(--gold-dim);
    color: var(--warm);
    font-size: 0.8rem;
    padding: 0.55rem 1rem;
    border-radius: var(--radius);
    text-decoration: none;
    transition: top 0.2s ease;
}

.skip-link:focus { top: 0.75rem; }

/* -- NAV ----------------------------------------------------------- */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 1.1rem 0;
    transition: padding 0.3s ease, background 0.3s ease, border-color 0.3s ease;
    border-bottom: 1px solid transparent;
}

.nav.scrolled {
    background: rgba(5, 10, 18, 0.9);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 0.7rem 0;
    border-bottom-color: var(--border);
}

.nav-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-brand {
    color: var(--warm-dim);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.84rem;
    letter-spacing: 0.01em;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

/* brand mark: a small compounding glyph, pure CSS */
.nav-brand::before {
    content: '';
    width: 9px;
    height: 9px;
    border: 1px solid var(--gold);
    transform: rotate(45deg);
    background: linear-gradient(135deg, var(--gold-soft), transparent);
    flex-shrink: 0;
}

.nav-brand:hover { color: var(--warm); }

.nav-links {
    display: flex;
    align-items: center;
    gap: 2.1rem;
}

.nav-links a {
    color: var(--warm-muted);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: color 0.2s;
    position: relative;
    padding: 0.3rem 0;
}

.nav-links a:not(.nav-cta)::after {
    content: '';
    position: absolute;
    left: 0;
    right: 100%;
    bottom: 0;
    height: 1px;
    background: var(--gold);
    opacity: 0.85;
    transition: right 0.25s ease;
}

.nav-links a:not(.nav-cta):hover::after,
.nav-links a.nav-active::after { right: 0; }

.nav-links a:hover { color: var(--warm); }
.nav-active { color: var(--gold) !important; }

.nav-links a.nav-cta {
    border: 1px solid rgba(201, 168, 76, 0.35);
    border-radius: 999px;
    padding: 0.42rem 1.1rem;
    color: var(--gold);
    transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.nav-links a.nav-cta::after { display: none; }

.nav-links a.nav-cta:hover {
    border-color: var(--gold);
    background: var(--gold-soft);
}

.nav-mobile {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    width: 28px;
    height: 20px;
    position: relative;
}

.nav-mobile span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--warm);
    position: absolute;
    left: 0;
    transition: all 0.2s;
}

.nav-mobile span:nth-child(1) { top: 0; }
.nav-mobile span:nth-child(2) { top: 9px; }
.nav-mobile span:nth-child(3) { top: 18px; }
.nav-mobile.open span:nth-child(1) { top: 9px; transform: rotate(45deg); }
.nav-mobile.open span:nth-child(2) { opacity: 0; }
.nav-mobile.open span:nth-child(3) { top: 9px; transform: rotate(-45deg); }

/* -- RAIL (section spine, desktop only) ---------------------------- */
.rail {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 64px;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.rail-track {
    position: relative;
    height: 46vh;
    width: 1px;
    background: var(--hairline);
    pointer-events: auto;
}

.rail-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 0%;
    background: linear-gradient(180deg, var(--gold-dim), var(--gold));
    transition: height 0.15s linear;
}

.rail-stop {
    position: absolute;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.rail-stop::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--warm-faint);
    transition: background 0.25s, box-shadow 0.25s, transform 0.25s;
}

.rail-stop:hover::before { background: var(--warm); transform: scale(1.3); }

.rail-stop.active::before {
    background: var(--gold);
    box-shadow: 0 0 0 4px rgba(201, 168, 76, 0.15);
}

.rail-label {
    position: absolute;
    left: 26px;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--mono);
    font-size: 0.58rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--warm-muted);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
}

.rail-stop:hover .rail-label,
.rail-stop.active .rail-label { opacity: 1; }
.rail-stop.active .rail-label { color: var(--gold); }

@media (max-width: 1259px) {
    .rail { display: none; }
}

/* -- SECTION SHELL -------------------------------------------------- */
.section { padding: 7.5rem 2rem; position: relative; }

.section-inner {
    max-width: var(--max-w);
    margin: 0 auto;
}

.section-narrow { max-width: var(--max-w-narrow); }

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

/* mono section index, sits above the eyebrow */
.section-index {
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.2em;
    color: var(--warm-faint);
    margin-bottom: 0.9rem;
}

.section-eyebrow {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    color: var(--gold);
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 1.6rem;
}

.section-eyebrow::before {
    content: '';
    width: 30px;
    height: 1px;
    background: var(--gold-dim);
    flex-shrink: 0;
}

.section-eyebrow--break { margin-top: 3.5rem; }
.section-eyebrow--teal { color: var(--teal); }
.section-eyebrow--teal::before { background: var(--teal-dim); }

.section-headline {
    font-family: var(--sans);
    font-size: clamp(1.8rem, 1.1rem + 2.6vw, 2.7rem);
    font-weight: 450;
    line-height: 1.16;
    letter-spacing: -0.025em;
    color: var(--warm);
    margin-bottom: 1.75rem;
    max-width: 720px;
    text-wrap: balance;
}

.section-body {
    color: var(--warm-dim);
    font-size: 1rem;
    line-height: 1.85;
    max-width: 640px;
    margin-bottom: 1.25rem;
}

.section-intro {
    color: var(--warm-dim);
    font-size: 1.05rem;
    line-height: 1.7;
    max-width: 640px;
    margin-top: -0.5rem;
    margin-bottom: 2.5rem;
}

.lede {
    font-size: clamp(1.15rem, 1rem + 0.8vw, 1.45rem);
    line-height: 1.65;
    color: var(--warm-dim);
    max-width: 720px;
}

.closing-statement {
    font-family: var(--sans);
    font-size: clamp(1.35rem, 1rem + 1.6vw, 1.85rem);
    font-weight: 450;
    line-height: 1.35;
    letter-spacing: -0.015em;
    color: var(--warm);
    margin-top: 2.25rem;
    max-width: 720px;
    text-wrap: balance;
}

.closing-statement em { font-style: normal; color: var(--gold); }

.inline-link {
    color: var(--warm);
    border-bottom: 1px solid var(--border-hover);
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s;
}
.inline-link:hover { color: var(--gold); border-bottom-color: var(--gold); }

.footnote-link {
    display: inline-block;
    margin-top: 0.85rem;
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--warm-muted);
    text-decoration: none;
    transition: color 0.15s;
}
.footnote-link .arrow { display: inline-block; margin-left: 0.25rem; transition: transform 0.2s; }
.footnote-link:hover { color: var(--gold); }
.footnote-link:hover .arrow { transform: translateX(3px); }

.tm {
    font-size: 0.55em;
    vertical-align: super;
    line-height: 0;
    color: var(--warm-muted);
}

/* -- BUTTONS -------------------------------------------------------- */
.btn-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    background: var(--gold);
    color: #0A0E16;
    border: 1px solid var(--gold);
    border-radius: var(--radius);
    padding: 0.85rem 1.7rem;
    font-family: var(--sans);
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.btn:hover { background: var(--gold-bright); border-color: var(--gold-bright); transform: translateY(-1px); }
.btn .arrow { display: inline-block; transition: transform 0.2s; }
.btn:hover .arrow { transform: translateX(3px); }

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    background: none;
    color: var(--warm-dim);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius);
    padding: 0.85rem 1.7rem;
    font-family: var(--sans);
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.btn-ghost:hover { color: var(--gold); border-color: rgba(201, 168, 76, 0.5); }

/* ==================================================================
   HERO — the divergence plot
   The animation IS the thesis: automation climbs to a plateau,
   transformation compounds past it, and the measured gap between
   them is the silent error. Plotted live behind the headline, which
   sits at the origin where the two paths are still one.
   ================================================================== */
.hero {
    position: relative;
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    align-items: center;
    padding: calc(var(--nav-h) + 3rem) 2rem 5rem;
    overflow: hidden;
}

/* content pages get a shorter static hero, no plot */
.hero--page {
    min-height: 0;
    padding-top: calc(var(--nav-h) + 7rem);
    padding-bottom: 4.5rem;
    display: block;
}
.hero--page .plot { display: none; }

/* plot canvas: full-bleed, drawn behind everything */
.plot {
    position: absolute;
    inset: 0;
    z-index: 0;
}
.plot canvas { width: 100%; height: 100%; display: block; }

/* crisp DOM annotation layer, positioned by JS over the canvas */
.plot-anno { position: absolute; inset: 0; z-index: 1; pointer-events: none; }

.pa {
    position: absolute;
    font-family: var(--mono);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.6s ease;
}
.pa.show { opacity: 1; }

.pa-label {
    font-size: 0.62rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    transform: translateY(-50%);
}
.pa-auto { color: var(--warm-muted); }
.pa-trans { color: var(--gold); }
.pa-label b {
    display: block;
    font-family: var(--sans);
    font-size: 1.15rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    margin-top: 0.25rem;
    font-variant-numeric: tabular-nums;
}
.pa-auto b { color: var(--warm-dim); }
.pa-trans b { color: var(--gold-bright); }

.pa-delta {
    transform: translateY(-50%);
    font-size: 0.6rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
    padding-left: 0.7rem;
}

/* readable scrim over the left half, where the copy lives.
   Faint enough that the grid and the shared origin of the two
   paths still ghost through behind the headline. */
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: linear-gradient(102deg,
        rgba(5, 10, 18, 0.92) 0%,
        rgba(5, 10, 18, 0.74) 40%,
        rgba(5, 10, 18, 0.22) 62%,
        rgba(5, 10, 18, 0) 80%);
}

.hero .section-inner {
    position: relative;
    z-index: 3;
    width: 100%;
}

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

.hero-eyebrow {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 2.25rem;
}

.hero-eyebrow::before {
    content: '';
    width: 36px;
    height: 1px;
    background: var(--gold-dim);
    flex-shrink: 0;
}

.hero-headline {
    font-family: var(--sans);
    font-size: clamp(2.6rem, 1rem + 6vw, 5.1rem);
    font-weight: 500;
    line-height: 1.04;
    letter-spacing: -0.038em;
    color: var(--warm-bright);
    margin-bottom: 2rem;
    max-width: 15ch;
    text-wrap: balance;
}

/* gold underline that draws in under a key word */
.u-gold {
    background-image: linear-gradient(90deg, var(--gold-dim), var(--gold));
    background-repeat: no-repeat;
    background-position: 0 96%;
    background-size: 0% 2px;
    transition: background-size 1s cubic-bezier(0.22, 0.61, 0.36, 1) 0.7s;
    padding-bottom: 0.06em;
}

.in .u-gold, .u-gold.in { background-size: 100% 2px; }

.hero-sub {
    color: var(--warm-dim);
    font-size: clamp(1.02rem, 0.9rem + 0.55vw, 1.2rem);
    line-height: 1.75;
    max-width: 540px;
    margin-bottom: 2.5rem;
}

/* live readout: the plot values in words, bottom-left */
.hero-readout {
    position: absolute;
    left: 2rem;
    bottom: 2rem;
    z-index: 3;
    display: flex;
    gap: 2.5rem;
    flex-wrap: wrap;
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.ro-item { display: flex; flex-direction: column; gap: 0.4rem; }
.ro-k { color: var(--warm-faint); }
.ro-v { font-size: 0.9rem; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.ro-item--auto .ro-v { color: var(--warm-dim); }
.ro-item--trans .ro-v { color: var(--gold); }
.ro-item--delta .ro-v { color: var(--warm-bright); }
.ro-item--delta .ro-k { color: var(--gold-dim); }

.hero-scroll {
    position: absolute;
    right: 2rem;
    bottom: 2.2rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-family: var(--mono);
    font-size: 0.6rem;
    letter-spacing: 0.24em;
    color: var(--warm-faint);
    text-transform: uppercase;
    z-index: 3;
}

.hero-scroll::after {
    content: '';
    width: 56px;
    height: 1px;
    background: var(--warm-faint);
    transform-origin: right;
    animation: scroll-line 2.6s ease-in-out infinite;
}

@keyframes scroll-line {
    0% { transform: scaleX(0); opacity: 0; }
    35% { transform: scaleX(1); opacity: 1; }
    70%, 100% { transform: scaleX(1); opacity: 0; }
}

@media (max-width: 720px) {
    .hero { min-height: 0; padding-top: calc(var(--nav-h) + 5rem); padding-bottom: 3rem; }
    .plot { position: relative; height: 300px; margin: 2.5rem -1.5rem -1rem; inset: auto; }
    .hero { display: block; }
    .hero::before { display: none; }
    .plot-anno { display: none; }
    .hero-readout { position: static; margin-top: 2.25rem; gap: 1.5rem 2.5rem; }
    .hero-scroll { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .hero-scroll::after { animation: none; }
}

/* ==================================================================
   EVIDENCE STRIP (index)
   ================================================================== */
.evidence { padding: 0 2rem; }

.evidence-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr 1fr 1.3fr auto;
}

.ev-stat {
    padding: 2.6rem 2rem 2.4rem 0;
    margin-right: 2rem;
    border-right: 1px solid var(--border);
    position: relative;
}

.ev-stat + .ev-stat { padding-left: 0; }
.ev-stat:nth-child(2), .ev-stat:nth-child(3) { padding-left: 0; }
.ev-stat:nth-child(n+2) { margin-left: 0; }

.ev-value {
    font-family: var(--sans);
    font-size: clamp(2.6rem, 1.6rem + 3.4vw, 3.8rem);
    font-weight: 500;
    line-height: 1;
    letter-spacing: -0.025em;
    color: var(--warm-bright);
    margin-bottom: 0.9rem;
    font-variant-numeric: tabular-nums;
}

.ev-bar {
    height: 3px;
    background: rgba(232, 224, 208, 0.08);
    margin-bottom: 1rem;
    max-width: 200px;
    overflow: hidden;
}

.ev-bar span {
    display: block;
    height: 100%;
    width: 0%;
    background: var(--gold);
    transition: width 1.4s cubic-bezier(0.22, 0.61, 0.36, 1) 0.3s;
    min-width: 2px;
}

.in .ev-bar span { width: var(--pct); }

.ev-label {
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--warm-dim);
    max-width: 26ch;
}

.ev-source {
    display: flex;
    align-items: flex-end;
    padding: 2.6rem 0 2.4rem;
}

.ev-source p {
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--warm-faint);
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    line-height: 1.6;
}

@media (max-width: 860px) {
    .evidence-inner { grid-template-columns: 1fr; }
    .ev-stat {
        border-right: 0;
        border-bottom: 1px solid var(--border);
        margin-right: 0;
        padding: 1.8rem 0 1.7rem;
    }
    .ev-source { padding: 1.4rem 0; }
    .ev-source p { writing-mode: horizontal-tb; transform: none; }
}

/* ==================================================================
   CRITERIA PLATES (definition)
   ================================================================== */
.plate-title {
    font-family: var(--sans);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--warm);
    letter-spacing: 0.01em;
    margin: 2.75rem 0 1.25rem;
}

.plates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
}

.plate {
    background: var(--bg);
    padding: 1.9rem 1.9rem 1.7rem;
    position: relative;
    transition: background 0.25s;
}

.plate:hover { background: var(--surface); }

.plate-num {
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    color: var(--gold);
    margin-bottom: 0.85rem;
}

.plate p {
    color: var(--warm-dim);
    font-size: 0.95rem;
    line-height: 1.7;
}

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

/* -- INSIGHT BOX (kept for content pages) --------------------------- */
.insight-box {
    border-left: 2px solid var(--gold);
    background: var(--gold-soft);
    padding: 1.5rem 1.75rem;
    margin: 2rem 0;
    border-radius: 0 var(--radius) var(--radius) 0;
}
.insight-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--warm);
    letter-spacing: 0.01em;
    margin-bottom: 1rem;
}
.insight-list { list-style: none; }
.insight-list li {
    color: var(--warm-dim);
    font-size: 0.98rem;
    line-height: 1.6;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.insight-list li:last-child { border-bottom: 0; }

/* ==================================================================
   SILENT ERROR COMPARISON
   ================================================================== */
.gap-viz {
    margin: 3rem 0 1rem;
    max-width: 720px;
}

.gap-row {
    display: grid;
    grid-template-columns: 150px 1fr 64px;
    align-items: center;
    gap: 1.25rem;
    padding: 0.9rem 0;
}

.gap-name {
    font-family: var(--mono);
    font-size: 0.64rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--warm-muted);
    line-height: 1.5;
}

.gap-track {
    height: 10px;
    background: rgba(232, 224, 208, 0.06);
    position: relative;
    overflow: hidden;
}

.gap-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0%;
    transition: width 1.5s cubic-bezier(0.22, 0.61, 0.36, 1) 0.2s;
}

.gap-row--delivered .gap-fill { background: rgba(232, 224, 208, 0.4); }
.gap-row--possible .gap-fill { background: linear-gradient(90deg, var(--gold-dim), var(--gold)); transition-delay: 0.55s; }

.in .gap-fill { width: var(--pct); }

.gap-pct {
    font-family: var(--sans);
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--warm);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.gap-bracket {
    display: grid;
    grid-template-columns: 150px 1fr 64px;
    gap: 1.25rem;
    margin-top: 0.4rem;
    padding-bottom: 2.6rem;
}

.gap-bracket-inner {
    margin-left: 40%;
    width: 50%;
    border-left: 1px solid var(--gold-dim);
    border-right: 1px solid var(--gold-dim);
    border-bottom: 1px solid var(--gold-dim);
    height: 14px;
    position: relative;
    opacity: 0;
    transition: opacity 0.6s ease 1.6s;
}

.in .gap-bracket-inner { opacity: 1; }

.gap-bracket-label {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
    white-space: nowrap;
    padding-top: 0.35rem;
}

@media (max-width: 640px) {
    .gap-row { grid-template-columns: 86px 1fr 52px; gap: 0.8rem; }
    .gap-bracket { grid-template-columns: 86px 1fr 52px; gap: 0.8rem; }
    .gap-pct { font-size: 1rem; }
}

/* ==================================================================
   MODEL STACK (index)
   ================================================================== */
.stack { margin-top: 3.5rem; }

.scale-card {
    position: sticky;
    background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 130%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 3rem 3rem 2.6rem;
    margin-bottom: 2.5rem;
    box-shadow: 0 -18px 50px rgba(2, 5, 12, 0.55);
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 3rem;
    align-items: center;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.25s;
}

.scale-card:hover { border-color: rgba(201, 168, 76, 0.3); }

.scale-card--1 { top: calc(var(--nav-h) + 2rem); }
.scale-card--2 { top: calc(var(--nav-h) + 4.5rem); }
.scale-card--3 { top: calc(var(--nav-h) + 7rem); }

.scale-tag {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1.1rem;
}

.scale-tag-num {
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.2em;
    color: var(--gold);
    text-transform: uppercase;
}

.scale-tag-level {
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.14em;
    color: var(--warm-faint);
    text-transform: uppercase;
}

.scale-name {
    font-family: var(--sans);
    font-size: clamp(1.3rem, 1rem + 1.2vw, 1.7rem);
    font-weight: 450;
    letter-spacing: -0.015em;
    color: var(--warm);
    margin-bottom: 0.5rem;
}

.scale-mechanism {
    font-size: 0.92rem;
    color: var(--teal);
    font-family: var(--mono);
    letter-spacing: 0.02em;
    font-size: 0.72rem;
    text-transform: uppercase;
    margin-bottom: 1.2rem;
}

.scale-body {
    color: var(--warm-dim);
    font-size: 0.95rem;
    line-height: 1.8;
    max-width: 600px;
}

.scale-link {
    margin-top: 1.5rem;
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gold);
}

.scale-link .arrow { display: inline-block; transition: transform 0.2s; }
.scale-card:hover .scale-link .arrow { transform: translateX(3px); }

/* Per-scale bar figure, pure CSS so the labels stay crisp.
   Bar direction encodes the mechanism: Scale 1 refines wide context
   down to a solution; Scales 2 and 3 build narrow inputs up into an
   asset / intelligence. */
.scale-viz {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.5rem;
    height: 100%;
    min-height: 200px;
}

.mbar {
    position: relative;
    height: 30px;
    display: flex;
    align-items: center;
}

.mbar-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    border: 1px solid var(--mbar-c, var(--gold));
    background: color-mix(in srgb, var(--mbar-c, var(--gold)) 12%, transparent);
    border-radius: 2px;
    transition: width 0.9s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.reveal.in .mbar-fill,
.in .mbar-fill { width: var(--w); }

.mbar:nth-child(1) .mbar-fill { transition-delay: 0.05s; }
.mbar:nth-child(2) .mbar-fill { transition-delay: 0.14s; }
.mbar:nth-child(3) .mbar-fill { transition-delay: 0.23s; }
.mbar:nth-child(4) .mbar-fill { transition-delay: 0.32s; }
.mbar:nth-child(5) .mbar-fill { transition-delay: 0.41s; }

.mbar-label {
    position: relative;
    z-index: 1;
    font-family: var(--mono);
    font-size: 0.58rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--warm-muted);
    padding-left: 0.75rem;
}

.scale-viz[data-viz="s1"] { --mbar-c: var(--gold); }
.scale-viz[data-viz="s2"] { --mbar-c: var(--teal); }
.scale-viz[data-viz="s3"] { --mbar-c: #8A9BB5; }

@media (max-width: 900px) {
    .scale-card {
        position: static;
        grid-template-columns: 1fr;
        padding: 2rem 1.5rem;
        gap: 1.5rem;
        margin-bottom: 1.25rem;
        box-shadow: none;
    }
    .scale-viz { min-height: 0; }
}

/* ==================================================================
   PIPELINE (proof section)
   ================================================================== */
.pipeline {
    margin: 3rem 0 2.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, var(--surface) 0%, transparent 140%);
    padding: 2.4rem 2.2rem 2.1rem;
    position: relative;
    overflow: hidden;
}

.pipeline-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.pipeline-title {
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--warm-muted);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.pipeline-title .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--teal);
    animation: pulse-dot 2.4s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}

.pipeline-meta {
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--warm-faint);
}

.pipeline-steps {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: nowrap;
}

.pl-step {
    font-family: var(--mono);
    font-size: 0.64rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--warm-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.6rem 0.9rem;
    white-space: nowrap;
    transition: color 0.3s, border-color 0.3s, background 0.3s;
    flex-shrink: 0;
}

.pl-step.lit {
    color: var(--teal);
    border-color: rgba(14, 212, 168, 0.35);
    background: rgba(14, 212, 168, 0.05);
}

.pl-step--out { color: var(--gold); border-color: rgba(201, 168, 76, 0.3); }
.pl-step--out.lit {
    color: #0A0E16;
    background: var(--gold);
    border-color: var(--gold);
}

.pl-link {
    height: 1px;
    background: var(--border-hover);
    flex: 1;
    min-width: 12px;
    position: relative;
    overflow: visible;
}

.pl-link .spark {
    position: absolute;
    top: 50%;
    left: 0;
    width: 18px;
    height: 1px;
    transform: translateY(-50%);
    background: linear-gradient(90deg, transparent, var(--teal));
    opacity: 0;
}

.pl-link.lit .spark { opacity: 1; }

.pipeline-foot {
    margin-top: 2rem;
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.pipeline-fact {
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--warm-faint);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pipeline-fact::before {
    content: '';
    width: 3px;
    height: 3px;
    background: var(--gold-dim);
    transform: rotate(45deg);
}

@media (max-width: 980px) {
    .pipeline-steps { flex-wrap: wrap; gap: 0.5rem; }
    .pl-link { display: none; }
}

/* ==================================================================
   ORIGIN (editorial)
   ================================================================== */
.origin-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 4rem;
    align-items: start;
}

.origin-side { position: sticky; top: calc(var(--nav-h) + 3rem); }

.origin-side .section-headline { font-size: clamp(1.5rem, 1rem + 1.8vw, 2.1rem); }

.origin-body p {
    color: var(--warm-dim);
    font-size: 1rem;
    line-height: 1.9;
    margin-bottom: 1.4rem;
}

.origin-body .hl {
    color: var(--warm);
    background: linear-gradient(180deg, transparent 72%, rgba(201, 168, 76, 0.22) 72%);
}

@media (max-width: 860px) {
    .origin-grid { grid-template-columns: 1fr; gap: 1.5rem; }
    .origin-side { position: static; }
}

/* ==================================================================
   RESEARCH COMPONENTS (dossier)
   ================================================================== */
.source-list { display: flex; flex-direction: column; margin-top: 3rem; border-top: 1px solid var(--border); }

.source-block {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 2.5rem;
    align-items: start;
    padding: 2.4rem 0;
    border-bottom: 1px solid var(--border);
    transition: background 0.25s;
}

.source-block:hover { background: rgba(232, 224, 208, 0.012); }

.source-attribution {
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--gold);
    text-transform: uppercase;
    line-height: 1.5;
    padding-top: 0.4rem;
}

.source-attribution a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted var(--gold-dim);
    transition: color 0.15s, border-color 0.15s;
}

.source-attribution a:hover { color: var(--warm); border-bottom-color: var(--warm); }

.source-attribution-secondary {
    color: var(--warm-muted);
    margin-top: 0.4rem;
    text-transform: none;
    letter-spacing: 0.02em;
    font-size: 0.68rem;
}

.source-content { min-width: 0; }

.source-title {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--warm);
    line-height: 1.4;
    margin-bottom: 0.85rem;
    letter-spacing: -0.005em;
}

.source-findings { list-style: none; }

.source-findings li {
    color: var(--warm-dim);
    font-size: 0.95rem;
    line-height: 1.7;
    padding: 0.4rem 0 0.4rem 1.5rem;
    position: relative;
}

.source-findings li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.95rem;
    width: 8px;
    height: 1px;
    background: var(--gold-dim);
}

.source-note {
    color: var(--warm-muted);
    font-size: 0.85rem;
    line-height: 1.6;
    margin-top: 1rem;
    font-style: italic;
}

.precedent-list { display: flex; flex-direction: column; gap: 0; margin-top: 3rem; border-top: 1px solid var(--border); }

.precedent-block {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 2.5rem;
    align-items: start;
    padding: 2.2rem 0;
    border-bottom: 1px solid var(--border);
}

.precedent-label {
    font-family: var(--mono);
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--gold);
    text-transform: uppercase;
    padding-top: 0.4rem;
    line-height: 1.6;
}

.precedent-name {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--warm);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.precedent-cite {
    font-family: var(--mono);
    font-size: 0.7rem;
    color: var(--warm-muted);
    margin-bottom: 0.85rem;
    letter-spacing: 0.04em;
}

.precedent-body {
    color: var(--warm-dim);
    font-size: 0.95rem;
    line-height: 1.75;
}

.source-list + .insight-box,
.source-list + .closing-statement,
.precedent-list + .insight-box,
.precedent-list + .closing-statement { margin-top: 4rem; }

@media (max-width: 760px) {
    .source-block, .precedent-block { grid-template-columns: 1fr; gap: 0.8rem; }
}

/* ==================================================================
   MODEL PAGE COMPONENTS
   ================================================================== */
.layer-section { scroll-margin-top: var(--nav-h); }

.layer-subtitle {
    color: var(--warm-dim);
    font-size: 1.05rem;
    line-height: 1.7;
    margin-top: -0.5rem;
    margin-bottom: 2.5rem;
    max-width: 640px;
}

.layer-part { margin-top: 2.75rem; }
.layer-part .section-eyebrow { font-size: 0.66rem; margin-bottom: 1rem; }
.layer-part p.section-body { max-width: none; }

.discipline-list { margin: 1.25rem 0; display: flex; flex-direction: column; gap: 1.5rem; }
.discipline { border-left: 1px solid var(--border-hover); padding-left: 1.5rem; }
.discipline-name { font-style: italic; color: var(--warm); font-size: 1rem; line-height: 1.6; margin-bottom: 0.5rem; }
.discipline-body { color: var(--warm-dim); font-size: 1rem; line-height: 1.85; }

.transformation-criterion {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 2px solid var(--gold-dim);
    padding: 1.6rem 1.85rem;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-top: 2.75rem;
}

.transformation-criterion .section-eyebrow { margin-top: 0; margin-bottom: 0.85rem; }
.transformation-criterion p { color: var(--warm); font-size: 1rem; line-height: 1.75; max-width: none; }

.integration-section { background: rgba(232, 224, 208, 0.015); }

.definition .section-body,
.why .section-body,
.produces .section-body { max-width: none; }

/* ==================================================================
   CHATBOT
   ================================================================== */
.open-door { padding-bottom: 3.5rem; }
.open-door .section-headline { max-width: 560px; margin-bottom: 3rem; }

.chatbot-frame {
    max-width: 640px;
    margin: 0 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    min-height: 360px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chatbot-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.chatbot-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--teal);
    animation: pulse-dot 2.5s ease-in-out infinite;
}

.chatbot-header-text {
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--warm-muted);
    letter-spacing: 0.06em;
}

.chatbot-body {
    flex: 1;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.chatbot-placeholder {
    color: var(--warm-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    text-align: center;
    max-width: 380px;
}

.chatbot-input-row {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
}

.chatbot-input {
    flex: 1;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.7rem 1rem;
    color: var(--warm);
    font-family: var(--sans);
    font-size: 0.88rem;
    font-weight: 300;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    overflow: hidden;
    min-height: 38px;
    max-height: 120px;
    line-height: 1.4;
}

.chatbot-input::placeholder { color: var(--warm-muted); }
.chatbot-input:focus { border-color: rgba(201, 168, 76, 0.45); }

.chatbot-send {
    background: var(--gold);
    color: #0A0E16;
    border: none;
    border-radius: var(--radius);
    padding: 0 1.25rem;
    font-family: var(--sans);
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.2s;
}

.chatbot-send:hover { background: var(--gold-bright); }
.chatbot-send:disabled { opacity: 0.35; cursor: not-allowed; }

.chatbot-active { max-height: 70vh; }

.chatbot-active .chatbot-body {
    justify-content: flex-start;
    align-items: stretch;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    gap: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--surface-3) transparent;
}

.chatbot-active .chatbot-body::-webkit-scrollbar { width: 4px; }
.chatbot-active .chatbot-body::-webkit-scrollbar-track { background: transparent; }
.chatbot-active .chatbot-body::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 2px; }

.chatbot-msg { padding: 0.6rem 0; animation: chatbot-msg-in 0.25s ease; }

@keyframes chatbot-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.chatbot-msg-user { border-left: 2px solid var(--gold-dim); padding-left: 1rem; margin-bottom: 0.25rem; }
.chatbot-msg-user .chatbot-msg-text { color: var(--warm); font-size: 0.9rem; line-height: 1.7; }
.chatbot-msg-assistant { margin-bottom: 0.25rem; }
.chatbot-msg-assistant .chatbot-msg-text { color: var(--warm-dim); font-size: 0.9rem; line-height: 1.85; }
.chatbot-msg-assistant .chatbot-msg-text p { margin-bottom: 0.65rem; }
.chatbot-msg-assistant .chatbot-msg-text p:last-child { margin-bottom: 0; }
.chatbot-msg-assistant .chatbot-msg-text strong { color: var(--warm); font-weight: 600; }

.chatbot-msg-assistant .chatbot-msg-text code {
    font-family: var(--mono);
    font-size: 0.82em;
    background: var(--surface-2);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    color: var(--warm);
}

.chatbot-msg-assistant .chatbot-msg-text a.chatbot-link {
    color: var(--gold);
    text-decoration: none;
    border-bottom: 1px solid var(--gold-dim);
    transition: border-color 0.2s;
}

.chatbot-msg-assistant .chatbot-msg-text a.chatbot-link:hover { border-color: var(--gold); }

.chatbot-msg-system { text-align: center; padding: 0.5rem 0; }
.chatbot-msg-system .chatbot-msg-text { color: var(--warm-muted); font-size: 0.82rem; font-style: italic; }

.chatbot-typing { display: flex; gap: 5px; padding: 0.75rem 0; align-items: center; }

.chatbot-typing span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--gold-dim);
    animation: chatbot-bounce 1.4s ease-in-out infinite;
}

.chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatbot-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.25; }
    30% { transform: translateY(-5px); opacity: 0.9; }
}

/* ==================================================================
   FOOTER — simple and centered
   ================================================================== */
.footer {
    border-top: 1px solid var(--border);
    padding: 2.5rem 2rem;
    text-align: center;
}

.footer-inner { max-width: var(--max-w); margin: 0 auto; }

.footer-nav {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 1.25rem;
}

.footer-nav a {
    color: var(--warm-muted);
    text-decoration: none;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.footer-nav a:hover { color: var(--gold); }

.footer-trademarks {
    font-size: 0.68rem;
    color: var(--warm-muted);
    opacity: 0.5;
    letter-spacing: 0.02em;
    margin-bottom: 0.5rem;
}

.footer-copy {
    font-size: 0.7rem;
    color: var(--warm-muted);
    opacity: 0.6;
    letter-spacing: 0.03em;
}

/* ==================================================================
   REVEAL
   ================================================================== */
@media (prefers-reduced-motion: no-preference) {
    .reveal {
        opacity: 0;
        transform: translateY(22px);
        transition: opacity 0.7s cubic-bezier(0.22, 0.61, 0.36, 1),
                    transform 0.7s cubic-bezier(0.22, 0.61, 0.36, 1);
        transition-delay: var(--d, 0s);
    }

    .reveal.in { opacity: 1; transform: translateY(0); }

    .reveal-delay-1 { --d: 0.1s; }
    .reveal-delay-2 { --d: 0.2s; }
    .reveal-delay-3 { --d: 0.3s; }
    .reveal-delay-4 { --d: 0.4s; }
    .reveal-delay-5 { --d: 0.5s; }
}

/* ==================================================================
   RESPONSIVE
   ================================================================== */
@media (max-width: 900px) {
    .nav-links { display: none; }
    .nav-mobile { display: block; }

    .nav-links.open {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: rgba(5, 10, 18, 0.97);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        padding: 1.5rem 2rem;
        gap: 1.25rem;
        border-bottom: 1px solid var(--border);
    }
}

@media (max-width: 600px) {
    .section { padding: 5rem 1.5rem; }
    .hero { padding-left: 1.5rem; padding-right: 1.5rem; }
    .hero--page { padding-top: calc(var(--nav-h) + 5rem); }
    .evidence { padding: 0 1.5rem; }
    .footer-nav { flex-wrap: wrap; gap: 1rem 1.5rem; }
    .pipeline { padding: 1.6rem 1.25rem 1.5rem; }
}


/* ==================================================================
   PORTED: AOIF architecture diagram (model.html Scale 3 figure)
   ================================================================== */
/* ── FIGURE 1: AOIF ARCHITECTURE DIAGRAM (Scale 3 / model.html) ──── */
.aoif-diagram {
    max-width: 100%;
    margin: 2rem auto 3rem;
    position: relative;
}
.aoif-diagram-frame {
    position: relative;
    padding-right: 52px;
}
.aoif-strip {
    display: grid;
    gap: 0.5rem;
}
.aoif-strip.audiences { grid-template-columns: repeat(4, 1fr); }
.aoif-strip.sources { grid-template-columns: repeat(8, 1fr); }
.aoif-chip {
    padding: 0.55rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: rgba(232, 224, 208, 0.015);
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--warm-muted);
    text-align: center;
    line-height: 1.3;
}
.aoif-chip.historical {
    color: rgba(14, 212, 168, 0.85);
    border-color: rgba(14, 212, 168, 0.22);
    background: rgba(14, 212, 168, 0.035);
}
.aoif-chip.audience {
    color: #CBB2F4;
    border-color: rgba(155, 89, 232, 0.22);
    background: rgba(155, 89, 232, 0.035);
}
.aoif-strip-caption {
    font-size: 0.62rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--warm-dim);
    margin: 0.5rem 0 0;
    text-align: center;
}
.aoif-strip-caption.top { margin: 0 0 0.5rem; }
.aoif-flow {
    height: 1.5rem;
    position: relative;
}
.aoif-flow::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(to top,
        rgba(232,224,208,0.04),
        rgba(232,224,208,0.22),
        rgba(232,224,208,0.04));
}
.aoif-flow::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 50%;
    width: 6px;
    height: 6px;
    margin-left: -3px;
    border-top: 1px solid rgba(232, 224, 208, 0.35);
    border-right: 1px solid rgba(232, 224, 208, 0.35);
    transform: rotate(-45deg);
}
.aoif-layer {
    --layer-color: var(--warm-muted);
    position: relative;
    background: linear-gradient(180deg,
        rgba(15, 24, 48, 0.55) 0%,
        rgba(10, 17, 32, 0.35) 100%);
    border: 1px solid var(--border);
    border-left: 3px solid var(--layer-color);
    border-radius: 8px;
    padding: 1rem 1.25rem 1.15rem;
}
.aoif-layer[data-layer="1"] { --layer-color: var(--aoif-ingestion); }
.aoif-layer[data-layer="2"] { --layer-color: var(--aoif-storage); }
.aoif-layer[data-layer="3"] { --layer-color: var(--aoif-intelligence); }
.aoif-layer[data-layer="4"] { --layer-color: var(--aoif-synthesis); }
.aoif-layer-head {
    display: flex;
    align-items: baseline;
    gap: 0.85rem;
    margin-bottom: 0.85rem;
}
.aoif-layer-num {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--layer-color);
    font-variant-numeric: tabular-nums;
}
.aoif-layer-name {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--warm);
    letter-spacing: -0.01em;
}
.aoif-layer-sub {
    font-size: 0.72rem;
    color: var(--warm-muted);
    letter-spacing: 0.02em;
    margin-left: 0.6rem;
}
.aoif-layer-body { display: grid; gap: 0.5rem; }
.aoif-layer[data-layer="1"] .aoif-layer-body { grid-template-columns: repeat(8, 1fr); }
.aoif-layer[data-layer="2"] .aoif-layer-body { grid-template-columns: repeat(3, 1fr); }
.aoif-layer[data-layer="3"] .aoif-layer-body { grid-template-columns: 1.35fr 1fr; }
.aoif-layer[data-layer="4"] .aoif-layer-body { grid-template-columns: repeat(4, 1fr); }
.aoif-port {
    padding: 0.5rem 0.2rem;
    border: 1px solid rgba(232, 197, 71, 0.22);
    border-radius: 4px;
    background: rgba(232, 197, 71, 0.04);
    font-size: 0.56rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(232, 197, 71, 0.9);
    text-align: center;
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
}
.aoif-db {
    border: 1px solid rgba(71, 181, 232, 0.2);
    background: rgba(71, 181, 232, 0.035);
    border-radius: 6px;
    padding: 0.75rem 0.85rem;
    text-align: center;
}
.aoif-db-icon {
    font-size: 1.3rem;
    color: var(--aoif-storage);
    line-height: 1;
    margin-bottom: 0.45rem;
    font-family: 'Courier New', monospace;
    font-weight: 700;
}
.aoif-db-name {
    font-size: 0.78rem;
    color: var(--warm);
    font-weight: 600;
    margin-bottom: 0.2rem;
    letter-spacing: -0.01em;
}
.aoif-db-desc {
    font-size: 0.62rem;
    color: var(--warm-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.aoif-hybrid {
    margin-top: 0.6rem;
    padding: 0.55rem;
    text-align: center;
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: rgba(71, 181, 232, 0.9);
    border: 1px dashed rgba(71, 181, 232, 0.28);
    border-radius: 4px;
    background: rgba(71, 181, 232, 0.025);
    font-weight: 600;
}
.aoif-region {
    border: 1px solid rgba(232, 92, 71, 0.18);
    background: rgba(232, 92, 71, 0.035);
    border-radius: 6px;
    padding: 0.7rem 0.85rem;
}
.aoif-region-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--aoif-intelligence);
    margin-bottom: 0.55rem;
    font-weight: 700;
}
.aoif-region-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}
.aoif-region-items span {
    font-size: 0.7rem;
    color: var(--warm-dim);
    padding: 0.22rem 0.6rem;
    border: 1px solid rgba(232, 92, 71, 0.22);
    border-radius: 20px;
    background: rgba(232, 92, 71, 0.05);
    white-space: nowrap;
}
.aoif-region.synthesis .aoif-region-items {
    flex-direction: column;
    gap: 0.35rem;
}
.aoif-region.synthesis span {
    text-align: center;
    font-style: italic;
    background: rgba(232, 92, 71, 0.08);
}
.aoif-output {
    border: 1px solid rgba(155, 89, 232, 0.2);
    background: rgba(155, 89, 232, 0.04);
    border-radius: 6px;
    padding: 0.7rem 0.6rem;
    text-align: center;
}
.aoif-output-name {
    font-size: 0.74rem;
    color: var(--warm);
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 0.2rem;
}
.aoif-output-aud {
    font-size: 0.6rem;
    color: #CBB2F4;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.aoif-recursive {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 48px;
    pointer-events: none;
}
.aoif-recursive svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}
.aoif-recursive-label {
    position: absolute;
    right: -2px;
    top: 50%;
    transform-origin: 100% 0%;
    transform: rotate(90deg) translate(0, -100%);
    font-size: 0.58rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #CDC0F2;
    white-space: nowrap;
    opacity: 1;
}
.aoif-diagram-caption {
    margin-top: 1.75rem;
    font-size: 0.78rem;
    color: var(--warm-dim);
    text-align: center;
    letter-spacing: 0.02em;
    font-style: italic;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.65;
}
.aoif-diagram-caption strong {
    color: var(--warm);
    font-style: normal;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 0.68rem;
}
@media (max-width: 820px) {
    .aoif-diagram-frame { padding-right: 0; }
    .aoif-recursive { display: none; }
    .aoif-strip.sources { grid-template-columns: repeat(4, 1fr); }
    .aoif-strip.audiences { grid-template-columns: repeat(2, 1fr); }
    .aoif-layer[data-layer="1"] .aoif-layer-body { grid-template-columns: repeat(4, 1fr); }
    .aoif-layer[data-layer="2"] .aoif-layer-body { grid-template-columns: 1fr; }
    .aoif-layer[data-layer="3"] .aoif-layer-body { grid-template-columns: 1fr; }
    .aoif-layer[data-layer="4"] .aoif-layer-body { grid-template-columns: repeat(2, 1fr); }
    .aoif-layer-head { flex-wrap: wrap; gap: 0.4rem 0.85rem; }
    .aoif-layer-sub { margin-left: 0; flex-basis: 100%; }
}

/* legibility: purple text variants on dark panels */
.aoif-layer[data-layer="4"] .aoif-layer-num { color: #CBB2F4; }
