/* ============ SoSIMply design system ============ */
:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --ink: #16212e;
  --muted: #5c6c7d;
  --line: #dde5ec;
  --accent: #0b5cad;
  --accent-soft: #e3effb;
  --orange: #e8590c;
  --green: #237032;   /* 5.3:1 on the #d3f9d8 chips — WCAG AA (FAZ 17F) */
  --amber: #9a5000;   /* 5.4:1 on the #fff3bf chips — WCAG AA (FAZ 17F) */
  --red: #c92a2a;
  --blue: #1864ab;
  --c-scint: #4dabf7;
  --c-slab: #868e96;
  --c-active: #2f9e44;   /* FAZ 18B: active (edep-scoring) volume */
  --c-sensor: #ff922b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 40, 60, .08), 0 4px 14px rgba(20, 40, 60, .06);
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--ink);
  display: flex; flex-direction: column;
}
h2 { margin: .2em 0 .5em; font-size: 1.25rem; }
h3 { margin: .8em 0 .45em; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
a { color: var(--accent); }
small, .muted { color: var(--muted); }
button {
  font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { filter: brightness(1.1); color: #fff; }
button.ghost { background: transparent; }
button.ghost.danger:hover { border-color: var(--red); color: var(--red); }
input, select {
  font: inherit; border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px;
  background: #fff; color: var(--ink); max-width: 100%;
}
input[type="number"] { width: 82px; }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- header ---------- */
.topbar {
  background: linear-gradient(90deg, #0e2a47, #14406b);
  color: #fff; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px;
}
.logo { font-size: 1.45rem; font-weight: 800; letter-spacing: .5px; }
.logo span { color: #63b3ff; }
.tagline { margin-left: 14px; font-size: .82rem; opacity: .75; }
.mode-switch { display: inline-flex; background: rgba(255,255,255,.12); border-radius: 9px; padding: 3px; }
.mode-switch button {
  border: 0; background: transparent; color: #cfe3f7; padding: 5px 14px; border-radius: 7px;
}
.mode-switch button.active { background: #fff; color: var(--ink); font-weight: 600; }

/* ---------- tabs ---------- */
/* the bar scrolls inside itself on narrow screens — the page never scrolls sideways (17C, A-05) */
.tabs { display: flex; gap: 4px; padding: 8px 18px 0; background: #0e2a47;
        overflow-x: auto; scrollbar-width: none; }
.tabs button {
  border: 0; border-radius: 9px 9px 0 0; padding: 9px 18px; background: rgba(255,255,255,.08);
  color: #cfe3f7; font-weight: 600; flex-shrink: 0; white-space: nowrap;
}
.tabs button.active { background: var(--bg); color: var(--ink); }
main { flex: 1; overflow: auto; padding: 14px 18px 30px; }
.tab { display: none; }
.tab.active { display: block; }
.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }

/* ---------- designer layout ---------- */
#tab-designer.active {
  display: grid; gap: 12px;
  grid-template-columns: 240px 1fr 320px;
  grid-template-rows: minmax(430px, calc(100vh - 300px)) auto;
  grid-template-areas: "palette canvas inspector" "runbar runbar runbar";
}
.palette { grid-area: palette; overflow: auto; }
.canvas-wrap { grid-area: canvas; display: flex; flex-direction: column; padding: 8px; min-width: 0; }
.inspector { grid-area: inspector; overflow: auto; }
.runbar { grid-area: runbar; display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }

.pal-item {
  display: flex; gap: 10px; align-items: center; padding: 9px; border: 1px dashed var(--line);
  border-radius: 9px; margin-bottom: 8px; cursor: grab; user-select: none; background: #fbfdff;
}
.pal-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.pal-item small { display: block; color: var(--muted); }
.pal-icon { width: 26px; height: 26px; border-radius: 6px; flex: none; }
.starter-list .starter {
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px;
  cursor: pointer; font-size: .86rem; background: #fbfdff;
}
.starter-list .starter:hover { border-color: var(--accent); background: var(--accent-soft); }
.starter-list .starter b { display: block; }

.canvas-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 6px 8px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; }
.seg button.active { background: var(--accent); color: #fff; }
.zoom { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.zoom button.active { background: #e8590c; color: #fff; border-color: #e8590c; }
.zoom span { font-size: .8rem; color: var(--muted); min-width: 70px; text-align: center; }
#canvas2d { flex: 1; width: 100%; background: #fbfcfe; border: 1px solid var(--line); border-radius: 8px; outline: none; }
#canvas3d { flex: 1; min-height: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; position: relative; }
#canvas3d canvas { display: block; position: absolute; inset: 0; }
.hidden { display: none !important; }

/* SVG scene */
.grid-line { stroke: #eef2f7; stroke-width: 1; }
.grid-line.major { stroke: #dfe7ef; }
.axis-label { fill: #9fb0c0; font-size: 11px; }
.beam-arrow { stroke: var(--red); stroke-width: 2.5; marker-end: url(#arrowhead); }
.comp { cursor: grab; }
.comp.dragging { cursor: grabbing; }
.comp rect.body, .comp ellipse.body { stroke-width: 1.5; }
.comp.selected .body { stroke: var(--orange) !important; stroke-width: 2.5; filter: drop-shadow(0 0 4px rgba(232,89,12,.5)); }
.comp text { font-size: 11px; fill: var(--ink); pointer-events: none; }
.sensor-mark { fill: var(--c-sensor); stroke: #b35a00; }

/* ---------- inspector ---------- */
.insp-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 7px 0; flex-wrap: wrap; }
.insp-row > span.lbl { font-size: .88rem; color: var(--muted); }
.insp-row .fields { display: flex; gap: 5px; align-items: center; }
.insp-row input[type="number"] { width: 72px; }
.insp-help { background: var(--accent-soft); border-radius: 8px; padding: 8px 10px; font-size: .84rem; margin: 8px 0; }
/* validation comparison-figure thumbnails: figures are white-backed PNGs, so mount
   them on a deliberate white "photo frame" in BOTH themes (17C, A-04) */
.vg-fig-thumb {
  width: 100%; height: 104px; object-fit: contain;
  background: #fff; padding: 3px; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 6px; display: block;
}
body.theme-dark .vg-fig-thumb { border-color: #3d4c5e; }
/* FAZ 17D: gallery strip under the primary thumbnail — every figure of the group */
.vg-fig-strip { display: flex; gap: 4px; align-items: stretch; }
.vg-fig-strip a { flex: 1; min-width: 0; display: flex; }
.vg-fig-mini {
  width: 100%; height: 34px; object-fit: contain;
  background: #fff; padding: 1px; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 4px;
}
body.theme-dark .vg-fig-mini { border-color: #3d4c5e; }
.vg-fig-more {
  flex: 0 0 auto !important; align-self: center; font-size: .72rem; color: var(--muted);
  padding: 2px 7px; border: 1px dashed var(--line); border-radius: 6px; white-space: nowrap;
}
.insp-section { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 8px; }
.sensor-chip { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; background: #fff7ef; border: 1px solid #ffd8a8; border-radius: 8px; padding: 6px 9px; margin: 5px 0; font-size: .86rem; }
/* FAZ 8 rev2: chip contents wrap instead of overflowing the narrow inspector */
.sensor-chip > span { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px; min-width: 0; }
/* FAZ 8 rev2: add-photosensor form — type/face/matrix stacked, button full-width below */
.sensor-add { border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; margin-top: 8px; }
.sensor-add-title { font-weight: 600; font-size: .85rem; margin-bottom: 4px; }
.sensor-add select { max-width: 100%; }
.sensor-add #btnAddSensor { display: block; width: 100%; margin-top: 6px; }
.badge-mini { font-size: .72rem; background: var(--accent-soft); color: var(--accent); border-radius: 5px; padding: 2px 6px; }

/* FAZ 11.1: datasheet auto-fill block in the component builder.
   FAZ 11 REV: theme-variable colors so the block follows dark mode. */
.ds-upload { border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; margin: 10px 0;
  background: var(--bg); }
.ds-upload-title { font-weight: 600; font-size: .88rem; display: flex; align-items: center; gap: 7px; color: var(--ink); }
.ds-upload-hint { font-size: .78rem; color: var(--muted); margin: 4px 0 8px; }
.ds-drop { display: flex; align-items: center; justify-content: center; gap: 8px; border: 1.5px dashed var(--line);
  border-radius: 8px; padding: 12px 10px; cursor: pointer; background: var(--panel);
  transition: border-color .15s, background .15s; }
.ds-drop:hover, .ds-drop.dragging { border-color: var(--accent); background: var(--accent-soft); }
.ds-drop.has-file { border-style: solid; border-color: #f08c00; background: rgba(240, 140, 0, .10); }
.ds-drop input[type="file"] { display: none; }
.ds-drop-label { font-size: .84rem; color: var(--ink); pointer-events: none; }
.ds-upload > #cbExtract { display: block; width: 100%; margin-top: 8px; }
.ds-upload-note { font-size: .78rem; margin: 6px 0 0; color: var(--muted); }

/* FAZ 11.2: maintenance overlay — shown when the API is unreachable at boot */
#maintOverlay {
  position: fixed; inset: 0; z-index: 4000; display: flex; align-items: center; justify-content: center;
  /* FAZ 13R-1: fully opaque — page content used to bleed through and overlap
     the overlay's own text (user screenshot) */
  background: rgb(8, 14, 24); animation: maint-fade .5s ease;
}
@keyframes maint-fade { from { opacity: 0; } to { opacity: 1; } }
.maint-card { max-width: 460px; width: calc(100% - 40px); text-align: center; color: #e8eef7; padding: 28px 26px; }
.maint-card h2 { font-size: 1.15rem; line-height: 1.45; margin: 18px 0 6px; color: #fff; }
.maint-sub { font-size: .85rem; color: #9fb2c8; margin: 0 0 18px; }
.maint-ask { font-size: .9rem; color: #cfdcec; margin: 14px 0 8px; }
.maint-pulse { position: relative; width: 92px; height: 92px; margin: 0 auto; }
.maint-pulse b { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: #74c0fc; animation: maint-breathe 2.4s ease-in-out infinite; }
.maint-pulse span { position: absolute; inset: 0; border: 2px solid #4dabf7; border-radius: 50%;
  opacity: 0; animation: maint-ring 2.4s ease-out infinite; }
.maint-pulse span:nth-child(2) { animation-delay: .8s; }
.maint-pulse span:nth-child(3) { animation-delay: 1.6s; }
@keyframes maint-ring { 0% { transform: scale(.45); opacity: .75; } 100% { transform: scale(1.25); opacity: 0; } }
@keyframes maint-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.maint-mail { display: flex; gap: 8px; justify-content: center; }
.maint-mail input { flex: 1; max-width: 260px; padding: 8px 10px; border-radius: 8px; border: 1px solid #3b4d63;
  background: #101a28; color: #e8eef7; font-size: .9rem; }
.maint-mail input::placeholder { color: #67788d; }
.maint-note { font-size: .82rem; color: #8ce99a; min-height: 1.2em; margin: 10px 0 0; }
.maint-status { font-size: .76rem; color: #64748b; margin-top: 18px; }
body.mode-basic .expert-only { display: none !important; }

/* preset pills: every facility visible at a glance */
.preset-chips { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; width: 100%; }
.preset-chip {
  font-size: .74rem; padding: 3px 10px; border-radius: 20px; border: 1px solid var(--line);
  background: #fbfdff; color: var(--muted); cursor: pointer;
}
.preset-chip:hover { border-color: var(--accent); color: var(--accent); }
.preset-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.status-paused { background: #fff3bf; color: var(--amber); }

/* ---------- run bar ---------- */
.beam-config { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.beam-config .chip { background: var(--accent-soft); border-radius: 8px; padding: 6px 10px; display: inline-flex; gap: 6px; align-items: center; }
.beam-config select, .beam-config input { max-width: 100%; }
.run-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.jobs-table { table-layout: auto; }
.jobs-table td { overflow-wrap: anywhere; }

/* ---------- electronics ---------- */
.elx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(370px, 1fr)); gap: 12px; margin-top: 12px; }
.elx-card { padding: 14px; }
.elx-card h4 { margin: 0 0 4px; font-size: 1.02rem; }
.elx-card .chain-stage { border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; margin: 8px 0; background: #fbfdff; }
.chain-stage .stage-title { font-weight: 700; font-size: .84rem; display: flex; justify-content: space-between; align-items: center; }
.chain-stage .stage-body { margin-top: 6px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: .88rem; }
.chain-arrow { text-align: center; color: var(--muted); margin: -3px 0; }
.hv-value { font-variant-numeric: tabular-nums; min-width: 58px; display: inline-block; text-align: right; }
input[type="range"] { accent-color: var(--accent); width: 150px; }

/* ---------- library ---------- */
.lib-section { margin-bottom: 20px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.lib-card { padding: 14px; display: flex; flex-direction: column; }
.lib-card h4 { margin: 0; }
.lib-card .mfr { color: var(--muted); font-size: .84rem; margin-bottom: 6px; }
.lib-card table { width: 100%; border-collapse: collapse; font-size: .84rem; margin: 6px 0; table-layout: fixed; }
.lib-card td { padding: 3px 4px; border-bottom: 1px solid #f0f4f8; vertical-align: top; overflow-wrap: anywhere; }
.lib-card td:first-child { width: 42%; color: var(--muted); }
.lib-card td:last-child { text-align: right; white-space: normal; }
/* FAZ 13R-1: a badge never breaks mid-text — whole chips wrap as units */
.badge { font-size: .7rem; font-weight: 700; padding: 2px 7px; border-radius: 20px;
  margin-left: 6px; vertical-align: middle; white-space: nowrap; display: inline-block; }
.lib-card h4 { line-height: 1.8; }
.badge.verified { background: #d3f9d8; color: var(--green); }
.badge.derived { background: #d0ebff; color: var(--blue); }
.badge.modeled { background: #fff3bf; color: var(--amber); }
.badge.unverified { background: #ffe3e3; color: var(--red); }
.badge.docs { background: #e9ecef; color: var(--muted); }
.badge.sim { background: #d3f9d8; color: var(--green); }
.lib-card .ds-link { margin-top: auto; padding-top: 8px; }
.lib-legend { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 14px; font-size: .84rem; }

/* ---------- jobs & results ---------- */
.jobs-panel { margin-bottom: 14px; }
.jobs-table { width: 100%; border-collapse: collapse; }
.jobs-table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 6px 8px; }
.jobs-table td { padding: 8px; border-top: 1px solid var(--line); }
.status-chip { font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.status-queued { background: #e9ecef; color: var(--muted); }
.status-running, .status-processing { background: #d0ebff; color: var(--blue); }
.status-done { background: #d3f9d8; color: var(--green); }
.status-error { background: #ffe3e3; color: var(--red); }
.status-cancelled { background: #f1f3f5; color: var(--muted); }
.progress { background: #eef2f6; border-radius: 8px; height: 10px; width: 140px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s; }

.results { margin-top: 14px; }
.results .summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.summary-card { padding: 10px 12px; }
.summary-card .num { font-size: 1.35rem; font-weight: 800; }
.summary-card .lbl { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.plot-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.plot-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.plot-area { min-height: 340px; }
.plot-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.downloads { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.chain-info-table { font-size: .84rem; border-collapse: collapse; }
.chain-info-table td { padding: 3px 10px 3px 0; }

/* FAZ 11 REV: results header — title left, setup action right, no floats */
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.results-head h2 { margin: 0; min-width: 0; }
.head-action {
  flex-shrink: 0; border: 1px solid var(--accent); color: var(--accent); background: transparent;
  border-radius: 20px; padding: 6px 14px; font-size: .84rem; font-weight: 600;
  transition: background .15s, color .15s;
}
.head-action:hover { background: var(--accent); color: #fff; }
body.theme-dark .head-action { background: transparent; color: var(--accent); }
body.theme-dark .head-action:hover { background: var(--accent); color: #0d1520; }

/* charts */
/* FAZ 11.9: charts scale to their container instead of overflowing the screen
   (viewBox keeps the aspect ratio; the panel never scrolls horizontally) */
.chart { display: block; width: 100%; max-width: 100%; height: auto; }
.plot-area { overflow-x: hidden; min-width: 0; }
.results .panel { min-width: 0; }
/* FAZ 11 REV: belt & braces — nothing inside results/modals may push the page
   sideways, whatever plot type or table renders there */
.results { overflow-x: hidden; }
.results svg, .modal-card svg { max-width: 100%; height: auto; }
.chain-info-table { display: block; overflow-x: auto; max-width: 100%; }
.chart text { font-size: 11px; fill: var(--muted); }
.chart .title { font-size: 13px; font-weight: 700; fill: var(--ink); }
.chart .hist-line { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.chart .hist-fill { fill: var(--accent); opacity: .12; }
.chart .wave-line { fill: none; stroke: var(--orange); stroke-width: 1.4; }
.chart .axis { stroke: #c6d2dd; stroke-width: 1; }
.chart .tick { stroke: #c6d2dd; }

/* ---------- toast & modal ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #16212e; color: #fff; border-radius: 9px; padding: 10px 18px;
  box-shadow: var(--shadow); z-index: 50; font-size: .92rem;
}
.modal { position: fixed; inset: 0; background: rgba(10,20,30,.45); display: flex; align-items: center; justify-content: center; z-index: 40; }
.modal-card { background: #fff; border-radius: 12px; padding: 18px; max-width: 620px; width: 92%; max-height: 84vh; overflow: auto; }

@media (max-width: 1100px) {
  #tab-designer.active { grid-template-columns: 1fr; grid-template-rows: auto auto auto auto; grid-template-areas: "palette" "canvas" "inspector" "runbar"; }
  .canvas-wrap { height: 560px; }
  #canvas2d { min-height: 380px; }
  .palette { max-height: 420px; }
}

/* ============ FAZ 4 — dark theme (account preference) ============ */
body.theme-dark {
  --bg: #12181f;
  --panel: #1b2430;
  --ink: #dde6f0;
  --muted: #8fa1b3;
  --line: #2c3949;
  --accent: #4dabf7;
  --accent-soft: #1d3350;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
  color-scheme: dark;   /* native selects, checkboxes, scrollbars follow */
}
body.theme-dark input, body.theme-dark select, body.theme-dark textarea,
body.theme-dark button { background: #232f3d; color: var(--ink); }
body.theme-dark button.primary { background: var(--accent); border-color: var(--accent); color: #0d1520; }
body.theme-dark button.ghost { background: transparent; }
body.theme-dark .mode-switch button { background: transparent; }
/* active segment chips follow the primary-button pattern: dark ink on the
   light accent (7.4:1) instead of white-on-blue at 2.5:1 (FAZ 17F, axe) */
body.theme-dark .seg button.active { color: #0d1520; }
body.theme-dark .plot-tabs button.active { color: #0d1520; }   /* same 2.5:1 fix (FAZ 18E, axe) */
body.theme-dark .mode-switch button.active { background: #232f3d; color: var(--ink); }
body.theme-dark .modal-card { background: var(--panel); color: var(--ink); }

/* designer: palette, starters, canvases */
body.theme-dark .pal-item,
body.theme-dark .starter-list .starter,
body.theme-dark .preset-chip,
body.theme-dark .elx-card .chain-stage { background: #151d28; }
body.theme-dark .pal-item:hover,
body.theme-dark .starter-list .starter:hover { background: var(--accent-soft); }
body.theme-dark #canvas2d { background: #141b24; }
body.theme-dark .grid-line { stroke: #1c2632; }
body.theme-dark .grid-line.major { stroke: #263243; }
body.theme-dark .axis-label { fill: #64798e; }
body.theme-dark .sensor-chip { background: #2a2418; border-color: #5c4a22; }

/* status / badge chips: translucent tints instead of pastel fills */
body.theme-dark .badge.verified, body.theme-dark .badge.sim,
body.theme-dark .status-done { background: rgba(43, 138, 62, .22); color: #69db7c; }
body.theme-dark .badge.derived, body.theme-dark .status-running,
body.theme-dark .status-processing { background: rgba(24, 100, 171, .28); color: #74c0fc; }
body.theme-dark .badge.modeled, body.theme-dark .status-paused { background: rgba(230, 119, 0, .2); color: #ffc078; }
body.theme-dark .badge.unverified, body.theme-dark .status-error { background: rgba(201, 42, 42, .22); color: #ffa8a8; }
body.theme-dark .badge.docs, body.theme-dark .status-queued,
body.theme-dark .status-cancelled { background: #26303d; color: var(--muted); }
body.theme-dark .progress { background: #232f3d; }
body.theme-dark .lib-card td { border-bottom-color: var(--line); }

/* charts */
body.theme-dark .chart .axis, body.theme-dark .chart .tick { stroke: #3a4a5c; }
body.theme-dark .toast { background: #060a0f; border: 1px solid var(--line); }

/* ============ FAZ 5i — first-visit tour ============ */
#tourOverlay { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
#tourSpot {
  position: fixed; border-radius: 10px; border: 2px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(8, 18, 30, .55); transition: all .25s ease;
}
#tourPop {
  position: fixed; width: 320px; max-width: 92vw; background: var(--panel); color: var(--ink);
  border-radius: 10px; box-shadow: var(--shadow); padding: 14px 16px; pointer-events: auto;
}
#tourPop h3 { margin: 0 0 6px; font-size: 1rem; text-transform: none; letter-spacing: 0; color: var(--ink); }
#tourPop p { margin: 0; font-size: .88rem; color: var(--muted); }

/* ---------- FAZ 6.5: account modal + bigger gear ---------- */
#btnAccount.gear { font-size: 1.3rem; padding: 2px 10px; line-height: 1; }
.acct-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.acct-avatar {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 1.3rem;
  display: flex; align-items: center; justify-content: center;
}
.acct-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)); gap: 10px; }
.acct-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.acct-card h3 { margin: 0 0 8px; font-size: .95rem; }
.acct-card .insp-row input, .acct-card .insp-row select { width: 100% !important; max-width: 230px; }

/* ---------- FAZ 6 rev2: admin limits form ---------- */
.adm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0 32px; }
.adm-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 0; border-bottom: 1px dashed var(--line);
}
.adm-row .albl { font-size: .87rem; }
.adm-row input {
  width: 112px; flex: none; text-align: right; padding: 4px 7px;
  border: 1px solid var(--line); border-radius: 6px; font: inherit;
  background: transparent; color: var(--ink);
}
.adm-sub {
  margin: 14px 0 2px; font-size: .74rem; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; color: var(--muted);
}

/* ---------- FAZ 12A: GDML volume tree + parameter editor ---------- */
.gdml-tree {
  border: 1px solid var(--line); border-radius: 8px; margin: 6px 0;
  max-height: 240px; overflow: auto; font-size: .8rem; background: var(--bg);
}
/* FAZ 13R-1: long volume names (user GDML files carry 40+ char names) never
   clip — the tree pans horizontally; rows keep their natural width */
.gdml-node {
  padding: 3px 8px; cursor: pointer; display: flex; align-items: center; gap: 6px;
  border-bottom: 1px dashed var(--line); white-space: nowrap;
  min-width: max-content; color: var(--ink);
}
.gdml-node:last-child { border-bottom: none; }
.gdml-node:hover { background: var(--accent-soft); }
.gdml-node.sel { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.gdml-node .gdml-name { font-weight: 600; }
.gdml-chip {
  width: 10px; height: 10px; border-radius: 3px; flex: none;
  border: 1px solid rgba(0, 0, 0, .25); display: inline-block;
}
/* FAZ 13A: scoring-role badge in the volume tree (right-aligned, compact) */
.gdml-role {
  margin-left: auto; flex: none; font-size: .68rem; padding: 1px 2px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--ink); max-width: 108px;
}
.gdml-edit {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px 8px; margin: 6px 0;
}
.gdml-edit h4 { font-size: .8rem; word-break: break-all; color: var(--accent); }
.gdml-solid {
  border-top: 1px dashed var(--line); padding: 6px 0 2px; margin-top: 6px; font-size: .8rem;
}
.gdml-solid b { font-size: .78rem; word-break: break-all; }
.gdml-params { display: flex; flex-wrap: wrap; gap: 6px 10px; margin: 4px 0 2px; }
.gdml-p { font-size: .72rem; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.gdml-p input {
  width: 76px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px;
  font: inherit; background: transparent; color: var(--ink);
}
.gdml-bool { border-left: 2px solid var(--line); padding-left: 8px; margin: 4px 0; }
.gdml-boolop { font-size: .76rem; font-weight: 600; margin: 4px 0; color: var(--ink); }
.gdml-mat-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 0;
  border-bottom: 1px dashed var(--line); font-size: .8rem;
}
.gdml-mat-row:last-child { border-bottom: none; }
.gdml-mat-row button { flex: none; }

/* ---------- FAZ 12G: design-system tokens ---------- */
/* One place for the visual constants every screen shares. Semantic theme
   colors (--bg/--panel/--ink/--line/--accent…) already live at :root /
   body.theme-dark above — these tokens add the scales on top of them. */
:root {
  /* Okabe-Ito colour-blind-safe data palette (charts/overlays) */
  --oi-blue: #0072B2; --oi-orange: #E69F00; --oi-green: #009E73;
  --oi-pink: #CC79A7; --oi-sky: #56B4E9; --oi-verm: #D55E00;
  --oi-yellow: #F0E442; --oi-grey: #999999;
  /* spacing scale (px) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px;
  /* type scale */
  --fs-xs: .74rem; --fs-sm: .82rem; --fs-md: .9rem; --fs-lg: 1.05rem; --fs-xl: 1.3rem;
  /* radii + shadows */
  --rad-sm: 6px; --rad-md: 10px; --rad-lg: 14px;
  --shadow-1: 0 1px 3px rgba(10, 20, 35, .12);
  --shadow-2: 0 6px 24px rgba(10, 20, 35, .18);
}

/* a11y: consistent, visible keyboard focus everywhere */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* motion: every animation/transition collapses for users who ask for calm */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* skeleton loaders: calm shimmer for content that is on its way */
.skeleton {
  position: relative; overflow: hidden;
  background: var(--line); border-radius: var(--rad-sm);
  min-height: 14px;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .25), transparent);
  animation: skel-slide 1.2s infinite;
}
@keyframes skel-slide { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* empty states: one voice for "nothing here yet" panels */
.empty-state {
  text-align: center; padding: 28px 16px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--rad-md);
  font-size: var(--fs-sm);
}
.empty-state .es-icon { font-size: 1.6rem; display: block; margin-bottom: 6px; }
