/* ==========================================================================
   Detail pages: shared pieces (title row, plate, data pad, readout row, peak
   ledger) used by the fragment detail page and the spectrum analyzer; the
   compound detail page's proof sheet is at the end of this file. Plus the
   editor dialogs. Inherits tokens from app.css / atlas.css.
   ========================================================================== */
.back-link {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 14px; color: var(--ink-2); text-decoration: none; margin-bottom: 10px;
}
.back-link svg { width: 14px; height: 14px; }
.back-link:hover { color: var(--ink); text-decoration: underline; }

.detail-title {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding-bottom: 14px; border-bottom: 1px solid var(--rule-strong); margin-bottom: 18px;
}
.detail-title .atlas-no { font-size: 15px; padding: 2px 7px; }
.detail-title h1 { font-size: 26px; font-weight: 700; font-stretch: 92%; letter-spacing: -0.02em; }
.detail-title .atlas-formula { margin-left: 0; font-size: 16px; color: var(--ink-2); }
.detail-title .page-actions { margin-left: auto; display: flex; gap: 8px; }
.detail-fullname { flex-basis: 100%; margin-top: -4px; font-size: 15px; color: var(--ink-2); }

/* Small section label (compound editor preview) and the "not recorded" note in the band */
.conditions-head { font-size: 11.5px; font-weight: 600; color: var(--ink-3); text-transform: none; margin-bottom: 6px; }
.conditions-none { font-size: 12.5px; color: var(--ink-3); }

.detail-split {
    display: grid;
    grid-template-columns: minmax(0, 56fr) minmax(0, 44fr);
    gap: 24px;
    align-items: start;
}
.detail-figure {
    position: sticky; top: 16px;
    background: var(--paper); border: 1px solid var(--rule);
}
.detail-plate {
    display: flex; align-items: center; justify-content: center;
    padding: 10px; min-height: 210px; border-right: 1px solid var(--rule);
    color: var(--ink-3); font-size: 13px;
}
.detail-plate img { display: block; max-width: 100%; max-height: 230px; }
.dark .detail-plate img { filter: invert(1) hue-rotate(180deg); }
.detail-data { padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.detail-data .atlas-data { gap: 14px 20px; }
.smiles-block dt { color: var(--ink-3); font-size: 11.5px; }
.smiles-block dd {
    font-family: var(--font-data); font-size: 12.5px; color: var(--ink);
    overflow-wrap: anywhere; line-height: 1.45;
}
.detail-spectrum { padding: 12px 14px 6px; }
.detail-spectrum .atlas-spectrum { padding: 0; }
.detail-readout-row {
    display: flex; align-items: baseline; gap: 12px;
    padding: 6px 14px 10px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--ink-3);
}
.detail-readout-row .atlas-readout { min-width: 16ch; }
.atlas-spectrum-svg .cap { fill: var(--ink); pointer-events: none; }

/* --- Peak ledger ---------------------------------------------------------- */
.ledger-wrap { background: var(--paper); border: 1px solid var(--rule); }
.ledger-head {
    display: flex; align-items: baseline; gap: 10px;
    padding: 10px 14px; border-bottom: 1px solid var(--rule-strong);
}
.ledger-head h2 { font-size: 16px; }
.ledger-head span { color: var(--ink-3); font-size: 13px; }
.ledger { background: transparent; font-size: 13.5px; }
.ledger th { position: sticky; top: 0; background: var(--paper); z-index: 1; }
.ledger th:first-child, .ledger td:first-child { padding-left: 14px; }
.ledger td { vertical-align: top; padding-top: 9px; padding-bottom: 9px; }
.ledger td.mz { font-family: var(--font-data); font-weight: 600; white-space: nowrap; }
.ledger { table-layout: fixed; }
.ledger th { white-space: nowrap; }
.ledger col.c-mz { width: 76px; }
.ledger col.c-int { width: 112px; }
.ledger td.int { font-family: var(--font-data); white-space: nowrap; }
.ledger-bar {
    display: block; height: 3px; margin-top: 5px; min-width: 1px;
    width: var(--w); background: var(--ink);
}
.ledger tr.is-bp td.mz, .ledger tr.is-bp td.int { color: var(--accent); }
.ledger tr.is-bp .ledger-bar { background: var(--accent); }
.ledger tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ledger tbody tr.is-active { background: var(--inset); }
.ledger tbody tr.is-active td.mz { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.2em; }
.ledger .none { color: var(--ink-3); }
.ledger-frags { display: flex; flex-wrap: wrap; gap: 6px; }
.ledger-frag {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    max-width: 100%; padding: 4px 6px 5px;
    border: 1px solid var(--rule); border-radius: var(--radius);
    text-decoration: none; color: var(--ink); font-size: 12px;
}
.ledger-frag:hover { border-color: var(--ink); }
.ledger-frag img { display: block; width: auto; height: auto; max-width: 100%; }   /* natural scale */
.dark .ledger-frag img { filter: invert(1) hue-rotate(180deg); }
.ledger-frag span { font-size: 12.5px; font-weight: 600; overflow-wrap: anywhere; text-align: center; }

.detail-record {
    margin-top: 16px; padding: 10px 14px;
    background: var(--paper); border: 1px solid var(--rule);
    display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: 13px;
}
.detail-record div { display: flex; flex-direction: column; }
.detail-record dt { color: var(--ink-3); font-size: 11.5px; }
.detail-record dd { font-family: var(--font-data); font-size: 12.5px; }

@media (max-width: 900px) {
    .detail-split { grid-template-columns: minmax(0, 1fr); }
    .detail-figure { position: static; }
}

/* ==========================================================================
   Fragment editor (dialog): ruled panel, tabs, candidate lists
   ========================================================================== */
[x-cloak] { display: none !important; }
.editor-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(10, 10, 10, 0.45);
    display: flex; align-items: center; justify-content: center;
}
.editor-panel {
    background: var(--paper); color: var(--ink);
    border: 1px solid var(--rule-strong); border-radius: var(--radius);
    width: min(960px, 94vw); max-height: 88vh;
    display: flex; flex-direction: column; overflow: hidden;
}
.editor-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 16px; border-bottom: 1px solid var(--rule-strong);
    cursor: move; user-select: none;
}
.editor-header h2 { font-size: 17px; }
.editor-header .muted { color: var(--ink-3); font-size: 13px; font-weight: 500; margin-left: 8px; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border: 1px solid transparent; border-radius: var(--radius);
    background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { border-color: var(--rule); color: var(--ink); }
.icon-btn svg { width: 14px; height: 14px; }
.editor-body { padding: 0 16px 16px; overflow-y: auto; flex: 1; }

.tabs {
    display: flex; gap: 2px; border-bottom: 1px solid var(--rule);
    margin: 0 -16px 16px; padding: 0 16px;
    position: sticky; top: 0; background: var(--paper); z-index: 2;
}
.tabs button {
    background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
    padding: 10px 12px; font: inherit; font-size: 14px; font-weight: 560; color: var(--ink-2); cursor: pointer;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); font-weight: 650; }
.tabs .count { font-family: var(--font-data); font-size: 12px; color: var(--ink-3); margin-left: 4px; }

.editor-note { color: var(--ink-2); font-size: 13.5px; margin-bottom: 12px; }
.candidate-list {
    columns: 3 260px; column-gap: 0;               /* cells stack per column: no row-height padding */
    border-top: 1px solid var(--rule); border-left: 1px solid var(--rule);
}
.candidate {
    break-inside: avoid;
    border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
    display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 10px; align-items: start;
    grid-template-areas: "check text" "art art";
    padding: 10px 12px; background: var(--paper); cursor: pointer;
}
.candidate:has(input:checked) { background: var(--inset); }
.candidate input { grid-area: check; margin-top: 3px; width: 15px; height: 15px; }
.candidate > span { grid-area: text; min-width: 0; }
.candidate > .structure-thumb { grid-area: art; justify-content: flex-start; }
.candidate .structure-thumb { height: auto; margin: 0; }
.candidate .structure-thumb img { max-width: 100%; height: auto; }   /* natural scale, full cell width at most */
.candidate-name { font-weight: 650; font-size: 14px; overflow-wrap: anywhere; }
.candidate-meta { font-family: var(--font-data); font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.candidate-smiles { font-family: var(--font-data); font-size: 11.5px; color: var(--ink-3); overflow-wrap: anywhere; margin-top: 4px; }
.candidate-plain { cursor: default; grid-template-columns: minmax(0, 1fr); grid-template-areas: "text" "art"; }
.editor-empty { padding: 24px 0; color: var(--ink-3); text-align: center; }

.compute-params {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 20px;
    padding: 14px; border: 1px solid var(--rule); margin-bottom: 14px;
}
.compute-params fieldset { border: 0; min-width: 0; }
.compute-params legend, .compute-params .lbl { font-weight: 600; font-size: 13px; margin-bottom: 6px; display: block; }
.segmented { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--radius); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
    display: block; min-width: 34px; padding: 5px 9px; text-align: center;
    font-family: var(--font-data); font-size: 13px; color: var(--ink-2); border-left: 1px solid var(--rule);
}
.segmented label:first-child span { border-left: 0; }
.segmented input:checked + span { background: var(--ink); color: var(--on-ink); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.segmented.text span { font-family: var(--font-ui); }
.compute-params input[type="number"] {
    width: 110px; min-height: 32px; padding: 5px 8px; border: 1px solid var(--rule); border-radius: var(--radius);
    background: var(--paper); color: var(--ink); font-family: var(--font-data); font-size: 13px;
}
.compute-run { grid-column: 1 / -1; }
.compute-stats { font-size: 13px; color: var(--ink-2); padding: 4px 0 12px; }
.compute-stats strong { color: var(--ink); font-family: var(--font-data); font-weight: 600; }

.editor-footer {
    display: flex; justify-content: flex-end; align-items: center; gap: 8px;
    padding: 12px 16px; border-top: 1px solid var(--rule-strong); background: var(--paper);
}

/* Save/Cancel stay reachable while the dialog body scrolls */
.editor-body .editor-footer { position: sticky; bottom: -16px; margin: 16px -16px -16px; z-index: 2; }

/* Focus ring outside the plot so it never crosses the axis unit */
.detail-spectrum .atlas-spectrum:focus-visible { outline-offset: 5px; }

/* Wide vs narrow spectrum drawing (SVG text scales with the drawing) */
.spectrum-narrow { display: none; }
.spectrum-legend { margin-left: auto; }
@media (max-width: 600px) {
    .spectrum-wide { display: none; }
    .spectrum-narrow { display: block; }
    .detail-readout-row { flex-wrap: wrap; }
    .spectrum-legend { margin-left: 0; flex-basis: 100%; font-size: 12px; }
}

/* Active peak on the plot: a full-height guide and an m/z label, visible even on a 1-unit stick */
.atlas-spectrum-svg .hit.is-active { stroke: var(--ink); stroke-opacity: 0.12; stroke-width: 9; }   /* a highlight column, never mistakable for a stick or the dotted precursor */
.atlas-spectrum-svg .active-label { fill: var(--ink); font-family: var(--font-data); font-size: 10px; font-weight: 700; }
.detail-readout-row .atlas-readout .hint { color: var(--ink-3); font-family: var(--font-ui); }
.ui-word { font-family: var(--font-ui); }

/* 2: on narrow screens each ledger row gives its fragment structures a full-width line */
@media (max-width: 600px) {
    /* rows become full-width grids: the table and its sections stop being table boxes */
    .ledger, .ledger thead, .ledger tbody { display: block; width: 100%; }
    .ledger colgroup { display: none; }
    .ledger thead tr, .ledger tbody tr { display: grid; grid-template-columns: 76px 112px minmax(0, 1fr); }
    .ledger thead th:nth-child(3) { display: none; }
    .ledger tbody td:nth-child(3) { grid-column: 1 / -1; padding-top: 0; padding-left: 14px; }
    .ledger tbody td:nth-child(3) .none { display: none; }
}

/* ==========================================================================
   Fragment detail: pinned structure beside its source compounds' spectra
   ========================================================================== */
.mz-badge {
    padding: 2px 8px; border: 1px solid var(--ink); border-radius: var(--radius);
    font-family: var(--font-data); font-size: 16px; font-weight: 700; line-height: 1.35;
    font-variant-numeric: tabular-nums;
}
.mz-badge .ui-word { font-weight: 500; font-style: italic; font-size: 13px; color: var(--ink-2); }
.frag-split { grid-template-columns: minmax(0, 40fr) minmax(0, 60fr); }
.frag-detail-plate { border-right: 0; border-bottom: 1px solid var(--rule); min-height: 240px; padding: 20px; }
.frag-detail-plate img { max-height: 300px; }

.source-list { list-style: none; margin: 0; padding: 0; }
.source-entry { padding: 12px 14px 8px; }
.source-entry + .source-entry { border-top: 1px solid var(--rule); }
.source-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.source-head .atlas-formula { margin-left: auto; }
.source-peak {
    margin-top: 6px; max-width: 280px;
    font-family: var(--font-data); font-size: 13px; color: var(--ink);
}
.source-peak .ui-word { color: var(--ink-3); }
.source-peak.is-bp { color: var(--accent); font-weight: 700; }
.source-peak .ledger-bar { background: var(--ink); }   /* red stays on the numbers only */
.source-peak .none { color: var(--ink-3); }
.source-no, .source-mass { font-family: var(--font-data); font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.source-spectrum { margin-top: 4px; container-type: inline-size; }
.source-spectrum .src-mid, .source-spectrum .src-narrow { display: none; }
@container (max-width: 680px) {
    .source-spectrum .src-wide { display: none; }
    .source-spectrum .src-mid { display: block; }
}
@container (max-width: 430px) {
    .source-spectrum .src-mid { display: none; }
    .source-spectrum .src-narrow { display: block; }
}

/* The fragment's peak: a static shaded column and a bold label (red stays the base peak's) */
.atlas-spectrum-svg line.hl { stroke: var(--ink); stroke-opacity: 0.12; stroke-width: 9; pointer-events: none; }
.atlas-spectrum-svg .pk-label.is-hl:not(.bp) { fill: var(--ink); font-weight: 700; }

.frag-split .ledger-head { flex-wrap: wrap; row-gap: 2px; }
@media (max-width: 900px) {
    .frag-split { grid-template-columns: minmax(0, 1fr); }
    .frag-detail-plate { min-height: 180px; }
}

/* Fragment detail: nominal m/z and exact mass disagree */
.mass-note {
    display: flex; gap: 8px; align-items: flex-start;
    padding: 8px 10px; border: 1px solid var(--ink-3); border-radius: var(--radius);
    font-size: 13px; color: var(--ink); line-height: 1.45;
}
.mass-note svg { flex-shrink: 0; width: 15px; height: 15px; margin-top: 2px; }

/* ==========================================================================
   Spectrum comparison: the spectra on one m/z axis beside the score
   ========================================================================== */
.compare-title .compare-names { color: var(--ink-2); font-size: 15px; font-weight: 560; overflow-wrap: anywhere; }
.compare-split { grid-template-columns: minmax(0, 68fr) minmax(0, 32fr); }
.compare-figure { background: var(--paper); border: 1px solid var(--rule); }
.compare-figure-head {
    display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
    padding: 10px 14px; border-bottom: 1px solid var(--rule);
}
.compare-figure-head h2, .compare-side h2, .compare-section h2 { font-size: 16px; }
.compare-legend { display: flex; gap: 16px; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; font-size: 13.5px; font-weight: 600; }
.compare-legend li { display: inline-flex; align-items: center; gap: 6px; }
.compare-legend .ui-word { color: var(--ink-3); font-weight: 500; }
.compare-legend svg { width: 14px; height: 14px; fill: none; stroke: var(--ink); stroke-width: 1.6; }

.compare-plot { padding: 12px 14px 4px; container-type: inline-size; }
.compare-plot:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.compare-plot .cmp-narrow { display: none; }
@container (max-width: 560px) {
    .compare-plot .cmp-wide { display: none; }
    .compare-plot .cmp-narrow { display: block; }
}
.stack-row + .stack-row { border-top: 1px solid var(--rule); margin-top: 6px; padding-top: 8px; }
.stack-name { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 650; margin-bottom: 2px; }
.stack-name .atlas-no { font-size: 12px; }

/* Mirror plot foot rule; shared m/z notched heavy on the axis */
.atlas-spectrum-svg .ax-foot { stroke: var(--rule-strong); stroke-width: 1; }
.atlas-spectrum-svg .sh { stroke: var(--ink); stroke-width: 3.5; pointer-events: none; }
.atlas-mirror-svg .sh { pointer-events: auto; }

.compare-readout-row { flex-wrap: wrap; border-top: 0; border-bottom: 1px solid var(--rule); padding-top: 8px; min-height: 36px; }   /* above the plot: stays on screen for tall stacks */
.atlas-spectrum-svg .hit.guide { pointer-events: none; }
.compare-readout { display: flex; flex-wrap: wrap; gap: 4px 14px; font-family: var(--font-data); font-size: 12.5px; color: var(--ink); }
.compare-readout .hint { color: var(--ink-3); font-family: var(--font-ui); }
.compare-readout .ro-mz { font-weight: 700; }
.compare-readout .ro-name { font-family: var(--font-ui); color: var(--ink-2); font-weight: 600; }
.compare-readout .is-absent { color: var(--ink-3); }
.compare-key { padding: 0 14px 10px; font-size: 12px; color: var(--ink-3); }

/* Side column: score, matrix, shared peaks */
.compare-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }
.mf-panel { background: var(--paper); border: 1px solid var(--rule); border-top: 2px solid var(--ink); padding: 12px 14px 14px; }
.mf-value { display: flex; align-items: baseline; gap: 8px; margin: 8px 0 2px; }
.mf-number {
    font-family: var(--font-data); font-size: 44px; font-weight: 700; letter-spacing: -0.03em; line-height: 1;
    font-variant-numeric: tabular-nums;
}
.mf-of { font-family: var(--font-data); font-size: 14px; color: var(--ink-3); }
.mf-band { font-size: 14px; color: var(--ink-2); }
.mf-band strong { color: var(--ink); }
.mf-scale { display: block; width: 100%; height: auto; margin: 14px 0 4px; overflow: visible; }
.mf-scale .mf-rule { stroke: var(--rule-strong); stroke-width: 1; }
.mf-scale .mf-band-line { stroke: var(--ink); stroke-width: 4; }
.mf-scale .mf-tick { stroke: var(--ink-3); stroke-width: 1; }
.mf-scale .mf-tick-label { fill: var(--ink-3); font-family: var(--font-data); font-size: 9.5px; }
.mf-scale .mf-marker { fill: var(--ink); }
.mf-bands { display: flex; flex-wrap: wrap; gap: 4px 12px; list-style: none; margin: 4px 0 0; padding: 0; font-size: 12.5px; color: var(--ink-3); }
.mf-bands span { font-family: var(--font-data); font-size: 11.5px; }
.mf-bands .is-current { color: var(--ink); font-weight: 700; }
.mf-note { margin-top: 10px; font-size: 12px; color: var(--ink-3); line-height: 1.45; }

.mf-matrix-wrap { overflow-x: auto; margin-top: 10px; }
.mf-matrix { border-collapse: collapse; font-size: 13px; background: transparent; width: auto; }
.mf-matrix th, .mf-matrix td { padding: 6px 8px; border: 1px solid var(--rule); white-space: nowrap; }
.mf-matrix thead th, .mf-matrix thead td { border-top: 0; border-left: 0; border-right: 0; text-align: center; background: transparent; }
.mf-matrix tbody th { text-align: left; font-weight: 600; border-left: 0; background: transparent; }
.mf-matrix td {
    text-align: center; font-family: var(--font-data); font-variant-numeric: tabular-nums;
    background: color-mix(in srgb, var(--ink) calc(var(--t, 0) * 26%), transparent);   /* ink tint, never a heat palette */
}
.mf-matrix td.diag { color: var(--ink-3); background: transparent; }

.shared-count { margin-top: 6px; font-size: 14px; color: var(--ink-2); }
.shared-count strong { color: var(--ink); font-family: var(--font-data); }
.shared-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.shared-mz { background: transparent; color: var(--ink); cursor: pointer; }
.shared-mz:hover { background: var(--inset); }
.shared-mz:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Below the split: the compounds, then the structures at the shared m/z */
.compare-section { margin-top: 28px; }
.compare-section h2 { padding-bottom: 8px; border-bottom: 1px solid var(--rule-strong); margin-bottom: 14px; }
.compare-section-note { margin: -6px 0 12px; font-size: 13px; color: var(--ink-3); }
.compare-entries { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; }   /* a pair fills the row */
.compare-entry .atlas-pad { flex-wrap: nowrap; }
.compare-entry { border: 1px solid var(--rule); border-top: 2px solid var(--ink); }
.compare-entry .frag-plate { min-height: 170px; }
.compare-entry .frag-plate img { max-height: 170px; }
.compare-frags .ledger-frag { padding: 8px 10px 9px; gap: 6px; }
.compare-frags .frag-mz { font-size: 12px; }

@media (max-width: 900px) {
    .compare-split { grid-template-columns: minmax(0, 1fr); }
    .compare-side { position: static; }
}
/* Stacked spectra share one axis: only the last row repeats the m/z numbers */
.stack-row:not(:last-child) .tk-label, .stack-row:not(:last-child) .ax-unit { display: none; }

/* Spectrum analyzer results: pinned compound beside the peak ledger */
.an-split { grid-template-columns: minmax(0, 46fr) minmax(0, 54fr); }
.an-figure .an-plate { border-right: 0; border-bottom: 1px solid var(--rule); min-height: 260px; }
.an-figure .an-plate img { max-height: 300px; }
.an-readout { font-family: var(--font-data); font-size: 12.5px; color: var(--ink); }
.an-readout .hint { color: var(--ink-3); font-family: var(--font-ui); }
.an-readout-row { align-items: center; }
.an-readout-row #an-clear { margin-left: auto; }
.an-legend { padding: 0 14px 10px; font-size: 12px; color: var(--ink-3); }
.an-frag { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.an-show { background: transparent; cursor: pointer; font: inherit; color: var(--ink); }
.an-show:hover:not(:disabled) { border-color: var(--ink); }
.an-show:disabled { cursor: default; opacity: 0.7; }
.an-show[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--inset); }
.an-show:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ledger-frag .an-frag-formula { font-family: var(--font-data); font-size: 11.5px; color: var(--ink-2); font-weight: 400; }   /* outranks .ledger-frag span */
.an-frag-open { font-size: 12px; color: var(--ink-3); }
.an-frag-open:hover { color: var(--ink); }
@media (max-width: 600px) {
    .ledger.ledger-2col tbody tr { grid-template-columns: 76px minmax(0, 1fr); }
    .ledger.ledger-2col thead th:nth-child(2) { display: none; }
    .ledger.ledger-2col tbody td:nth-child(2) { grid-column: auto; padding-top: 9px; padding-left: 0; }
    .ledger.ledger-2col tbody td:nth-child(2) .none { display: inline; }
}
.an-filter { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.an-filter input { width: 14px; height: 14px; margin: 0; }
.ledger.only-explained tbody tr:not(.is-explained) { display: none; }
.an-results .ledger-head { flex-wrap: wrap; row-gap: 4px; }
@media (max-width: 900px) {
    .an-split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
    /* Here an unexplained peak is information, not an empty cell: keep its note */
    #an-ledger tbody td .none { display: inline; }
}
#an-clear[hidden] { display: none; }
/* The pinned figure fits a laptop window whole: plate capped by the viewport height */
.an-figure .an-plate { min-height: min(260px, 30vh); }
.an-figure .an-plate img { max-height: min(300px, 32vh); }
/* The spectrum's sticks lead to their ledger rows: hover in ink, not red */
.an-spectrum .atlas-spectrum-svg .hit { cursor: pointer; }
.an-spectrum .atlas-spectrum-svg .hit:hover { stroke: var(--ink); stroke-opacity: 0.08; }
#an-back[hidden] { display: none; }
@media (max-width: 900px) {
    .an-search.is-analysed .sub-preview { display: none; }   /* the results plate shows the same drawing */
    .an-readout-row { flex-wrap: wrap; }
}

/* ------------------------------------------------------------------------
   Compound editor (dialog): spectrum table + live preview, conditions, full name
   ------------------------------------------------------------------------ */
.compound-editor input[type="text"], .compound-editor textarea {
    width: 100%; min-height: 32px; padding: 5px 8px;
    border: 1px solid var(--rule); border-radius: var(--radius);
    font: inherit; font-size: 14px; background: var(--paper); color: var(--ink);
}
.compound-editor input[type="text"]:hover, .compound-editor textarea:hover { border-color: var(--ink-3); }
.compound-editor input[type="text"]:focus, .compound-editor textarea:focus {
    outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink);
}
.compound-editor input[aria-invalid="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.compound-editor .lbl { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; color: var(--ink); }
.compound-editor textarea { font-family: var(--font-data); font-size: 13px; line-height: 1.5; resize: vertical; }

.spectrum-edit { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 20px; align-items: start; }
.spectrum-edit-preview { position: sticky; top: 52px; }

.peak-table { width: 100%; border-collapse: collapse; }
.peak-table th {
    text-align: left; font-size: 11.5px; font-weight: 600; color: var(--ink-3);
    padding: 0 6px 4px; border-bottom: 1px solid var(--rule-strong);
}
.peak-table td { padding: 2px 0; border-bottom: 1px solid var(--rule); }
.peak-table td + td { padding-left: 6px; }
.peak-table input[type="text"] {
    min-height: 28px; padding: 3px 6px; border-color: transparent; background: transparent;
    font-family: var(--font-data); font-size: 13px; font-variant-numeric: tabular-nums;
}
.peak-table input[type="text"]:hover { border-color: var(--rule); }
.peak-table tr.is-base input[data-col="intensity"] { color: var(--accent); font-weight: 700; }   /* red = base peak only */
.row-delete {
    display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px;
    border: 1px solid transparent; border-radius: var(--radius); background: none; color: var(--ink-3); cursor: pointer;
}
.row-delete svg { width: 12px; height: 12px; }
.row-delete:hover { color: var(--accent); border-color: var(--accent); }
.row-delete:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.peak-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.paste-box { border-top: 1px solid var(--rule); padding-top: 10px; margin-top: 4px; }
.paste-box summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.paste-box summary:hover { color: var(--ink); }
.paste-box[open] summary { margin-bottom: 8px; }
.paste-box .lbl { font-weight: 500; color: var(--ink-2); }

.preview-frame { border: 1px solid var(--rule); padding: 10px 12px 6px; min-height: 120px; }
.preview-frame .atlas-spectrum-svg { width: 100%; height: auto; }
.preview-status { font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.preview-note, .field-hint { font-size: 12.5px; color: var(--ink-3); margin-top: 4px; }
.preview-lost { margin-top: 10px; padding: 8px 10px; border: 1px solid var(--rule-strong); background: var(--inset); font-size: 13px; }
.preview-lost ul { margin: 4px 0 0 18px; }
.preview-error, .editor-error { color: var(--accent); font-size: 13px; margin-top: 6px; }
.compound-editor > .editor-error { margin: 0 0 10px; }

.conditions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 20px; }
.full-name-input { max-width: 640px; }

.compound-editor .footer-buttons, .compound-editor .footer-choice { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.footer-choice p { font-size: 13.5px; color: var(--ink); margin-right: 6px; }

@media (max-width: 700px) {
    .spectrum-edit { grid-template-columns: minmax(0, 1fr); }
    .spectrum-edit-preview { position: static; order: -1; }
}

/* ==========================================================================
   Compound detail: the proof sheet. A compound row (parent plate beside its
   data), then the full-width spectrum, pinned over a ruled grid of assigned-peak
   cells in m/z order; unassigned peaks fold into one line; the record closes
   the page.
   ========================================================================== */
.detail-title:has(+ .compound-row) { border-bottom: 0; padding-bottom: 14px; margin-bottom: 0; }
.detail-subline { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: -4px; }
.detail-subline .detail-fullname { flex-basis: auto; margin-top: 0; }
.title-mods { list-style: none; display: flex; flex-wrap: wrap; gap: 5px; margin: 0; padding: 0; }
.title-mods .chip { min-height: 24px; padding: 2px 7px; font-size: 12.5px; color: var(--ink-2); }
.title-mods .chip:hover { color: var(--ink); }

/* Row 1: the parent structure beside its data (scrolls with the page) */
.compound-row {
    display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    background: var(--paper);
    border: 1px solid var(--rule); border-top: 2px solid var(--ink);
}
.band-plate {
    display: flex; align-items: center; justify-content: center;
    padding: 18px 20px; border-right: 1px solid var(--rule);
    color: var(--ink-3); font-size: 13px; min-width: 0; min-height: 220px;
}

/* Row 2: the full-width spectrum, pinned over the proof sheet. Condensed (compound row out
   of view) it makes room for a small copy of the structure at its left */
.sheet-band {
    position: sticky; top: 0; z-index: 15;
    display: grid; grid-template-columns: 0 minmax(0, 1fr);
    background: var(--paper);
    border: 1px solid var(--rule); border-top: 0;
}
.band-mini { display: none; grid-column: 1; grid-row: 1; }
.sheet-band > .band-spectrum { grid-column: 2; grid-row: 1; }
.sheet-band.is-condensed { grid-template-columns: minmax(0, 290px) minmax(0, 1fr); border-top: 2px solid var(--ink); }
.sheet-band.is-condensed .band-mini {
    display: flex; align-items: center; justify-content: center;
    padding: 10px 12px; border-right: 1px solid var(--rule); min-width: 0;
}
.band-mini img { display: block; width: 100%; max-height: 170px; height: auto; }
.dark .band-mini img { filter: invert(1) hue-rotate(180deg); }
.band-plate img {
    /* vector drawing, scaled up to fill the plate: the parent leads the page */
    display: block; width: 100%; height: auto; max-height: 320px;
}
.dark .band-plate img { filter: invert(1) hue-rotate(180deg); }
.band-spectrum { margin: 0; padding: 14px 16px 0; min-width: 0; display: flex; flex-direction: column; }
.band-spectrum .atlas-spectrum { padding: 0; }
.band-spectrum .atlas-spectrum:focus-visible { outline-offset: 4px; }

.band-readout {
    display: flex; align-items: baseline; gap: 12px; min-height: 30px;
    padding: 5px 0 7px; font-size: 12.5px; color: var(--ink-3);
}
.band-readout .atlas-readout { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.band-readout .atlas-readout .hint { color: var(--ink-3); font-family: var(--font-ui); }
.band-conditions-values .cond { white-space: nowrap; }
.band-conditions-values .cond-sep { color: var(--ink-3); }
.sheet-head .ui-word { font-style: italic; font-weight: 500; font-size: 12.5px; color: var(--ink-2); margin-left: 2px; }
.band-data {
    padding: 16px 20px 16px; display: flex; flex-direction: column; justify-content: center; gap: 14px; min-width: 0;
}
.band-numbers { gap: 10px 28px; }
.band-numbers dd { font-size: 15px; }
.band-smiles dd { font-size: 12.5px; line-height: 1.45; }
.band-conditions { display: flex; flex-direction: column; gap: 2px; margin: 0; padding-top: 8px; border-top: 1px solid var(--rule); }
.band-label { font-size: 11.5px; color: var(--ink-3); }
.band-conditions-values { font-family: var(--font-data); font-size: 12.5px; line-height: 1.5; color: var(--ink); }

.proof-sheet { margin-top: 22px; }
.sheet-head {
    display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
    padding-bottom: 8px; border-bottom: 1px solid var(--rule-strong);
}
.sheet-head h2 { font-size: 16px; }
.sheet-head span { font-size: 13px; color: var(--ink-3); }

/* Rows of cells sized to their structures: each cell starts at its natural width (--cell-w,
   from the server) and rows stretch in proportion to fill the width, like a justified proof
   sheet. The last row keeps natural widths (the filler takes the rest) */
.sheet-grid {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-wrap: wrap;
    border-left: 1px solid var(--rule);
}
.sheet-grid::after { content: ""; flex: 100000 1 0px; }
.sheet-cell {
    flex: var(--cell-w, 168) 1 calc(var(--cell-w, 168) * 1px); max-width: 100%;
    display: flex; flex-direction: column; gap: 8px; min-width: 0;
    padding: 9px 11px 11px;
    background: var(--paper);
    border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
    scroll-margin-top: calc(var(--band-h, 0px) + 12px); scroll-margin-bottom: 16px;
}
.sheet-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sheet-cell.is-active { background: var(--inset); box-shadow: inset 0 0 0 1px var(--ink); }
.cell-head { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; column-gap: 8px; row-gap: 5px; }
.cell-mz { font-family: var(--font-data); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.cell-int { justify-self: end; font-family: var(--font-data); font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
/* Intensity on a full-width track, so 1-5 % reads as a small share of a visible scale */
.cell-bar {
    grid-column: 1 / -1; display: block; height: 2px; width: 100%;
    background: linear-gradient(var(--ink) 0 0) 0 0 / var(--w) 100% no-repeat, var(--rule);
}
.sheet-cell.is-bp .cell-mz, .sheet-cell.is-bp .cell-int { color: var(--accent); }
.sheet-cell.is-bp .cell-bar { background: linear-gradient(var(--accent) 0 0) 0 0 / var(--w) 100% no-repeat, var(--rule); }
/* the structures sit centred in what the cell has left under its key */
.cell-frags { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; align-content: center; gap: 10px 14px; flex: 1; }
.cell-frag {
    display: flex; flex-direction: column; align-items: center; gap: 3px; max-width: 100%;
    color: var(--ink); text-decoration: none;
}
.cell-frag img { display: block; width: auto; height: auto; max-width: 100%; }   /* natural scale */
.dark .cell-frag img { filter: invert(1) hue-rotate(180deg); }
.cell-frag span { font-size: 12.5px; font-weight: 650; text-align: center; overflow-wrap: anywhere; }
.cell-frag:hover span { text-decoration: underline; text-underline-offset: 3px; }

.sheet-empty {
    display: flex; align-items: center; gap: 14px; padding: 18px 14px;
    border: 1px solid var(--rule); border-top: 0; background: var(--paper);
    color: var(--ink-3); font-size: 14px;
}

.sheet-unassigned { display: flex; align-items: baseline; gap: 6px 12px; flex-wrap: wrap; padding: 12px 0 0; }
.un-label { font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.un-count { font-family: var(--font-data); font-weight: 500; color: var(--ink-3); margin-left: 2px; }
.sheet-unassigned ul { list-style: none; display: flex; flex-wrap: wrap; margin: 0; padding: 0; }
.sheet-unassigned li { display: inline-flex; align-items: baseline; }
.sheet-unassigned li + li::before { content: "·"; color: var(--ink-3); padding: 0 1px; }
.unassigned-peak {
    font: inherit; font-family: var(--font-data); font-size: 12.5px; font-variant-numeric: tabular-nums;
    color: var(--ink-2); background: none; cursor: default;
    border: 1px solid transparent; border-radius: var(--radius); padding: 1px 4px;
    scroll-margin-top: calc(var(--band-h, 0px) + 12px);
}
.unassigned-peak .un-int { color: var(--ink-3); }
.unassigned-peak:hover, .unassigned-peak.is-active { color: var(--ink); background: var(--inset); border-color: var(--rule); }
.unassigned-peak.is-active { border-color: var(--ink); }
.unassigned-peak:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.unassigned-peak.is-bp .un-mz { color: var(--accent); }

.proof-sheet + .detail-record {
    margin-top: 28px; padding: 10px 0 0;
    background: none; border: 0; border-top: 1px solid var(--rule);
}

@media (max-width: 900px) {
    .compound-row { grid-template-columns: minmax(0, 1fr); }
    .band-plate { border-right: 0; border-bottom: 1px solid var(--rule); min-height: 0; }
    .sheet-band { position: static; }
    .sheet-band.is-condensed { grid-template-columns: 0 minmax(0, 1fr); border-top: 0; }
    .sheet-band.is-condensed .band-mini { display: none; }
    .band-readout { flex-direction: column; gap: 2px; }
    .band-readout .spectrum-legend { margin-left: 0; }
}
