/* Crack-risk analysis. Light and dark themes; everything is self-hosted (CSP: self only). */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin-wght.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin-ext-wght.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f2f5f8;
  --surface-3: #e9eef3;
  --border: #e2e8ef;
  --border-strong: #cdd6e1;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --accent: #0b78ad;
  --accent-hover: #08618d;
  --accent-soft: #e5f3fa;
  --accent-ring: rgba(36, 169, 225, .32);
  --on-accent: #ffffff;
  --low: #15803d;    --low-bg: #dcfce7;
  --medium: #b45309; --medium-bg: #fef3c7;
  --high: #b91c1c;   --high-bg: #fee2e2;
  --changed: #fff8e6; --changed-border: #e9b949;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --shadow-lg: 0 12px 40px -12px rgba(15, 23, 42, .25);
  --header-bg: rgba(255, 255, 255, .8);
  --code-bg: #f2f5f8;
  --radius: 14px;
  --radius-sm: 9px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0e14;
  --surface: #121821;
  --surface-2: #18202b;
  --surface-3: #202a37;
  --border: #222c39;
  --border-strong: #334155;
  --text: #e7ecf3;
  --text-2: #c4ccd7;
  --muted: #8d9aab;
  --accent: #38bdf8;
  --accent-hover: #7dd3fc;
  --accent-soft: rgba(56, 189, 248, .12);
  --accent-ring: rgba(56, 189, 248, .35);
  --on-accent: #03131d;
  --low: #4ade80;    --low-bg: rgba(74, 222, 128, .12);
  --medium: #fbbf24; --medium-bg: rgba(251, 191, 36, .13);
  --high: #f87171;   --high-bg: rgba(248, 113, 113, .14);
  --changed: rgba(251, 191, 36, .07); --changed-border: rgba(251, 191, 36, .5);
  --shadow: 0 0 0 1px rgba(255, 255, 255, .015);
  --shadow-lg: 0 16px 48px -12px rgba(0, 0, 0, .6);
  --header-bg: rgba(10, 14, 20, .78);
  --code-bg: #0d131b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0a0e14; --surface: #121821; --surface-2: #18202b; --surface-3: #202a37;
    --border: #222c39; --border-strong: #334155;
    --text: #e7ecf3; --text-2: #c4ccd7; --muted: #8d9aab;
    --accent: #38bdf8; --accent-hover: #7dd3fc; --accent-soft: rgba(56, 189, 248, .12);
    --accent-ring: rgba(56, 189, 248, .35); --on-accent: #03131d;
    --low: #4ade80; --low-bg: rgba(74, 222, 128, .12);
    --medium: #fbbf24; --medium-bg: rgba(251, 191, 36, .13);
    --high: #f87171; --high-bg: rgba(248, 113, 113, .14);
    --changed: rgba(251, 191, 36, .07); --changed-border: rgba(251, 191, 36, .5);
    --shadow: 0 0 0 1px rgba(255, 255, 255, .015); --shadow-lg: 0 16px 48px -12px rgba(0, 0, 0, .6);
    --header-bg: rgba(10, 14, 20, .78); --code-bg: #0d131b;
  }
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }
h1 { font-size: 1.85rem; line-height: 1.2; margin: 0 0 .35rem; font-weight: 650; letter-spacing: -.025em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; font-weight: 620; letter-spacing: -.01em; }
h3 { font-size: .98rem; margin: 0; font-weight: 600; }
p { margin: 0 0 .6rem; }
.lede { color: var(--muted); max-width: 72ch; font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.pre-line { white-space: pre-line; }
.clamp { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; max-width: 42ch; }
.num, .table td, .kv dd { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent-ring); }

/* ------------------------------------------------------------------ header */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--header-bg); border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.6) blur(12px); -webkit-backdrop-filter: saturate(1.6) blur(12px); }
.topbar-inner { max-width: 1320px; margin: 0 auto; padding: .7rem 1.75rem; display: flex; align-items: center; gap: 2rem; }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); font-weight: 650; letter-spacing: -.01em; }
.brand:hover { color: var(--text); text-decoration: none; }
.brand-sub { color: var(--muted); font-weight: 500; }
.brand-mark { width: 22px; height: 22px; border-radius: 7px; flex: none;
  background: conic-gradient(from 210deg, #ffeda0, #fd8d3c, #e31a1c, #800026, #ffeda0);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); }
.topnav { display: flex; gap: .25rem; flex: 1; }
.topnav a { color: var(--muted); padding: .38rem .75rem; border-radius: 999px; font-weight: 520; font-size: .93rem; }
.topnav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.topnav a.active { color: var(--text); background: var(--surface-3); }
.topbar-right { display: flex; align-items: center; gap: .6rem; }
.topbar-right form { margin: 0; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 17px; height: 17px; }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .i-sun { display: none; } :root:not([data-theme="light"]) .i-moon { display: block; } }
.who { display: flex; align-items: center; gap: .5rem; color: var(--text-2); font-size: .92rem; font-weight: 520; padding: .15rem .55rem .15rem .2rem; border-radius: 999px; }
.who:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.avatar { width: 28px; height: 28px; border-radius: 999px; display: grid; place-items: center; font-size: .75rem; font-weight: 650;
  color: var(--on-accent); background: var(--accent); }

.page { width: 100%; max-width: 1320px; margin: 0 auto; padding: 2rem 1.75rem 3.5rem; flex: 1; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.2rem 1.75rem 2rem; }
.crumbs { font-size: .87rem; color: var(--muted); margin-bottom: .7rem; display: flex; gap: .45rem; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1.5rem; margin-bottom: 1.6rem; flex-wrap: wrap; }
.page-head .lede { margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

/* ------------------------------------------------------------------ surfaces and layout */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem 1.4rem;
  margin-bottom: 1.1rem; box-shadow: var(--shadow); }
.cols3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.1rem; margin-bottom: 1.1rem; }
.cols2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.1rem; margin-bottom: 1.1rem; }
.cols3 > .panel, .cols2 > .panel { margin-bottom: 0; }
@media (max-width: 1000px) { .cols3, .cols2 { grid-template-columns: 1fr; } }
.narrow { max-width: 580px; }
.stack { display: flex; flex-direction: column; gap: .95rem; }
.stack.tight { gap: .55rem; margin: .8rem 0 .4rem; }
details.panel > summary, details.import > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: .5rem; }
details > summary::-webkit-details-marker { display: none; }
details.panel > summary::before, details.import > summary::before { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; opacity: .6; }
details[open].panel > summary::before, details[open].import > summary::before { transform: rotate(45deg); }
details.panel[open] > summary { margin-bottom: .9rem; }

/* ------------------------------------------------------------------ forms */
label { display: block; font-weight: 550; font-size: .93rem; color: var(--text-2); }
.label { font-weight: 550; font-size: .93rem; color: var(--text-2); }
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input:not([type]), input[type=password], input[type=number], select, textarea {
  display: block; width: 100%; margin-top: .35rem; padding: .55rem .7rem; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-weight: 450; transition: border-color .12s, box-shadow .12s; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
textarea { font-family: var(--mono); font-size: .84rem; resize: vertical; }
input[readonly] { background: var(--surface-2); color: var(--muted); }
input[type=file] { margin-top: .35rem; font-size: .88rem; color: var(--muted); max-width: 100%; }
input[type=file]::file-selector-button { font: inherit; font-weight: 550; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: .4rem .8rem; margin-right: .7rem; cursor: pointer; }
input[type=file]::file-selector-button:hover { border-color: var(--accent); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 1rem; height: 1rem; margin: 0; }
.choice { display: flex; align-items: center; gap: .55rem; font-weight: 450; margin: .35rem 0; color: var(--text); }
.choice input[type=number] { display: inline-block; width: 7rem; margin: 0; }
.with-unit { display: flex; align-items: center; gap: .55rem; max-width: 17rem; }
.with-unit.inline { display: inline-flex; }
.with-unit input { margin-top: 0; }
.unit { color: var(--muted); font-size: .88rem; white-space: nowrap; }
.hint { color: var(--muted); font-size: .85rem; margin: .4rem 0 0; font-weight: 400; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; height: 2.35rem; padding: 0 1rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  cursor: pointer; font-weight: 560; font-size: .92rem; white-space: nowrap; transition: background .12s, border-color .12s, color .12s, box-shadow .12s; }
.btn:hover { border-color: var(--muted); text-decoration: none; color: var(--text); background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { color: var(--high); }
.btn-danger:hover { color: var(--high); border-color: var(--high); background: var(--high-bg); }
.btn-small { height: 1.95rem; padding: 0 .7rem; font-size: .84rem; border-radius: 8px; }
.btn-big { height: 2.9rem; padding: 0 1.5rem; font-size: 1rem; border-radius: 11px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: .9rem; font-weight: 520; }
.linklike:hover { text-decoration: underline; text-underline-offset: 3px; }
.linklike.danger { color: var(--high); }
.inline-form { display: inline-flex; gap: .4rem; align-items: center; margin: 0 .5rem 0 0; }
.inline-form input { margin: 0; width: 11rem; padding: .35rem .55rem; }

/* ------------------------------------------------------------------ messages */
.flashes { margin-bottom: 1.2rem; display: flex; flex-direction: column; gap: .5rem; }
.flash { margin: 0; padding: .7rem 1rem; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text);
  border: 1px solid transparent; display: flex; gap: .6rem; align-items: baseline; }
.flash::before { content: ""; width: 8px; height: 8px; border-radius: 99px; background: var(--accent); flex: none; transform: translateY(-1px); }
.flash-error { background: var(--high-bg); } .flash-error::before { background: var(--high); }
.flash-warn { background: var(--medium-bg); } .flash-warn::before { background: var(--medium); }
.flash-ok { background: var(--low-bg); } .flash-ok::before { background: var(--low); }

/* ------------------------------------------------------------------ tables */
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th { text-align: left; font-size: .8rem; font-weight: 560; color: var(--muted); padding: .65rem .8rem; border-bottom: 1px solid var(--border); }
.table td { padding: .75rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover td { background: var(--surface-2); }
.table.projects { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table.projects td:first-child, .table.projects th:first-child { padding-left: 1.2rem; }
.table.projects a.strong { color: var(--text); font-weight: 600; }
.table.projects a.strong:hover { color: var(--accent); }
.table-scroll { overflow-x: auto; }

/* ------------------------------------------------------------------ badges, status, bars */
.risk { display: inline-flex; align-items: center; gap: .38rem; padding: .16rem .6rem .16rem .5rem; border-radius: 999px;
  font-size: .78rem; font-weight: 620; line-height: 1.35; }
.risk::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.risk-low { color: var(--low); background: var(--low-bg); }
.risk-medium { color: var(--medium); background: var(--medium-bg); }
.risk-high { color: var(--high); background: var(--high-bg); }
.status { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 560; padding: .12rem .55rem;
  border-radius: 999px; background: var(--surface-2); color: var(--muted); vertical-align: middle; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
h1 .status { font-size: .8rem; position: relative; top: -5px; margin-left: .5rem; letter-spacing: 0; }
.status-running { color: var(--accent); background: var(--accent-soft); }
.status-running::before { animation: pulse 1.2s ease-in-out infinite; }
.status-done { color: var(--low); background: var(--low-bg); }
.status-failed { color: var(--high); background: var(--high-bg); }
@keyframes pulse { 50% { opacity: .25; } }
.bar { width: 100%; height: 6px; display: block; border-radius: 99px; overflow: hidden; }
.bar-bg { fill: var(--surface-3); }
.bar-fg { fill: var(--text-2); }
.bar-tick { stroke: var(--surface); stroke-width: .9; }
.bar-cell { display: flex; align-items: center; gap: .6rem; }
.bar-cell .num { min-width: 2ch; text-align: right; font-weight: 600; }

/* ------------------------------------------------------------------ project page */
.runbox { display: flex; justify-content: space-between; align-items: center; gap: 1.5rem; padding: 1.3rem 1.5rem; margin-bottom: 1.1rem;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.runbox::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent); }
.runbox h2 { margin-bottom: .3rem; }
.runbox p { margin: 0; max-width: 80ch; color: var(--text-2); }
.runbox form { margin: 0; }
.filename { font-weight: 600; word-break: break-all; margin-bottom: .1rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.2rem; margin: 0 0 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); }
.kv.wide { grid-template-columns: minmax(10rem, max-content) 1fr; }
.changed { margin: 0 0 1rem; padding-left: 1.1rem; color: var(--text-2); }
.changed li { margin: .15rem 0; }
.import { margin-top: .9rem; padding-top: .8rem; border-top: 1px dashed var(--border); }
.import > summary { font-size: .88rem; color: var(--accent); font-weight: 560; }
.import form { display: flex; flex-direction: column; gap: .6rem; margin-top: .7rem; }
.import label { font-weight: 450; font-size: .88rem; }
.cmd { font-family: var(--mono); font-size: .8rem; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .75rem .85rem; white-space: pre-wrap; word-break: break-all; margin: .4rem 0 .5rem; color: var(--text-2); }
.empty-state { text-align: center; padding: 4rem 1rem; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.empty-state p { max-width: 56ch; margin: 0 auto 1.2rem; color: var(--muted); }

/* ------------------------------------------------------------------ settings */
.settings-form { padding: .4rem 1.4rem 1.3rem; }
.settings-form .field { display: grid; grid-template-columns: 14rem 1fr; gap: 1.2rem; padding: 1.15rem 0; border-bottom: 1px solid var(--border); }
.settings-form .field > label, .settings-form .field > .label { padding-top: .45rem; }
.settings-form .actions { margin-top: 1.2rem; }
@media (max-width: 720px) { .settings-form .field { grid-template-columns: 1fr; gap: .3rem; } }

/* ------------------------------------------------------------------ thresholds editor */
.thr-section { padding: 1.3rem 1.4rem .4rem; }
.thr-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .5rem; }
.thr-head h2 { margin-bottom: .2rem; }
.thr-head p { margin: 0; max-width: 80ch; }
.thr-row { display: grid; grid-template-columns: minmax(14rem, 1.1fr) minmax(16rem, 1.2fr) 9rem; gap: .4rem 1.4rem;
  align-items: start; padding: 1rem .9rem; margin: 0 -.9rem; border-top: 1px solid var(--border); border-radius: 0; transition: background .12s; }
.thr-row.changed { background: var(--changed); box-shadow: inset 3px 0 0 var(--changed-border); }
.thr-label .hint { margin-top: .2rem; }
.thr-inputs { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .45rem .75rem; }
.thr-inputs .sub { font-weight: 450; font-size: .8rem; color: var(--muted); }
.thr-inputs input { width: 7.5rem; }
.thr-inputs .unit { padding-bottom: .6rem; }
.band { flex-basis: 100%; margin: .15rem 0 0; font-size: .82rem; color: var(--muted); }
.band .b-low { color: var(--low); font-weight: 620; }
.band .b-medium { color: var(--medium); font-weight: 620; }
.band .b-high { color: var(--high); font-weight: 620; }
.band.bad { color: var(--high); font-weight: 600; }
.default { margin: .5rem 0 0; text-align: right; }
@media (max-width: 860px) { .thr-row { grid-template-columns: 1fr; } .default { text-align: left; margin: 0; } }
.thr-inputs input.changed, .mat-table input.changed { border-color: var(--changed-border); background: var(--changed); }
.mat-table td { padding: .5rem .45rem; }
.mat-table input { width: 100%; min-width: 6.5rem; margin: 0; }
.mat-table td:first-child { min-width: 11rem; }
.savebar { position: sticky; bottom: 1rem; display: flex; gap: .6rem; align-items: center; padding: .75rem 1rem; margin-top: .5rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); }

/* ------------------------------------------------------------------ run page */
.risk-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.1rem; margin-bottom: 1.1rem; }
@media (max-width: 1000px) { .risk-cards { grid-template-columns: 1fr; } }
.risk-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem 1.3rem 1.1rem;
  box-shadow: var(--shadow); position: relative; overflow: hidden; display: flex; flex-direction: column; gap: .55rem; }
.risk-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--border-strong); }
.risk-card.level-low::before { background: var(--low); }
.risk-card.level-medium::before { background: var(--medium); }
.risk-card.level-high::before { background: var(--high); }
.risk-card header { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.risk-index { margin: .1rem 0 0; display: flex; align-items: baseline; gap: .35rem; }
.risk-index .num { font-size: 2.4rem; font-weight: 680; letter-spacing: -.035em; line-height: 1; }
.risk-index .of { color: var(--muted); font-size: .9rem; }
.risk-card .bar { height: 7px; }
.risk-card.level-low .bar-fg { fill: var(--low); }
.risk-card.level-medium .bar-fg { fill: var(--medium); }
.risk-card.level-high .bar-fg { fill: var(--high); }
.risk-card .driver { margin: .2rem 0 0; font-size: .9rem; color: var(--text-2); }
.risk-card .what { margin: 0; font-size: .84rem; color: var(--muted); }
.waiting { display: flex; align-items: center; gap: 1rem; }
.waiting p { margin: 0; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner, .status-running::before { animation-duration: 3s; } }
.alert-error { border-color: var(--high); background: var(--high-bg); box-shadow: none; }
.log { font-family: var(--mono); font-size: .78rem; white-space: pre-wrap; word-break: break-word; max-height: 32rem; overflow: auto;
  background: var(--code-bg); border: 1px solid var(--border); padding: .8rem .9rem; border-radius: var(--radius-sm); margin: 0; color: var(--text-2); }
.downloads { list-style: none; margin: 0 0 .7rem; padding: 0; display: grid; gap: .35rem; }
.downloads a { display: flex; align-items: center; gap: .55rem; padding: .5rem .7rem; border-radius: var(--radius-sm); border: 1px solid var(--border);
  color: var(--text); font-size: .92rem; }
.downloads a::before { content: ""; width: 14px; height: 14px; flex: none; background: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12m0 0l-5-5m5 5l5-5M4 19h16'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12m0 0l-5-5m5 5l5-5M4 19h16'/%3E%3C/svg%3E") center / contain no-repeat; }
.downloads a:hover { border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.downloads a:hover::before { background: var(--accent); }
.figure { background: #ffffff; border-radius: var(--radius-sm); padding: .6rem; border: 1px solid var(--border); }
.depthmap { max-width: 100%; height: auto; display: block; margin: 0 auto; }

/* ------------------------------------------------------------------ 3D viewer */
.viewer-panel { padding: 1.1rem; }
.viewer-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; padding: 0 .3rem .8rem; }
.viewer-head h2 { margin: 0; }
.viewer-head .hint { margin: 0; }
.stage { position: relative; height: 640px; border-radius: 12px; overflow: hidden;
  background: radial-gradient(120% 90% at 40% 0%, #243247 0%, #111826 55%, #0a0f18 100%); color: #e7ecf3; }
.stage:fullscreen { height: 100vh; border-radius: 0; }
.viewer { position: absolute; inset: 0; touch-action: none; }
.viewer canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.viewer canvas:active { cursor: grabbing; }
.viewer-status { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; color: #a7b4c6; }
.readout { position: absolute; left: .9rem; top: .9rem; background: rgba(8, 12, 19, .78); color: #fff; font-size: .82rem; font-weight: 500;
  padding: .38rem .7rem; border-radius: 8px; pointer-events: none; font-variant-numeric: tabular-nums;
  border: 1px solid rgba(255, 255, 255, .08); backdrop-filter: blur(6px); }
.viewer-controls { position: absolute; top: .9rem; right: .9rem; max-height: calc(100% - 1.8rem); width: 262px; overflow-y: auto; padding: .95rem 1rem;
  border-radius: 12px; background: rgba(13, 19, 29, .72); border: 1px solid rgba(255, 255, 255, .09);
  backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); color: #dfe6ef; font-size: .88rem;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .2) transparent; }
.viewer-controls fieldset { border: 0; padding: 0 0 .75rem; margin: 0 0 .75rem; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.viewer-controls fieldset:last-of-type { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.viewer-controls legend { font-weight: 600; font-size: .8rem; color: #9fb0c4; padding: 0; margin-bottom: .55rem; letter-spacing: .01em; }
.viewer-controls .choice { color: #dfe6ef; font-size: .87rem; margin: .4rem 0; }
.viewer-controls .muted { color: #8293a8; }
.viewer-controls .btn { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .12); color: #e7ecf3; }
.viewer-controls .btn:hover { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .25); }
.viewer-controls .btn:disabled { opacity: .4; }
.viewer-controls .hint { color: #8fa0b5; font-size: .8rem; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); background: rgba(255, 255, 255, .06); border-radius: 9px; padding: 3px; margin-bottom: .7rem; }
.seg label { margin: 0; font-weight: 550; color: inherit; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: .3rem 0; cursor: pointer; font-size: .84rem; border-radius: 7px; color: #b6c3d3; transition: background .12s, color .12s; }
.seg span:hover { color: #fff; }
.seg input:checked + span { background: #e7ecf3; color: #0b1220; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.seg input:focus-visible + span { outline: 2px solid #38bdf8; outline-offset: 1px; }
#cut-pos { width: 100%; accent-color: #38bdf8; margin: 0; }
.cut-row { font-size: .8rem; margin: .35rem 0 .6rem; color: #9fb0c4; font-variant-numeric: tabular-nums; }
.btn-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.key-deepest { background: #1e88e5; box-shadow: 0 0 0 2px #fff; }
.key-junction { background: #e040c8; }
.key-edge { width: 14px; height: 3px; border-radius: 2px; background: #0b0f16; box-shadow: 0 0 0 1px rgba(255, 255, 255, .5); }
.legend { position: absolute; left: .9rem; bottom: .9rem; display: grid; grid-template-columns: repeat(2, 170px); gap: .35rem 1rem;
  padding: .7rem .85rem .6rem; border-radius: 12px; background: rgba(13, 19, 29, .72); border: 1px solid rgba(255, 255, 255, .09);
  backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); color: #dfe6ef; pointer-events: none; }
.legend p { margin: 0 0 .3rem; color: #dfe6ef; font-weight: 560; font-size: .78rem; }
.legend .legend-note { grid-column: 1 / -1; margin: .15rem 0 0; color: #8fa0b5; font-weight: 450; font-size: .75rem; }
.lut { width: 100%; height: 8px; display: block; border-radius: 99px; }
.lut-scale { display: flex; justify-content: space-between; color: #8fa0b5; font-size: .74rem; margin-top: .2rem; }
@media (max-width: 900px) {
  .stage { height: auto; overflow: visible; }
  .viewer { position: relative; height: 62vh; border-radius: 12px; overflow: hidden; }
  .viewer-controls { position: static; width: auto; max-height: none; margin: .6rem; }
  .legend { position: static; margin: 0 .6rem .6rem; grid-template-columns: 1fr 1fr; }
}

/* ------------------------------------------------------------------ login */
.login-page .page { display: flex; align-items: center; justify-content: center; }
.login { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 2.2rem 2rem 2rem; margin-top: 7vh; box-shadow: var(--shadow-lg); }
.login h1 { display: flex; align-items: center; gap: .65rem; font-size: 1.45rem; margin-bottom: .5rem; }
.login .brand-mark { width: 28px; height: 28px; border-radius: 9px; }
.login .lede { font-size: .93rem; margin-bottom: 1.5rem; }
.login .btn { width: 100%; height: 2.6rem; margin-top: .3rem; }
