/* ============================================================
   savetools — base, layout, components
   Order: reset → base → layout → nav → console → components
   → report pieces → states/animation → responsive → a11y
   ============================================================ */

/* ---------- Reset ---------- */

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

button, input {
    font: inherit;
    color: inherit;
    border-radius: 0;
}

/* ---------- Base ---------- */

html {
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: var(--fs-body);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .mono {
    font-family: var(--font-mono);
    font-weight: 600;
    line-height: 1.25;
}

code {
    font-family: var(--font-mono);
    font-size: 0.92em;
    background: var(--surface);
    padding: 0.1em 0.35em;
}

a {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 2px;
}

::selection {
    background: var(--ink);
    color: var(--paper);
}

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

.icon {
    width: 1.05em;
    height: 1.05em;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: square;
    stroke-linejoin: miter;
    fill: none;
    vertical-align: -0.16em;
    flex: none;
}

/* Uppercase micro-label — the workhorse of the system */
.label {
    font-family: var(--font-mono);
    font-size: var(--fs-label);
    font-weight: 500;
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    color: var(--muted);
}

.muted { color: var(--muted); }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Layout ---------- */

.shell {
    display: flex;
    min-height: 100dvh;
}

.sidebar {
    width: var(--sidebar-w);
    flex: none;
    border-right: var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100dvh;
}

.main {
    flex: 1;
    min-width: 0;
}

.content {
    max-width: var(--content-max);
    padding: var(--sp-6) var(--sp-6) var(--sp-7);
}

/* ---------- Sidebar / brand / nav ---------- */

.brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-4);
    border-bottom: var(--border);
}

.brand-mark {
    width: 28px;
    height: 28px;
    flex: none;
    display: grid;
    grid-template: 1fr 1fr / 1fr 1fr;
    gap: 3px;
}

.brand-mark span {
    border: 1.5px solid var(--ink);
}

.brand-mark span:first-child {
    background: var(--ink);
}

.brand-name {
    font-family: var(--font-mono);
    font-size: var(--fs-data);
    font-weight: 600;
    letter-spacing: 0.06em;
    line-height: 1.3;
    text-transform: uppercase;
}

.brand-name small {
    display: block;
    font-size: var(--fs-label);
    font-weight: 400;
    letter-spacing: var(--track-label);
    color: var(--muted);
}

.nav {
    padding: var(--sp-4) 0;
    flex: 1;
    overflow-y: auto;
}

.nav .label {
    display: block;
    padding: 0 var(--sp-4) var(--sp-2);
}

.nav-group + .nav-group {
    margin-top: var(--sp-4);
}

/* collapsible category headings */
.nav-group > summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: color var(--t-fast);
}

.nav-group > summary::-webkit-details-marker {
    display: none;
}

.nav-group > summary:hover {
    color: var(--ink);
}

.nav-group > summary .chev {
    width: 0.9em;
    height: 0.9em;
    transition: transform var(--t-fast);
}

.nav-group:not([open]) > summary .chev {
    transform: rotate(-90deg);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    width: 100%;
    padding: var(--sp-3) var(--sp-4);
    background: none;
    border: none;
    border-left: 3px solid transparent;
    font-family: var(--font-mono);
    font-size: var(--fs-data);
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast);
}

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

.nav-item[aria-current="page"] {
    background: var(--ink);
    color: var(--paper);
    border-left-color: var(--ink);
}

.nav-soon {
    padding: var(--sp-3) var(--sp-4);
    font-family: var(--font-mono);
    font-size: var(--fs-label);
    color: var(--muted);
}

.sidebar-foot {
    border-top: var(--border);
    padding: var(--sp-3) var(--sp-4);
    display: grid;
    gap: var(--sp-1);
}

/* API status square: pulses while online */
.health {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-family: var(--font-mono);
    font-size: var(--fs-label);
    letter-spacing: var(--track-label);
    text-transform: uppercase;
}

.health-dot {
    width: 8px;
    height: 8px;
    border: 1.5px solid var(--ink);
    flex: none;
}

.health.is-up .health-dot {
    background: var(--ink);
    animation: pulse 2.4s ease-in-out infinite;
}

.health.is-down { color: var(--muted); }

.health.is-down .health-dot {
    border-color: var(--muted);
    background: repeating-linear-gradient(135deg, var(--muted) 0 1px, transparent 1px 3px);
}

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

/* ---------- View header ---------- */

.view-head {
    margin-bottom: var(--sp-5);
}

.view-head .label {
    margin-bottom: var(--sp-2);
}

.view-title {
    font-size: var(--fs-display);
    letter-spacing: -0.01em;
    margin-bottom: var(--sp-2);
}

.view-desc {
    max-width: 56ch;
    color: var(--muted);
}

/* Locus chip — where a tool runs. Hollow square = stays in the browser,
   filled square = the input travels to this site's server. Same
   fill-density language as the severity glyphs. */
.locus {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    margin-left: var(--sp-3);
    padding: 2px var(--sp-2);
    border: var(--border);
    font-family: var(--font-mono);
    font-size: var(--fs-label);
    font-weight: 500;
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    color: var(--muted);
    vertical-align: 1px;
    white-space: nowrap;
}

.locus::before {
    content: '';
    width: 7px;
    height: 7px;
    flex: none;
}

.locus[data-locus='local']::before {
    border: 1px solid var(--ink);
}

.locus[data-locus='server']::before {
    background: var(--ink);
}

/* ---------- Console (URL input + run) ---------- */

.console {
    display: flex;
    border: var(--border-ink);
    position: relative;
    background: var(--paper);
}

.console-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: none;
    padding: var(--sp-3) var(--sp-4);
    font-family: var(--font-mono);
    font-size: var(--fs-md);
}

.console-input::placeholder {
    color: var(--muted);
}

.console-input:focus {
    outline: none;
}

.console:focus-within {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-5);
    background: var(--ink);
    color: var(--paper);
    border: none;
    font-family: var(--font-mono);
    font-size: var(--fs-data);
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}

.btn:hover {
    background: var(--paper);
    color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--ink);
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    cursor: wait;
    background: var(--surface);
    color: var(--muted);
    box-shadow: inset 0 0 0 1px var(--rule);
    transform: none;
}

/* Ghost button — small inline actions (copy, expand-all) */
.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: var(--sp-1) var(--sp-2);
    background: none;
    border: var(--border);
    font-family: var(--font-mono);
    font-size: var(--fs-label);
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    color: var(--muted);
    cursor: pointer;
    transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.btn-ghost:hover {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--paper);
}

/* Scanline: indeterminate loader pinned under the console */
.scanline {
    position: absolute;
    left: -1px;
    right: -1px;
    bottom: -1px;
    height: 2px;
    overflow: hidden;
    opacity: 0;
    transition: opacity var(--t-fast);
}

.console.is-loading .scanline {
    opacity: 1;
}

.scanline::before {
    content: "";
    display: block;
    width: 35%;
    height: 100%;
    background: var(--ink);
    animation: scan 1.1s linear infinite;
}

@keyframes scan {
    from { transform: translateX(-100%); }
    to { transform: translateX(300%); }
}

/* Textarea variant of the console (multiline tools like JSON beautify) */
.console--area {
    display: block;
}

.area-input {
    display: block;
    width: 100%;
    min-height: 200px;
    resize: vertical;
    font-size: var(--fs-data);
    line-height: 1.6;
}

/* Secondary single-line input under the main console */
.console--sub {
    margin-top: var(--sp-2);
}

/* Inline cluster of related options inside an opt-row */
.opt-group {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2) var(--sp-4);
    flex-wrap: wrap;
}

/* Option row under the console; .checkbox is the reusable square toggle */
.opt-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2) var(--sp-5);
    margin-top: var(--sp-3);
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-family: var(--font-mono);
    font-size: var(--fs-label);
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    color: var(--muted);
    cursor: pointer;
    transition: color var(--t-fast);
}

.checkbox:hover {
    color: var(--ink);
}

.checkbox input {
    appearance: none;
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    flex: none;
    border: 1.5px solid var(--ink);
    background: var(--paper);
    cursor: pointer;
    transition: background var(--t-fast);
}

.checkbox input:checked {
    background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5'%3E%3Cpath d='M5 13l5 5L19 7'/%3E%3C/svg%3E") center / 10px no-repeat;
}

.checkbox input:checked ~ span {
    color: var(--ink);
}

.opt-row .btn,
.opt-actions {
    margin-left: auto;
}

/* Action pair: primary stays solid ink, secondary is outlined */
.opt-actions {
    display: inline-flex;
    gap: var(--sp-2);
}

.opt-actions .btn {
    margin-left: 0;
}

.btn--secondary {
    background: var(--paper);
    color: var(--ink);
    box-shadow: inset 0 0 0 1px var(--ink);
}

.btn--secondary:hover {
    background: var(--ink);
    color: var(--paper);
}

.form-hint {
    margin-top: var(--sp-2);
    font-family: var(--font-mono);
    font-size: var(--fs-label);
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    color: var(--muted);
    min-height: 1.2em;
}

.form-hint.is-error {
    color: var(--ink);
}

/* ---------- Report area & states ---------- */

.report {
    margin-top: var(--sp-6);
}

.idle {
    border: 1px dashed var(--rule-strong);
    padding: var(--sp-7) var(--sp-5);
    text-align: center;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: var(--fs-data);
}

.idle-squares {
    display: flex;
    justify-content: center;
    gap: var(--sp-2);
    margin-bottom: var(--sp-3);
}

.idle-squares span {
    width: 10px;
    height: 10px;
    border: 1.5px solid var(--rule-strong);
}

.idle-squares span:nth-child(2) {
    background: linear-gradient(135deg, var(--rule-strong) 50%, transparent 50%);
}

.idle-squares span:nth-child(3) {
    background: var(--rule-strong);
}

.error-box {
    border: var(--border-ink);
    padding: var(--sp-4) var(--sp-5);
    display: flex;
    gap: var(--sp-3);
    align-items: flex-start;
}

.error-box .icon {
    width: 1.3em;
    height: 1.3em;
    margin-top: 0.15em;
}

.error-box > div {
    flex: 1;
    min-width: 0;
}

.error-box h3 {
    font-size: var(--fs-body);
    margin-bottom: var(--sp-1);
}

/* Result reveal: fade + rise on every state change */
.reveal {
    animation: reveal var(--t-med) both;
}

@keyframes reveal {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Panels & summary ---------- */

.panel {
    border: var(--border);
}

.panel + .panel,
.panel + details.raw,
details.raw + .panel {
    margin-top: var(--sp-4);
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: var(--border);
}

.panel-head h3 {
    font-size: var(--fs-data);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.panel-body {
    padding: var(--sp-4);
}

/* Summary: stamp + ledger sentence + square meter */
.summary {
    border: var(--border-ink);
    padding: var(--sp-5);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--sp-3) var(--sp-5);
    align-items: start;
    margin-bottom: var(--sp-4);
}

.stamp {
    font-family: var(--font-mono);
    font-size: var(--fs-lg);
    font-weight: 600;
    letter-spacing: 0.08em;
    padding: var(--sp-2) var(--sp-4);
    border: 2px solid var(--ink);
    background: var(--ink);
    color: var(--paper);
    animation: stamp var(--t-med) both;
}

/* Tone scale in ink only: bad = solid fill (default),
   warn = outline, ok = double-rule outline */
.stamp[data-tone="warn"] {
    background: var(--paper);
    color: var(--ink);
}

.stamp[data-tone="ok"] {
    background: var(--paper);
    color: var(--ink);
    border-style: double;
    border-width: 4px;
}

@keyframes stamp {
    from { opacity: 0; transform: scale(1.15); }
    to { opacity: 1; transform: none; }
}

.summary-text {
    align-self: center;
}

.summary-text .big {
    font-family: var(--font-mono);
    font-size: var(--fs-lg);
    font-weight: 600;
}

.summary-meta {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2) var(--sp-5);
}

/* Square meter — one square per scored header */
.meter {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}

.meter .sq {
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--ink);
    background: var(--paper);
    transition: background 180ms ease;
}

.meter.is-on .sq.is-filled {
    background: var(--ink);
}

/* ---------- Severity glyphs (color-free severity language) ---------- */

.sev {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-family: var(--font-mono);
    font-size: var(--fs-label);
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    white-space: nowrap;
}

.sev i {
    width: 10px;
    height: 10px;
    border: 1.5px solid currentColor;
    flex: none;
}

.sev[data-sev="low"] i,
.sev[data-sev="none"] i {
    background: var(--paper);
}

.sev[data-sev="medium"] i {
    background: linear-gradient(135deg, var(--ink) 50%, transparent 50%);
}

.sev[data-sev="high"] i {
    background: var(--ink);
}

.sev[data-sev="critical"] i {
    background: var(--ink);
    box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ink);
}

.sev[data-sev="critical"] {
    font-weight: 600;
}

/* ---------- Ledger rows (findings, libraries) ---------- */

.row {
    border-bottom: var(--border);
}

.row:last-child {
    border-bottom: none;
}

.row-head {
    width: 100%;
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-3) var(--sp-4);
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background var(--t-fast);
}

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

.row-head[aria-expanded="true"] .chev {
    transform: rotate(180deg);
}

.chev {
    margin-left: auto;
    transition: transform var(--t-fast);
    color: var(--muted);
}

.row-idx {
    font-family: var(--font-mono);
    font-size: var(--fs-label);
    color: var(--muted);
    width: 2ch;
    flex: none;
}

.row-name {
    font-family: var(--font-mono);
    font-size: var(--fs-data);
    font-weight: 500;
    word-break: break-word;
}

.row-name small {
    font-weight: 400;
    color: var(--muted);
}

.row-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows var(--t-med);
}

.row-body > div {
    overflow: hidden;
}

.row.is-open .row-body {
    grid-template-rows: 1fr;
}

.row-detail {
    padding: 0 var(--sp-4) var(--sp-4) calc(2ch + var(--sp-4) + var(--sp-4));
    display: grid;
    gap: var(--sp-3);
}

.row-detail p {
    max-width: 62ch;
}

/* Recommended value / code line with copy action */
.codeline {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    background: var(--surface);
    border: var(--border);
    padding: var(--sp-2) var(--sp-3);
    font-family: var(--font-mono);
    font-size: var(--fs-data);
    overflow-x: auto;
}

.codeline code {
    background: none;
    padding: 0;
    white-space: pre-wrap;
    word-break: break-all;
    flex: 1;
}

/* ---------- Vulnerability entries ---------- */

.vuln {
    border: var(--border);
    padding: var(--sp-3);
    display: grid;
    gap: var(--sp-2);
}

.vuln + .vuln {
    margin-top: var(--sp-2);
}

.vuln-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2) var(--sp-4);
}

.vuln-range {
    font-family: var(--font-mono);
    font-size: var(--fs-label);
    color: var(--muted);
}

.tag {
    display: inline-block;
    border: var(--border);
    padding: 0 var(--sp-2);
    font-family: var(--font-mono);
    font-size: var(--fs-label);
    letter-spacing: 0.04em;
}

.taglist {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
}

/* ---------- Code block (multiline mono output) ---------- */

.codeblock {
    margin: 0;
    padding: var(--sp-4);
    background: var(--surface);
    font-family: var(--font-mono);
    font-size: var(--fs-data);
    line-height: 1.6;
    white-space: pre;
    overflow: auto;
    max-height: 480px;
}

/* Wrapping variant for single-blob output (Base64 strings, long values) */
.codeblock--wrap {
    white-space: pre-wrap;
    word-break: break-all;
}

.panel-tools {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-3);
}

/* ---------- Copy list (one value per row, click a row to copy it) ------- */

.copylist {
    background: var(--surface);
    font-family: var(--font-mono);
    font-size: var(--fs-data);
    line-height: 1.8;
    padding: var(--sp-2) 0;
    overflow: auto;
    max-height: 520px;
}

.copyline {
    display: flex;
    width: 100%;
    align-items: center;
    gap: var(--sp-3);
    padding: 0 var(--sp-4);
    background: none;
    border: none;
    font: inherit;
    line-height: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
    transition: background var(--t-fast), box-shadow var(--t-fast);
}

.copyline:hover,
.copyline:focus-visible,
.copyline.is-copied {
    background: var(--paper);
    box-shadow: inset 3px 0 0 var(--ink);
}

.copyline-meta {
    flex: none;
    min-width: 14ch;
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: 500;
}

/* the icon sits right after the value, not pushed to the far edge */
.copyline-text {
    flex: 0 1 auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.copyline .icon {
    opacity: 0;
    color: var(--muted);
    transition: opacity var(--t-fast);
}

.copyline:hover .icon,
.copyline:focus-visible .icon,
.copyline.is-copied .icon {
    opacity: 1;
}

.copyline.is-copied .icon {
    color: var(--ink);
}

/* "Copied!" label shown next to the check while feedback is active */
.copyline-done {
    display: none;
    font-size: var(--fs-label);
    font-weight: 500;
    letter-spacing: var(--track-label);
    text-transform: uppercase;
    color: var(--ink);
    white-space: nowrap;
}

.copyline.is-copied .copyline-done {
    display: inline;
}

/* ---------- Collapsible JSON tree ---------- */

.jt {
    padding: var(--sp-4);
    background: var(--surface);
    font-family: var(--font-mono);
    font-size: var(--fs-data);
    line-height: 1.7;
    overflow: auto;
    max-height: 520px;
}

.jt summary {
    list-style: none;
    cursor: pointer;
    white-space: pre-wrap;
    word-break: break-all;
    transition: background var(--t-fast);
}

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

.jt summary:hover {
    background: var(--paper);
}

.jt-chev {
    width: 0.85em;
    height: 0.85em;
    margin-right: var(--sp-1);
    color: var(--muted);
    transform: rotate(-90deg);
    transition: transform var(--t-fast);
}

.jt details[open] > summary .jt-chev {
    transform: none;
}

/* collapsed preview ("… 3 keys }") hides once the node is open */
.jt details[open] > summary .jt-preview {
    display: none;
}

.jt-preview {
    color: var(--muted);
}

.jt-children {
    margin-left: 0.4rem;
    padding-left: 1.1rem;
    border-left: 1px solid var(--rule);
}

.jt-line,
.jt-close {
    white-space: pre-wrap;
    word-break: break-all;
}

.jt-k {
    font-weight: 600;
}

/* ---------- Color swatch ---------- */

.swatch-row {
    display: flex;
    gap: var(--sp-4);
    align-items: stretch;
    padding: var(--sp-4);
    background: var(--surface);
}

/* checkerboard underneath so alpha is visible; the color sits on ::after */
.swatch {
    position: relative;
    width: 96px;
    min-height: 96px;
    flex: none;
    border: var(--border-ink);
    background: repeating-conic-gradient(var(--rule) 0 25%, var(--paper) 0 50%) 0 0 / 16px 16px;
}

.swatch::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--swatch-color);
}

.swatch-row .copylist {
    flex: 1;
    padding: 0;
    background: none;
}

@media (max-width: 560px) {
    .swatch-row {
        flex-direction: column;
    }
}

/* ---------- Text diff ---------- */

.diff-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
}

.diff-inputs > div > .label {
    display: block;
    margin-bottom: var(--sp-1);
}

/* Side-by-side diff: original left, changed right, own line numbers.
   Monochrome change language: removed = hatched and receding,
   added = ink edge on paper, changed characters = inverted. */
.diff {
    font-family: var(--font-mono);
    font-size: var(--fs-data);
    line-height: 1.6;
    background: var(--surface);
    overflow: auto;
    max-height: 560px;
}

.diff-srow {
    display: grid;
    grid-template-columns: 4.5ch minmax(0, 1fr) 4.5ch minmax(0, 1fr);
}

.diff-no {
    color: var(--muted);
    font-size: var(--fs-label);
    line-height: inherit;
    text-align: right;
    padding-right: 0.75ch;
    user-select: none;
}

/* hairline seam between the two halves */
.diff-no--right {
    border-left: var(--border);
}

.diff-cell {
    white-space: pre-wrap;
    word-break: break-all;
    padding-right: var(--sp-2);
}

.diff-cell--del {
    color: var(--muted);
    background: repeating-linear-gradient(135deg, transparent 0 4px, var(--rule) 4px 5px);
    box-shadow: inset 3px 0 0 var(--rule-strong);
}

.diff-cell--add {
    background: var(--paper);
    box-shadow: inset 3px 0 0 var(--ink);
}

/* the side that has no line at all */
.diff-cell--void {
    background: repeating-linear-gradient(135deg, transparent 0 7px, var(--rule) 7px 8px);
    opacity: 0.5;
}

/* changed characters within a paired line */
.diff-hl {
    background: var(--ink);
    color: var(--paper);
}

/* ---------- Parse-error context (numbered lines, offending char inverted) */

.ctx {
    margin-top: var(--sp-2);
    background: var(--surface);
    font-family: var(--font-mono);
    font-size: var(--fs-data);
    line-height: 1.7;
    padding: var(--sp-3) 0;
    overflow: auto;
}

.ctx-row {
    display: grid;
    grid-template-columns: 5ch minmax(0, 1fr);
}

.ctx-no {
    color: var(--muted);
    font-size: var(--fs-label);
    line-height: inherit;
    text-align: right;
    padding-right: 1ch;
    user-select: none;
}

.ctx-text {
    white-space: pre-wrap;
    word-break: break-all;
    padding-right: var(--sp-3);
}

.ctx-row.is-err {
    box-shadow: inset 3px 0 0 var(--ink);
}

.ctx-row.is-err .ctx-no {
    color: var(--ink);
    font-weight: 600;
}

@media (max-width: 700px) {
    .diff-inputs {
        grid-template-columns: 1fr;
    }
}

/* ---------- Key-value grid (raw headers) ---------- */

details.raw {
    border: var(--border);
}

details.raw > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    font-family: var(--font-mono);
    font-size: var(--fs-data);
    cursor: pointer;
    transition: background var(--t-fast);
}

details.raw > summary::-webkit-details-marker { display: none; }

details.raw > summary:hover {
    background: var(--surface);
}

details.raw[open] > summary {
    border-bottom: var(--border);
}

details.raw[open] > summary .chev {
    transform: rotate(180deg);
}

.kv {
    display: grid;
    grid-template-columns: minmax(140px, max-content) 1fr;
    font-family: var(--font-mono);
    font-size: var(--fs-data);
}

.kv > dt {
    padding: var(--sp-2) var(--sp-4);
    border-bottom: var(--border);
    color: var(--muted);
    word-break: break-all;
}

.kv > dd {
    padding: var(--sp-2) var(--sp-4);
    border-bottom: var(--border);
    word-break: break-all;
}

.kv > dt:nth-last-of-type(1),
.kv > dd:last-of-type {
    border-bottom: none;
}

/* ---------- Footnote ---------- */

.footnote {
    margin-top: var(--sp-4);
    padding-top: var(--sp-3);
    border-top: var(--border);
    color: var(--muted);
    font-size: var(--fs-data);
    max-width: 68ch;
}

/* ---------- View switching ---------- */

.view[hidden] {
    display: none;
}

.view {
    animation: reveal var(--t-med) both;
}

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
    .shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: var(--border);
    }

    .nav {
        display: flex;
        padding: 0;
        overflow-x: auto;
        overflow-y: hidden;
    }

    /* groups flatten into one scrollable strip on mobile
       (JS forces them open there — a closed details hides its items) */
    .nav-group {
        display: contents;
    }

    .nav .label, .nav-group > summary, .nav-soon {
        display: none;
    }

    .nav-item {
        width: auto;
        border-left: none;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
    }

    .nav-item[aria-current="page"] {
        border-bottom-color: var(--ink);
    }

    .sidebar-foot {
        border-top: var(--border);
        flex-direction: row;
        justify-content: space-between;
    }

    .content {
        padding: var(--sp-5) var(--sp-4) var(--sp-7);
    }

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

@media (max-width: 560px) {
    .console {
        flex-direction: column;
    }

    .console .btn {
        justify-content: center;
        border-top: var(--border-ink);
    }
}

/* ---------- Reduced motion ---------- */

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