/* 3DSConvert page styles, in the look of 3DSView (warm stone surfaces, a sand
   accent, Inter and JetBrains Mono at 13 px). Colours are tokens on :root;
   dark mode follows the system unless the theme button sets data-theme on
   <html>. --accent draws lines, switches and bars; --fill is the face of the
   main buttons and the selected segment. */
:root {
  --bg: #f2f0e9; --panel: #faf9f5; --raised: #fffefb; --input: #f7f5ef; --hover: #efece3;
  --border: #e5e1d6; --border-strong: #d4cec1;
  --text: #2a2825; --text-2: #55524b; --muted: #716d65;
  --fill: #e2d8c8; --fill-hover: #d9cdb9; --fill-press: #cec0a9; --fill-border: #cdbfa8; --on-fill: #2a2825;
  --accent: #7d6d57; --on-accent: #ffffff; --accent-soft: rgba(125, 109, 87, .12); --accent-ink: #6f604c;
  --accent-line: rgba(125, 109, 87, .30);
  --ok: #4f7a4a; --ok-soft: #eef3e8; --warn: #8d6516; --warn-soft: #f8f0dd; --err: #a94a36; --err-soft: #f8e9e3;
  --track: #e5e1d6; --nan: #d4cec1; --plot-bg: #fffefb; --topbar-bg: #faf9f5;
  --float: rgba(255, 254, 251, .92); --float-border: rgba(42, 40, 37, .15); --overlay: rgba(42, 40, 37, .30);
  --shadow: 0 1px 2px rgba(31, 30, 28, .05), 0 8px 24px rgba(31, 30, 28, .07);
  --card-shadow: var(--shadow);
  --focus: 0 0 0 3px var(--accent-line);
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", "Cascadia Code", Consolas, ui-monospace, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, ui-serif, serif;
  --radius-sm: 7px; --radius: 10px; --radius-lg: 13px;
  --gap: 8px; --topbar-h: 52px; --actionbar-h: 56px; --control-h: 32px; --control-sm: 28px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1f1e1b; --panel: #262522; --raised: #2b2a26; --input: #302f2b; --hover: #373531;
    --border: #35332e; --border-strong: #46433c;
    --text: #ebe8df; --text-2: #c0bcb1; --muted: #9d998e;
    --fill: #e2d8c8; --fill-hover: #ebe4d8; --fill-press: #d5c9b5; --fill-border: transparent; --on-fill: #262420;
    --accent: #e2d8c8; --on-accent: #262420; --accent-soft: rgba(226, 216, 200, .12); --accent-ink: #e2d8c8;
    --accent-line: rgba(226, 216, 200, .34);
    --ok: #9cc38f; --ok-soft: rgba(156, 195, 143, .11); --warn: #e0bb6e; --warn-soft: rgba(224, 187, 110, .11);
    --err: #e39584; --err-soft: rgba(227, 149, 132, .12);
    --track: #46433c; --nan: #4a4740; --plot-bg: #1b1a17; --topbar-bg: #22211e;
    --float: rgba(38, 37, 34, .86); --float-border: rgba(235, 232, 223, .15); --overlay: rgba(12, 11, 10, .55);
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 10px 30px rgba(0, 0, 0, .22);
    --card-shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1f1e1b; --panel: #262522; --raised: #2b2a26; --input: #302f2b; --hover: #373531;
  --border: #35332e; --border-strong: #46433c;
  --text: #ebe8df; --text-2: #c0bcb1; --muted: #9d998e;
  --fill: #e2d8c8; --fill-hover: #ebe4d8; --fill-press: #d5c9b5; --fill-border: transparent; --on-fill: #262420;
  --accent: #e2d8c8; --on-accent: #262420; --accent-soft: rgba(226, 216, 200, .12); --accent-ink: #e2d8c8;
  --accent-line: rgba(226, 216, 200, .34);
  --ok: #9cc38f; --ok-soft: rgba(156, 195, 143, .11); --warn: #e0bb6e; --warn-soft: rgba(224, 187, 110, .11);
  --err: #e39584; --err-soft: rgba(227, 149, 132, .12);
  --track: #46433c; --nan: #4a4740; --plot-bg: #1b1a17; --topbar-bg: #22211e;
  --float: rgba(38, 37, 34, .86); --float-border: rgba(235, 232, 223, .15); --overlay: rgba(12, 11, 10, .55);
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 10px 30px rgba(0, 0, 0, .22);
  --card-shadow: none;
  color-scheme: dark;
}
/* touch screens: controls a finger can hit */
@media (pointer: coarse) { :root { --control-h: 38px; --control-sm: 34px; } }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.4 var(--font); -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent-line); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--muted); }
::-webkit-scrollbar-track { background: transparent; }
:focus-visible { outline: none; box-shadow: var(--focus); }
code, .mono { font-family: var(--mono); font-size: .93em; }
a { color: var(--accent-ink); }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
svg.i.s15 { width: 15px; height: 15px; }
svg.i.s16 { width: 16px; height: 16px; }
.muted { color: var(--muted); }
.spacer { flex: 1 1 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- frame ---- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h); padding: 0 14px 0 10px; background: var(--topbar-bg); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--fill); border: 1px solid var(--fill-border); color: var(--on-fill); }
.logo svg.i { width: 18px; height: 18px; stroke-width: 2; }
.brand b { display: block; font-family: var(--serif); font-size: 17px; font-weight: 600; letter-spacing: 0; line-height: 1.15; }
.brand small { display: block; font-size: 12px; color: var(--muted); line-height: 1.25; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--raised); color: var(--text-2); font-size: 12px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.pill.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); height: 22px; padding: 0 8px;
  font-size: 11.5px; font-weight: 550; }
.pill.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.toplink { display: inline-flex; align-items: center; gap: 7px; height: var(--control-h); padding: 0 11px 0 9px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); color: var(--text-2); font-size: 12.5px;
  font-weight: 550; text-decoration: none; transition: background-color .15s, color .15s; }
.toplink:hover { background: var(--hover); color: var(--text); }
/* Two columns of panels with a bar between them (--flow-w: the first
   column's width when dragged); the second column stays in view, and there
   the preview takes the height the other panels leave. */
.workspace { flex: 1 1 auto; width: 100%; max-width: 1720px; margin: 0 auto; padding: var(--gap);
  display: grid; grid-template-columns: var(--flow-w, minmax(460px, 620px)) var(--gap) minmax(0, 1fr); gap: var(--gap) 0; align-items: start; }
.workspace.swapped { grid-template-columns: minmax(0, 1fr) var(--gap) var(--flow-w, minmax(460px, 620px)); }
.workspace.swapped > .side { order: 1; }
.workspace.swapped > .colsplit { order: 2; }
.workspace.swapped > .flow { order: 3; }
.flow { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; min-height: 120px; }
.side { position: sticky; top: calc(var(--topbar-h) + var(--gap)); display: flex; flex-direction: column; gap: var(--gap);
  min-width: 0; min-height: 560px; height: calc(100vh - var(--topbar-h) - var(--actionbar-h) - 3 * var(--gap));
  overflow-y: auto; padding: 2px 6px 6px; margin: -2px -6px 0; }
.colsplit { align-self: stretch; position: relative; cursor: col-resize; touch-action: none; }
.colsplit::after { content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 4px; margin-left: -2px; border-radius: 2px;
  transition: background-color .15s; }
.colsplit:hover::after, .colsplit:focus-visible::after, .colsplit.dragging::after { background: var(--accent); }
.colsplit:focus-visible { box-shadow: none; }
@media (max-width: 1100px) {
  .workspace, .workspace.swapped { grid-template-columns: minmax(0, 1fr); }
  .colsplit { display: none; }
  .side { position: static; height: auto; min-height: 0; overflow: visible; padding: 0; margin: 0; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 12px; }
  .brand small, .topbar .pill, .toplink span { display: none; }
}

/* ---- cards ---- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--card-shadow);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 30px; }
.card-head h2 { margin: 0; font-size: 13px; font-weight: 650; }
.num { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  font-size: 10.5px; font-weight: 700; background: var(--hover); color: var(--muted); }
.card.done .num { background: var(--ok-soft); color: var(--ok); }
.card.active .num { background: var(--accent-soft); color: var(--accent-ink); }
.sub { font-size: 11.5px; line-height: 1.45; color: var(--muted); }
.waiting { opacity: .45; pointer-events: none; }
/* moving panels: the grip, the panel on the move, where it would go */
.grip { width: 22px; height: 28px; margin: 0 -4px 0 -8px; padding: 0; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); cursor: grab; display: inline-grid; place-items: center; opacity: .6; flex-shrink: 0; }
.grip:hover, .grip:focus-visible { opacity: 1; background: var(--hover); }
.grip:active { cursor: grabbing; }
.card.moving { opacity: .45; }
.card.drop-before { box-shadow: 0 -4px 0 -1px var(--accent), var(--card-shadow); }
.flow.drop-end, .side.drop-end { box-shadow: inset 0 -4px 0 -1px var(--accent); }

/* ---- controls ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--control-h); padding: 0 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--input); color: var(--text);
  font-size: 12.5px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s; }
.btn:hover:not(:disabled) { background: var(--hover); border-color: var(--muted); }
.btn.primary { background: var(--fill); border-color: var(--fill-border); color: var(--on-fill); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--fill-hover); border-color: var(--fill-border); }
.btn.primary:active:not(:disabled) { background: var(--fill-press); }
.btn.big { height: 38px; padding: 0 20px; font-size: 13.5px; }
.btn.tall { height: 36px; padding: 0 18px; font-size: 13px; }
.btn.icon { width: var(--control-h); padding: 0; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { background: var(--hover); border-color: transparent; color: var(--text); }
.btn.dashed { border-style: dashed; border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.btn.dashed:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.theme-btn { width: var(--control-h); height: var(--control-h); padding: 0; background: transparent; border-color: transparent; color: var(--text-2); }
.theme-btn:hover:not(:disabled) { background: var(--hover); border-color: transparent; color: var(--text); }
.theme-btn[aria-expanded="true"] { background: var(--hover); color: var(--text); }
.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--input); flex-wrap: wrap; width: fit-content; }
.seg button { height: 26px; padding: 0 11px; border: 0; border-radius: 5px; background: transparent;
  color: var(--text-2); font-size: 12px; font-weight: 550; cursor: pointer; white-space: nowrap; transition: background-color .15s, color .15s; }
.seg button:hover:not(:disabled):not([aria-pressed="true"]) { background: var(--hover); color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--fill); color: var(--on-fill); font-weight: 650; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span, .label { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.field input, .field select, .text {
  height: var(--control-h); padding: 0 9px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--input); color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; min-width: 0; width: 100%;
  transition: border-color .15s, box-shadow .15s; }
.field input:hover:not(:disabled), .field select:hover:not(:disabled), .text:hover:not(:disabled) { border-color: var(--muted); }
.field input:focus-visible, .field select:focus-visible, .text:focus-visible { border-color: var(--accent); }
.field input:disabled, .field select:disabled { opacity: .5; cursor: not-allowed; }
.field input[type="file"] { height: auto; padding: 6px; font-size: 12.5px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
select { appearance: none; -webkit-appearance: none; padding-right: 26px !important; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2 3.5l3 3 3-3' fill='none' stroke='%23948f84' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; }
select option, select optgroup { background: var(--raised); color: var(--text); }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .field { flex: 1 1 220px; }
/* checkboxes read as switches */
input[type="checkbox"] { flex: none; appearance: none; -webkit-appearance: none; position: relative; width: 32px; height: 18px;
  margin: 0; border: 0; border-radius: 999px; background: var(--border-strong); cursor: pointer; transition: background-color .18s; }
input[type="checkbox"]::before { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .35); transition: transform .18s; }
input[type="checkbox"]:checked { background: var(--accent); }
input[type="checkbox"]:checked::before { transform: translateX(14px); background: var(--on-accent); }
input[type="checkbox"]:disabled { opacity: .45; cursor: not-allowed; }
.check { display: inline-flex; align-items: center; gap: 9px; min-height: var(--control-sm); font-size: 12.5px; color: var(--text-2);
  cursor: pointer; user-select: none; }
.check:has(input:disabled) { color: var(--muted); }
input[type="range"] { -webkit-appearance: none; appearance: none; height: 20px; margin: 0; background: transparent; cursor: pointer; }
input[type="range"]:focus-visible { box-shadow: none; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--border-strong); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%;
  border: 0; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); transition: box-shadow .15s; }
input[type="range"]:hover::-webkit-slider-thumb, input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 6px var(--accent-line); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: var(--border-strong); }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--accent); }
input[type="range"]:disabled { opacity: .45; cursor: not-allowed; }
.switch { width: 32px; height: 18px; flex-shrink: 0; padding: 2px; border: 0; border-radius: 999px; cursor: pointer;
  display: flex; justify-content: flex-start; background: var(--border-strong); transition: background-color .18s; }
.switch[aria-checked="true"] { justify-content: flex-end; background: var(--accent); }
.switch::after { content: ''; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.switch[aria-checked="true"]::after { background: var(--on-accent); }

/* ---- data ---- */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px 20px; text-align: center;
  border-radius: var(--radius); border: 1.5px dashed var(--accent-line);
  background: radial-gradient(ellipse at center, var(--accent-soft), transparent 70%), var(--raised); }
.dropzone .badge { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink); border: 1px solid var(--accent-line); }
.dropzone .badge svg.i { width: 28px; height: 28px; }
.dropzone b { font-size: 15px; font-weight: 600; }
.dropzone p { margin: 0; font-size: 12.5px; color: var(--muted); max-width: 430px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 11.5px; background: var(--raised); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.chip.soft { background: var(--hover); color: var(--text); border-color: transparent; height: 26px; padding: 0 10px; }
.chip button { display: grid; place-items: center; width: 18px; height: 18px; margin-right: -4px; padding: 0; border: 0;
  border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.chip button:hover { background: var(--border-strong); color: var(--text); }
.filecard { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--raised); }
.filecard .kind { width: 40px; height: 40px; flex-shrink: 0; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink); }
.filecard .kind svg.i { width: 22px; height: 22px; stroke-width: 1.7; }
.filecard .body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.filecard .title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.filecard .title b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat span { font-size: 10.5px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.stat b { font-family: var(--mono); font-size: 12px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter { display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--muted); }
.meter .bar { flex: 1 1 auto; height: 4px; border-radius: 4px; background: var(--track); overflow: hidden; }
.meter .bar i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.meter b { font-family: var(--mono); font-weight: 400; font-size: 12px; color: var(--text); }
.notes-btn { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; height: var(--control-sm); padding: 0 10px;
  border-radius: var(--radius-sm); border: 0; background: var(--warn-soft); color: var(--warn); font-size: 12px; font-weight: 550; cursor: pointer; }
.notes { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--muted); }
details.more > summary { list-style: none; cursor: pointer; font-size: 12px; color: var(--muted); width: fit-content; user-select: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: ''; display: inline-block; width: 5px; height: 5px; margin: 0 8px 2px 1px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .2s; }
details.more[open] > summary::before { transform: rotate(45deg); }
details.more > summary:hover { color: var(--text); }
details.more[open] > summary { margin-bottom: 10px; }
details.more .field { margin-top: 10px; }
.croprow { display: flex; gap: 8px 16px; flex-wrap: wrap; }
.croprow label { display: inline-flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.croprow input { width: 5.5em; height: var(--control-sm); padding: 0 7px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--input); color: var(--text); font-family: var(--mono); font-size: 12px; }
.cellgrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.cellgrid input { font-family: var(--mono); font-size: 12px; }
.cell-warn { font-size: 12px; color: var(--warn); }
@media (max-width: 640px) {
  .cellgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- processing ---- */
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.steps:empty::before { content: 'No steps: the data are written as read.'; color: var(--muted); font-size: 12.5px; padding: 4px 0 6px 2px; }
.step { display: flex; gap: 10px; }
.step .rail { width: 28px; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; }
.step .dot { width: 28px; height: 28px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); }
.step .dot svg.i { width: 16px; height: 16px; }
.step .line { width: 2px; flex: 1 1 auto; min-height: 8px; margin: 4px 0; border-radius: 1px; background: var(--border); }
.step:last-child .line { background: transparent; }
.step .box { flex: 1 1 auto; min-width: 0; margin-bottom: 8px; padding: 7px 10px 7px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--raised); }
.step.open .box { border-color: var(--accent-line); background: var(--panel); }
.step.off .box, .step.off .dot { opacity: .6; }
.step.off .dot { background: var(--hover); color: var(--muted); }
.step.bad .box { border-color: var(--err); }
.stephead { display: flex; align-items: center; gap: 8px; }
.stephead .toggle { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 9px; padding: 3px 0; border: 0;
  background: none; text-align: left; cursor: pointer; }
.stephead .toggle b { font-weight: 600; white-space: nowrap; }
.stephead .hint { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stephead .hint.err { color: var(--err); }
.stepbody { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.fields { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.fields > span { display: inline-flex; flex-direction: column; gap: 4px; }
.fields label { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.fields .inputs { display: inline-flex; gap: 4px; align-items: center; min-height: var(--control-sm); }
.fields input:not([type=checkbox]), .fields select { height: var(--control-sm); width: 6.5em; padding: 0 7px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--input); color: var(--text); font-family: var(--mono); font-size: 12px; }
.fields input:not([type=checkbox]):hover, .fields select:hover { border-color: var(--muted); }
.fields input:not([type=checkbox]):focus-visible, .fields select:focus-visible { border-color: var(--accent); }
.fields input.wide { width: 15em; }
.fields input.text-field { width: min(26em, 70vw); }
.fields select { width: auto; font-family: var(--font); }
.stepactions { display: flex; gap: 4px; }
.step { position: relative; }
.step .rail { cursor: grab; }
.step.dragging { opacity: .45; }
.step.drop-before::before, .step.drop-after::after { content: ''; position: absolute; left: 38px; right: 0; height: 3px;
  border-radius: 2px; background: var(--accent); }
.step.drop-before::before { top: -5px; }
.step.drop-after::after { bottom: 2px; }
.jsonpanel { display: flex; flex-direction: column; gap: 8px; }
.jsonpanel textarea { width: 100%; min-height: 180px; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--input); color: var(--text); font-family: var(--mono); font-size: 12px; line-height: 1.5; resize: vertical; }
.jsonpanel textarea:focus-visible { border-color: var(--accent); }
.jsonpanel .row { align-items: center; }
#jsonError { color: var(--err); }
.addrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-left: 38px; }
.addrow select { width: auto; max-width: 240px; }
.menu { position: absolute; z-index: 25; top: calc(100% + 6px); right: 0; min-width: 280px; padding: 6px;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--raised); box-shadow: var(--shadow); }
.menu button { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 7px 10px;
  border: 0; border-radius: 6px; background: transparent; text-align: left; cursor: pointer; font-size: 12.5px; font-weight: 550; }
.menu button:hover { background: var(--hover); }
.menu button small { color: var(--muted); font-size: 11.5px; font-weight: 400; }
.menu p { margin: 6px 10px 4px; font-size: 11.5px; line-height: 1.45; }
.anchor { position: relative; }

/* ---- output ---- */
.formats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.format { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 9px 11px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--raised); text-align: left; cursor: pointer; min-width: 0;
  transition: border-color .15s, background-color .15s; }
.format b { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; }
.format small { font-size: 11.5px; line-height: 1.35; color: var(--muted); }
.format:hover { border-color: var(--border-strong); background: var(--hover); }
.format[aria-pressed="true"] { border: 1.5px solid var(--accent); background: var(--accent-soft); padding: 8.5px 10.5px; }
.format:disabled { opacity: .6; cursor: not-allowed; }
.format:disabled small { color: var(--warn); }
.options { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.options .field select { width: auto; }
@media (max-width: 640px) { .formats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---- preview ---- */
.previewbody { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.plot { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; gap: 6px 8px;
  align-items: center; flex: 1 1 360px; min-width: 240px; }
/* the canvas keeps the plane's proportions inside the area (app.js sizes it) */
.plotarea { position: relative; min-width: 0; min-height: 0; height: min(64vh, 560px); align-self: stretch;
  display: flex; align-items: center; justify-content: center; }
.plot canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.plot .ax { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.canvaswrap { position: relative; flex: 0 0 auto; overflow: hidden; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--plot-bg); touch-action: none; }
.zoomlayer { position: relative; width: 100%; height: 100%; transform-origin: 0 0; }
.canvaswrap.zoomed canvas { cursor: grab; }
.canvaswrap.panning canvas { cursor: grabbing; }
.mark { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; pointer-events: none;
  border: 2px solid #fff; box-shadow: 0 0 0 1.5px rgba(0, 0, 0, .65); transform: scale(calc(1 / var(--zoom, 1))); }
.zoombar { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.zoombar button { min-width: 28px; height: 26px; padding: 0 6px; border-radius: var(--radius-sm); border: 1px solid var(--float-border);
  background: var(--float); color: var(--text); font: 600 13px/1 var(--font); cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.zoombar button:hover { background: var(--accent-soft); border-color: var(--accent); }
.zoombar button:focus-visible { box-shadow: var(--focus); }
.plot .ax.x { grid-column: 2; text-align: center; }
.colorbar { display: flex; gap: 8px; align-self: stretch; padding: 8px 0 28px; }
.colorbar i { width: 12px; border-radius: 6px; }
.colorbar div { display: flex; flex-direction: column; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.slicestats { flex: 1 1 140px; display: flex; flex-direction: column; gap: 10px; padding-top: 8px; min-width: 140px; }
.readout { display: flex; align-items: center; min-height: 30px; padding: 5px 9px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--raised); font-family: var(--mono); font-size: 12px; line-height: 1.45; color: var(--text-2); white-space: pre-wrap; }
.slicer { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.slicer input[type=range] { flex: 1 1 160px; }
.slicer b { font-family: var(--mono); font-weight: 400; color: var(--text); min-width: 9ch; }
.slicer .slice-at { width: 11ch; height: var(--control-sm); font-family: var(--mono); font-size: 12px; }
.slicer.levels { margin-top: 6px; }
.slicer .lvl { width: 12ch; height: var(--control-sm); font-family: var(--mono); font-size: 12px; }
.slicer .lvlnote { font-size: 11.5px; }
.slicer .nrm { width: 7ch; height: var(--control-sm); font-family: var(--mono); font-size: 12px; }
.slicer.customrow { margin-top: 6px; }
.ubgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 9rem)); gap: 6px; }
.ubgrid input { font-family: var(--mono); font-size: 12px; height: var(--control-sm); padding: 0 7px; }
.ubfoot { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.empty-preview { height: 420px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  border-radius: var(--radius); border: 1px dashed var(--border-strong); color: var(--muted); text-align: center; padding: 0 20px;
  font-size: 12.5px; background: radial-gradient(ellipse at center, var(--accent-soft), transparent 65%), var(--plot-bg); }
.empty-preview svg.i { width: 40px; height: 40px; stroke-width: 1.4; color: var(--accent-ink); }
.empty-preview b { font-size: 15px; font-weight: 600; color: var(--text); }

#previewView { display: flex; flex-direction: column; }
#profileView { display: flex; flex-direction: column; gap: 10px; }
#profileCanvas { width: 100%; height: 380px; display: block; cursor: crosshair; touch-action: none; }
.histo { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.histo canvas { width: 100%; height: 54px; display: block; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--input); }
.histo-axis { display: flex; justify-content: space-between; gap: 10px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.histo-axis span:nth-child(2) { font-family: var(--font); }

/* ---- toasts ---- */
.toasts { position: fixed; right: 16px; bottom: calc(var(--actionbar-h) + 16px); z-index: 40; display: flex; flex-direction: column; gap: 8px;
  width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 10px 10px 10px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--raised); box-shadow: var(--shadow); font-size: 12.5px;
  animation: toast-in .18s ease-out; }
.toast .ti { display: flex; padding-top: 1px; }
.toast.err .ti { color: var(--err); }
.toast.ok .ti { color: var(--ok); }
.toast p { margin: 0; flex: 1 1 auto; overflow-wrap: anywhere; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- log ---- */
.logcard { position: relative; flex: 0 0 auto; height: var(--log-h, 180px); min-height: 90px; padding: 12px 14px; gap: 8px; }
/* the bar above the log shares the height with the panel above it */
.rowsplit { position: absolute; left: 0; right: 0; top: -9px; height: 8px; cursor: row-resize; touch-action: none; }
.rowsplit::after { content: ''; position: absolute; left: 50%; width: 32px; margin-left: -16px; top: 2px; height: 4px; border-radius: 2px;
  transition: background-color .15s; }
.rowsplit:hover::after, .rowsplit:focus-visible::after, .rowsplit.dragging::after { background: var(--accent); }
.rowsplit:focus-visible { box-shadow: none; }
.logcard:first-child .rowsplit { display: none; }

/* In the column that stays in view, the preview fills what the others leave. */
@media (min-width: 1101px) {
  .side > #previewCard { flex: 1 1 0; min-height: 420px; }
  .side > #previewCard > #previewView:not([hidden]), .side > #previewCard > #profileView:not([hidden]) { flex: 1 1 auto; min-height: 0; }
  .side > #previewCard .previewbody { flex: 1 1 0; min-height: 300px; flex-wrap: nowrap; align-items: stretch; }
  .side > #previewCard .plotarea { height: auto; }
  .side > #previewCard .slicestats { flex: 0 1 190px; }
  .side > #previewCard .empty-preview { flex: 1 1 auto; height: auto; min-height: 240px; }
  .side > #previewCard #profileCanvas { flex: 1 1 0; height: auto; min-height: 240px; }
}
#log { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; font-size: 12.5px; line-height: 1.45; }
#log > div { display: flex; align-items: flex-start; gap: 10px; padding: 4px 2px; }
#log > div + div { border-top: 1px solid var(--border); }
#log time { font-family: var(--mono); font-size: 11px; color: var(--muted); padding-top: 1px; white-space: nowrap; }
#log .lv { display: flex; padding-top: 1px; color: var(--accent-ink); }
#log .ok .lv { color: var(--ok); }
#log .warn .lv, #log .warn .msg { color: var(--warn); }
#log .err .lv, #log .err .msg { color: var(--err); }
#log .msg { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---- action bar ---- */
.actionbar { position: sticky; bottom: 0; z-index: 30; display: flex; align-items: center; gap: 12px; min-height: var(--actionbar-h);
  padding: 8px 14px; background: var(--topbar-bg); border-top: 1px solid var(--border); flex-wrap: wrap; }
.actionbar .fileicon { width: 34px; height: 34px; flex-shrink: 0; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-ink); }
.actionbar .out { display: flex; flex-direction: column; min-width: 0; }
.actionbar .out b { font-family: var(--mono); font-size: 12.5px; font-weight: 500; overflow-wrap: anywhere; }
.actionbar .out span { font-size: 11.5px; color: var(--muted); }
.busy { display: flex; flex-direction: column; gap: 6px; width: min(320px, 100%); }
.busy span { font-size: 12px; color: var(--muted); }
.busy progress { width: 100%; height: 4px; appearance: none; border: 0; border-radius: 4px; background: var(--track); overflow: hidden; }
.busy progress::-webkit-progress-bar { background: var(--track); }
.busy progress::-webkit-progress-value { background: var(--accent); border-radius: 4px; }
.busy progress::-moz-progress-bar { background: var(--accent); }

/* ---- drag and drop ---- */
.dropveil { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; pointer-events: none; background: var(--overlay); }
.dropveil div { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 28px 46px; border-radius: 16px;
  border: 2px dashed var(--accent); background: var(--raised); box-shadow: var(--shadow); font-size: 15px; font-weight: 600; }
.dropveil svg.i { width: 32px; height: 32px; color: var(--accent-ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
