/*
 Copyright 2026 Google LLC
 SPDX-License-Identifier: Apache-2.0
*/

* {
    box-sizing: border-box;
}

body {
    font-family: 'Public Sans', system-ui, -apple-system, sans-serif;
    margin: 0;
    background-color: var(--bg);
    color: var(--body);
    line-height: 1.5;
}

h1, h2, h3 { color: var(--heading); }
h1 { font-size: 1.6rem; font-weight: 800; margin: 0 0 24px; }
h2 { font-size: 1.15rem; font-weight: 700; margin: 28px 0 12px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Shell: the sections in a sidebar beside the page, each with its figure
   and a sparkline. On a phone the sidebar folds into a bar over the page
   with the sections in a scrolling row. */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; align-self: start; height: 100vh; display: flex; flex-direction: column; gap: 18px; padding: 20px 14px; background: var(--side); border-right: 1px solid var(--side-border); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 10px; color: var(--heading); font-size: 15px; font-weight: 800; }
.brand:hover { text-decoration: none; }
.mark { display: block; border-radius: 6px; }
.secs { display: flex; flex-direction: column; gap: 2px; }
.secs a { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 2px 10px; padding: 10px 12px; border-radius: 8px; color: var(--secondary); }
.secs a:hover { background: color-mix(in srgb, #fff 55%, transparent); text-decoration: none; }
.secs a[aria-current="page"] { background: #fff; color: var(--heading); box-shadow: 0 1px 2px rgb(28 25 23 / 8%); }
.sec-label { font-size: 13px; font-weight: 600; }
.spark { grid-row: span 2; align-self: center; }
.spark path { fill: none; stroke: var(--viz-ok); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark.bars path { fill: var(--viz-ok); stroke: none; }
.sec-fig { grid-column: 1; color: var(--heading); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sec-unit { color: var(--muted); font-size: 11.5px; font-weight: 500; }
.side-foot { margin: auto 0 0; padding: 0 10px; color: var(--muted); font-size: 12px; }
.page { min-width: 0; max-width: 1180px; padding: 24px 34px 48px; }

@media (max-width: 760px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px 0; border-right: none; border-bottom: 1px solid var(--side-border); }
    .side-foot { margin: 0; padding: 0; }
    .secs { order: 1; flex: 0 0 100%; flex-direction: row; gap: 4px; padding-bottom: 10px; overflow-x: auto; scrollbar-width: none; }
    .secs a { flex: none; display: flex; flex-direction: column; justify-content: center; gap: 0; padding: 4px 12px; }
    .spark { display: none; }
    .sec-label { font-size: 12px; }
    .sec-fig { font-size: 14px; }
    .page { padding: 16px 16px 40px; }
}

/* Page-load progress bar, set by the layout script. The delay keeps fast
   loads from flashing it. */
html.navigating::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    height: 2px;
    background: var(--accent);
    transform-origin: left;
    animation: navigating 8s cubic-bezier(0.1, 0.6, 0.2, 1) 150ms both;
}
@keyframes navigating {
    from { transform: scaleX(0); }
    to { transform: scaleX(0.9); }
}
@media (prefers-reduced-motion: reduce) {
    html.navigating::before { animation: none; opacity: 0.6; }
}

/* Tables (index recent rebuilds, package & attempt views) */
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
    font-variant-numeric: tabular-nums;
}
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--fill); color: var(--heading); font-weight: 600; font-size: 0.85rem; }
tr:last-child td { border-bottom: none; }
tr:hover > td { background: color-mix(in srgb, var(--fill) 60%, transparent); }
time { white-space: nowrap; }

.status-success { color: var(--accent); font-weight: 600; }
.status-fail { color: var(--mismatch); font-weight: 600; }
.status-success, .status-fail, .status-running { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.status-success::before, .status-fail::before, .status-running::before {
    content: "";
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

/* Record lists: a row per record over two lines, its identity and time on
   the first and why it failed on the second, narrow enough for a phone. */
.rows { list-style: none; margin: 0 0 20px; padding: 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.row { display: flex; flex-direction: column; gap: 2px; padding: 9px 14px; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: none; }
.row-head, .row-sub { display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-sub { padding-left: 16px; font-size: 0.85rem; color: var(--secondary); }
.row-name { font-weight: 600; }
.row-ver { flex-shrink: 0; max-width: 11em; color: var(--secondary); font-variant-numeric: tabular-nums; }
.row-var { flex-shrink: 10; color: var(--muted); font-size: 0.85rem; }
.row-name, .row-ver, .row-var, .cause, .note { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-end { flex: none; display: inline-flex; gap: 8px; margin-left: auto; color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
a.row-end:hover { color: var(--heading); text-decoration: none; }
.tag { flex: none; padding: 0 7px; border: 1px solid var(--border); border-radius: 999px; background: var(--fill); color: var(--secondary); font-size: 0.72rem; font-weight: 600; line-height: 18px; }
.stage { flex: none; padding: 0 5px; border: 1px solid color-mix(in srgb, var(--muted) 45%, transparent); border-radius: 3px; color: var(--secondary); font-size: 0.66rem; font-weight: 700; letter-spacing: 0.05em; line-height: 16px; text-transform: uppercase; }
/* A failure message shows its start and keeps the whole message in its
   title. Touch has no hover, so tapping one that is not a link expands it. */
.cause { color: var(--secondary); font-family: ui-monospace, monospace; font-size: 0.8rem; }
span.cause:focus { white-space: normal; overflow-wrap: anywhere; outline: none; }
.pip { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--viz-live); }
.pip.ok { background: var(--viz-ok); }
.pip.bad { background: var(--viz-bad); }
.pip.warn { background: var(--viz-warn); }
.tone-ok, .tone-bad, .tone-warn { font-weight: 600; }
.tone-ok { color: var(--accent); }
.tone-bad { color: var(--mismatch); }
.tone-warn { color: var(--failure); }
/* A package's page drops the package from its rows and names each row's
   kind and outcome. A version's page also drops the version. */
.row-kind, .row-outcome { display: none; }
.rows.in-package .row-kind, .rows.in-package .row-outcome, .rows.in-version .row-outcome { display: inline; }
.rows.in-package .row-pkg, .rows.in-version .row-pkg, .rows.in-version .row-ver { display: none; }
/* Filter chips: hidden radios inside a .rowlist. Checking f-<key> leaves
   only the is-<key> rows. */
.list-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin: 28px 0 12px; }
.list-head h2 { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { padding: 2px 10px; border: 1px solid var(--border); border-radius: 999px; background: #fff; color: var(--secondary); font-size: 0.82rem; font-weight: 600; cursor: pointer; }
.tab-radio:checked + .chip { border-color: var(--heading); background: var(--heading); color: var(--bg); }
.tab-radio:focus-visible + .chip { outline: 2px solid var(--accent); outline-offset: 2px; }
.rowlist:has(.f-bad:checked) .row:not(.is-bad),
.rowlist:has(.f-ok:checked) .row:not(.is-ok),
.rowlist:has(.f-done:checked) .row:not(.is-done),
.rowlist:has(.f-live:checked) .row:not(.is-live) { display: none; }

/* Preformatted blocks (package & attempt views) */
pre {
    background: var(--fill);
    color: var(--body);
    padding: 15px;
    overflow: auto;
    border-radius: 6px;
    border: 1px solid var(--border);
    max-height: 500px;
}

/* Benchmark coverage grid (index view): one tile per tracked package. */
.benchmark-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}
.benchmark-item {
    padding: 10px;
    text-align: center;
    font-weight: 600;
    border-radius: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
    display: block;
}
.bg-green { background-color: var(--accent); color: #fff; }
.bg-red { background-color: var(--mismatch); color: #fff; }
.bg-gray { background-color: var(--fill); color: var(--muted); }

/* Sessions and running status */
.hint { color: var(--muted); font-size: 0.85rem; margin: 4px 0 0; }
.status-running { color: var(--failure); font-weight: 600; }
.session { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; background: #fff; }
.session-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.session-id { font-family: ui-monospace, monospace; font-size: 0.85rem; color: var(--secondary); }
.session-meta { color: var(--muted); font-size: 0.85rem; }
.session-summary { margin: 6px 0; color: var(--body); }
.session table { margin-top: 8px; }

/* Session trajectory. */
.traj-iter { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; background: #fff; }
.traj-iter-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.traj-event { border-left: 3px solid var(--border); padding: 4px 10px; margin: 8px 0; }
.traj-event.kind-model { border-left-color: var(--accent); }
.traj-event.kind-call, .traj-event.kind-proposal { border-left-color: var(--heading); }
.traj-event.kind-thought, .traj-event.kind-prompt { border-left-color: var(--muted); }
.traj-event.kind-exec { border-left-color: var(--secondary); }
.traj-event.kind-build { border-left-color: var(--mismatch); }
.traj-event.kind-handoff { border-left-color: var(--accent); }
.traj-event.kind-review, .traj-event.kind-formalize { border-left-color: var(--heading); }
.traj-event.kind-giveup { border-left-color: var(--mismatch); }
.traj-kind { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--secondary); margin-right: 8px; }
.traj-time { color: var(--muted); font-size: 0.8rem; }
.traj-text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 500px; overflow: auto; }
details.traj-body > summary { cursor: pointer; color: var(--secondary); font-size: 0.85rem; }

/* Session page: the session's figures, its time as one strip, and a row per
   candidate with a cell per stage. Compare and Review cells open a popout,
   and each row opens a drawer of the calls after it. */
.mono { font-family: ui-monospace, monospace; }
.page-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 18px; }
.crumbs { color: var(--muted); font-size: 0.85rem; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.title-row h1 { margin: 0; overflow-wrap: anywhere; }
.outcome { padding: 1px 10px; border-radius: 999px; background: var(--fill); font-size: 0.78rem; font-weight: 700; }
.outcome.tone-ok { background: #ccfbf1; }
.outcome.tone-bad { background: #fee2e2; }
.outcome.tone-warn { background: #fef3c7; }
.card.figs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 14px 0; margin-bottom: 18px; }
.figs > div { padding: 0 18px; }
.figs > div + div { border-left: 1px solid var(--viz-grid); }
.fig-label { display: block; color: var(--muted); font-size: 0.72rem; }
.fig-value { display: block; color: var(--heading); font-size: 0.95rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.fig-value small { color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.card.strip-card, .card.cands { margin-bottom: 18px; }
.strip-head, .cands-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; color: var(--muted); font-size: 0.78rem; }
.strip { position: relative; height: 26px; border-radius: 5px; background: var(--viz-none); overflow: hidden; }
.sp { position: absolute; top: 0; bottom: 0; }
.sp-setup { --c: var(--viz-setup); }
.sp-timeout { --c: var(--viz-bad); }
.sp-build { --c: var(--viz-ok); }
.sp-verify { --c: var(--viz-stage-replay); }
.sp-other { --c: var(--viz-none); }
.strip .sp { background: var(--c); }
.strip-ticks { position: relative; height: 16px; color: var(--muted); font-size: 0.68rem; }
.strip-ticks span { position: absolute; top: 2px; transform: translateX(-50%); }
.cand-grid { display: grid; grid-template-columns: 24px 64px minmax(0, 1fr) 62px repeat(7, 52px) 58px; gap: 6px; align-items: center; }
.stages { display: contents; }
.cand-cols { padding-bottom: 4px; border-bottom: 1px solid var(--viz-grid); color: var(--muted); font-size: 0.7rem; font-weight: 700; }
.cand-cols .stages span { text-align: center; }
.cand-cols .r, .calls-toggle, .took { text-align: right; }
.cand-list { margin: 0; padding: 0; list-style: none; }
.cand { border-bottom: 1px solid var(--viz-grid); }
.cand > .cand-grid { padding: 5px 0; }
.cand .n { text-align: right; color: var(--secondary); font-weight: 700; font-variant-numeric: tabular-nums; }
.cand .t, .took { color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.chg { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.85rem; }
.chg.mono { font-size: 0.78rem; }
.row-hit { display: contents; cursor: pointer; }
.cand > .cand-grid:has(> .row-hit:hover) { background: color-mix(in srgb, var(--fill) 70%, transparent); }
.calls-toggle { display: inline-flex; align-items: center; justify-content: flex-end; gap: 7px; color: var(--accent); font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.calls-toggle::before { content: ""; width: 7px; height: 7px; margin-top: -2px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform 0.15s; }
.cand:has(> .drawer-toggle:checked) .calls-toggle::before { margin-top: -5px; transform: rotate(45deg); }
.drawer { display: none; margin: 0 0 6px 30px; padding: 8px 14px; border-left: 2px solid var(--side-border); border-radius: 0 0 8px 8px; background: var(--fill); }
.cand:has(> .drawer-toggle:checked) > .drawer { display: block; }
.drawer-cmd { margin: 0 0 6px; padding: 6px 8px; max-height: 12em; overflow: auto; border-radius: 5px; background: #fff; font-size: 0.75rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.drawer-sum { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 8px 0 4px; color: var(--secondary); font-size: 0.8rem; }
.drawer-text { padding: 6px 8px; border-radius: 5px; background: #fff; font-size: 0.8rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 28px; margin-bottom: 8px; }
.facts > div { display: flex; flex-direction: column; min-width: 0; }
.facts .fact-wide { flex: 1 0 100%; }
.fact-k { color: var(--muted); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.fact-v { font-size: 0.85rem; overflow-wrap: anywhere; }
.verdict { border-bottom: none; border-top: 2px solid var(--viz-grid); }
.verdict .pip { display: inline-block; width: 10px; height: 10px; }
.verdict .chg b { font-weight: 700; }
.verdict-box { grid-column: 5 / span 7; min-width: 0; padding: 3px 10px; border-radius: 5px; background: var(--fill); color: var(--secondary); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.callrow { display: grid; grid-template-columns: 62px 104px minmax(0, 1fr) 92px; gap: 10px; align-items: baseline; padding: 3px 0; border-top: 1px solid var(--border); font-size: 0.78rem; }
.callrow > .mono, .callrow .tool { color: var(--muted); }
.callrow > a.mono:hover { color: var(--accent); }
.callrow .tool { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.callrow code { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--body); }
.callrow .res { text-align: right; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.callrow.bad .res { color: var(--mismatch); }
.callrow:target { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.linkish { all: unset; cursor: pointer; color: var(--accent); font-size: 0.78rem; font-weight: 600; text-align: left; }
.linkish:hover { text-decoration: underline; }
.cands-head .linkish + .linkish { margin-left: 14px; }
.cell { display: flex; align-items: center; justify-content: center; height: 24px; border-radius: 5px; font-size: 0.72rem; font-weight: 700; white-space: nowrap; }
.st-ok { background: #ccfbf1; color: var(--accent); }
.st-reused { box-shadow: inset 0 0 0 1px #99d8cf; color: #5eb7a9; }
.st-timeout { box-shadow: inset 0 0 0 1.5px var(--viz-bad); color: var(--mismatch); }
.st-failed { background: #fee2e2; color: var(--mismatch); }
.st-off { background: #fef3c7; color: #92400e; }
.st-match { background: var(--viz-ok); color: #fff; }
.st-none { color: #d6d3d1; }
details.pop { position: relative; }
summary.cell { position: relative; list-style: none; cursor: pointer; }
summary.cell::-webkit-details-marker { display: none; }
summary.cell::after, .cell.notch::after { content: ""; position: absolute; right: 3px; bottom: 3px; border-left: 4px solid transparent; border-bottom: 4px solid currentColor; opacity: 0.55; }
.cell.notch { position: relative; width: 30px; height: 18px; box-shadow: inset 0 0 0 1px var(--border); color: var(--muted); }
summary.cell:hover { box-shadow: 0 0 0 2px var(--border); }
details.pop[open] > summary.cell { box-shadow: 0 0 0 2px var(--heading); }
.cand-legend { margin-top: 12px; font-size: 0.75rem; color: var(--secondary); }
.cand-legend .cell { width: 30px; height: 18px; }
.popout { position: absolute; z-index: 5; top: calc(100% + 8px); right: -6px; width: 460px; display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border: 1px solid #d6d3d1; border-radius: 10px; background: #fff; box-shadow: 0 10px 30px rgb(28 25 23 / 16%), 0 2px 6px rgb(28 25 23 / 8%); font-size: 0.8rem; line-height: 1.5; color: var(--body); }
.popout::before { content: ""; position: absolute; top: -6px; right: 26px; width: 10px; height: 10px; border-left: 1px solid #d6d3d1; border-top: 1px solid #d6d3d1; background: #fff; transform: rotate(45deg); }
.pop-head { display: flex; align-items: baseline; gap: 8px; }
.pop-head b { color: var(--heading); font-size: 0.85rem; }
.pop-head .mono { color: var(--muted); font-size: 0.72rem; }
.pop-close { all: unset; margin-left: auto; padding: 0 4px; color: var(--muted); cursor: pointer; }
.pop-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; color: var(--muted); font-size: 0.72rem; }
.pchip { padding: 1px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.pchip.tone-ok { background: #ccfbf1; }
.pchip.tone-warn { background: #fef3c7; color: #92400e; }
.pchip.tone-bad { background: #fee2e2; }
.pop-lead { margin: 0; font-size: 0.82rem; }
.pop-group { display: flex; flex-direction: column; max-height: 22em; overflow: auto; }
.pop-group .eyebrow { padding-bottom: 4px; }
.pop-item { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 8px; align-items: start; padding: 5px 0; border-top: 1px solid var(--viz-grid); }
.pop-item > div { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.pop-tag { display: flex; align-items: center; justify-content: center; height: 20px; border-radius: 4px; font-size: 0.68rem; font-weight: 700; }
.m-differ { background: #fef3c7; color: #92400e; }
.m-upstream, .m-candidate { background: var(--viz-none); color: var(--secondary); }
.m-rule { background: #fee2e2; color: var(--mismatch); }
.m-decl { background: #ccfbf1; color: var(--accent); }
.pop-main { font-weight: 600; }
.pop-note { color: var(--secondary); font-size: 0.75rem; }
.pop-code { margin: 3px 0 0; padding: 6px 8px; border-radius: 5px; background: var(--fill); font-size: 0.72rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.pop-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding-top: 8px; border-top: 1px solid var(--viz-grid); color: var(--muted); font-size: 0.75rem; }
.pop-foot a, .pop-foot .linkish { flex: none; }
.page-links { margin: 0; color: var(--muted); font-size: 0.85rem; }
.traj-event:target { background: color-mix(in srgb, var(--accent) 8%, transparent); }

@media (max-width: 760px) {
    .card.figs { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 0; }
    .figs > div:nth-child(4) { border-left: none; }
    .cand-cols { display: none; }
    .cand-grid { grid-template-columns: 22px minmax(0, 1fr) auto; row-gap: 4px; }
    .cand .t, .took { display: none; }
    .stages { display: grid; grid-column: 2 / -1; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
    .verdict-box { grid-column: 2 / -1; }
    .drawer { margin-left: 0; }
    .callrow { grid-template-columns: 56px minmax(0, 1fr) auto; }
    .callrow .tool { display: none; }
    .popout { position: fixed; top: auto; bottom: 12px; left: 12px; right: 12px; width: auto; max-height: 75vh; overflow: auto; }
    .popout::before { display: none; }
}

/* Summary cards. */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 12px;
}
.card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 2px rgba(28, 25, 23, 0.04);
}
.card-value { font-size: 1.9rem; }
.card-label { color: var(--secondary); font-size: 0.9rem; margin-top: 4px; }

/* Legends: each series' swatch or mark beside its name. */
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 8px; font-size: 0.85rem; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }

/* Tabs: links to filtered views, the current one marked server-side.
   .tab-radio hides the radios behind filter chips. */
.tab-radio { position: absolute; opacity: 0; width: 0; height: 0; }
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}
.tab {
    padding: 8px 16px;
    white-space: nowrap;
    cursor: pointer;
    color: var(--muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    font-weight: 600;
}
.tab:hover { color: var(--secondary); }
.tabs a.tab:hover { text-decoration: none; }
.tabs a.active { color: var(--heading); border-bottom-color: var(--accent); }

/* Win-loss strip of recent builds: successes (.ok) rise above the midline and
   failures, unmarked to keep the markup small, drop below it. A fixed width
   right-aligns the newest build on every row. Sized for recentBuilds in
   packages.go. */
.beads {
    display: inline-flex;
    justify-content: flex-end;
    gap: 2px;
    width: 70px;
    height: 15px;
    vertical-align: middle;
    background: linear-gradient(var(--border), var(--border)) center / 100% 1px no-repeat;
}
.beads i { flex: none; width: 4px; height: 7px; align-self: flex-end; background: var(--mismatch); border-radius: 0 0 2px 2px; }
.beads .ok { align-self: flex-start; background: var(--accent); border-radius: 2px 2px 0 0; }

/* Badges naming a kind or severity. */
.badge {
    display: inline-block;
    padding: 1px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--fill);
    color: var(--secondary);
    font-size: 0.78rem;
    font-weight: 600;
}

/* Shared page furniture: snapshot timestamps, de-emphasized values, magnitude
   bars, and the definitions behind a "?" marker. A hidden definition is
   display: none so it adds no scrollable width at the page edge. */
.asof { color: var(--muted); }
.muted { color: var(--muted); }
.bar { background-color: var(--accent); height: 12px; border-radius: 2px; min-width: 1px; }
.info { display: inline-block; position: relative; margin-left: 5px; width: 1.15em; height: 1.15em; line-height: 1.15em; border-radius: 50%; border: 1px solid var(--border); background: var(--fill); color: var(--muted); font-size: 0.72rem; font-weight: 600; text-align: center; vertical-align: middle; cursor: help; }
.info::after { content: attr(data-tip); position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%); width: max-content; max-width: 22em; padding: 6px 10px; border-radius: 4px; background: var(--heading); color: var(--bg); font-size: 0.8rem; font-weight: 400; letter-spacing: normal; text-transform: none; line-height: 1.4; text-align: left; white-space: normal; display: none; z-index: 1; }
.info:hover::after, .info:focus-visible::after { display: block; }
.info:focus-visible { outline-offset: 1px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 18%, transparent); }
summary:hover { color: var(--heading); }

@media (max-width: 640px) {
    /* Wide tables scroll within themselves instead of the page. */
    table { display: block; overflow-x: auto; }
    th, td { padding: 8px 10px; }
    .cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
    .card { padding: 14px 16px; }
    .card-value { font-size: 1.6rem; }
    .row { padding: 10px 12px; }
    .rows:not(.in-version) .row-var { display: none; }
    .chip { padding: 8px 12px; }
    .tabs { overflow-x: auto; scrollbar-width: none; }
}

@media print {
    body { background: #fff; }
    .shell { display: block; }
    .side, .info, html.navigating::before { display: none; }
    a { color: inherit; }
    tr, .card, .session, .traj-event { break-inside: avoid; }
    pre, .traj-text { max-height: none; overflow: visible; white-space: pre-wrap; }
}

/* Overview bands: headline figures, part-to-whole bars, and the marks
   charts.js draws. Series classes set --c, which every mark, swatch, and
   tooltip key reads. */
.ok { --c: var(--viz-ok); }
.warn { --c: var(--viz-warn); }
/* A failure with a retry waiting or running: warn, faded toward queued. */
.retry { --c: color-mix(in srgb, var(--viz-warn) 40%, var(--viz-none)); }
.bad { --c: var(--viz-bad); }
.none { --c: var(--viz-none); }
.live { --c: var(--viz-live); }
.muted { --c: var(--muted); }
.stage-replay { --c: var(--viz-stage-replay); }
.stage-infer { --c: var(--viz-stage-infer); }
.stage-agent { --c: var(--viz-stage-agent); }
.ok-deep { --c: var(--viz-ok-deep); }
.cost-builder { --c: var(--viz-cost-builder); }
.cost-infer { --c: var(--viz-cost-infer); }
.cost-guest { --c: var(--viz-cost-guest); }
.cost-llm { --c: var(--viz-cost-llm); }

.eyebrow { display: flex; align-items: center; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
/* Proportional digits, since these never stack in a column. */
.hero-figure, .figure-value, .tile-value, .card-value {
    font-weight: 650;
    color: var(--heading);
    letter-spacing: -0.02em;
    line-height: 1.05;
}
.hero-figure { font-size: 3.4rem; margin: 8px 0 6px; }
.hero-sub { color: var(--secondary); margin-bottom: 18px; }
.hero-sub b, .chart-sub b { color: var(--heading); }
/* A clause that wraps as one unit, so a figure keeps its noun. */
.nobreak { white-space: nowrap; }
.chart-title { display: flex; align-items: center; font-weight: 600; color: var(--heading); font-size: 0.95rem; margin-bottom: 4px; }
.chart-sub { color: var(--secondary); font-size: 0.85rem; }
.chart-note { color: var(--muted); font-size: 0.8rem; }

.eco-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 10px; }
.eco-card { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px 14px; }
.eco-head { display: flex; justify-content: space-between; align-items: baseline; }
.eco-head h3 { margin: 0; font-size: 1rem; }
.eco-head a { font-size: 0.85rem; }
.figure { display: flex; align-items: baseline; gap: 10px; margin-top: 4px; }
.figure-value { font-size: 2.3rem; }
.figure-pct { font-size: 1.05rem; font-weight: 600; color: var(--secondary); }
.figure-label { color: var(--muted); font-size: 0.85rem; }

/* Part-to-whole bar: flex-grow carries each count and a 2px surface gap
   separates the segments. */
.segbar {
    display: flex;
    gap: 2px;
    height: 12px;
    margin: 8px 0;
    border-radius: 4px;
    overflow: hidden;
    animation: viz-reveal 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.seg { flex: 1 1 0; min-width: 2px; background: var(--c); transition: filter 0.15s; }
.seg:hover { filter: brightness(1.12) saturate(1.1); }
.swatch { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.swatch.none { box-shadow: inset 0 0 0 1px rgba(28, 25, 23, 0.08); }
.legend .legend-item { color: var(--secondary); }

.band { display: grid; grid-template-columns: 2fr 3fr; gap: 16px; margin: 8px 0 18px; }
.band-main .hero-figure { font-size: 2.8rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin: 8px 0 20px; }
.tile { padding: 16px 18px 10px; }
.tile-value { font-size: 1.9rem; margin: 8px 0 10px; }
.chart-card { padding: 16px 18px 12px; margin-bottom: 14px; }
.outcomes { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 20px; }
.outcome-row { display: grid; grid-template-columns: 80px 1fr 64px; align-items: center; gap: 12px; }
.outcome-row .segbar { height: 16px; margin: 0; }
.outcome-name { font-weight: 600; color: var(--heading); }
.outcome-total { text-align: right; color: var(--secondary); font-variant-numeric: tabular-nums; }
.tier-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 10px 0 4px; }
.tier-tile { display: grid; gap: 14px; padding: 12px 14px 14px; border-radius: 8px; background: var(--fill); }
.tier-tile h3 { margin: 0; font-size: 0.95rem; }
.tier-row { display: grid; grid-template-columns: 4.4rem 1fr 2.8rem; gap: 8px; align-items: center; font-variant-numeric: tabular-nums; }
.tier-label { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.tier-row .segbar { height: 26px; margin: 0; }
.tier-row b { text-align: right; color: var(--heading); }
.tier-row.weak b { color: var(--viz-warn); }
table.spend { width: 100%; margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
table.spend td.mixcell { width: 55%; }
table.spend .segbar { height: 14px; margin: 0; }
table.spend th, table.spend td:not(.mixcell) { white-space: nowrap; }
@media (max-width: 640px) {
    table.spend th, table.spend td { padding-inline: 6px; }
}
@media (max-width: 760px) {
    .band { grid-template-columns: 1fr; }
    .hero-figure { font-size: 2.8rem; }
}

/* Home: the headline figures over their running counts, a tile per
   ecosystem, builds and campaigns side by side, then the give-ups to
   triage. Below 1080px beside the sidebar the three figures no longer fit
   one row, so the lead takes its own and the paired panels stack. */
.home { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; margin-bottom: 8px; }
.home .card { padding: 20px 24px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 14px; margin-bottom: 10px; }
.home .legend { gap: 4px 14px; font-size: 0.82rem; }
.panel-head .legend { margin: 0; }
.headline { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 14px 28px; margin-bottom: 14px; }
.headline > div + div { padding-left: 24px; border-left: 1px solid var(--viz-grid); }
.headline .hero-figure { margin: 6px 0 4px; }
.headline .figure-value { margin: 6px 0 4px; line-height: 1.05; }
.headline .hero-sub { margin: 0; }
.eco-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); overflow: hidden; }
.home .card.eco-tiles { padding: 0; }
/* Each tile rules its left and top edges, and the card clips the rules on
   its outer edges however the tiles wrap. */
.eco-tile { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px; color: inherit; box-shadow: -1px 0 var(--viz-grid), 0 -1px var(--viz-grid); }
.eco-tile:hover { background: color-mix(in srgb, var(--fill) 60%, transparent); text-decoration: none; }
.eco-tile-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; color: var(--heading); }
.eco-tile-head span { color: var(--muted); font-size: 0.75rem; }
.eco-tile-fig { color: var(--heading); font-size: 1.9rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.05; }
.eco-tile-fig.weak { color: var(--failure); }
.eco-tiers { display: grid; gap: 5px; }
.eco-tier { display: grid; grid-template-columns: 3.4rem minmax(0, 1fr) 2.2rem; gap: 6px; align-items: center; color: var(--secondary); font-size: 0.75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.eco-tier > :last-child { text-align: right; }
.track { display: block; height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.track > span { display: block; height: 100%; border-radius: 3px; background: var(--c); }
.eco-tile-foot { padding-top: 8px; border-top: 1px solid var(--viz-grid); color: var(--secondary); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.home-pair { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; }
.home .outcomes { margin: 4px 0 0; }
.home .outcome-row .segbar { height: 14px; }
.home .card.attention { padding: 18px 0 0; }
.attention .panel-head { padding: 0 24px; }
.attention .rows { margin: 0; border: none; border-top: 1px solid var(--border); border-radius: 0 0 8px 8px; }
.attention .row { padding-inline: 24px; }
@media (max-width: 1080px) {
    .headline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .headline > :first-child { grid-column: 1 / -1; }
    .headline > :nth-child(2) { padding-left: 0; border-left: none; }
    .headline > :nth-child(n+2) { padding-top: 12px; border-top: 1px solid var(--viz-grid); }
    .home-pair { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
    .home { gap: 14px; }
    .home .card { padding: 16px; }
    .headline .hero-figure { font-size: 2.6rem; }
    .headline .figure-value { font-size: 1.5rem; }
    .headline .hero-sub { font-size: 0.85rem; }
    /* A tile becomes a row: the figures on the left, the tiers on the right. */
    .eco-tiles { grid-template-columns: minmax(0, 1fr); }
    .eco-tile { display: grid; grid-template-columns: minmax(0, 1fr) 10rem; grid-template-areas: "head tiers" "fig tiers" "foot tiers"; gap: 2px 14px; padding: 10px 16px; }
    .eco-tile-head { grid-area: head; }
    .eco-tile-fig { grid-area: fig; font-size: 1.4rem; }
    .eco-tiers { grid-area: tiers; align-self: center; }
    .eco-tile-foot { grid-area: foot; padding-top: 0; border-top: none; }
    .home .card.attention { padding: 14px 0 0; }
    .attention .panel-head { padding: 0 16px; }
    .attention .row { padding-inline: 16px; }
}

/* Series charts: the group color, legend keys, and threshold zones. */
.group { --c: var(--viz-live); }
.key-line, .key-dash { display: inline-block; flex: none; width: 16px; height: 0; border-top: 2px solid var(--c); }
.key-dash { border-top-style: dashed; }
.chart .zone { fill: var(--c); fill-opacity: 0.06; }
.chart .thresh { stroke: var(--viz-bad); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart path.line.dash { stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .group path.line { stroke-width: 1.5; stroke-opacity: 0.75; }

.chart svg { display: block; overflow: visible; }
.chart .rise path { fill: var(--c); }
.chart path.area { fill: var(--c); fill-opacity: 0.1; }
.chart path.line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart circle.dot { fill: var(--c); stroke: #fff; stroke-width: 2; }
.chart .grid { stroke: var(--viz-grid); }
.chart .axis { stroke: var(--border); }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .cap { fill: var(--secondary); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .cross { stroke: var(--secondary); }
.chart .hl { fill: var(--fill); }
.enter .rise { transform-box: fill-box; transform-origin: bottom; animation: viz-rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.enter .reveal { animation: viz-reveal 1.2s cubic-bezier(0.3, 0.6, 0.2, 1) both; }
@keyframes viz-reveal { from { clip-path: inset(0 100% 0 0); } }
@keyframes viz-rise { from { transform: scaleY(0); } }
@media (prefers-reduced-motion: reduce) {
    .segbar, .enter .rise, .enter .reveal { animation: none; }
}

.viz-tip {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 20;
    min-width: 120px;
    padding: 8px 10px;
    border-radius: 6px;
    background: var(--heading);
    color: #fff;
    font-size: 0.8rem;
    line-height: 1.4;
    box-shadow: 0 6px 18px rgba(28, 25, 23, 0.18);
    pointer-events: none;
}
.viz-tip-title { color: #d6d3d1; margin-bottom: 2px; }
.viz-tip-row { display: flex; align-items: center; gap: 8px; }
.viz-tip-row b { font-variant-numeric: tabular-nums; }
.viz-tip-row span { color: #d6d3d1; }
.viz-tip .key { flex: none; width: 12px; height: 3px; border-radius: 2px; background: var(--c); }

/* Package page: the summary figures over the version ledger, a row per
   attempted version with a mark per attempt, and the causes its failures
   share. Below 1180px the ledger columns no longer fit beside the sidebar,
   so each row folds onto two lines, and on a phone the marks take a line of
   their own. */
.pkg-repo { color: var(--muted); font-family: ui-monospace, monospace; font-size: 0.8rem; overflow-wrap: anywhere; }
/* The 1px gaps over the panel's background draw the rules between cells in
   any arrangement. */
.pkg-sum { display: grid; grid-template-columns: 1fr 1fr 1.5fr 1fr; gap: 1px; margin-bottom: 18px; padding: 0; overflow: hidden; background: var(--viz-grid); }
.sum-cell { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 16px 20px; background: #fff; }
.sum-fig { color: var(--heading); font-size: 1.9rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.sum-fig small { color: var(--muted); font-size: 1rem; font-weight: 600; }
.sum-fig.bad { color: var(--mismatch); }
.sum-fig.muted { color: var(--muted); }
.sum-sub { color: var(--secondary); font-size: 0.8rem; }
.vstrip { display: flex; gap: 2px; height: 10px; }
.vstrip i { flex: 1; min-width: 1px; border-radius: 2px; background: var(--c); }
.sum-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sum-head a, .sum-context { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.sum-head a { -webkit-line-clamp: 2; color: var(--heading); font-weight: 700; }
.sum-context { -webkit-line-clamp: 3; color: var(--secondary); font-family: ui-monospace, monospace; font-size: 0.75rem; }

.pkg-panel { margin-bottom: 18px; padding: 14px 0 6px; }
.pkg-panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 16px; padding: 0 22px 10px; }
.pkg-panel-head .legend { margin: 0; gap: 14px; font-size: 0.75rem; }
.pkg-panel-head .legend-item { gap: 5px; }
.pkg-panel-note { color: var(--muted); font-size: 0.75rem; }
.pkg-panel-foot { margin: 0; padding: 10px 22px 8px; border-top: 1px solid var(--viz-grid); color: var(--secondary); font-size: 0.8rem; }
.lrows, .fail-rows { list-style: none; margin: 0; padding: 0; }
.lrow { position: relative; display: grid; grid-template-columns: 96px 112px 232px minmax(0, 1fr) 84px; gap: 14px; align-items: center; padding: 9px 22px; border-top: 1px solid var(--viz-grid); }
.lrows .lrow:hover { background: color-mix(in srgb, var(--fill) 60%, transparent); }
.lhead { padding-block: 2px 6px; border-top: none; color: var(--muted); font-size: 0.72rem; font-weight: 600; }
.lhead span:last-child, .l-last { text-align: right; }
.l-ver { overflow: hidden; color: var(--heading); font-family: ui-monospace, monospace; font-size: 0.82rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
/* The version link covers its row. Positioning lifts the marks and the
   failure link above it. */
.l-ver::after { content: ""; position: absolute; inset: 0; }
.l-fail a, .mk { position: relative; }
.l-marks { display: flex; flex-wrap: wrap; gap: 3px; }
.l-fail { display: flex; align-items: center; gap: 8px; min-width: 0; }
.l-fail.fixed { opacity: 0.55; }
.l-fail .note, .fail-line .note { color: var(--secondary); font-size: 0.82rem; }
.l-last { color: var(--secondary); font-size: 0.8rem; white-space: nowrap; }
.vstate { padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--c) 16%, #fff); color: var(--secondary); font-size: 0.72rem; font-weight: 700; white-space: nowrap; }
.vstate.ok { color: var(--accent); }
.vstate.bad { color: var(--mismatch); }
/* A square per rebuild and a circle per agent session, hollow when the
   session did not reproduce. */
.mk { flex: none; width: 9px; height: 9px; border-radius: 2px; background: var(--c); }
.mk.agent { border-radius: 50%; }
.mk.agent:not(.ok) { background: none; box-shadow: inset 0 0 0 2px var(--c); }
a.mk:hover { outline: 2px solid var(--heading); outline-offset: 1px; }
.fail-row { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 3px 12px; padding: 9px 22px; border-top: 1px solid var(--viz-grid); }
.fail-n { grid-row: span 2; color: var(--mismatch); font-size: 1.05rem; font-weight: 800; line-height: 1.3; text-align: right; font-variant-numeric: tabular-nums; }
.fail-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.fail-scope { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--muted); font-size: 0.75rem; }
.fail-track { flex: none; width: 120px; height: 4px; border-radius: 2px; background: var(--viz-grid); }
.fail-track i { display: block; height: 100%; min-width: 2px; border-radius: 2px; background: var(--viz-bad); }
@media (max-width: 1180px) {
    .pkg-sum { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .sum-fail { grid-column: 1 / -1; order: 1; }
    .lhead { display: none; }
    .lrow { grid-template-columns: minmax(0, max-content) auto minmax(0, 1fr) auto; grid-template-areas: "ver state marks last" "fail fail fail fail"; gap: 6px 10px; padding: 10px 16px; }
    .l-ver { grid-area: ver; }
    .l-state { grid-area: state; }
    .l-marks { grid-area: marks; }
    .l-fail { grid-area: fail; }
    .l-fail:empty { display: none; }
    .l-last { grid-area: last; }
    .pkg-panel-head, .pkg-panel-foot, .fail-row { padding-inline: 16px; }
}
@media (max-width: 640px) {
    .pkg-sum { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sum-attempts { display: none; }
    .lrow { grid-template-areas: "ver state . last" "marks marks marks marks" "fail fail fail fail"; gap: 6px 8px; }
    .sum-cell { padding: 14px 16px; }
    .sum-fig { font-size: 1.6rem; }
    .fail-line { flex-direction: column; align-items: stretch; gap: 3px; }
    .fail-line .stage { align-self: flex-start; }
    .fail-track { display: none; }
}
