/* DSLR SQM Estimator: one page, no build step.
   Themes: Light, Dark and Night (red) from the header switch; with no choice saved, the OS setting
   picks light or dark. Colour does jobs only: actions, state, and the Bortle scale. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --border: #d5d9e0;          /* panel edges */
  --control: #7b8494;         /* input and button edges (3:1 or better) */
  --text: #14181f;
  --muted: #4d5563;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-soft: #e8eefc;
  --ok: #15803d;
  --warn: #8a4b00;
  --warn-bg: #fff6e5;
  --warn-line: #e3b25c;
  --severe: #b42318;
  --severe-bg: #fdecea;
  --severe-line: #e8968e;
  --frame-bg: #0b0d10;
  --mark: #14181f;            /* reading marker on the Bortle scale */
  --radius: 6px;
  --radius-sm: 3px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0f1115; --surface: #171a20; --surface-2: #1f232b; --border: #2c313b; --control: #6b7484;
    --text: #e7e9ee; --muted: #a3aab7; --accent: #7ea6ff; --accent-ink: #0f1115; --accent-soft: #1c2740;
    --ok: #4cc38a; --warn: #f0b44c; --warn-bg: #2a2214; --warn-line: #6b5426;
    --severe: #ff8a80; --severe-bg: #2c1716; --severe-line: #6e2f2a; --frame-bg: #050607; --mark: #e7e9ee;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0f1115; --surface: #171a20; --surface-2: #1f232b; --border: #2c313b; --control: #6b7484;
    --text: #e7e9ee; --muted: #a3aab7; --accent: #7ea6ff; --accent-ink: #0f1115; --accent-soft: #1c2740;
    --ok: #4cc38a; --warn: #f0b44c; --warn-bg: #2a2214; --warn-line: #6b5426;
    --severe: #ff8a80; --severe-bg: #2c1716; --severe-line: #6e2f2a; --frame-bg: #050607; --mark: #e7e9ee;
    color-scheme: dark;
}
/* Red night mode: one hue only. State is carried by icons, weight and wording, never by colour. */
:root[data-theme="red"] {
  --bg: #0a0000; --surface: #140303; --surface-2: #1d0505; --border: #3d0c0c; --control: #b8352b;
  --text: #ff6a5a; --muted: #e0503f; --accent: #ff4a3a; --accent-ink: #0a0000; --accent-soft: #2a0707;
  --ok: #ff6a5a; --warn: #ff6a5a; --warn-bg: #1d0505; --warn-line: #b8352b;
  --severe: #ff6a5a; --severe-bg: #2a0707; --severe-line: #e0503f; --frame-bg: #050000; --mark: #ff6a5a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { scrollbar-color: var(--control) var(--bg); }
body {
  min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text); font: 16px/1.5 var(--font);
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: var(--accent-ink); }
a { color: var(--accent); text-underline-offset: 0.18em; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 0.35rem; letter-spacing: -0.01em; }
h2 { font-size: 1.125rem; line-height: 1.3; margin: 2rem 0 0.6rem; }
.lead { color: var(--muted); max-width: 44rem; margin: 0 0 1.5rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ shell */
.top { background: var(--surface); border-bottom: 1px solid var(--border); view-transition-name: site-header; }
.top-inner, .foot-inner, main { width: 100%; max-width: 72rem; margin: 0 auto; padding: 0 16px; }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 56px; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.top nav { display: flex; gap: 0.5rem; align-items: center; }
.top nav a, .top nav button {
  font: inherit; font-size: 0.9375rem; color: var(--text); text-decoration: none; background: none;
  border: 1px solid transparent; border-radius: var(--radius-sm); padding: 0.35rem 0.6rem; cursor: pointer; min-height: 36px;
}
.top nav a:hover { background: var(--surface-2); }
/* Theme switch: three quiet text options, no box; the chosen one sits on a soft accent tint. */
.theme-switch { display: inline-flex; gap: 2px; }
.top nav .theme-switch button { min-height: 32px; padding: 0.25rem 0.65rem; border: 0; border-radius: var(--radius-sm); background: none; font-weight: 500; font-size: 0.875rem; color: var(--muted); }
.top nav .theme-switch button:hover { background: var(--surface-2); color: var(--text); }
.top nav .theme-switch button[aria-checked="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
main { flex: 1 0 auto; padding-top: 2rem; padding-bottom: 3rem; }
.foot { border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 0.875rem; view-transition-name: site-footer; }
.foot-inner { padding-top: 1rem; padding-bottom: 1.25rem; }
.foot p { margin: 0.2rem 0; }

.banner { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 0.7rem 1rem; margin: 0 0 1.5rem; }
.banner.error { border-color: var(--severe-line); background: var(--severe-bg); color: var(--severe); }

/* ------------------------------------------------------------------ controls */
button, .button-link {
  font: inherit; font-weight: 600; border-radius: var(--radius-sm); padding: 0.55rem 1rem; min-height: 40px; cursor: pointer;
  border: 1px solid var(--control); background: var(--surface); color: var(--text); text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}
button:hover, .button-link:hover { background: var(--surface-2); }
button.primary, .button-link.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover, .button-link.primary:hover { filter: brightness(1.08); background: var(--accent); }
button.link { background: none; border: none; color: var(--accent); padding: 0.25rem 0; min-height: 32px; font-weight: 500; text-decoration: underline; text-underline-offset: 0.18em; }
button:disabled { opacity: 0.55; cursor: progress; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label { display: block; font-size: 0.9375rem; }
label.check { display: flex; gap: 0.55rem; align-items: center; min-height: 32px; }
input[type="text"], input[type="number"], input[type="datetime-local"], select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--control);
  border-radius: var(--radius-sm); padding: 0.45rem 0.6rem; margin-top: 0.25rem; min-height: 40px;
}
input::placeholder { color: var(--muted); opacity: 1; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem; }
.help { color: var(--muted); font-size: 0.875rem; margin: 0.3rem 0 0; }

.icon { width: 1em; height: 1em; flex: none; vertical-align: -0.125em; }

/* ------------------------------------------------------------------ upload */
.upload { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 2rem; align-items: start; }
.drop {
  display: block; position: relative; border: 1.5px dashed var(--control); border-radius: var(--radius);
  padding: 2.25rem 1.25rem; text-align: center; background: var(--surface); margin-bottom: 0.75rem; cursor: pointer;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.drop.small { padding: 1.1rem 1.25rem; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.drop.has-file { border-style: solid; border-color: var(--accent); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop-title { display: flex; justify-content: center; align-items: center; gap: 0.4rem; font-weight: 600; }
.drop-title em { font-weight: 400; color: var(--muted); font-style: normal; }
.drop-hint { display: block; color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; margin-top: 0.15rem; }
.drop.has-file .drop-hint { color: var(--text); }
.upload-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.tips { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 1rem 1.25rem; }
.tips h2 { margin: 0 0 0.5rem; font-size: 1rem; }
.tips ul { padding-left: 1.1rem; margin: 0 0 0.6rem; }
.tips li { margin: 0.2rem 0; }
.tips p { margin: 0; }

/* ------------------------------------------------------------------ review */
.attention { border: 1px solid var(--warn-line); background: var(--warn-bg); border-radius: var(--radius); padding: 0.75rem 1rem; margin: 0 0 1.5rem; }
.attention b { display: flex; align-items: center; gap: 0.45rem; color: var(--warn); }
.attention ul { margin: 0.35rem 0 0; padding-left: 1.5rem; }
.review-layout { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; gap: 2rem; align-items: start; }
.group { margin: 0 0 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.group > h2 { margin: 0; font-size: 0.9375rem; padding: 0.6rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.item { display: grid; grid-template-columns: 12.5rem minmax(0, 1fr) auto; gap: 0.25rem 1rem; align-items: center; padding: 0.55rem 1rem; min-height: 48px; border-top: 1px solid var(--border); }
.group > h2 + .item { border-top: 0; }
.item .label { display: flex; align-items: center; gap: 0.3rem; color: var(--muted); font-size: 0.9375rem; }
.item.needs .label { color: var(--warn); font-weight: 600; }
.item .full { grid-column: 1 / -1; }
.item .val { display: flex; align-items: center; gap: 0.35rem; min-width: 0; }
.item .val-text { min-width: 0; overflow-wrap: anywhere; }
.item:has(.editor) .val-text { cursor: text; }
.item.editing .val-text, .item.editing .edit-btn, .item.editing .reset-btn { display: none; }
.item .editor { display: flex; gap: 0.5rem; flex: 1; min-width: 0; }
.item .editor input, .item .editor select {
  margin: -2px 0; min-height: 32px; padding: 0.2rem 0.5rem; font-size: 1rem; line-height: 1.4;
  width: auto; flex: 0 1 11rem; min-width: 0; border-color: var(--border); background: var(--bg);
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.item .editor input[type="datetime-local"] { flex-basis: 15rem; }
.item .editor select { flex-basis: 14rem; padding-right: 1.6rem; }
.item .editor input:focus, .item .editor select:focus { border-color: var(--accent); background: var(--surface); }
.item .src { justify-self: end; }
.icon-btn { min-height: 30px; width: 30px; padding: 0; border: 1px solid transparent; background: none; color: var(--muted); font-weight: 400; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.icon-btn .icon { width: 16px; height: 16px; }
.reset-btn { color: var(--accent); }
button.info { min-height: 24px; width: 24px; padding: 0; border: 0; background: none; color: var(--muted); border-radius: 50%; }
button.info:hover, button.info[aria-expanded="true"] { color: var(--accent); background: none; }
button.info .icon { width: 16px; height: 16px; }
.inline-warn { grid-column: 2 / -1; display: flex; gap: 0.45rem; align-items: flex-start; color: var(--warn); font-size: 0.875rem; margin: 0.15rem 0 0; }
.inline-warn .icon { margin-top: 0.2em; }
.review-side { position: sticky; top: 1rem; display: grid; gap: 1rem; }
.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 0.9rem 1rem 0.75rem; }
.panel h2 { margin: 0 0 0.6rem; font-size: 0.9375rem; }
.map { position: relative; height: 240px; border-radius: var(--radius-sm); border: 1px solid var(--control); background: var(--surface-2); cursor: crosshair; }
.map-hint { margin: 0.55rem 0 0.1rem; color: var(--muted); font-size: 0.9375rem; }
.side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.side-actions .primary { order: 2; }
.darks { margin: 0 0 1.25rem; }
/* Red mode: the map loses its colour too (tiles and pin), then takes the one red. */
:root[data-theme="red"] .map .leaflet-pane { filter: grayscale(1) brightness(0.5) contrast(1.15); }
:root[data-theme="red"] .map::after { content: ""; position: absolute; inset: 0; background: #ff2a1a; mix-blend-mode: multiply; pointer-events: none; z-index: 900; }
:root[data-theme="red"] .map .leaflet-bar a { background: var(--surface); color: var(--text); border-color: var(--control); }
:root[data-theme="red"] .map .leaflet-control-attribution { background: var(--surface); color: var(--muted); }
:root[data-theme="red"] .map .leaflet-control-attribution a { color: var(--text); }
:root[data-theme="red"] .map .leaflet-attribution-flag { display: none !important; }

/* Info pop-up (native popover, positioned by script next to its (i) button). */
.pop {
  position: fixed; inset: auto; margin: 0; max-width: 22rem; padding: 0.65rem 0.8rem; font-size: 0.875rem; line-height: 1.45;
  color: var(--muted); background: var(--surface); border: 1px solid var(--control); border-radius: var(--radius);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
}
.pop p { margin: 0; }
.pop p + p { margin-top: 0.4rem; }
.pop b { font-weight: 600; color: var(--text); }

.chip {
  display: inline-block; font-size: 0.75rem; line-height: 1.4; padding: 0.15rem 0.45rem; border-radius: 2px;
  border: 1px solid var(--control); color: var(--muted); white-space: nowrap; background: var(--surface);
}
.chip.user { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip.missing { border-color: var(--warn-line); color: var(--warn); background: var(--warn-bg); font-weight: 600; }

/* ------------------------------------------------------------------ processing */
.processing { max-width: 40rem; }
.progress { height: 8px; background: var(--surface-2); border-radius: 2px; overflow: hidden; border: 1px solid var(--border); margin: 1rem 0 0.5rem; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width 600ms var(--ease); }
.checklist { list-style: none; padding: 0; margin: 1.25rem 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.checklist li { display: flex; gap: 0.6rem; align-items: center; padding: 0.45rem 0.9rem; color: var(--muted); border-top: 1px solid var(--border); }
.checklist li:first-child { border-top: 0; }
.checklist li .icon { width: 1.1em; height: 1.1em; }
.checklist li.running { color: var(--text); font-weight: 600; background: var(--accent-soft); }
.checklist li.running .icon { color: var(--accent); animation: spin 1s linear infinite; }
.checklist li.ran { color: var(--text); }
.checklist li.ran .icon { color: var(--ok); }
.checklist li.degraded .icon { color: var(--warn); }
.checklist li.failed { color: var(--severe); font-weight: 600; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ results */
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.result-head h1 { margin: 0; }
.head-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.result-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 13.5rem minmax(0, 26rem); grid-template-rows: auto 1fr;
  grid-template-areas: "reading scale frame" "facts scale frame"; column-gap: 2rem; align-items: start;
}
.result-grid .reading { grid-area: reading; }
.result-grid .scale { grid-area: scale; }
.result-grid .frame { grid-area: frame; }
.result-grid .facts { grid-area: facts; }
.result-grid.no-frame { grid-template-columns: minmax(0, 32rem) 13.5rem; grid-template-areas: "reading scale" "facts scale"; }
.sqm-row { display: flex; align-items: center; gap: 0.75rem; }
.sqm { font-size: 4.5rem; font-weight: 700; line-height: 1; letter-spacing: -0.03em; }
.sqm-side { display: flex; flex-direction: column; gap: 0.1rem; }
.sqm-side .sigma { display: flex; align-items: center; gap: 0.2rem; font-size: 1.25rem; font-weight: 500; color: var(--text); }
.sqm-side .unit { color: var(--muted); }
.band-label { font-size: 1.25rem; font-weight: 700; margin: 1rem 0 0; display: flex; align-items: center; gap: 0.55rem; }
.band-label .swatch { width: 14px; height: 14px; border-radius: 2px; border: 1px solid var(--control); flex: none; }
.band-sub { margin: 0.1rem 0 0; color: var(--muted); }
.trust { display: flex; gap: 0.6rem; align-items: flex-start; border: 1px solid var(--warn-line); background: var(--warn-bg); border-radius: var(--radius); padding: 0.75rem 0.9rem; margin: 1.25rem 0 0; }
.trust .icon { color: var(--warn); margin-top: 0.2em; }
.trust b { color: var(--warn); }
.trust.neutral { border-color: var(--border); background: var(--surface); }
.trust.neutral .icon { color: var(--muted); }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.45rem 1.25rem; margin: 1.5rem 0 0; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.facts dt { color: var(--muted); font-size: 0.9375rem; }
.facts dd { margin: 0; }

/* Vertical Bortle scale: seven classes at equal height, three shades each, darkest sky at the top. */
.scale { margin: 0; }
.scale-inner { display: inline-flex; flex-direction: column; align-items: center; }
.scale figcaption { font-weight: 600; font-size: 0.9375rem; margin-bottom: 0.6rem; text-align: center; }
.scale-body { display: grid; grid-template-columns: 3rem 22px 3rem; column-gap: 0.5rem; position: relative; }
.scale-classes, .scale-bounds { position: relative; height: var(--scale-h, 378px); font-size: 0.8125rem; color: var(--text); }
.scale-classes span { position: absolute; right: 0; transform: translateY(-50%); }
.scale-bounds span { position: absolute; left: 0; transform: translateY(-50%); }
.scale-bar { position: relative; height: var(--scale-h, 378px); display: flex; flex-direction: column; border: 1px solid var(--control); border-radius: 2px; overflow: visible; }
.scale-bar i { display: block; flex: 1; }
/* Lines between Bortle classes: bold, overhanging the bar so they meet the class values. */
.scale-bar i.cls-top { position: relative; }
.scale-bar i.cls-top::before { content: ""; position: absolute; left: -5px; right: -5px; top: -1px; height: 2px; background: var(--text); }
/* Reading marker: a dotted line from the bar's left edge out to the value tag (bar border + column gap + tag offset). */
.scale-mark { position: absolute; left: 0; right: calc(-2rem - 1px); height: 0; border-top: 2px dotted var(--mark); }
.scale-bounds .scale-read { left: 1.5rem; }
.scale-read { position: absolute; transform: translateY(-50%); background: var(--mark); color: var(--bg); font-weight: 700; font-size: 0.8125rem; padding: 0.1rem 0.4rem; border-radius: 2px; white-space: nowrap; }
/* Red mode keeps the scale's lightness steps but only one hue: grey it, then multiply red over it. */
:root[data-theme="red"] .scale-bar i, :root[data-theme="red"] .band-label .swatch { filter: grayscale(1) brightness(0.85); }
:root[data-theme="red"] .scale-bar::after, :root[data-theme="red"] .band-label .swatch::after {
  content: ""; position: absolute; inset: 0; background: #ff2a1a; mix-blend-mode: multiply; pointer-events: none;
}
.band-label .swatch { position: relative; }
:root[data-theme="red"] .legend svg * { stroke: #ff6a5a; }

/* Frame preview with what the analysis used drawn over it. */
.frame { margin: 0; }
.frame figcaption { font-weight: 600; font-size: 0.9375rem; margin-bottom: 0.6rem; }
.frame-view { position: relative; background: var(--frame-bg); border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); }
.frame-view img { display: block; width: 100%; height: auto; }
.frame-view svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.frame-view .used { fill: none; stroke: #ffd24a; stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.frame-view .matched { fill: none; stroke: #9fb3c8; stroke-width: 1; stroke-dasharray: 2 2; vector-effect: non-scaling-stroke; opacity: 0.8; }
.frame-view .bgbox, .frame-view .catalog { fill: none; stroke: #7fd0ff; stroke-width: 1.4; stroke-dasharray: 6 4; vector-effect: non-scaling-stroke; }
.frame-view .catalog { stroke: #c9a7ff; }
:root[data-theme="red"] .frame-view img { filter: sepia(1) hue-rotate(-50deg) saturate(6) brightness(0.75); }
:root[data-theme="red"] .frame-view .used, :root[data-theme="red"] .frame-view .matched,
:root[data-theme="red"] .frame-view .bgbox, :root[data-theme="red"] .frame-view .catalog { stroke: #ff6a5a; }
.frame-empty { aspect-ratio: 3 / 2; display: grid; place-items: center; text-align: center; padding: 1rem; color: var(--muted); border: 1px dashed var(--control); border-radius: var(--radius-sm); font-size: 0.875rem; }
.legend { list-style: none; padding: 0; margin: 0.6rem 0 0; display: grid; gap: 0.3rem; font-size: 0.8125rem; color: var(--muted); }
.legend li { display: flex; gap: 0.5rem; align-items: center; }
.legend svg { width: 22px; height: 14px; flex: none; background: var(--frame-bg); border-radius: 2px; }

.conditions dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.4rem 1.25rem; margin: 0; }
.conditions .cond { display: contents; }
.conditions dt { color: var(--muted); }
.conditions dd { margin: 0; display: flex; gap: 0.45rem; align-items: flex-start; }
.conditions dd .icon { margin-top: 0.2em; }
.conditions .cond.ok dd .icon { color: var(--ok); }
.conditions .cond.warn dd .icon { color: var(--warn); }
.conditions .cond.neutral dd .icon { color: var(--muted); }

.notice-list { display: grid; gap: 0.5rem; margin: 0.6rem 0; }
.notice { display: flex; gap: 0.6rem; align-items: flex-start; border: 1px solid var(--border); background: var(--surface); padding: 0.65rem 0.9rem; border-radius: var(--radius); }
.notice .icon { margin-top: 0.2em; color: var(--muted); }
.notice.warn { border-color: var(--warn-line); background: var(--warn-bg); }
.notice.warn .icon { color: var(--warn); }
.notice.severe { border-color: var(--severe-line); background: var(--severe-bg); }
.notice.severe .icon { color: var(--severe); }
.notice .fix { display: block; color: var(--muted); font-size: 0.875rem; }
.tips-list { margin: 0.4rem 0; padding-left: 1.25rem; }

details.how { margin-top: 2rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
details.how > summary { cursor: pointer; font-weight: 600; padding: 0.75rem 1rem; min-height: 44px; display: flex; align-items: center; gap: 0.5rem; list-style: none; }
details.how > summary::-webkit-details-marker { display: none; }
details.how > summary .icon { transition: transform 150ms var(--ease); color: var(--muted); }
details.how[open] > summary .icon { transform: rotate(90deg); }
details.how > summary:hover { background: var(--surface-2); }
details.how[open] > summary { border-bottom: 1px solid var(--border); }
details.how > .how-body { padding: 0.25rem 1rem 1rem; }
details.how h3 { font-size: 1rem; margin: 1.25rem 0 0.5rem; }
details summary { cursor: pointer; }
.log { font-family: var(--mono); font-size: 0.8125rem; background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.75rem 1rem; overflow-x: auto; margin-top: 0.75rem; }
.log div { display: flex; gap: 0.5rem; align-items: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; padding: 0.1rem 0; }
.log .icon { margin-top: 0.2em; }
.log .s-ran .icon { color: var(--ok); } .log .s-degraded .icon { color: var(--warn); } .log .s-failed { color: var(--severe); } .log .s-skipped { color: var(--muted); }
table.inputs { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
table.inputs th, table.inputs td { text-align: left; padding: 0.5rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.inputs th { color: var(--muted); font-weight: 500; }
table.inputs td:last-child { text-align: right; }
.inputs-wrap { overflow-x: auto; }

.share { margin-top: 2rem; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); padding: 1rem 1.25rem; }
.share h2 { margin: 0 0 0.5rem; font-size: 1rem; }
.share-row { display: flex; gap: 0.75rem; align-items: stretch; margin-top: 0.5rem; }
.share-row input { margin-top: 0; font-family: var(--mono); font-size: 0.8125rem; }
.share-row button { flex: none; }

/* ------------------------------------------------------------------ guide (Read) */
.prose > * { max-width: 42rem; }
.prose p, .prose li { max-width: 68ch; }
.prose h2 { margin-top: 2.25rem; }
.prose li { margin: 0.35rem 0; }

/* ------------------------------------------------------------------ step changes */
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) { animation: 160ms var(--ease) both step-out; }
  ::view-transition-new(root) { animation: 240ms var(--ease) both step-in; }
}
@keyframes step-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes step-in { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) {
  .checklist li.running .icon { animation: none; }
  .progress .bar { transition: none; }
}

/* ------------------------------------------------------------------ narrow screens */
@media (max-width: 1100px) {
  .review-layout { grid-template-columns: minmax(0, 1fr) 18rem; gap: 1.5rem; }
  .result-grid { grid-template-columns: minmax(0, 1fr) 13.5rem; grid-template-rows: auto auto auto; grid-template-areas: "reading scale" "facts scale" "frame frame"; }
  .result-grid .frame { max-width: 32rem; margin-top: 2rem; }
}
@media (max-width: 760px) {
  .upload { grid-template-columns: 1fr; }
  .review-layout { grid-template-columns: 1fr; }
  .review-side { position: static; }
  .item { grid-template-columns: minmax(0, 1fr) auto; }
  .item .label { grid-column: 1 / -1; font-size: 0.875rem; }
  .item .val { grid-column: 1; }
  .item .src { grid-row: 2; grid-column: 2; }
  .inline-warn { grid-column: 1 / -1; }
  .result-grid.no-frame { grid-template-columns: 1fr; grid-template-areas: "reading" "scale" "facts"; }
  .result-grid { grid-template-columns: 1fr; grid-template-areas: "reading" "scale" "frame" "facts"; row-gap: 2rem; }
  .result-grid .frame { margin-top: 0; }
  .sqm { font-size: 3.5rem; }
  .facts { grid-template-columns: 1fr; gap: 0.1rem; margin-top: 0; }
  .facts dd { margin-bottom: 0.5rem; }
  .share-row { flex-direction: column; }
}
@media (max-width: 440px) {
  .brand { font-size: 0.9375rem; }
  .top nav { gap: 0.25rem; }
  .top nav .theme-switch button { padding: 0.25rem 0.5rem; }
  .head-actions { display: grid; grid-template-columns: auto 1fr; width: 100%; }
  .head-actions > * { font-size: 0.875rem; padding-left: 0.75rem; padding-right: 0.75rem; }
}
