:root {
    --stock: #d4dad3;
    --sheet: #f4f5f0;
    --paper: #ffffff;
    --ink: #17201c;
    --ink-soft: #526058;
    --ink-faint: #758179;
    --copper: #b45c2b;
    --copper-soft: #e5c6a8;
    --verdigris: #2f6a62;
    --verdigris-soft: #b9d0ca;
    --rule: #a8b2a8;
    --rule-light: #d2d8d1;
    --danger: #8a3b22;
    --danger-soft: #f0d5c8;
    --code: #121815;
    --code-ink: #d7e0d6;
    --shadow: 0 26px 70px rgba(23, 32, 28, 0.13);
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: light;
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(90deg, transparent 0, transparent calc(100% - 1px), rgba(23, 32, 28, 0.04) calc(100% - 1px)),
        radial-gradient(900px 540px at 92% -8%, rgba(47, 106, 98, 0.11), transparent 54%),
        radial-gradient(700px 440px at -5% 20%, rgba(180, 92, 43, 0.09), transparent 52%),
        var(--stock);
    background-size: 24px 24px, auto, auto, auto;
    font-family: "Source Serif 4", Georgia, serif;
    font-size: 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    content: "";
    pointer-events: none;
    opacity: 0.16;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
    mix-blend-mode: multiply;
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    color: inherit;
}

a {
    color: var(--verdigris);
}

code,
pre,
output,
.header-meta,
.eyebrow,
.panel-kicker,
.deck-index,
.metric-label,
.strip-head,
.strip-legend,
th,
td,
dt,
dd,
.action-code,
.bench-footer {
    font-family: "IBM Plex Mono", ui-monospace, monospace;
}

code {
    padding: 0.06em 0.32em;
    background: rgba(23, 32, 28, 0.06);
    font-size: 0.86em;
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 2px solid var(--verdigris);
    outline-offset: 3px;
}

.bench-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 64px;
    padding: clamp(24px, 4.5vw, 58px);
    background: var(--sheet);
    box-shadow: var(--shadow);
}

.bench-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--rule);
}

.brand {
    color: var(--ink);
    font-family: Inter, sans-serif;
    font-size: 0.94rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-decoration: none;
    text-transform: uppercase;
}

.brand span {
    color: var(--copper);
}

.header-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px 24px;
    color: var(--ink-soft);
    font-size: 0.69rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.engine-state {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.engine-state i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--rule);
}

.engine-state[data-engine-state="up"] i {
    background: var(--verdigris);
    box-shadow: 0 0 0 4px rgba(47, 106, 98, 0.1);
}

.engine-state[data-engine-state="down"] i {
    background: var(--danger);
    box-shadow: 0 0 0 4px rgba(138, 59, 34, 0.1);
}

.bench-intro {
    padding: 28px 0 26px;
}

.eyebrow,
.panel-kicker {
    margin: 0 0 12px;
    color: var(--copper);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

h2,
h3,
p {
    text-wrap: pretty;
}

h2 {
    font-family: Inter, sans-serif;
    letter-spacing: -0.045em;
}

.intro-copy {
    max-width: 62ch;
    margin: 0;
    color: var(--ink-soft);
    font-size: 1.02rem;
    line-height: 1.55;
}

.control-deck {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) 42px;
    border-top: 1px solid var(--ink);
    border-bottom: 1px solid var(--ink);
}

.deck-index {
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid var(--rule);
    color: var(--ink-faint);
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.deck-index-out {
    border-right: 0;
    border-left: 1px solid var(--rule);
}

.benchmark-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(235px, 0.37fr);
    min-width: 0;
}

.source-field {
    min-width: 0;
    padding: clamp(24px, 4vw, 42px);
}

.source-field label {
    display: block;
    margin-bottom: 12px;
    font-family: Inter, sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
}

.url-control {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    border-bottom: 2px solid var(--ink);
    background: var(--paper);
}

.url-control:focus-within {
    border-color: var(--verdigris);
    box-shadow: 0 4px 0 rgba(47, 106, 98, 0.12);
}

.protocol {
    padding: 0 14px;
    color: var(--copper);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
}

.url-control input {
    width: 100%;
    min-width: 0;
    padding: 16px 16px 16px 0;
    border: 0;
    outline: 0;
    color: var(--ink);
    background: transparent;
    font-family: "IBM Plex Mono", monospace;
    font-size: clamp(0.79rem, 1.4vw, 0.92rem);
}

.url-control input::placeholder {
    color: #8c9790;
}

.url-control.is-invalid {
    border-color: var(--danger);
}

.field-note {
    margin: 12px 0 0;
    color: var(--ink-soft);
    font-size: 0.86rem;
}

.run-count-field {
    margin-top: 22px;
}

.run-count-field label {
    margin-bottom: 8px;
    font-size: 0.78rem;
}

.run-count-control {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
}

.run-count-control button {
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--ink);
    background: var(--paper);
    cursor: pointer;
    font-family: "IBM Plex Mono", monospace;
    font-size: 1.1rem;
    line-height: 1;
}

.run-count-control button:hover:not(:disabled) {
    color: var(--paper);
    background: var(--ink);
}

.run-count-control button:disabled {
    cursor: wait;
    opacity: 0.46;
}

.run-count-control input {
    width: 4.2ch;
    height: 36px;
    padding: 0;
    border: 0;
    border-bottom: 2px solid var(--ink);
    background: transparent;
    color: var(--ink);
    font-family: "IBM Plex Mono", monospace;
    font-size: 1.15rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.run-count-control input:focus {
    outline: 0;
    border-color: var(--verdigris);
}

.run-count-control input::-webkit-outer-spin-button,
.run-count-control input::-webkit-inner-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

.run-count-control input[type="number"] {
    appearance: textfield;
}

.run-count-control input.is-invalid {
    border-color: var(--danger);
}

.run-count-hint {
    color: var(--ink-soft);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.68rem;
}

.action-bank {
    display: grid;
    grid-template-rows: 1fr 1fr;
    border-left: 1px solid var(--rule);
}

.action {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 13px;
    align-items: center;
    min-height: 78px;
    padding: 20px 22px;
    border: 0;
    border-bottom: 1px solid var(--rule);
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: color 150ms ease, background 150ms ease;
}

.action:last-child {
    border-bottom: 0;
}

.action:hover:not(:disabled) {
    color: var(--paper);
    background: var(--ink);
}

.action:disabled {
    cursor: wait;
    opacity: 0.46;
}

.action.is-active {
    color: var(--paper);
    background: var(--verdigris);
}

.action-code {
    color: var(--copper);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.08em;
}

.action:hover .action-code,
.action.is-active .action-code {
    color: var(--copper-soft);
}

.action-label {
    font-family: Inter, sans-serif;
    font-size: 0.87rem;
    font-weight: 700;
}

.action svg {
    width: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: square;
    stroke-width: 1.5;
}

.run-state {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 56px;
    padding: 0 42px;
    border-bottom: 1px solid var(--rule);
    color: var(--ink-soft);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
}

.state-copy {
    display: flex;
    align-items: center;
    gap: 10px;
}

.state-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--rule);
}

.run-state[data-state="running"] .state-dot {
    background: var(--copper);
    animation: pulse 1s ease-in-out infinite;
}

.run-state[data-state="success"] .state-dot {
    background: var(--verdigris);
}

.run-state[data-state="error"] .state-dot {
    background: var(--danger);
}

.live-clock {
    color: var(--ink);
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
}

.report,
.error-panel,
.history {
    margin-top: clamp(42px, 7vw, 80px);
}

.error-panel {
    padding: clamp(24px, 4vw, 42px);
    border-left: 4px solid var(--danger);
    background: var(--danger-soft);
}

.error-panel h2 {
    margin: 0 0 8px;
    font-size: clamp(1.5rem, 3vw, 2.4rem);
}

.error-panel p:not(.panel-kicker) {
    margin: 0;
}

.error-panel pre {
    max-height: 260px;
    margin: 22px 0 0;
    padding: 18px;
    overflow: auto;
    color: var(--code-ink);
    background: var(--code);
    font-size: 0.72rem;
    white-space: pre-wrap;
}

.report-header,
.history-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--ink);
}

.report-header h2,
.history-head h2 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.4rem);
    line-height: 1;
}

.report-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.file-action,
.quiet-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 9px 13px;
    border: 1px solid var(--ink);
    border-radius: 0;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.68rem;
    text-decoration: none;
    cursor: pointer;
}

.file-action {
    color: var(--paper);
    background: var(--ink);
}

.file-action:hover {
    background: var(--verdigris);
}

.quiet-action {
    color: var(--ink);
    background: transparent;
}

.quiet-action:hover {
    background: var(--paper);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-bottom: 1px solid var(--rule);
}

.metric {
    min-width: 0;
    padding: clamp(22px, 3vw, 34px) clamp(16px, 2.5vw, 28px);
    border-right: 1px solid var(--rule);
}

.metric:last-child {
    border-right: 0;
}

.metric-primary {
    background: var(--paper);
}

.metric-label {
    display: block;
    margin-bottom: 14px;
    color: var(--ink-soft);
    font-size: 0.63rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.metric strong {
    display: block;
    overflow: hidden;
    font-family: Inter, sans-serif;
    font-size: clamp(1.65rem, 3.3vw, 2.8rem);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.05em;
    line-height: 1;
    text-overflow: ellipsis;
}

.metric small {
    display: block;
    margin-top: 10px;
    color: var(--ink-faint);
    font-size: 0.76rem;
}

.timing-strip {
    padding: 30px 0 36px;
}

.strip-head,
.strip-legend {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--ink-soft);
    font-size: 0.63rem;
}

.strip-track {
    position: relative;
    display: flex;
    height: 24px;
    margin: 10px 0 12px;
    overflow: hidden;
    background: var(--rule-light);
}

.strip-track::before {
    position: absolute;
    inset: 0;
    z-index: 2;
    content: "";
    pointer-events: none;
    background-image: repeating-linear-gradient(90deg, transparent 0, transparent calc(10% - 1px), rgba(23, 32, 28, 0.25) 10%);
}

.strip-service,
.strip-overhead {
    width: 0;
    transition: width 620ms cubic-bezier(.2, .75, .25, 1);
}

.strip-service {
    background: var(--verdigris);
}

.strip-overhead {
    background: var(--copper-soft);
}

.strip-cursor {
    position: absolute;
    top: -5px;
    right: 0;
    bottom: -5px;
    z-index: 3;
    width: 2px;
    background: var(--ink);
}

.strip-legend {
    justify-content: flex-start;
    gap: 22px;
}

.strip-legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.strip-legend i {
    width: 9px;
    height: 9px;
}

.legend-service {
    background: var(--verdigris);
}

.legend-overhead {
    background: var(--copper-soft);
}

.preview-sheet {
    margin: 0;
    border-bottom: 1px solid var(--ink);
}

.preview-sheet figcaption,
.preview-fallback {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 2px 14px;
    color: var(--ink-soft);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.63rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.preview-fallback {
    margin: 0;
    border-bottom: 1px solid var(--rule);
    color: var(--ink-faint);
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.92rem;
    font-family: "Source Serif 4", Georgia, serif;
}

.preview-stage {
    padding: 18px;
    background:
        linear-gradient(90deg, transparent 0, transparent calc(100% - 1px), rgba(23, 32, 28, 0.05) calc(100% - 1px)),
        var(--stock);
    background-size: 24px 24px, auto;
}

.preview-stage iframe {
    display: block;
    width: 100%;
    height: min(86vh, 1120px);
    border: 1px solid var(--ink);
    background: #5c6164;
}

.report-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-top: 1px solid var(--ink);
    border-bottom: 1px solid var(--ink);
}

.fact-sheet {
    padding: clamp(24px, 4vw, 38px);
}

.fact-sheet + .fact-sheet {
    border-left: 1px solid var(--rule);
}

.fact-sheet h3 {
    margin: 0 0 24px;
    font-family: Inter, sans-serif;
    font-size: 0.9rem;
}

.fact-sheet dl {
    margin: 0;
}

.fact-sheet dl div {
    display: grid;
    grid-template-columns: minmax(92px, 0.42fr) minmax(0, 1fr);
    gap: 16px;
    padding: 10px 0;
    border-top: 1px solid var(--rule-light);
}

.fact-sheet dt,
.fact-sheet dd {
    margin: 0;
    font-size: 0.68rem;
}

.fact-sheet dt {
    color: var(--ink-faint);
}

.fact-sheet dd {
    overflow-wrap: anywhere;
    text-align: right;
}

.status-ok {
    color: var(--verdigris);
}

.fact-url {
    max-height: 4.5em;
    overflow: auto;
}

.debug-drawer {
    margin-top: 22px;
    border: 1px solid var(--ink);
    background: var(--code);
}

.debug-drawer summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 17px 20px;
    color: var(--code-ink);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.74rem;
    cursor: pointer;
}

.debug-drawer summary small {
    color: #87938a;
}

.debug-drawer pre {
    max-height: 520px;
    margin: 0;
    padding: 22px;
    overflow: auto;
    border-top: 1px solid #354039;
    color: var(--code-ink);
    font-size: 0.71rem;
    line-height: 1.6;
}

.history-empty {
    padding: 34px 0;
    border-bottom: 1px solid var(--rule);
    color: var(--ink-soft);
}

.history-table-wrap {
    overflow-x: auto;
}

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

.history th,
.history td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--rule-light);
    white-space: nowrap;
}

.history th {
    color: var(--ink-faint);
    font-weight: 500;
}

.history td:first-child,
.history th:first-child {
    padding-left: 0;
}

.history td:last-child,
.history th:last-child {
    padding-right: 0;
    text-align: right;
}

.history-format {
    color: var(--copper);
    font-weight: 600;
}

.history tbody tr:not(.history-url-row) td {
    border-bottom: 0;
    padding-bottom: 4px;
}

.history-url-row td {
    padding-top: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: left;
}

.history-url-row a {
    color: var(--ink);
    text-underline-offset: 2px;
}

.history-url-row a:hover {
    color: var(--copper);
}

.bench-footer {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    margin-top: 64px;
    padding-top: 18px;
    border-top: 1px solid var(--rule);
    color: var(--ink-soft);
    font-size: 0.64rem;
}

.bench-footer a {
    color: var(--ink);
}

noscript {
    display: block;
    padding: 20px;
    color: white;
    background: var(--danger);
    text-align: center;
}

@keyframes pulse {
    0%, 100% { opacity: 0.38; transform: scale(0.85); }
    50% { opacity: 1; transform: scale(1.2); }
}

@media (max-width: 860px) {
    .benchmark-form {
        grid-template-columns: 1fr;
    }

    .action-bank {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto;
        border-top: 1px solid var(--rule);
        border-left: 0;
    }

    .action {
        border-right: 1px solid var(--rule);
        border-bottom: 0;
    }

    .action:last-child {
        border-right: 0;
    }

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

    .metric:nth-child(2) {
        border-right: 0;
    }

    .metric:nth-child(-n + 2) {
        border-bottom: 1px solid var(--rule);
    }
}

@media (max-width: 620px) {
    .bench-shell {
        width: 100%;
        margin: 0;
        padding: 22px 18px 34px;
    }

    .bench-header,
    .report-header,
    .history-head,
    .bench-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-meta {
        justify-content: flex-start;
    }

    .control-deck {
        grid-template-columns: 28px minmax(0, 1fr);
    }

    .deck-index-out {
        display: none;
    }

    .source-field {
        padding: 22px 18px;
    }

    .action-bank {
        grid-template-columns: 1fr;
    }

    .action {
        border-right: 0;
        border-bottom: 1px solid var(--rule);
    }

    .action:last-child {
        border-bottom: 0;
    }

    .run-state {
        padding: 0 0 0 28px;
    }

    .report-actions {
        justify-content: flex-start;
    }

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

    .metric,
    .metric:nth-child(2) {
        border-right: 0;
        border-bottom: 1px solid var(--rule);
    }

    .metric:last-child {
        border-bottom: 0;
    }

    .preview-stage {
        padding: 12px;
    }

    .preview-stage iframe {
        height: min(78vh, 820px);
    }

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

    .fact-sheet + .fact-sheet {
        border-top: 1px solid var(--rule);
        border-left: 0;
    }

    .debug-drawer summary {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
