/* BrainStack 3D web. A dark imaging bench: the work area stays dark like a microscope
   room, red is reserved for the dye, yellow for markers and measurements. */
:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --panel: #12161b;
  --panel-2: #171c22;
  --line: #242b33;
  --line-2: #323b46;
  --fg: #dfe5ea;
  --muted: #8a96a2;
  --dye: #ff4b4b;
  --accent: #5fb4ff;
  --mark: #ffd23f;
  --ok: #57d68d;
  --warn: #f0b35a;
  --display: "Familjen Grotesk", "Helvetica Neue", Arial, sans-serif;
  --body: "IBM Plex Sans", "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg); font: 14px/1.5 var(--body); min-height: 100vh;
  display: flex; flex-direction: column;
}
.gutter { padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }

/* header + stepper */
header { border-bottom: 1px solid var(--line); background: var(--panel); }
.head { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; padding-block: 12px; }
.brand { font: 700 19px var(--display); letter-spacing: -.01em; white-space: nowrap; }
.brand span { color: var(--dye); }
.steps { display: flex; gap: 4px; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; }
.steps button {
  font: 500 13px var(--body); color: var(--muted); background: none; border: 1px solid transparent;
  border-radius: 999px; padding: 5px 12px; cursor: pointer; display: flex; gap: 7px; align-items: center;
}
.steps button .n { font: 500 11px var(--mono); width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line-2); }
.steps button[aria-current="step"] { color: #fff; border-color: var(--line-2); background: var(--panel-2); }
.steps button[aria-current="step"] .n { background: var(--dye); border-color: var(--dye); color: #fff; }
.steps button.done .n { border-color: var(--ok); color: var(--ok); }
.steps button:disabled { opacity: .45; cursor: default; }
.privacy { margin-left: auto; font-size: 12px; color: var(--muted); }

main { flex: 1; padding-block: 18px; min-height: 0; }
.step { display: none; }
.step.active { display: block; }
.step h1 { font: 700 24px/1.15 var(--display); margin: 0 0 4px; text-wrap: balance; }
.step .lede { color: var(--muted); margin: 0 0 16px; max-width: 70ch; }
.grid2 { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 16px; align-items: start; }
.grid-view { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; min-width: 0; }
.card + .card { margin-top: 12px; }
.card h2 { font: 600 11px var(--body); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 0 0 10px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.form { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 12px; align-items: center; }
label { font-size: 13.5px; }

button.btn, .btn {
  font: 500 13px var(--body); color: var(--fg); background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: 6px; padding: 7px 12px; cursor: pointer; text-decoration: none; display: inline-flex; gap: 6px; align-items: center;
}
.btn:hover { border-color: #46525f; }
.btn.primary { background: var(--dye); border-color: var(--dye); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: default; }
.btn[aria-pressed="true"] { border-color: var(--dye); color: #fff; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--mark); outline-offset: 2px; }
input[type=number], input[type=text], select {
  font: 13.5px var(--body); color: var(--fg); background: #0e1216; border: 1px solid var(--line-2);
  border-radius: 6px; padding: 6px 8px; min-width: 0; width: 100%;
}
input[type=range] { width: 100%; accent-color: var(--dye); }
input[type=color] { width: 34px; height: 26px; padding: 0; border: 1px solid var(--line-2); border-radius: 4px; background: none; }
input[type=checkbox], input[type=radio] { accent-color: var(--dye); }
.radio { display: flex; gap: 8px; align-items: flex-start; }
.radio input { margin-top: 3px; }

/* file list */
.drop { border: 1.5px dashed var(--line-2); border-radius: 8px; padding: 16px; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--dye); color: var(--fg); }
.files { list-style: none; margin: 10px 0 0; padding: 0; max-height: 44vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.files li { display: flex; gap: 8px; align-items: center; padding: 5px 8px; border-bottom: 1px solid var(--line); font: 12.5px var(--mono); cursor: pointer; }
.files li:last-child { border-bottom: 0; }
.files li.sel { background: #1b2229; }
.files li .num { color: var(--muted); width: 26px; text-align: right; }
.files li .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files li .end { color: var(--dye); font-family: var(--body); font-size: 11.5px; white-space: nowrap; }
.files .empty { padding: 18px; color: var(--muted); font-family: var(--body); text-align: center; cursor: default; }

/* image previews */
.preview { background: #050607; border: 1px solid var(--line); border-radius: 6px; display: block; width: auto; height: auto; max-width: 100%; max-height: 62vh; margin: 0 auto; }
.preview.click { cursor: crosshair; }
.legend { font-size: 12px; color: var(--muted); }
.legend b { font-weight: 600; }
.key-m { color: #ff5cff; } .key-g { color: #5cff7a; }
.plane-pic { width: 100%; height: 120px; display: block; }
.big { font: 500 28px var(--mono); color: var(--dye); font-variant-numeric: tabular-nums; }
.result { font-size: 14px; }
.result b { font-family: var(--mono); font-weight: 500; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.thumbs button { padding: 0; border: 2px solid var(--line-2); border-radius: 4px; background: #050607; cursor: pointer; position: relative; }
.thumbs button canvas { display: block; width: 100%; height: auto; }
.thumbs button span { position: absolute; left: 3px; top: 1px; font: 500 10px var(--mono); color: var(--muted); }
.thumbs button[aria-pressed="true"] { border-color: var(--dye); }
.thumbs button[aria-pressed="true"] span { color: var(--dye); }
.thumbs button.cur { outline: 2px solid var(--mark); outline-offset: 1px; }

/* 3D */
.stage { position: relative; height: min(72vh, 760px); min-height: 380px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #151a21 0%, var(--bg) 70%); }
.stage canvas.gl { display: block; width: 100%; height: 100%; cursor: grab; }
.stage .cams { position: absolute; left: 12px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.stage .compass { position: absolute; right: 10px; bottom: 10px; width: 90px; height: 90px; pointer-events: none; }
.stage .hud { position: absolute; left: 12px; top: 10px; right: 12px; font: 11px var(--mono); color: var(--muted); letter-spacing: .04em; pointer-events: none; }
table.rep { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.rep td { padding: 5px 0; border-bottom: 1px dashed var(--line); vertical-align: baseline; }
table.rep td.v { font-family: var(--mono); text-align: right; white-space: nowrap; }
table.rep td.p { font-family: var(--mono); text-align: right; color: var(--muted); width: 58px; white-space: nowrap; }
.bar { height: 6px; background: var(--line); border-radius: 3px; position: relative; margin: 4px 0 2px; }
.bar i { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--dye); }
.ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }

/* footer */
footer { border-top: 1px solid var(--line); background: var(--panel); position: sticky; bottom: 0; }
.foot { display: flex; align-items: center; gap: 12px; padding-block: 10px; }
.status { flex: 1; min-width: 0; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
progress { width: 200px; height: 8px; accent-color: var(--dye); }
.notice { border: 1px solid var(--warn); color: var(--fg); background: rgba(240,179,90,.08); border-radius: 6px; padding: 10px 12px; font-size: 13px; }
.notice.err { border-color: var(--dye); background: rgba(255,75,75,.08); }

dialog { background: var(--panel); color: var(--fg); border: 1px solid var(--line-2); border-radius: 10px; max-width: 520px; padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h3 { font: 700 18px var(--display); margin: 0 0 8px; }

@media (max-width: 900px) {
  .grid2, .grid-view { grid-template-columns: 1fr; }
  .privacy { margin-left: 0; }
  progress { width: 100px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
