/* ============ tokens ============ */
:root {
    --ink: #1c1917;
    --ink-soft: #44403c;
    --ink-mute: #57534e;
    --paper: #fafaf9;
    --panel: #ffffff;
    --band: #f5f5f4;
    --line: #d6d3d1;
    --line-strong: #a8a29e;
    --accent: #0f766e;
    --accent-deep: #134e4a;
    --accent-soft: #ccfbf1;
    --font-sans: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, monospace;
    --radius: 2px;
    --container: 80rem;
    --gutter: clamp(1.25rem, 4vw, 2.5rem);
    --focus-ring: 2px solid var(--accent, #0f766e);
    --focus-offset: 2px;
    --transition-fast: 0.15s ease;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    color-scheme: light;
}

/* ============ reduced motion ============ */
@media (prefers-reduced-motion: reduce) {

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

/* ============ base ============ */
* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: var(--font-sans, "Space Grotesk", ui-sans-serif, system-ui, sans-serif);
    color: var(--ink, #1c1917);
    background: var(--paper, #fafaf9);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.1;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

h3 {
    letter-spacing: 0;
}

p {
    margin: 0;
}

a {
    color: inherit;
}

code {
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 0.8125rem;
    background: var(--band, #f5f5f4);
    border: 1px solid var(--line, #d6d3d1);
    border-radius: var(--radius, 2px);
    padding: 0.05rem 0.3rem;
}

.container {
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.band {
    padding-block: clamp(3.5rem, 8vw, 6rem);
}

.band--light {
    background: var(--panel, #ffffff);
    border-block: 1px solid var(--line, #d6d3d1);
}

.band--muted {
    background: var(--band, #f5f5f4);
    border-block: 1px solid var(--line, #d6d3d1);
}

.label,
.eyebrow {
    display: block;
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 0.75rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.label {
    color: var(--ink-mute, #57534e);
}

.eyebrow {
    color: var(--accent-deep, #134e4a);
    margin-bottom: 0.9rem;
}

.accent {
    color: var(--accent-deep, #134e4a);
}

.lead {
    margin-top: 0.9rem;
    max-width: 42rem;
    color: var(--ink-soft, #44403c);
}

.section-head {
    margin-bottom: 2.25rem;
}

.section-footnote {
    margin-top: 2rem;
    font-size: 0.9375rem;
    color: var(--ink-soft, #44403c);
    max-width: 52rem;
    border-left: 2px solid var(--accent, #0f766e);
    padding-left: 1.25rem;
    clear: both;
}

/* ============ header / footer ============ */
.site-header {
    border-bottom: 1px solid var(--line, #d6d3d1);
    background: var(--paper, #fafaf9);
}

.header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    padding-block: 1rem;
}

.brand {
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-weight: 600;
    font-size: 1.125rem;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius, 2px);
    transition: color var(--transition-fast, 0.15s ease), background-color var(--transition-fast, 0.15s ease);
}

.brand:hover {
    color: var(--accent-deep, #134e4a);
    background: var(--accent-soft, #ccfbf1);
}

.brand:focus-visible {
    outline: var(--focus-ring, 2px solid #0f766e);
    outline-offset: var(--focus-offset, 2px);
}

.brand-mark {
    color: var(--accent, #0f766e);
    margin-left: 0.35rem;
}

.nav {
    display: none;
    gap: 1.75rem;
    font-size: 0.875rem;
}

.nav-link {
    text-decoration: none;
    color: var(--ink-soft, #44403c);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius, 2px);
    transition: color var(--transition-fast, 0.15s ease), background-color var(--transition-fast, 0.15s ease);
}

.nav-link:hover {
    color: var(--accent-deep, #134e4a);
    background: var(--accent-soft, #ccfbf1);
}

.nav-link:focus-visible {
    outline: var(--focus-ring, 2px solid #0f766e);
    outline-offset: var(--focus-offset, 2px);
}

@media (min-width: 80rem) {
    .nav {
        display: flex;
    }
}

.site-footer {
    border-top: 1px solid var(--line, #d6d3d1);
    background: var(--paper, #fafaf9);
}

.footer-inner {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding-block: 2rem;
    font-size: 0.875rem;
    color: var(--ink-soft, #44403c);
}

@media (min-width: 40rem) {
    .footer-inner {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

/* ============ hero ============ */
.hero {
    padding-block: clamp(4rem, 9vw, 7rem) clamp(3rem, 7vw, 5rem);
}

.hero-title {
    font-size: clamp(2.75rem, 7vw, 4.75rem);
    font-weight: 600;
}

.hero-sub {
    margin-top: 1rem;
    font-size: clamp(1.125rem, 2vw, 1.375rem);
    font-weight: 500;
    color: var(--ink-soft, #44403c);
}

.hero-grid {
    margin-top: 2.5rem;
    display: grid;
    gap: 2.5rem;
}

@media (min-width: 48rem) {
    .hero-grid {
        grid-template-columns: 2fr 1fr;
        align-items: end;
    }
}

.hero-lede {
    font-size: 1.0625rem;
    line-height: 1.75;
    color: var(--ink-soft, #44403c);
    max-width: 40rem;
}

.badge-row {
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.badge {
    display: inline-block;
    border: 1px solid var(--line-strong, #a8a29e);
    padding: 0.3rem 0.7rem;
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-soft, #44403c);
    background: var(--panel, #ffffff);
    transition: background-color var(--transition-fast, 0.15s ease), border-color var(--transition-fast, 0.15s ease), color var(--transition-fast, 0.15s ease);
}

.badge:hover {
    background: var(--band, #f5f5f4);
    border-color: var(--accent, #0f766e);
    color: var(--accent-deep, #134e4a);
}

.hero-aside {
    border-left: 2px solid var(--accent, #0f766e);
    padding-left: 1.25rem;
}

.hero-aside-title {
    margin-top: 0.75rem;
    font-size: 1.25rem;
    font-weight: 500;
}

.hero-aside-note {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--ink-mute, #57534e);
}

.gh-group {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.star-badge-link {
    display: inline-flex;
    align-items: center;
    line-height: 0;
}

.star-badge-link:hover {
    opacity: 0.85;
}

.star-badge-link img {
    display: block;
}

/* The stars badge only fits once the header has room to spare. */
@media (max-width: 47.999rem) {
    .star-badge-link {
        display: none;
    }
}

/* ============ buttons ============ */
.btn {
    display: inline-block;
    border: 1px solid var(--ink, #1c1917);
    border-radius: var(--radius, 2px);
    padding: 0.7rem 1.25rem;
    font: 500 0.875rem var(--font-sans, "Space Grotesk", ui-sans-serif, system-ui, sans-serif);
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background-color var(--transition-fast, 0.15s ease), color var(--transition-fast, 0.15s ease), border-color var(--transition-fast, 0.15s ease), box-shadow var(--transition-fast, 0.15s ease);
}

.btn--dark {
    background: var(--ink, #1c1917);
    color: var(--panel, #ffffff);
}

.btn--dark:hover {
    background: var(--ink-soft, #44403c);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.05));
}

.btn--dark:active {
    background: var(--ink-mute, #57534e);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    border-color: transparent;
    color: var(--ink, #1c1917);
}

.btn-icon:hover {
    background: transparent;
    box-shadow: none;
    opacity: 0.7;
}

.btn-icon:active {
    background: transparent;
    color: var(--ink-mute, #57534e);
}

.btn--primary {
    background: var(--accent, #0f766e);
    border-color: var(--accent, #0f766e);
    color: var(--panel, #ffffff);
}

.btn--primary:hover {
    background: var(--accent-deep, #134e4a);
    border-color: var(--accent-deep, #134e4a);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.05));
}

.btn--primary:active {
    background: var(--accent, #0f766e);
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Focus visible - unified token-based */
:where(.btn, .stepper-button, .copy-btn, .nav-link, .brand, .expand-btn):focus-visible {
    outline: var(--focus-ring, 2px solid #0f766e);
    outline-offset: var(--focus-offset, 2px);
}

/* Form elements - higher specificity to override browser defaults */
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    outline: var(--focus-ring, 2px solid #0f766e);
    outline-offset: var(--focus-offset, 2px);
}

/* ============ demo section ============ */
.demo-head {
    display: grid;
    gap: 2rem;
    margin-bottom: 2.5rem;
    align-items: center;
}

.demo-title {
    margin-bottom: 0.5rem;
    font-weight: 600;
}

@media (min-width: 48rem) {
    .demo-head {
        grid-template-columns: 7fr 5fr;
        align-items: end;
    }
}

.api-key-row {
    display: flex;
    margin-top: 0.5rem;
}

.api-key-field > .label {
    text-transform: none;
    letter-spacing: 0.01em;
    font-weight: 500;
    font-size: 0.875rem;
}

.api-key-field input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--line-strong, #a8a29e);
    border-radius: var(--radius, 2px);
    background: var(--panel, #ffffff);
    padding: 0.7rem 0.75rem;
    font: 0.875rem var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    color: var(--ink, #1c1917);
    transition: border-color var(--transition-fast, 0.15s ease), box-shadow var(--transition-fast, 0.15s ease);
}

.api-key-field input:hover {
    border-color: var(--accent, #0f766e);
}

.api-key-field input:focus-visible {
    outline: var(--focus-ring, 2px solid #0f766e);
    outline-offset: var(--focus-offset, 2px);
    border-color: var(--accent, #0f766e);
    box-shadow: 0 0 0 3px var(--accent-soft, #ccfbf1);
}

/* Verified connection hides the key input until the key is edited or a run fails. */
.api-key-field.is-connected > .label,
.api-key-field.is-connected .api-key-row {
    display: none;
}

/* API-key auth is disabled temporarily (backend no longer accepts keys):
   the field carries the hidden attribute in index.html. The rules below
   stay for re-enabling. */

.api-key-field .api-key-hint {
    margin-top: 0.4rem;
    font-size: 0.8125rem;
}

.api-key-field .api-key-hint[data-state='ok'] {
    color: var(--accent, #0f766e);
}

.api-key-field .api-key-hint[data-state='error'] {
    color: #b91c1c;
}

.api-key-field.is-error input {
    border-color: #b91c1c;
}

/* Ensure focus outlines are not clipped by overflow:hidden containers */
.pane-body:focus-within,
.codeblock:focus-within,
.figure:focus-within,
.editor:focus-within {
    overflow: visible;
}

.mode-panel {
    margin-top: 1.5rem;
    padding-block: 1.5rem;
    border-block: 1px solid var(--line, #d6d3d1);
}

.mode-panel .label {
    margin-bottom: 0.5rem;
}

.mode-panel select {
    display: block;
    width: 100%;
    border: 1px solid var(--line-strong, #a8a29e);
    border-radius: var(--radius, 2px);
    background: var(--panel, #ffffff);
    padding: 0.7rem 0.75rem;
    font: 0.875rem var(--font-sans, "Space Grotesk", ui-sans-serif, system-ui, sans-serif);
    color: var(--ink, #1c1917);
    transition: border-color var(--transition-fast, 0.15s ease), box-shadow var(--transition-fast, 0.15s ease);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357534e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

.mode-panel select:hover {
    border-color: var(--accent, #0f766e);
}

.mode-panel select:focus-visible {
    outline: var(--focus-ring, 2px solid #0f766e);
    outline-offset: var(--focus-offset, 2px);
    border-color: var(--accent, #0f766e);
    box-shadow: 0 0 0 3px var(--accent-soft, #ccfbf1);
}

.mode-note {
    margin-top: 0.6rem;
    font-size: 0.875rem;
    color: var(--ink-mute, #57534e);
    max-width: 42rem;
}

.mode-panel .btn {
    margin-top: 1.25rem;
}

@media (min-width: 48rem) {
    #run-custom {
        width: auto;
        min-width: 16rem;
    }
}

.params-row {
    margin-top: 1.5rem;
    display: grid;
    gap: 1.5rem;
}

@media (min-width: 40rem) {
    .params-row {
        grid-template-columns: 1fr auto;
        align-items: end;
    }
}

.control-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.control {
    display: flex;
    flex-direction: column;
}

.mode-panel .label {
    margin-bottom: 0.4rem;
    font-weight: 500;
    font-size: 0.875rem;
    text-transform: none;
    letter-spacing: 0.01em;
    color: var(--ink-soft, #44403c);
}

.param-select-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.param-file-status {
    margin-top: 0.4rem;
    font-size: 0.8125rem;
    color: var(--ink-mute, #57534e);
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.param-upload-btn {
    display: inline-block;
    padding: 0.7rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--panel, #ffffff);
    background: var(--ink, #1c1917);
    border-radius: var(--radius, 2px);
    cursor: pointer;
    transition: opacity var(--transition-fast, 0.15s ease);
}

.param-upload-btn:hover {
    opacity: 0.8;
}

.param-download {
    display: inline-flex;
    align-items: center;
    padding: 0.7rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ink, #1c1917);
    background: var(--band, #f5f5f4);
    border: 1px solid var(--line-strong, #a8a29e);
    border-radius: var(--radius, 2px);
    text-decoration: none;
    transition: background-color var(--transition-fast, 0.15s ease), color var(--transition-fast, 0.15s ease);
}

.param-download:hover {
    background: var(--line, #d6d3d1);
    color: var(--ink, #1c1917);
}

.control-value,
.stepper-value {
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 0.875rem;
    color: var(--ink, #1c1917);
    font-variant-numeric: tabular-nums;
    min-width: 2.5rem;
    text-align: right;
}

.stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line-strong, #a8a29e);
    border-radius: var(--radius, 2px);
    background: var(--panel, #ffffff);
}

.stepper-button {
    border: 0;
    background: transparent;
    width: 2rem;
    height: 2rem;
    font: 500 1rem var(--font-sans, "Space Grotesk", ui-sans-serif, system-ui, sans-serif);
    color: var(--ink-soft, #44403c);
    cursor: pointer;
    transition: background-color var(--transition-fast, 0.15s ease), color var(--transition-fast, 0.15s ease);
}

.stepper-button:hover {
    background: var(--band, #f5f5f4);
    color: var(--ink, #1c1917);
}

.stepper-button:active {
    background: var(--line, #d6d3d1);
    transform: scale(0.95);
}

.stepper-value {
    padding: 0 0.4rem;
}

.editor-grid {
    display: grid;
    gap: 1.25rem;
}

@media (min-width: 64rem) {
    .editor-grid {
        grid-template-columns: 1fr 1fr;
    }
}

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

.editor textarea {
    width: 100%;
    height: 14rem;
    resize: vertical;
    border: 1px solid var(--line-strong, #a8a29e);
    border-radius: var(--radius, 2px);
    background: var(--band, #f5f5f4);
    padding: 1rem;
    font: 0.8125rem/1.5 var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    color: var(--ink-soft, #44403c);
    transition: border-color var(--transition-fast, 0.15s ease), box-shadow var(--transition-fast, 0.15s ease);
}

.editor textarea:hover {
    border-color: var(--accent, #0f766e);
}

.editor textarea:focus-visible {
    outline: var(--focus-ring, 2px solid #0f766e);
    outline-offset: var(--focus-offset, 2px);
    border-color: var(--accent, #0f766e);
    box-shadow: 0 0 0 3px var(--accent-soft, #ccfbf1);
    background: var(--panel, #ffffff);
}

.custom-foot {
    margin-top: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 64rem) {
    .custom-foot {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.status {
    margin-top: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem 0.75rem;
    border-left: 2px solid var(--accent, #0f766e);
    background: var(--band, #f5f5f4);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border-radius: 0 var(--radius, 2px) var(--radius, 2px) 0;
    transition: background-color var(--transition-fast, 0.15s ease), border-color var(--transition-fast, 0.15s ease);
}

.status-job {
    margin-left: auto;
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 0.75rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent-deep, #134e4a);
    background: var(--accent-soft, #ccfbf1);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius, 2px);
    font-weight: 500;
}

/* engine health states (js/ui/demo.js runHealthCheck) */
.status[data-state="ready"] {
    border-left-color: #15803d;
}

.status[data-state="ready"] .status-job {
    color: #14532d;
    background: #dcfce7;
}

.status[data-state="offline"] {
    border-left-color: #b91c1c;
}

.status[data-state="offline"] .status-job {
    color: #991b1b;
    background: #fee2e2;
}

/* ============ panes ============ */
.panes {
    margin-top: 2.25rem;
    display: grid;
    gap: 1.75rem;
    align-items: start;
}

@media (min-width: 64rem) {
    .panes {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.pane {
    min-width: 0;
}

.pane-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 3rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--line, #d6d3d1);
    margin-bottom: 0.75rem;
}

.pane-head h3 {
    min-width: 0;
    font-size: 1.0625rem;
    font-weight: 500;
}

.pane-body {
    display: flex;
    flex-direction: column;
    background: var(--panel, #ffffff);
    border: 1px solid var(--line, #d6d3d1);
    border-radius: var(--radius, 2px);
    height: 37rem;
    padding: 0.75rem;
    overflow: hidden;
}

#svg-output {
    position: relative;
    display: flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

#svg-output svg {
    display: block;
    flex: 1 1 0;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

@media (max-width: 63.999rem) {
    .pane-body {
        height: 32rem;
    }
}

.pane-body svg {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
}

.graph-empty {
    min-height: 15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding-inline: 1.5rem;
    border: 1px dashed var(--line-strong, #a8a29e);
    font-size: 0.875rem;
    color: var(--ink-mute, #57534e);
}

/* dark pane */
/* ============ panels: checks + stages ============ */
.panel-grid {
    margin-top: 2.25rem;
    display: grid;
    gap: 1.75rem;
}

@media (min-width: 64rem) {
    .panel-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--line, #d6d3d1);
}

.panel-title {
    font-weight: 500;
    font-size: 1.0625rem;
}

.stages-summary {
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-deep, #134e4a);
    font-variant-numeric: tabular-nums;
}

.check-row {
    display: flex;
    gap: 0.75rem;
    align-items: baseline;
    padding-block: 0.7rem;
    border-bottom: 1px solid var(--line, #d6d3d1);
    font-size: 0.875rem;
    color: var(--ink-soft, #44403c);
}

.check-row:last-of-type {
    border-bottom: 0;
}

.check-marker {
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    background: var(--accent, #0f766e);
    align-self: center;
}

.stage-row .check-marker {
    background: var(--line-strong, #a8a29e);
}

.stage-row.is-done .check-marker {
    background: var(--accent, #0f766e);
}

.stage-row.is-active .check-marker {
    background: var(--accent-deep, #134e4a);
}

.stage-row.is-failed .check-marker {
    background: var(--ink, #1c1917);
}

.stage-row.is-pending {
    color: var(--ink-mute, #57534e);
}

.panel-note {
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    color: var(--ink-mute, #57534e);
}

/* ============ codeblocks + tabs ============ */
.codeblock {
    margin-top: 1.75rem;
    border: 1px solid var(--line, #d6d3d1);
    border-radius: var(--radius, 2px);
    overflow: hidden;
    color-scheme: dark; /* dark scrollbars and selection inside code panels */
}

.codeblock-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--line, #d6d3d1);
    background: var(--band, #f5f5f4);
}

.codeblock-title {
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: var(--ink-soft, #44403c);
}

.codeblock pre {
    margin: 0;
    background: var(--ink, #1c1917);
    color: #e7e5e4;
    padding: 1rem;
    overflow-x: auto;
    max-width: 100%;
    border-radius: 0 0 var(--radius, 2px) var(--radius, 2px);
}

.codeblock pre code {
    background: transparent;
    border: 0;
    color: inherit;
    font-size: 0.8125rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    display: block;
}

.codeblock--flat pre {
    background: var(--panel, #ffffff);
    color: var(--ink-soft, #44403c);
    border-radius: 0 0 var(--radius, 2px) var(--radius, 2px);
}

.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid var(--line-strong, #a8a29e);
    border-radius: var(--radius, 2px);
    background: var(--panel, #ffffff);
    color: var(--ink-soft, #44403c);
    padding: 0.3rem 0.6rem;
    font: 500 0.75rem var(--font-sans, "Space Grotesk", ui-sans-serif, system-ui, sans-serif);
    cursor: pointer;
    transition: background-color var(--transition-fast, 0.15s ease), border-color var(--transition-fast, 0.15s ease), color var(--transition-fast, 0.15s ease);
}

.copy-btn:hover {
    background: var(--band, #f5f5f4);
    border-color: var(--accent, #0f766e);
    color: var(--accent-deep, #134e4a);
}

.copy-btn:active {
    background: var(--line, #d6d3d1);
    transform: scale(0.98);
}

.copy-btn [data-copy-label] {
    transition: opacity var(--transition-fast, 0.15s ease);
}

/* ============ contract + about ============ */
.contract {
    margin-top: 1.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line, #d6d3d1);
    font-size: 0.875rem;
    color: var(--ink-soft, #44403c);
}

.contract summary {
    cursor: pointer;
    font-weight: 500;
}

.contract-grid {
    margin-top: 1rem;
    display: grid;
    gap: 1.5rem;
}

@media (min-width: 48rem) {
    .contract-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.contract-grid p {
    margin-top: 0.5rem;
    line-height: 1.65;
}

.contract-grid .label {
    margin-bottom: 0;
}

.about {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line, #d6d3d1);
    font-size: 0.875rem;
    color: var(--ink-soft, #44403c);
}

.about .label {
    margin: 0;
}

.about p {
    margin-top: 0.75rem;
    line-height: 1.7;
    max-width: 52rem;
}

/* ============ video embed ============ */
.video-embed {
    margin: 0;
    max-width: 60rem;
}

.video-stage {
    position: relative;
    aspect-ratio: 16 / 9;
    border: 1px solid var(--line, #d6d3d1);
    border-radius: var(--radius, 2px);
    background: var(--ink, #1c1917);
    overflow: hidden;
}

.video-facade {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.video-facade img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.video-facade:hover img,
.video-facade:focus-visible img {
    transform: scale(1.02);
    opacity: 0.88;
}

.video-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    display: grid;
    place-items: center;
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 50%;
    background: var(--accent, #0f766e);
    color: var(--panel, #ffffff);
    box-shadow: var(--shadow-md, 0 4px 6px rgba(0, 0, 0, 0.07));
    transition: background-color var(--transition-fast, 0.15s ease), transform var(--transition-fast, 0.15s ease);
}

.video-play svg {
    margin-left: 0.2rem;
}

.video-facade:hover .video-play,
.video-facade:focus-visible .video-play {
    background: var(--accent-deep, #134e4a);
    transform: translate(-50%, -50%) scale(1.06);
}

.video-facade:focus-visible {
    outline: var(--focus-ring, 2px solid #0f766e);
    /* Negative offset keeps the outline visible inside the clipped stage */
    outline-offset: -3px;
}

/* Both the muted preview and the full player are staged inside .video-stage */
.video-stage iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.video-preview-frame {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none; /* clicks fall through to the facade button */
}

.video-preview-hint {
    display: none;
    position: absolute;
    left: 0.75rem;
    bottom: 0.75rem;
    z-index: 2;
    padding: 0.25rem 0.5rem;
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--panel, #ffffff);
    background: rgba(28, 25, 23, 0.78);
    border-radius: var(--radius, 2px);
}

.video-embed--preview .video-preview-hint {
    display: inline-block;
}

/* Slightly smaller play affordance while the preview loops behind it */
.video-embed--preview .video-play {
    width: 3.5rem;
    height: 3.5rem;
}

.video-embed--preview .video-play svg {
    width: 22px;
    height: 22px;
}

.video-caption {
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    color: var(--ink-mute, #57534e);
}

.video-caption a {
    color: var(--accent-deep, #134e4a);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.video-caption a:hover {
    color: var(--accent, #0f766e);
}

@media (prefers-reduced-motion: reduce) {

    .video-facade img,
    .video-play {
        transition: none;
    }
}

/* ============ architecture figures ============ */
.figure {
    margin: 0 0 2.5rem;
    overflow-x: hidden;
    max-width: 100%;
    clear: both;
}

/* Narrow screens: scroll figures instead of shrinking the SVG below
   readable text sizes. */
@media (max-width: 63.999rem) {
    .figure {
        overflow-x: auto;
    }

    .figure svg {
        min-width: 60rem;
    }

    .figure.arch-inline {
        overflow-x: auto;
    }

    .arch-inline .arch-svg {
        min-width: 84rem;
    }
}

#architecture .figure {
    margin-bottom: 3rem;
}

#architecture .section-footnote {
    margin-top: 3rem;
}

.figure svg {
    width: 100%;
    height: auto;
    display: block;
}

.figure figcaption {
    margin-top: 1.5rem;
}

/* ============ reproduce ============ */
.steps {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.step {
    display: grid;
    gap: 1rem;
}

@media (min-width: 48rem) {
    .step {
        grid-template-columns: 6rem 1fr;
        align-items: start;
    }
}

.step-num {
    display: inline-block;
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 0.75rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent-deep, #134e4a);
    border: 1px solid var(--accent, #0f766e);
    padding: 0.3rem 0.6rem;
    justify-self: start;
}

.step h3 {
    font-size: 1.0625rem;
    font-weight: 500;
}

.step>div>p {
    margin-top: 0.4rem;
    font-size: 0.9375rem;
    color: var(--ink-soft, #44403c);
    max-width: 44rem;
}

.step .codeblock {
    margin-top: 1.5rem;
    max-width: 100%;
    clear: both;
}

#reproduce .step .codeblock--flat pre {
    overflow-x: auto;
    max-width: 100%;
}

.repro-rows {
    margin-top: 3rem;
    border-block: 1px solid var(--line, #d6d3d1);
}

.repro-row {
    display: grid;
    gap: 0.25rem;
    padding: 1rem;
    border-bottom: 1px solid var(--line, #d6d3d1);
    font-size: 0.875rem;
    color: var(--ink-soft, #44403c);
}

.repro-row:last-child {
    border-bottom: 0;
}

@media (min-width: 40rem) {
    .repro-row {
        grid-template-columns: 11rem 1fr;
        gap: 1.5rem;
    }
}

/* ============ resources ============ */
.resources-grid {
    display: grid;
    gap: 2.5rem;
    max-width: 100%;
}

@media (min-width: 64rem) {
    .resources-grid {
        grid-template-columns: 1fr 1fr;
        align-items: start;
    }
}

.links {
    border-top: 1px solid var(--line, #d6d3d1);
    overflow-x: auto;
    max-width: 100%;
}

.link-row {
    display: grid;
    gap: 0.25rem;
    padding-block: 1rem;
    border-bottom: 1px solid var(--line, #d6d3d1);
    font-size: 0.875rem;
    color: var(--ink-soft, #44403c);
    min-width: 0;
}

@media (min-width: 40rem) {
    .link-row {
        grid-template-columns: 1fr auto;
        gap: 1.5rem;
        align-items: baseline;
    }
}

.link-row a {
    font-weight: 500;
    color: var(--accent-deep, #134e4a);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    word-break: break-word;
}

.link-row a:hover {
    color: var(--accent, #0f766e);
}

.link-note {
    font-size: 0.8125rem;
    color: var(--ink-mute, #57534e);
}

.link-pending {
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-mute, #57534e);
    border: 1px solid var(--line-strong, #a8a29e);
    padding: 0.2rem 0.5rem;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --line: #000;
        --line-strong: #000;
        --ink-soft: #000;
        --ink-mute: #333;
    }
}

/* ============ animations ============ */

/* --- Keyframes --- */
@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(1.25rem);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes node-pop {
    0% {
        opacity: 0;
        transform: scale(0);
    }

    70% {
        transform: scale(1.25);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes edge-draw {
    from {
        stroke-dashoffset: 1;
    }

    to {
        stroke-dashoffset: 0;
    }
}

@keyframes flow-dash {
    to {
        stroke-dashoffset: -16;
    }
}

@keyframes marker-pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.45);
    }

    50% {
        box-shadow: 0 0 0 6px rgba(15, 118, 110, 0);
    }
}

/* --- Hero entrance (on load) --- */
.hero .eyebrow,
.hero .hero-title,
.hero .hero-sub,
.hero .hero-grid {
    animation: fade-in-up 0.6s ease both;
}

.hero .eyebrow {
    animation-delay: 0.05s;
}

.hero .hero-title {
    animation-delay: 0.15s;
}

.hero .hero-sub {
    animation-delay: 0.3s;
}

.hero .hero-grid {
    animation-delay: 0.45s;
}

.hero .badge {
    animation: fade-in 0.4s ease both;
}

.hero .badge:nth-child(1) {
    animation-delay: 0.55s;
}

.hero .badge:nth-child(2) {
    animation-delay: 0.65s;
}

.hero .badge:nth-child(3) {
    animation-delay: 0.75s;
}

.hero .badge:nth-child(4) {
    animation-delay: 0.85s;
}

/* --- Scroll reveal (JS adds .is-visible when section enters viewport) --- */
.reveal {
    opacity: 0;
    transform: translateY(1.5rem);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger children inside revealed sections */
.reveal .step,
.reveal .repro-row,
.reveal .link-row {
    opacity: 0;
    transform: translateY(0.75rem);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal.is-visible .step,
.reveal.is-visible .repro-row,
.reveal.is-visible .link-row {
    opacity: 1;
    transform: translateY(0);
}

.reveal.is-visible .step:nth-child(1) {
    transition-delay: 0.05s;
}

.reveal.is-visible .step:nth-child(2) {
    transition-delay: 0.15s;
}

.reveal.is-visible .step:nth-child(3) {
    transition-delay: 0.25s;
}

.reveal.is-visible .step:nth-child(4) {
    transition-delay: 0.35s;
}

.reveal.is-visible .repro-row:nth-child(1) {
    transition-delay: 0.05s;
}

.reveal.is-visible .repro-row:nth-child(2) {
    transition-delay: 0.12s;
}

.reveal.is-visible .repro-row:nth-child(3) {
    transition-delay: 0.19s;
}

.reveal.is-visible .repro-row:nth-child(4) {
    transition-delay: 0.26s;
}

.reveal.is-visible .link-row:nth-child(1) {
    transition-delay: 0.05s;
}

.reveal.is-visible .link-row:nth-child(2) {
    transition-delay: 0.12s;
}

.reveal.is-visible .link-row:nth-child(3) {
    transition-delay: 0.19s;
}

.reveal.is-visible .link-row:nth-child(4) {
    transition-delay: 0.26s;
}

.reveal.is-visible .link-row:nth-child(5) {
    transition-delay: 0.33s;
}

/* --- SVG pipeline data-flow animation (Figures 1 & 2) --- */
/* Flowing dashes on connector lines/arrows visualize the data path:
   Lua script -> REST -> render */
.figure svg line,
.figure svg path {
    stroke-dasharray: 6 4;
    animation: flow-dash 1.2s linear infinite;
}

/* The dashed codegen-to-OGDF connector keeps its own dash pattern */
.figure svg path[stroke-dasharray="4,2"] {
    stroke-dasharray: 4 2;
    animation: flow-dash 1.6s linear infinite;
}

/* --- Run stages animation --- */
/* Active stage marker pulses while the job progresses */
.stage-row.is-active .check-marker {
    animation: marker-pulse 1.4s ease-in-out infinite;
}

.stage-row {
    transition: opacity 0.3s ease, color 0.3s ease;
}

.stage-row.is-done {
    animation: fade-in 0.4s ease;
}

/* --- Reduced motion: disable all animations --- */
@media (prefers-reduced-motion: reduce) {

    .hero .eyebrow,
    .hero .hero-title,
    .hero .hero-sub,
    .hero .hero-grid,
    .hero .badge,
    .stage-row.is-done {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
        stroke-dashoffset: 0 !important;
    }

    .figure svg line,
    .figure svg path {
        animation: none !important;
    }

    .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .reveal .step,
    .reveal .repro-row,
    .reveal .link-row {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .stage-row.is-active .check-marker {
        animation: none !important;
    }
}


/* ============ terminal beautification (Reproduce section) ============ */

/* Terminal window chrome: traffic-light dots */
.terminal-dots {
    display: inline-flex;
    gap: 0.4rem;
    align-items: center;
}

.terminal-dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 50%;
    display: inline-block;
}

.terminal-dot--red {
    background: #ff5f57;
}

.terminal-dot--yellow {
    background: #febc2e;
}

.terminal-dot--green {
    background: #28c840;
}

/* Terminal codeblock: dark window look */
.codeblock--flat {
    border: 1px solid #2d2a26;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: var(--shadow-md, 0 4px 6px rgba(0, 0, 0, 0.07));
}

.codeblock--flat .codeblock-head {
    background: #2d2a26;
    border-bottom: 1px solid #3f3c39;
    padding: 0.6rem 0.9rem;
}

.codeblock--flat .codeblock-title {
    color: #a8a29e;
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.codeblock--flat .copy-btn {
    background: transparent;
    border-color: #57534e;
    color: #d6d3d1;
}

.codeblock--flat .copy-btn:hover {
    background: #3f3c39;
    border-color: #a8a29e;
    color: #fafaf9;
}

/* Terminal body: dark background with light text */
.codeblock--flat pre {
    background: #1c1917;
    color: #e7e5e4;
    padding: 1.1rem 1.25rem;
    font-size: 0.8125rem;
    line-height: 1.75;
    border-radius: 0;
}

.codeblock--flat pre code {
    color: inherit;
}

/* Prompt symbol: green like a real shell prompt */
.t-prompt {
    color: #2dd4bf;
    font-weight: 600;
    user-select: none;
}

/* Comments: muted green-gray, terminal style */
.t-comment {
    color: #7d8590;
    font-style: italic;
}

/* --- Reduced motion: no changes needed (terminal is static) --- */

/* Print styles */
@media print {

    .site-header,
    .demo-head,
    .mode-panel,
    .status,
    .copy-btn,
    .btn,
    .nav,
    .badge-row {
        display: none !important;
    }

    .pane-body {
        min-height: auto;
        border: 1px solid #000;
    }

    .band {
        padding-block: 1rem;
    }

    body {
        font-size: 12pt;
        line-height: 1.5;
    }
}

.side-tag {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0.2rem 0.55rem;
    border: 1px solid var(--line-strong);
    color: var(--ink-soft);
    white-space: nowrap;
}

.side-tag--a {
    border-color: var(--ink);
    color: var(--ink);
}

.side-tag--b {
    border-color: var(--accent);
    color: var(--accent-deep);
    background: var(--accent-soft);
}

/* SVG viewer affordances: pan/zoom cursor states and the floating toolbar. */
.pane-body {
    position: relative;
}

.pane-body svg {
    touch-action: none;
    cursor: grab;
}

.pane-body svg.is-panning {
    cursor: grabbing;
}

.graph-toolbar {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.3rem;
}

.graph-btn {
    border: 1px solid var(--line-strong);
    background: var(--panel);
    font: 500 0.75rem var(--font-mono);
    color: var(--ink-soft);
    min-height: 2rem;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
}

.graph-btn:hover {
    border-color: var(--accent);
    color: var(--accent-deep);
    background: var(--band);
}

/* ==== pane B: GraphML viewer ==== */
.pane-body--3d {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.graph3d-meta {
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 0.75rem;
    color: var(--ink-mute, #57534e);
    font-variant-numeric: tabular-nums;
    margin: 0;
}

.graph3d-help {
    margin: 0;
    color: var(--ink-mute, #57534e);
    font-size: 0.75rem;
}

.graph3d-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    border: 1px solid var(--line, #d6d3d1);
    border-radius: var(--radius, 2px);
    background:
        radial-gradient(ellipse at center, rgba(204, 251, 241, 0.3), transparent 70%),
        var(--panel, #ffffff);
    overflow: hidden;
}

.graph3d-stage:fullscreen {
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
    background: var(--panel, #ffffff);
}

.graph3d-stage canvas {
    display: block;
    position: absolute;
    inset: 0;
    touch-action: none;
}

.graph3d-toolbar {
    position: absolute;
    z-index: 2;
    top: 0.5rem;
    inset-inline: 0.5rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3rem;
    pointer-events: none;
}

.graph3d-toolbar>* {
    pointer-events: auto;
}

.graph3d-toolbar button[aria-pressed="true"] {
    border-color: var(--accent, #0f766e);
    color: var(--accent-deep, #134e4a);
    background: var(--accent-soft, #ccfbf1);
}

.graph3d-toolbar .graph-btn {
    min-height: 2rem;
    padding-inline: 0.55rem;
    box-shadow: var(--shadow-sm);
}

.graph3d-search {
    flex: 1 1 9rem;
    min-width: 8rem;
    max-width: 15rem;
    min-height: 2rem;
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--line-strong, #a8a29e);
    border-radius: var(--radius, 2px);
    background: var(--panel, #fff);
    color: var(--ink, #1c1917);
    font: 0.75rem var(--font-sans, "Space Grotesk", ui-sans-serif, system-ui, sans-serif);
    box-shadow: var(--shadow-sm);
}

.graph3d-search:focus-visible,
.graph3d-toolbar button:focus-visible {
    outline: var(--focus-ring, 2px solid #0f766e);
    outline-offset: var(--focus-offset, 2px);
}

.graph3d-node-info {
    position: absolute;
    z-index: 1;
    inset-inline-start: 0.65rem;
    inset-block-end: 0.55rem;
    max-width: calc(100% - 1.3rem);
    padding: 0.3rem 0.55rem;
    border: 1px solid rgba(214, 211, 209, 0.85);
    border-radius: var(--radius, 2px);
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink-soft, #44403c);
    font: 0.75rem var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    overflow-wrap: anywhere;
    pointer-events: none;
}

/* ==== panes: path switch (visible only when both paths returned data) ==== */
.view-switch {
    display: inline-flex;
    border: 1px solid var(--line-strong, #a8a29e);
    border-radius: var(--radius, 2px);
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.view-switch button {
    appearance: none;
    border: 0;
    background: var(--panel, #fff);
    padding: 0.4rem 0.8rem;
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-mute, #57534e);
    cursor: pointer;
    transition: background var(--transition-fast, 0.15s ease), color var(--transition-fast, 0.15s ease);
}

.view-switch button+button {
    border-left: 1px solid var(--line-strong, #a8a29e);
}

.view-switch button:hover {
    color: var(--ink, #1c1917);
}

.view-switch button.is-active {
    background: var(--ink, #1c1917);
    color: #fff;
}

/* ==== layout parameters: toolbar + modal ==== */
.params-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.param-toolbar-note {
    font-size: 0.8125rem;
    color: var(--ink-mute, #57534e);
}

.param-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--ink, #1c1917);
    background: var(--panel, #ffffff);
    border: 1px solid var(--line-strong, #a8a29e);
    border-radius: var(--radius, 2px);
    cursor: pointer;
    transition: border-color var(--transition-fast, 0.15s ease), background-color var(--transition-fast, 0.15s ease);
}

.param-open-btn:hover {
    border-color: var(--accent, #0f766e);
    background: var(--band, #f5f5f4);
}

.param-open-btn:focus-visible {
    outline: var(--focus-ring, 2px solid var(--accent, #0f766e));
    outline-offset: var(--focus-offset, 2px);
}

.param-count {
    min-width: 1.35rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--accent, #0f766e);
    color: #fff;
    font: 500 0.75rem/1.35rem var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    text-align: center;
}

.parameters-modal,
.editor-modal {
    display: flex;
    flex-direction: column;
    width: min(46rem, calc(100vw - 2rem));
    max-height: min(38rem, calc(100vh - 2rem));
    max-height: min(38rem, calc(100dvh - 2rem));
    border: 1px solid var(--line-strong, #a8a29e);
    border-top: 2px solid var(--accent, #0f766e);
    border-radius: var(--radius, 2px);
    background: var(--panel, #ffffff);
    color: var(--ink, #1c1917);
    padding: 0;
    box-shadow: var(--shadow-md, 0 4px 6px rgba(0, 0, 0, 0.07)),
        0 24px 48px -16px rgba(28, 25, 23, 0.28);
}

.editor-modal {
    width: min(64rem, calc(100vw - 2rem));
    height: min(52rem, calc(100vh - 2rem));
    height: min(52rem, calc(100dvh - 2rem));
}

/* Keep a closed dialog actually hidden: the display:flex above would
   otherwise override the UA's hidden state for non-open dialogs. */
.parameters-modal:not([open]),
.editor-modal:not([open]) {
    display: none;
}

.parameters-modal::backdrop,
.editor-modal::backdrop {
    background: rgba(28, 25, 23, 0.45);
    backdrop-filter: blur(2px);
    animation: modal-backdrop-in var(--transition-fast, 0.15s ease) ease-out;
}

@keyframes modal-backdrop-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.parameters-modal[open],
.editor-modal[open] {
    animation: modal-in 0.22s cubic-bezier(0.16, 1, 0.3, 1) ease-out;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(0.75rem) scale(0.985);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--line, #d6d3d1);
    background: var(--paper, #fafaf9);
}

.modal-heading {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
}

.modal-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 2.375rem;
    height: 2.375rem;
    border-radius: var(--radius, 2px);
    background: var(--accent-soft, #ccfbf1);
    color: var(--accent-deep, #134e4a);
}

.modal-head h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.modal-sub {
    margin: 0.3rem 0 0;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--ink-mute, #57534e);
    max-width: 34rem;
}

.modal-close {
    appearance: none;
    flex: 0 0 auto;
    width: 2.25rem;
    height: 2.25rem;
    border: 1px solid transparent;
    border-radius: var(--radius, 2px);
    background: transparent;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--ink-mute, #57534e);
    cursor: pointer;
    transition: border-color var(--transition-fast, 0.15s ease), background-color var(--transition-fast, 0.15s ease),
        color var(--transition-fast, 0.15s ease);
}

.modal-close:hover {
    color: var(--accent-deep, #134e4a);
    border-color: var(--accent, #0f766e);
    background: var(--accent-soft, #ccfbf1);
}

.modal-close:focus-visible {
    outline: var(--focus-ring, 2px solid var(--accent, #0f766e));
    outline-offset: var(--focus-offset, 2px);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    min-height: 0;
    background: var(--paper, #fafaf9);
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--line-strong, #a8a29e) transparent;
}

.editor-modal .modal-body {
    display: flex;
    flex: 1 1 auto;
    padding: 1rem 1.5rem;
}

.code-editor {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    background: #1c1917;
    border: 1px solid var(--line-strong, #a8a29e);
    border-radius: var(--radius, 2px);
    overflow: hidden;
}

.code-editor:focus-within {
    outline: var(--focus-ring, 2px solid #0f766e);
    outline-offset: 2px;
}

.code-editor textarea,
.code-editor-gutter {
    font: 0.8125rem/1.5 var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    tab-size: 2;
}

.code-editor-gutter {
    flex: 0 0 auto;
    margin: 0;
    padding: 1rem 0.75rem 1rem 1rem;
    min-width: 3rem;
    text-align: right;
    color: #a8a29e;
    background: #292524;
    overflow: hidden;
    user-select: none;
}

.code-editor textarea {
    flex: 1 1 auto;
    width: 100%;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 1rem;
    color: #e7e5e4;
    caret-color: #5eead4;
    resize: none;
    white-space: pre;
    overflow: auto;
}

.code-editor textarea:focus-visible {
    outline: none;
    box-shadow: none;
}

.editor-modal .modal-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--line, #d6d3d1);
    background: var(--paper, #fafaf9);
}

.code-editor-status {
    font-size: 0.75rem;
    color: var(--ink-mute, #57534e);
    font-variant-numeric: tabular-nums;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.expand-btn {
    appearance: none;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent-deep, #134e4a);
    background: var(--panel, #ffffff);
    border: 1px solid var(--line-strong, #a8a29e);
    border-radius: var(--radius, 2px);
    cursor: pointer;
    transition: color var(--transition-fast, 0.15s ease), border-color var(--transition-fast, 0.15s ease), background-color var(--transition-fast, 0.15s ease);
}

.expand-btn:hover {
    border-color: var(--accent, #0f766e);
    background: var(--accent-soft, #ccfbf1);
}

.param-empty {
    margin: 0;
    padding: 2.5rem 1.5rem;
    text-align: center;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--ink-mute, #57534e);
    border: 1px dashed var(--line-strong, #a8a29e);
    border-radius: var(--radius, 2px);
    background: var(--panel, #ffffff);
}

#layout-parameters {
    display: grid;
    gap: 1rem;
}

/* Each parameter is its own card so fields never blur together. */
#layout-parameters .param-control {
    padding: 0.9rem 1rem 1rem;
    background: var(--panel, #ffffff);
    border: 1px solid var(--line, #d6d3d1);
    border-left: 2px solid var(--line-strong, #a8a29e);
    border-radius: var(--radius, 2px);
    transition: border-color var(--transition-fast, 0.15s ease), box-shadow var(--transition-fast, 0.15s ease);
}

#layout-parameters .param-control:hover {
    border-left-color: var(--accent, #0f766e);
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0, 0, 0, 0.05));
}

@media (min-width: 40rem) {
    #layout-parameters {
        grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
        align-items: start;
    }
}

#layout-parameters .param-control select,
#layout-parameters .param-control input[type="number"],
#layout-parameters .param-control input[type="text"] {
    width: 100%;
    margin-top: 0.5rem;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--panel);
    padding: 0.7rem 0.75rem;
    font: 0.875rem var(--font-sans);
    color: var(--ink);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

#layout-parameters .param-control select:hover,
#layout-parameters .param-control input:hover {
    border-color: var(--accent);
}

#layout-parameters .param-control select:focus-visible,
#layout-parameters .param-control input:focus-visible {
    outline: var(--focus-ring);
    outline-offset: var(--focus-offset);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

#layout-parameters .param-control select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357534e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

#layout-parameters .param-control .label {
    transition: color var(--transition-fast, 0.15s ease);
}

#layout-parameters .param-control:hover .label {
    color: var(--ink-soft, #44403c);
}

#layout-parameters .param-control:has(> input[type="checkbox"]) {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem 1rem;
}

#layout-parameters .param-control:has(> input[type="checkbox"]) .param-description {
    flex-basis: 100%;
}

#layout-parameters .param-control input[type="checkbox"] {
    flex: 0 0 auto;
    margin: 0;
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--accent);
    cursor: pointer;
}

.param-description {
    margin-top: 0.35rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--ink-mute);
    max-width: 30rem;
}

#layout-parameters .param-control .control-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.5rem 0 0;
}

#layout-parameters .param-control .control-row .control-value {
    padding: 0.125rem 0.5rem;
    border: 1px solid var(--line, #d6d3d1);
    border-radius: var(--radius, 2px);
    background: var(--band, #f5f5f4);
    font-size: 0.8125rem;
    min-width: 2.75rem;
}

#layout-parameters .param-control input[type="number"] {
    font-variant-numeric: tabular-nums;
}

#layout-parameters .param-control input[type="range"] {
    flex: 1;
    min-width: 0;
    margin: 0;
    height: 1.25rem;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    cursor: pointer;
}

#layout-parameters .param-control input[type="range"]::-webkit-slider-runnable-track {
    height: 0.25rem;
    border-radius: 999px;
    background: var(--line, #d6d3d1);
}

#layout-parameters .param-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    margin-top: -0.375rem;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--accent, #0f766e);
    border: 2px solid var(--panel, #ffffff);
    box-shadow: 0 0 0 1px var(--line-strong, #a8a29e);
    transition: transform var(--transition-fast, 0.15s ease), box-shadow var(--transition-fast, 0.15s ease);
}

#layout-parameters .param-control input[type="range"]:hover::-webkit-slider-thumb,
#layout-parameters .param-control input[type="range"]:active::-webkit-slider-thumb {
    transform: scale(1.15);
    box-shadow: 0 0 0 3px var(--accent-soft, #ccfbf1);
}

#layout-parameters .param-control input[type="range"]::-moz-range-track {
    height: 0.25rem;
    border-radius: 999px;
    background: var(--line, #d6d3d1);
}

#layout-parameters .param-control input[type="range"]::-moz-range-thumb {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--accent, #0f766e);
    border: 2px solid var(--panel, #ffffff);
    box-shadow: 0 0 0 1px var(--line-strong, #a8a29e);
}

#layout-parameters .param-control input[type="range"]:hover::-moz-range-thumb,
#layout-parameters .param-control input[type="range"]:active::-moz-range-thumb {
    box-shadow: 0 0 0 3px var(--accent-soft, #ccfbf1);
}

/* ============ privacy policy ============ */
.policy {
    max-width: 52rem;
}

.policy h1 {
    font-size: clamp(2rem, 5vw, 3rem);
}

.policy h2 {
    font-size: 1.25rem;
    margin: 2.5rem 0 0.75rem;
}

.policy p {
    margin-top: 0.75rem;
    color: var(--ink-soft, #44403c);
    max-width: 46rem;
}

.policy ul {
    margin: 0.75rem 0 0;
    padding-left: 1.25rem;
    color: var(--ink-soft, #44403c);
}

.policy li {
    margin-top: 0.375rem;
}

.policy li strong {
    color: var(--ink, #1c1917);
}

.policy a {
    color: var(--accent, #0f766e);
}

.policy a:hover {
    color: var(--accent-deep, #134e4a);
}

.meta-role {
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent-deep, #134e4a);
}

.rq-grid {
    margin-top: 2rem;
    display: grid;
    gap: 1.25rem;
}

@media (min-width: 48rem) {
    .rq-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.rq-card {
    background: var(--panel, #ffffff);
    border: 1px solid var(--line, #d6d3d1);
    border-radius: var(--radius, 2px);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
    box-shadow: var(--shadow-sm, 0 1px 2px rgba(0,0,0,0.05));
}

.rq-card h2 {
    font-size: 1.0625rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0;
}

.rq-card p {
    font-size: 0.875rem;
    color: var(--ink-soft, #44403c);
    line-height: 1.55;
}

.metrics-strip {
    display: grid;
    gap: 1rem;
    margin-bottom: 2.5rem;
}

@media (min-width: 48rem) {
    .metrics-strip {
        grid-template-columns: repeat(3, 1fr);
    }
}

.metric-card {
    background: var(--panel, #ffffff);
    border: 1px solid var(--line, #d6d3d1);
    border-radius: var(--radius, 2px);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.metric-val {
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-deep, #134e4a);
    line-height: 1;
}

.metric-lbl {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ink, #1c1917);
}

.metric-sub {
    font-size: 0.75rem;
    color: var(--ink-mute, #57534e);
}

.table-container {
    width: 100%;
    overflow-x: auto;
    margin-block: 1.5rem;
    border: 1px solid var(--line, #d6d3d1);
    background: var(--panel, #ffffff);
    border-radius: var(--radius, 2px);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line, #d6d3d1);
    vertical-align: middle;
}

.data-table th {
    background: var(--band, #f5f5f4);
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--ink-soft, #44403c);
    text-transform: uppercase;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: rgba(15, 118, 110, 0.03);
}

.data-table td.num,
.data-table th.num {
    text-align: right;
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
}

.data-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius, 2px);
    text-transform: uppercase;
}

.data-badge--verified {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.data-badge--stable {
    background: var(--accent-soft, #ccfbf1);
    color: var(--accent-deep, #134e4a);
    border: 1px solid #99f6e4;
}

.data-badge--highlight {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
}

.case-grid {
    display: grid;
    gap: 1.5rem;
    margin-top: 2rem;
}

@media (min-width: 48rem) {
    .case-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.case-card {
    background: var(--panel, #ffffff);
    border: 1px solid var(--line, #d6d3d1);
    border-radius: var(--radius, 2px);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.case-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.case-timing {
    font-family: var(--font-mono, "IBM Plex Mono", ui-monospace, monospace);
    font-size: 0.75rem;
    color: var(--accent-deep, #134e4a);
    background: var(--accent-soft, #ccfbf1);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius, 2px);
}

.case-card h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.case-card p {
    font-size: 0.875rem;
    color: var(--ink-soft, #44403c);
    line-height: 1.55;
}

/* ============ component view (collapsed by default) ============ */
.arch-detail {
    margin-top: 2rem;
    border: 1px solid var(--line, #d6d3d1);
    border-radius: var(--radius, 2px);
    background: var(--panel, #ffffff);
}

.arch-detail > summary {
    cursor: pointer;
    padding: 0.9rem 1.25rem;
    font-weight: 600;
    color: var(--accent-deep, #134e4a);
}

.arch-detail[open] > summary {
    border-bottom: 1px solid var(--line, #d6d3d1);
}

.arch-zoom {
    padding: 1.25rem;
}

.arch-inline {
    display: block;
    margin: 0;
    overflow: visible;
}

.arch-svg {
    width: 100%;
    height: auto;
    display: block;
    font-family: 'IBM Plex Mono', monospace;
}

.arch-svg text {
    font-size: 13px;
    fill: var(--ink, #1c1917);
}

.arch-col-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 16px !important;
    font-weight: 600;
    fill: var(--accent-deep, #134e4a) !important;
}

.arch-group {
    stroke-width: 1;
}

.arch-group--stone {
    fill: #f5f5f4;
    stroke: #a8a29e;
}

.arch-group--teal {
    fill: #f0fdfa;
    stroke: var(--accent, #0f766e);
}

.arch-group-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13px !important;
    font-weight: 600;
    fill: var(--ink-mute, #57534e) !important;
}

.arch-node {
    transform-box: fill-box;
    transform-origin: center;
    animation: node-pop 0.5s ease-out both;
}

.arch-node rect {
    fill: #ffffff;
    stroke: #a8a29e;
    stroke-width: 0.6;
}

.arch-node--teal rect {
    fill: var(--accent-soft, #ccfbf1);
    stroke: var(--accent, #0f766e);
}

.arch-node.is-key rect {
    fill: var(--accent, #0f766e);
    stroke: var(--accent-deep, #134e4a);
}

.arch-node.is-key text {
    fill: #ffffff;
    font-weight: 600;
}

.arch-edge {
    fill: none;
    stroke: var(--accent, #0f766e);
    stroke-width: 1.1;
    opacity: 0.75;
    animation: edge-draw 0.6s ease-out both;
}

.arch-edge.is-strong {
    stroke-width: 2;
    opacity: 1;
}

.arch-edge-label {
    font-size: 11.5px !important;
    fill: var(--accent-deep, #134e4a) !important;
    paint-order: stroke;
    stroke: #ffffff;
    stroke-width: 4px;
    stroke-linejoin: round;
}

/* Zoom was removed: edge labels stay visible in the collapsed view. */
.arch-zoom-caption {
    margin: 1rem 0 0;
}

@media (prefers-reduced-motion: reduce) {
    .arch-node,
    .arch-edge {
        animation: none;
    }
}

.known-limits {
    margin: 0;
    padding-left: 1.25rem;
    display: grid;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--ink-soft, #44403c);
    line-height: 1.55;
}

.case-findings {
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--line, #d6d3d1);
    font-size: 0.8125rem;
    color: var(--ink-mute, #57534e);
}

/* ============ iOS zoom-on-focus ============ */
/* iOS Safari zooms the page when a focused field's font is < 16px;
   keep every focusable field at 1rem on phones. */
@media (max-width: 47.999rem) {

    .mode-panel select,
    .mode-panel input,
    .api-key-field input,
    .editor textarea,
    .code-editor textarea,
    .graph3d-search,
    #layout-parameters .param-control select,
    #layout-parameters .param-control input {
        font-size: 1rem;
    }
}
