/* ============================================================================
   ASM · Wastewater Plant Designer — interface styles
   Dark, dense, engineering-tool aesthetic. No frameworks.
   ========================================================================== */

:root {
  --bg:        #080b10;
  --stage:     #0a0e14;
  --panel:     #0f151e;
  --panel-2:   #131b26;
  --raised:    #182231;
  --line:      #1c2634;
  --line-2:    #27354a;
  --txt:       #e7eef8;
  --txt-2:     #93a4bb;
  --txt-3:     #5f7189;
  --acc:       #3b82f6;
  --acc-soft:  rgba(59,130,246,.15);
  --ok:        #34d399;
  --warn:      #fbbf24;
  --err:       #f87171;

  --hd-h:   48px;
  --st-h:   26px;
  --pal-w:  254px;
  --insp-w: 316px;
  --rail-w: 30px;   /* width a side panel folds down to */

  --r-sm: 5px;
  --r-md: 7px;
  --r-lg: 11px;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--txt);
  font: 13px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* several hidden elements set their own `display`, so make [hidden] win */
[hidden] { display: none !important; }

::selection { background: rgba(59,130,246,.35); }

/* thin scrollbars everywhere */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border: 2px solid transparent; background-clip: content-box; border-radius: 9px; }
*::-webkit-scrollbar-thumb:hover { background: #35455c; background-clip: content-box; }

.app {
  height: 100%;
  display: grid;
  grid-template-rows: var(--hd-h) 1fr var(--st-h);
}

/* ═══════════════════════════════════════════════════════════════ topbar ═══ */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 12px;
  background: linear-gradient(180deg, #121a25, #0d141d);
  border-bottom: 1px solid var(--line);
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 9px; min-width: 190px; }
.brand-mark { width: 26px; height: 26px; color: var(--acc); stroke-width: 1.7; flex: none; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-txt strong { font-size: 13px; letter-spacing: .2px; }
.brand-sub {
  font-size: 11px; color: var(--txt-3); outline: none;
  border-radius: 3px; padding: 0 2px; margin-left: -2px;
  max-width: 180px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.brand-sub:hover  { color: var(--txt-2); background: rgba(255,255,255,.04); }
.brand-sub:focus  { color: var(--txt); background: rgba(59,130,246,.14); box-shadow: 0 0 0 1px var(--acc); }

.toolbar { display: flex; align-items: center; gap: 6px; flex: 1; }
.topright { display: flex; align-items: center; gap: 6px; }

.tgroup {
  display: flex; align-items: center; gap: 1px;
  background: #0b1119;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 2px;
}

.tbtn {
  appearance: none; border: 0; background: transparent;
  color: var(--txt-2);
  font: 500 12px/1 var(--sans);
  padding: 6px 9px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.tbtn:hover  { background: var(--raised); color: var(--txt); }
.tbtn:active { transform: translateY(.5px); }
.tbtn svg { width: 14px; height: 14px; }
.tbtn.icon { padding: 6px; }
.tbtn.ghost { border: 1px solid var(--line); }
.tbtn.toggle.is-on { background: var(--acc-soft); color: #93c5fd; box-shadow: inset 0 0 0 1px rgba(59,130,246,.3); }
/* the padlock shows whether this copy can seal files, without being opened */
.tbtn.lic-on { color: #6ee7b7; box-shadow: inset 0 0 0 1px rgba(52,211,153,.32); }
.tbtn[disabled] { opacity: .34; pointer-events: none; }
.tbtn.zoomlbl { font-family: var(--mono); font-size: 11px; min-width: 48px; justify-content: center; }

/* ════════════════════════════════════════════════════════════ workspace ═══ */
.workspace {
  display: grid;
  grid-template-columns: var(--pal-w) 1fr var(--insp-w);
  min-height: 0;
}
/* Collapsed panels drop to a rail. Overriding the whole template rather than
   the width variable, because the variable is set inline by the resize drag
   and an inline declaration outranks any class rule. */
.workspace.pal-off             { grid-template-columns: var(--rail-w) 1fr var(--insp-w); }
.workspace.insp-off            { grid-template-columns: var(--pal-w) 1fr var(--rail-w); }
.workspace.pal-off.insp-off    { grid-template-columns: var(--rail-w) 1fr var(--rail-w); }

/* ═════════════════════════════════════════════ collapse / resize chrome ═══ */
/* Drag strip sitting on the panel's inner edge. */
.gutter {
  position: absolute; top: 0; bottom: 0; width: 7px;
  cursor: col-resize; z-index: 40;
  background: transparent;
  transition: background .12s;
}
.gutter-r { right: -3px; }
.gutter-l { left: -3px; }
.gutter::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 2px; height: 30px; border-radius: 2px;
  background: var(--line-2); opacity: 0; transition: opacity .12s;
}
.gutter:hover::after, .gutter.dragging::after { opacity: 1; }
.gutter:hover, .gutter.dragging { background: color-mix(in srgb, var(--acc) 22%, transparent); }
body.resizing-panel { cursor: col-resize; user-select: none; }
body.resizing-panel .gutter { background: color-mix(in srgb, var(--acc) 22%, transparent); }

/* Small chevron that folds the panel away. */
.panel-x {
  flex: none; appearance: none; border: 0; background: transparent;
  width: 24px; height: 26px; padding: 0; border-radius: var(--r-sm);
  display: grid; place-items: center; cursor: pointer; color: var(--txt-3);
}
.panel-x:hover { background: var(--raised); color: var(--txt); }
.panel-x svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; }

/* The collapsed state: a vertical strip that puts the panel back. */
.rail {
  display: none;
  appearance: none; border: 0; background: transparent;
  width: 100%; height: 100%; padding: 10px 0 0;
  cursor: pointer; color: var(--txt-3);
  flex-direction: column; align-items: center; gap: 10px;
}
.rail:hover { background: var(--panel-2); color: var(--txt); }
.rail svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; }
.rail span {
  writing-mode: vertical-rl;
  font: 600 10px var(--sans); letter-spacing: .12em; text-transform: uppercase;
}
.workspace.pal-off  .palette   > :not(.rail) { display: none; }
.workspace.pal-off  .palette   > .rail       { display: flex; }
.workspace.insp-off .inspector > :not(.rail) { display: none; }
.workspace.insp-off .inspector > .rail       { display: flex; }
.workspace.insp-off .inspector > .rail span  { rotate: 180deg; }

/* ══════════════════════════════════════════════════════════════ palette ═══ */
.palette {
  position: relative;
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  z-index: 20;
}

.pal-head { padding: 10px; border-bottom: 1px solid var(--line); }
.pal-top { display: flex; align-items: center; gap: 4px; }
.pal-top .search { flex: 1; min-width: 0; }
.search { position: relative; }
.search-ico {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--txt-3); pointer-events: none;
}
.search input {
  width: 100%; appearance: none;
  background: #080c12; color: var(--txt);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 7px 9px 7px 28px;
  font: 12px var(--sans); outline: none;
}
.search input::placeholder { color: var(--txt-3); }
.search input:focus { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.search input::-webkit-search-cancel-button { filter: invert(.6); cursor: pointer; }
.pal-hint { margin: 8px 2px 0; font-size: 10.5px; color: var(--txt-3); line-height: 1.4; }

.pal-body { flex: 1; overflow-y: auto; padding: 6px 8px 14px; }

.pal-group { margin-top: 8px; }
.pal-group-hd {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 4px; cursor: pointer;
  font: 600 10px/1 var(--sans); letter-spacing: .09em; text-transform: uppercase;
  color: var(--txt-3); user-select: none;
}
.pal-group-hd:hover { color: var(--txt-2); }
.pal-group-hd .swatch { width: 7px; height: 7px; border-radius: 2px; background: var(--cat); flex: none; }
.pal-group-hd .chev { width: 12px; height: 12px; margin-left: auto; transition: transform .15s; }
.pal-group.collapsed .chev { transform: rotate(-90deg); }
.pal-group.collapsed .pal-items { display: none; }
.pal-items { display: flex; flex-direction: column; gap: 3px; }

.pal-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 8px;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: var(--panel-2);
  cursor: grab; user-select: none;
  transition: background .12s, border-color .12s, transform .08s;
}
.pal-item:hover { background: var(--raised); border-color: var(--line-2); }
.pal-item:active { cursor: grabbing; transform: scale(.985); }
.pal-item.dragging { opacity: .45; }
.pal-ico {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--cat) 13%, transparent);
  color: var(--cat);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cat) 24%, transparent);
}
.pal-ico svg { width: 16px; height: 16px; stroke-width: 1.55; }
.pal-txt { min-width: 0; }
.pal-name { font-size: 12px; color: var(--txt); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-meta { font: 10px var(--mono); color: var(--txt-3); }

.pal-empty { padding: 22px 10px; text-align: center; color: var(--txt-3); font-size: 11.5px; }

.pal-foot { border-top: 1px solid var(--line); padding: 9px 10px 10px; }
.legend-title { font: 600 9.5px/1 var(--sans); letter-spacing: .09em; text-transform: uppercase; color: var(--txt-3); margin-bottom: 7px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--txt-2); }
.legend-item i { width: 14px; height: 2.5px; border-radius: 2px; background: var(--c); }

/* ═══════════════════════════════════════════════════════════════ stage ═══ */
.stage {
  position: relative; overflow: hidden;
  background: var(--stage);
  cursor: default;
  touch-action: none;
}
.stage.is-panning { cursor: grabbing; }
.stage.is-connecting { cursor: crosshair; }

.grid {
  position: absolute; inset: 0;
  background-image: radial-gradient(circle at 1px 1px, #1b2534 1px, transparent 0);
  background-size: 22px 22px;
  pointer-events: none;
}
/* vignette so the canvas edges read as depth, not a hard cut */
.stage::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 100% at 50% 0%, transparent 55%, rgba(0,0,0,.35));
}

.viewport { position: absolute; inset: 0; transform-origin: 0 0; }
/* sized to the stage; `overflow: visible` lets streams draw outside that box */
.edge-layer {
  position: absolute; left: 0; top: 0;
  width: 100%; height: 100%;
  overflow: visible; pointer-events: none;
}
.node-layer { position: absolute; left: 0; top: 0; }

/* ── edges ─────────────────────────────────────────────────────────────── */
.edge { pointer-events: none; }
/* the whole line is grabbable, not just the handle, so it reads as movable */
.edge-hit { stroke: transparent; stroke-width: 18; pointer-events: stroke; cursor: move; }
.edge-line {
  stroke: var(--c, #38bdf8); stroke-width: 2;
  transition: stroke-width .1s, opacity .12s;
}
.edge.recycle .edge-line { stroke-dasharray: 7 5; }
.edge:hover .edge-line { stroke-width: 3; }
.edge.selected .edge-line { stroke-width: 3.2; filter: drop-shadow(0 0 5px var(--c)); }
.edge.dimmed .edge-line { opacity: .18; }

.edge-lbl {
  font: 600 9.5px var(--mono);
  fill: var(--txt-2); stroke: none;
  paint-order: stroke; stroke: #0a0e14; stroke-width: 4px; stroke-linejoin: round;
  text-anchor: middle; dominant-baseline: middle;
  pointer-events: none; user-select: none;
}
.edge.selected .edge-lbl { fill: var(--txt); }
.streams-off .edge-lbl { display: none; }

.ghost-link {
  stroke: var(--acc); stroke-width: 2.2; stroke-dasharray: 6 4;
  pointer-events: none; opacity: .95;
}
.ghost-link.invalid { stroke: var(--err); }

/* Draggable runs. The grip is an invisible fat line over each segment that is
   not tied to a port; the small square advertises that it can be moved. */
.seg-grip { stroke: transparent; stroke-width: 12; pointer-events: stroke; }
.seg-grip.v { cursor: ew-resize; }
.seg-grip.h { cursor: ns-resize; }

.seg-handle {
  fill: var(--acc); stroke: #0a0e14; stroke-width: 1.2;
  opacity: 0; pointer-events: none; transition: opacity .12s;
}
.edge:hover .seg-handle,
.edge.selected .seg-handle { opacity: 1; }

/* keep runs out of the way while a new connection is being drawn */
.is-connecting .seg-grip { pointer-events: none; }
.is-connecting .seg-handle { opacity: 0; }

/* ── nodes ─────────────────────────────────────────────────────────────── */
.node {
  position: absolute;
  background: linear-gradient(180deg, #141d29, #101822);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  box-shadow: 0 2px 5px rgba(0,0,0,.35), 0 10px 26px -14px rgba(0,0,0,.7);
  cursor: grab;
  user-select: none;
  transition: box-shadow .13s, border-color .13s;
}
.node:hover { border-color: #35455c; }
.node.dragging { cursor: grabbing; box-shadow: 0 8px 30px -6px rgba(0,0,0,.75); z-index: 5; }
.node.selected {
  border-color: var(--acc);
  box-shadow: 0 0 0 1px var(--acc), 0 0 22px -6px rgba(59,130,246,.55), 0 10px 26px -14px rgba(0,0,0,.7);
}
.node.has-error { border-color: rgba(248,113,113,.55); }
.node.dimmed { opacity: .38; }
.node.flash { animation: flash .9s ease-out; }
@keyframes flash {
  0%, 100% { box-shadow: 0 0 0 1px var(--acc), 0 10px 26px -14px rgba(0,0,0,.7); }
  30%      { box-shadow: 0 0 0 3px rgba(59,130,246,.75), 0 0 30px rgba(59,130,246,.5); }
}

.node-hd {
  display: flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 9px;
  border-bottom: 1px solid var(--line);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  background: color-mix(in srgb, var(--cat) 9%, transparent);
}
.node-ico { width: 17px; height: 17px; flex: none; color: var(--cat); }
.node-ico svg { width: 100%; height: 100%; stroke-width: 1.6; }
.node-name {
  font: 600 11.5px var(--sans); color: var(--txt);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
  outline: none; border-radius: 3px; padding: 1px 2px; margin: -1px -2px;
}
.node-name[contenteditable="true"] { background: rgba(59,130,246,.18); box-shadow: 0 0 0 1px var(--acc); cursor: text; }
.node-tag {
  font: 600 9.5px var(--mono); letter-spacing: .02em;
  color: var(--cat); flex: none;
  background: color-mix(in srgb, var(--cat) 14%, transparent);
  border-radius: 3px; padding: 2px 5px;
}

/* what this block is, and the design values people actually use */
.node-info, .pal-info {
  appearance: none; border: 0; background: transparent; padding: 0;
  width: 16px; height: 16px; flex: none; cursor: help;
  color: var(--txt-3); display: grid; place-items: center;
  opacity: .55; transition: opacity .12s, color .12s;
}
.node-info svg, .pal-info svg {
  width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7;
}
.node:hover .node-info, .pal-item:hover .pal-info { opacity: 1; }
.node-info:hover, .pal-info:hover { color: var(--acc); opacity: 1; }
.pal-info { margin-left: auto; }

/* membrane array / skid diagram in the advanced panel.
   The inline copy carries no text — at 300 px wide labels overlap and mislead —
   so it is a thumbnail you click to open full size. */
.pfd {
  position: relative;
  margin: 2px 0 10px; padding: 8px 6px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r-md);
  overflow-x: auto;
}
.pfd-svg { width: 100%; max-width: 100%; height: auto; display: block; cursor: zoom-in; }
.pfd-max {
  position: absolute; top: 4px; right: 4px;
  appearance: none; border: 1px solid var(--line); background: var(--panel);
  color: var(--txt-3); border-radius: var(--r-sm); padding: 3px;
  display: grid; place-items: center; cursor: pointer; opacity: .55;
  transition: opacity .12s, color .12s;
}
.pfd:hover .pfd-max { opacity: 1; }
.pfd-max:hover { color: var(--acc); border-color: var(--acc); }
.pfd-max svg {
  width: 13px; height: 13px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.pfd-vessel rect {
  fill: color-mix(in srgb, var(--acc) 12%, transparent);
  stroke: var(--acc); stroke-width: 1;
}
.pfd-el { stroke: var(--acc); stroke-width: .6; opacity: .5; }
.pfd-pipe { stroke: var(--txt-3); stroke-width: 1.2; fill: none; }
.pfd-pipe.feed { stroke: #38bdf8; }
.pfd-pipe.conc { stroke: #f59e0b; }
.pfd-pipe.perm { stroke: #34d399; }
/* concentrate / retentate returned to the feed — dashed, because it is an
   internal loop and never crosses the block boundary */
.pfd-pipe.recyc { stroke: #a78bfa; stroke-dasharray: 3 2; }
.pfd-arrow.recyc { fill: #a78bfa; stroke: none; }
.pfd-arrow { fill: var(--txt-3); stroke: none; }
.pfd-arrow.feed { fill: #38bdf8; }
.pfd-arrow.conc { fill: #f59e0b; }
.pfd-lbl { font: 8px var(--mono); fill: var(--txt-3); }
.pfd-lbl.recyc { fill: #a78bfa; }
/* full size: labels only appear here, where there is room for them */
.pfd-svg.big .pfd-lbl { font-size: 11px; }
.pfd-svg.big .pfd-lbl.feed { fill: #38bdf8; }
.pfd-svg.big .pfd-lbl.conc { fill: #f59e0b; }
.pfd-svg.big .pfd-lbl.perm { fill: #34d399; }
.pfd-svg.big .pfd-pipe { stroke-width: 1.8; }
.pfd-svg.big .pfd-pipe.recyc { stroke-dasharray: 6 4; }

.pfd-stage {
  padding: 14px 10px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--r-md);
}
.pfd-stage .pfd-svg { cursor: default; max-height: 52vh; }
.pfd-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 2px 4px; }
.pfd-legend .lg {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--txt-2);
}
.pfd-legend .sw { width: 16px; height: 0; border-top: 2px solid var(--txt-3); }
.pfd-legend .sw.feed  { border-color: #38bdf8; }
.pfd-legend .sw.perm  { border-color: #34d399; }
.pfd-legend .sw.conc  { border-color: #f59e0b; }
.pfd-legend .sw.recyc { border-color: #a78bfa; border-top-style: dashed; }
.pfd-cols {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 4px 26px; margin-top: 14px;
}
.pfd-col h4 { margin-top: 6px; }

/* the reference table inside the info sheet */
table.guide { width: 100%; border-collapse: collapse; margin-top: 4px; }
table.guide th, table.guide td {
  text-align: left; vertical-align: top; padding: 5px 8px 5px 0;
  border-bottom: 1px solid rgba(255,255,255,.05); font-size: 11.5px;
}
table.guide th { font-weight: 500; color: var(--txt-2); width: 45%; }
table.guide td.v { font-family: var(--mono); font-size: 11px; color: var(--txt); white-space: nowrap; }
table.guide td.note { color: var(--txt-3); font-size: 10.5px; }

.node-bd { position: relative; }

.port-row {
  position: absolute; height: 24px;
  display: flex; align-items: center;
  white-space: nowrap;
}
.port-row.in  { left: 0; }
.port-row.out { right: 0; flex-direction: row-reverse; }

.port {
  position: relative; flex: none;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  cursor: crosshair;
}
.port-row.in  .port { margin-left: -11px; }
.port-row.out .port { margin-right: -11px; }

.port .dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: #0c131c;
  border: 2px solid var(--c);
  transition: transform .11s, background .11s, box-shadow .11s;
}
.port.filled .dot { background: var(--c); }
.port.required .dot { box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 26%, transparent); }
.port:hover .dot { transform: scale(1.34); }

.port-lbl {
  font-size: 10.5px; color: var(--txt-2);
  padding: 0 4px;
  overflow: hidden; text-overflow: ellipsis;
  max-width: 132px;
}
.port-cnt { font: 9px var(--mono); color: var(--txt-3); padding: 0 2px; }

/* Connection-drag affordances. Invalid ports stay hit-testable on purpose so
   hovering one can explain *why* it is refusing the stream. */
.is-connecting .port { cursor: crosshair; }
.is-connecting .port.tgt-bad { opacity: .22; }
.is-connecting .port.tgt-bad.hot { opacity: .55; }
.is-connecting .port.tgt-bad.hot .dot { border-color: var(--err); }
.is-connecting .port.tgt-ok  .dot { transform: scale(1.28); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 30%, transparent); }
.is-connecting .port.tgt-ok.hot .dot { transform: scale(1.6); box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 45%, transparent); }

/* ── stage furniture ───────────────────────────────────────────────────── */
/* ══════════════════════════════════════════════ mass balance table ═══════ */
.tableview {
  position: absolute; inset: 0; z-index: 45;
  display: flex; flex-direction: column;
  background: var(--stage);
}
.tv-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; flex: none;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.tv-tabs { display: flex; gap: 2px; background: #0b1119; border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 2px; }
.tv-tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  color: var(--txt-3); font: 500 11.5px var(--sans);
  padding: 6px 11px; border-radius: var(--r-sm);
}
.tv-tab:hover { color: var(--txt-2); background: var(--raised); }
.tv-tab.is-active { background: var(--acc-soft); color: #93c5fd; box-shadow: inset 0 0 0 1px rgba(59,130,246,.3); }
.tv-meta { flex: 1; font-size: 11px; color: var(--txt-3); }
.tv-meta.stale { color: var(--warn); }

.tv-body { flex: 1; overflow: auto; padding: 0 0 40px; }

table.mb { border-collapse: separate; border-spacing: 0; font: 11.5px var(--sans); }
table.mb th, table.mb td {
  padding: 6px 12px; white-space: nowrap;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
}
table.mb thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--panel-2); color: var(--txt);
  font-weight: 600; text-align: left;
  border-bottom: 1px solid var(--line-2);
}
table.mb tbody th {
  text-align: left; font-weight: 500; color: var(--txt-2);
  background: var(--panel);
}
table.mb.sticky tbody th:first-child,
table.mb.sticky thead th:first-child {
  position: sticky; left: 0; z-index: 4; background: var(--panel-2);
  border-right: 1px solid var(--line-2);
}
table.mb.sticky thead th:first-child { z-index: 5; }
table.mb td { color: var(--txt); }
table.mb td.n { text-align: right; font-family: var(--mono); font-size: 11px; }
table.mb td.unit, table.mb th.unit {
  color: var(--txt-3); font-family: var(--mono); font-size: 10px;
}
table.mb tbody tr:hover td, table.mb tbody tr:hover th { background: var(--panel-2); }
table.mb tr.meta td, table.mb tr.meta th {
  font-family: var(--mono); font-size: 10px; color: var(--txt-3);
  background: #0c121a;
}
table.mb tr.group th, table.mb tr.group td { border-top: 1px solid var(--line-2); }

.tv-note {
  max-width: 720px; margin: 16px 14px; padding: 10px 12px;
  background: rgba(59,130,246,.07); border: 1px solid rgba(59,130,246,.2);
  border-radius: var(--r-md); font-size: 11.5px; line-height: 1.6; color: #a8c5f0;
}
.tv-cards { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 14px; }
.tv-card {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 9px 13px; min-width: 130px;
}
.tv-card .k { font-size: 10px; color: var(--txt-3); text-transform: uppercase; letter-spacing: .07em; }
.tv-card .v { font: 600 14px var(--mono); color: var(--txt); margin-top: 3px; }

.marquee {
  position: absolute; z-index: 30;
  border: 1px solid var(--acc);
  background: rgba(59,130,246,.1);
  border-radius: 3px; pointer-events: none;
}

.empty-state {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: min(420px, 78%); text-align: center; pointer-events: none;
  color: var(--txt-3);
}
.empty-state.hidden { display: none; }
.empty-ico { width: 46px; height: 46px; color: var(--line-2); margin-bottom: 12px; stroke-width: 1.4; }
.empty-state h2 { margin: 0 0 7px; font-size: 15px; font-weight: 600; color: var(--txt-2); }
.empty-state p { margin: 0 0 16px; font-size: 12px; line-height: 1.6; }
.empty-state em { color: var(--txt-2); font-style: normal; border-bottom: 1px dotted var(--line-2); }
.empty-state .btn { pointer-events: auto; }

.btn {
  appearance: none; cursor: pointer;
  font: 500 12px var(--sans);
  padding: 7px 14px; border-radius: var(--r-md);
  border: 1px solid var(--line-2); background: var(--raised); color: var(--txt);
  transition: background .12s, border-color .12s;
}
.btn:hover { background: #1f2b3c; border-color: #3a4a63; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: #fff; }
.btn.primary:hover { background: #2f76ee; }
.btn.subtle { background: transparent; }
.btn.danger:hover { background: rgba(248,113,113,.14); border-color: rgba(248,113,113,.5); color: #fca5a5; }
.btn.block { width: 100%; justify-content: center; }

.stage-tip {
  position: absolute; z-index: 35;
  transform: translate(-50%, -140%);
  padding: 5px 9px; border-radius: var(--r-sm);
  background: #1a2331; border: 1px solid var(--line-2);
  color: var(--txt); font-size: 11px; white-space: nowrap;
  box-shadow: 0 6px 18px -6px rgba(0,0,0,.8); pointer-events: none;
}
.stage-tip.bad { border-color: rgba(248,113,113,.6); color: #fca5a5; }

/* ═══════════════════════════════════════════════════════════ inspector ═══ */
.inspector {
  position: relative;
  display: flex; flex-direction: column; min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--line);
  z-index: 20;
}

.tabs { display: flex; align-items: center; border-bottom: 1px solid var(--line); flex: none; padding-right: 4px; }
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  flex: 1; padding: 11px 8px;
  font: 500 11.5px var(--sans); color: var(--txt-3);
  border-bottom: 2px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: color .12s, border-color .12s;
}
.tab:hover { color: var(--txt-2); }
.tab.is-active { color: var(--txt); border-bottom-color: var(--acc); }
.badge {
  min-width: 17px; padding: 1px 5px; border-radius: 9px;
  font: 600 9.5px var(--mono);
  background: var(--line-2); color: var(--txt-2);
}
.badge.err  { background: rgba(248,113,113,.2); color: #fca5a5; }
.badge.warn { background: rgba(251,191,36,.18); color: #fcd34d; }
.badge.ok   { background: rgba(52,211,153,.16); color: #6ee7b7; }

/* named container so the parameter rows can restack when the panel is narrowed */
.insp-body {
  flex: 1; overflow-y: auto; padding: 12px;
  container: insp / inline-size;
}

.insp-hero { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.insp-hero .ico {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--cat) 13%, transparent);
  color: var(--cat); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cat) 26%, transparent);
}
.insp-hero .ico svg { width: 20px; height: 20px; }
.insp-hero h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.insp-hero .sub { font: 10.5px var(--mono); color: var(--txt-3); }

.insp-blurb {
  margin: 10px 0 0; padding: 9px 10px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: 11.5px; line-height: 1.55; color: var(--txt-2);
}

.sec { margin-top: 16px; }

/* advanced (collapsed) sections — the ASM3 coefficient set lives in these */
.sec.adv { margin-top: 8px; }
.sec.adv .sec-hd.toggle {
  cursor: pointer; margin-bottom: 0;
  padding: 7px 8px; border-radius: var(--r-sm);
  background: var(--panel-2); border: 1px solid var(--line);
}
.sec.adv .sec-hd.toggle::after { display: none; }
.sec.adv .sec-hd.toggle:hover { background: var(--raised); color: var(--txt-2); }
.sec.adv .sec-hd .adv-count {
  margin-left: auto; font: 9px var(--mono);
  background: var(--line); color: var(--txt-3);
  border-radius: 8px; padding: 1px 6px;
}
.sec.adv .sec-hd .chev { width: 12px; height: 12px; transition: transform .15s; }
.sec.adv.open .sec-hd .chev { transform: rotate(180deg); }
.sec.adv.open .sec-hd.toggle { border-color: var(--line-2); color: var(--txt-2); }
.sec.adv .adv-body { display: none; padding: 9px 2px 2px; }
.sec.adv.open .adv-body { display: block; }
.sec-hd {
  display: flex; align-items: center; gap: 8px; margin-bottom: 9px;
  font: 600 9.5px var(--sans); letter-spacing: .09em; text-transform: uppercase; color: var(--txt-3);
}
.sec-hd::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* Parameter names are long ("Std. oxygen transfer efficiency"). They wrap onto
   as many lines as they need rather than being clipped — an ellipsis on an
   engineering parameter is worse than a taller row. */
.field { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.field label {
  flex: 1 1 auto; min-width: 0;
  font-size: 11.5px; line-height: 1.35; color: var(--txt-2);
  overflow-wrap: break-word; hyphens: auto;
}
.field .ctrl { flex: none; display: flex; align-items: center; gap: 5px; }
.field input, .field select {
  appearance: none; width: 84px;
  background: #080c12; color: var(--txt);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 5px 7px; font: 11.5px var(--mono); text-align: right; outline: none;
}
.field input:hover { border-color: var(--line-2); }
.field input:focus { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(59,130,246,.12); text-align: right; }
.field input[type="text"] { text-align: left; font-family: var(--sans); }
.field select {
  text-align: left; font-family: var(--sans); cursor: pointer;
  padding-right: 4px;
}
.field select:focus { border-color: var(--acc); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.field select option { background: var(--panel-2); color: var(--txt); }

/* tick box — switches an alternative calculation method on */
.field input.chk {
  appearance: none; width: 34px; height: 18px; flex: none;
  padding: 0; border-radius: 9px; position: relative; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line-2);
  transition: background .15s, border-color .15s;
}
.field input.chk::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--txt-3); transition: transform .15s, background .15s;
}
.field input.chk:checked { background: color-mix(in srgb, var(--acc) 35%, transparent); border-color: var(--acc); }
.field input.chk:checked::after { transform: translateX(16px); background: var(--acc); }
.field input.chk:focus-visible { box-shadow: 0 0 0 3px rgba(59,130,246,.18); outline: none; }

/* read-only derived values */
.field input.ro {
  background: transparent; border-color: transparent;
  color: var(--ok); cursor: default; font-weight: 600;
}
.field input.ro:hover, .field input.ro:focus { border-color: var(--line); box-shadow: none; }
.field .unit {
  width: 60px; flex: none;
  font: 10px/1.3 var(--mono); color: var(--txt-3);
  overflow-wrap: break-word;
}

/* Below this the label no longer earns a column of its own, so it sits on its
   own line with the control right-aligned underneath. */
@container insp (max-width: 262px) {
  .field { flex-wrap: wrap; row-gap: 3px; margin-bottom: 9px; }
  .field label { flex: 1 0 100%; }
  .field .ctrl { margin-left: auto; }
  .field .unit { width: auto; min-width: 34px; text-align: right; }
  .kv { flex-wrap: wrap; row-gap: 1px; }
  .kv dd { margin-left: auto; }
}

.ports-table { display: flex; flex-direction: column; gap: 3px; }
.ptrow {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: var(--r-sm);
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 11px;
}
.ptrow i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.ptrow .nm { flex: 1; color: var(--txt-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptrow .dir { font: 9px var(--mono); color: var(--txt-3); text-transform: uppercase; }
.ptrow .cn { font: 10px var(--mono); color: var(--txt-3); }
.ptrow.unmet { border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.07); }
.ptrow.unmet .cn { color: #fca5a5; }

.insp-empty { text-align: center; padding: 26px 8px; color: var(--txt-3); }
.insp-empty svg { width: 34px; height: 34px; color: var(--line-2); margin-bottom: 10px; stroke-width: 1.4; }
.insp-empty p { margin: 0; font-size: 11.5px; line-height: 1.6; }

.kv {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 11.5px; padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,.03);
}
.kv dt { color: var(--txt-3); min-width: 0; overflow-wrap: break-word; line-height: 1.35; }
.kv dd {
  margin: 0; color: var(--txt); font-family: var(--mono); font-size: 11px;
  text-align: right; white-space: nowrap; flex: none;
}

/* headline verdict for the influent ion balance */
.check {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 10px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--panel-2);
}
.check .k { font-size: 11.5px; color: var(--txt-2); }
.check .v { font: 600 13px var(--mono); margin-left: auto; }
.check .pill {
  font: 600 9.5px var(--sans); letter-spacing: .06em; text-transform: uppercase;
  border-radius: 9px; padding: 2px 7px; flex: none;
}
.check.ok   { border-color: rgba(52,211,153,.35);  background: rgba(52,211,153,.07); }
.check.ok   .v, .check.ok   .pill { color: var(--ok); }
.check.ok   .pill { background: rgba(52,211,153,.16); }
.check.warn { border-color: rgba(251,191,36,.35);  background: rgba(251,191,36,.07); }
.check.warn .v, .check.warn .pill { color: var(--warn); }
.check.warn .pill { background: rgba(251,191,36,.16); }
.check.err  { border-color: rgba(248,113,113,.4);  background: rgba(248,113,113,.07); }
.check.err  .v, .check.err  .pill { color: var(--err); }
.check.err  .pill { background: rgba(248,113,113,.18); }

.stack { display: flex; gap: 6px; margin-top: 12px; }

.note {
  margin-top: 12px; padding: 8px 10px; border-radius: var(--r-md);
  background: rgba(59,130,246,.07); border: 1px solid rgba(59,130,246,.2);
  font-size: 10.5px; line-height: 1.55; color: #a8c5f0;
}
.note.stale {
  background: rgba(251,191,36,.08); border-color: rgba(251,191,36,.28); color: #fcd34d;
  margin-top: 0; margin-bottom: 8px;
}

/* run button */
.tbtn.run {
  background: var(--ok); color: #05231a; font-weight: 600;
  border: 1px solid rgba(52,211,153,.5);
}
.tbtn.run:hover { background: #4ade80; }
.tbtn.run svg { fill: currentColor; stroke: none; width: 12px; height: 12px; }
.tbtn.run.busy { opacity: .6; pointer-events: none; }
.tbtn.run.busy svg { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── issues list ───────────────────────────────────────────────────────── */
.issue {
  display: flex; gap: 9px; align-items: flex-start;
  padding: 9px 10px; margin-bottom: 5px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-left-width: 2px;
  border-radius: var(--r-sm);
  cursor: pointer; transition: background .12s, border-color .12s;
}
.issue:hover { background: var(--raised); }
.issue.error { border-left-color: var(--err); }
.issue.warn  { border-left-color: var(--warn); }
.issue.info  { border-left-color: var(--acc); }
.issue .ic { width: 14px; height: 14px; flex: none; margin-top: 1px; }
.issue.error .ic { color: var(--err); }
.issue.warn  .ic { color: var(--warn); }
.issue.info  .ic { color: var(--acc); }
.issue .body { min-width: 0; }
.issue .msg { font-size: 11.5px; line-height: 1.45; color: var(--txt); }
.issue .where { font: 10px var(--mono); color: var(--txt-3); margin-top: 2px; }

.issue-head {
  font: 10px var(--mono);
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--txt-3);
  padding: 4px 2px 6px;
  border-top: 1px solid var(--line);
  margin-top: 6px;
}
.all-clear { text-align: center; padding: 30px 12px; color: var(--txt-3); }
.all-clear svg { width: 36px; height: 36px; color: var(--ok); margin-bottom: 10px; }
.all-clear strong { display: block; color: var(--txt-2); font-size: 12px; margin-bottom: 4px; }
.all-clear p { margin: 0; font-size: 11px; line-height: 1.6; }

/* ════════════════════════════════════════════════════════════ statusbar ═══ */
.statusbar {
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  background: #0c121a; border-top: 1px solid var(--line);
  font: 10.5px var(--sans); color: var(--txt-3);
}
.statusbar .spacer { flex: 1; }
.statusbar .sep { width: 1px; height: 12px; background: var(--line); }
.statusbar .stat.clickable { cursor: pointer; }
.statusbar .stat.clickable:hover { color: var(--txt-2); }
.statusbar .stat.muted { opacity: .68; }
.statusbar .stat b { color: var(--txt-2); font-weight: 600; }
.statusbar .stat .e { color: #fca5a5; }
.statusbar .stat .w { color: #fcd34d; }
.statusbar .stat .o { color: #6ee7b7; }

/* ═════════════════════════════════════════════════════════════ context ═══ */
.ctxmenu {
  position: fixed; z-index: 70; min-width: 178px;
  background: var(--panel-2); border: 1px solid var(--line-2);
  border-radius: var(--r-md); padding: 4px;
  box-shadow: 0 14px 40px -10px rgba(0,0,0,.85);
}
.ctxmenu button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 9px; border-radius: var(--r-sm);
  font: 12px var(--sans); color: var(--txt-2); text-align: left;
}
.ctxmenu button:hover { background: var(--raised); color: var(--txt); }
.ctxmenu button svg { width: 13px; height: 13px; opacity: .75; }
.ctxmenu button .sc { margin-left: auto; font: 9.5px var(--mono); color: var(--txt-3); }
.ctxmenu button.danger:hover { background: rgba(248,113,113,.13); color: #fca5a5; }
.ctxmenu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }

/* ══════════════════════════════════════════════════════════════ toasts ═══ */
.toasts {
  position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%);
  z-index: 80; display: flex; flex-direction: column; gap: 7px; align-items: center;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 14px; border-radius: 999px;
  background: #17202d; border: 1px solid var(--line-2);
  color: var(--txt); font-size: 12px;
  box-shadow: 0 12px 34px -10px rgba(0,0,0,.9);
  animation: toastIn .18s ease-out;
}
.toast svg { width: 14px; height: 14px; flex: none; }
.toast.bad  { border-color: rgba(248,113,113,.45); }
.toast.bad  svg { color: var(--err); }
.toast.good svg { color: var(--ok); }
.toast.info svg { color: var(--acc); }
.toast.out { animation: toastOut .18s ease-in forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes toastOut { to   { opacity: 0; transform: translateY(6px) scale(.98); } }

/* ═══════════════════════════════════════════════════════════════ modal ═══ */
.modal {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  background: rgba(4,7,11,.7); backdrop-filter: blur(3px);
  animation: fade .14s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal-card {
  width: min(620px, 92vw); max-height: 84vh; display: flex; flex-direction: column;
  /* a diagram or a project list needs the room a help sheet does not */

  background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 13px; overflow: hidden;
  box-shadow: 0 30px 90px -20px rgba(0,0,0,.9);
}
.modal-card.wide { width: min(1120px, 94vw); max-height: 90vh; }
.modal-card header {
  display: flex; align-items: center; padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-card h3 { margin: 0; font-size: 14px; font-weight: 600; }
.modal-card .x {
  margin-left: auto; appearance: none; border: 0; background: transparent;
  color: var(--txt-3); cursor: pointer; padding: 4px; border-radius: var(--r-sm);
  display: grid; place-items: center;
}
.modal-card .x:hover { background: var(--raised); color: var(--txt); }
.modal-card .x svg { width: 15px; height: 15px; }
.modal-body { padding: 6px 16px 18px; overflow-y: auto; }
.modal-body section { margin-top: 16px; }
.modal-body h4 {
  margin: 0 0 8px; font: 600 9.5px var(--sans);
  letter-spacing: .09em; text-transform: uppercase; color: var(--txt-3);
}
.modal-body ul { margin: 0; padding-left: 17px; }
.modal-body li { font-size: 12px; line-height: 1.75; color: var(--txt-2); }
.modal-note { font-size: 11.5px; line-height: 1.65; color: var(--txt-2); margin: 0; }
.modal-body code {
  font: 11px var(--mono); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: #a8c5f0;
}
/* ═════════════════════════════════════════════════════════════ sign in ═══ */
.auth {
  position: fixed; inset: 0; z-index: 95;
  display: grid; place-items: center; overflow-y: auto;
  background:
    radial-gradient(900px 600px at 50% -10%, rgba(59,130,246,.13), transparent 70%),
    var(--bg);
  padding: 30px 18px;
}
.auth-card {
  width: min(430px, 100%);
  background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 15px; padding: 28px 28px 20px;
  box-shadow: 0 30px 90px -24px rgba(0,0,0,.85);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .logo { width: 30px; height: 30px; fill: none; stroke: var(--acc); stroke-width: 2; }
.auth-brand strong { display: block; font-size: 15px; color: var(--txt); }
.auth-brand span { display: block; font-size: 11.5px; color: var(--txt-3); }
.auth-card h1 { margin: 0 0 5px; font-size: 19px; font-weight: 600; color: var(--txt); }
.auth-sub { margin: 0 0 18px; font-size: 12.5px; line-height: 1.6; color: var(--txt-3); }
.auth-f { display: block; margin-bottom: 12px; }
.auth-f > span {
  display: block; margin-bottom: 5px;
  font: 500 11.5px var(--sans); color: var(--txt-2);
}
.auth-f > em {
  display: block; margin-top: 4px; font-style: normal;
  font-size: 10.5px; color: var(--txt-3);
}
.auth-f input {
  width: 100%; box-sizing: border-box;
  background: var(--panel-2); color: var(--txt);
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  padding: 9px 11px; font: 13px var(--sans);
}
.auth-f input:focus { outline: none; border-color: var(--acc); }
.auth-card .btn.block { margin-top: 6px; }
.auth-alt { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 15px; }
.linkish {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  padding: 0; font: 500 12px var(--sans); color: var(--acc);
}
.linkish:hover { text-decoration: underline; }
.auth-msg {
  margin-bottom: 16px; padding: 10px 12px; border-radius: var(--r-md);
  font-size: 12px; line-height: 1.55;
}
.auth-msg.bad  { background: rgba(248,113,113,.11); border: 1px solid rgba(248,113,113,.34); color: #fca5a5; }
.auth-msg.ok   { background: rgba(52,211,153,.10); border: 1px solid rgba(52,211,153,.32); color: #6ee7b7; }
.auth-msg.warn { background: rgba(245,158,11,.10); border: 1px solid rgba(245,158,11,.32); color: #fcd34d; }
.auth-code {
  margin-top: 8px; font: 700 22px var(--mono); letter-spacing: .28em;
  color: var(--txt); text-align: center;
}
.auth-foot {
  margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 9px; align-items: flex-start;
}
.auth-back { display: flex; gap: 8px; font-size: 11px; line-height: 1.5; color: var(--txt-3); }
.auth-back .dot {
  width: 7px; height: 7px; border-radius: 50%; margin-top: 5px; flex: none;
  background: var(--txt-3);
}
.auth-back .dot.ok { background: #34d399; }
.auth-back .dot.warn { background: #f59e0b; }

/* ═══════════════════════════════════════════════════════ landing page ═══
   A full-screen hub over the editor: projects, profile, licence, settings. */
.landing {
  position: fixed; inset: 0; z-index: 80;
  display: flex; flex-direction: column;
  background: var(--bg);
}
.lnd-top {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.lnd-top .brand { display: flex; align-items: center; gap: 11px; }
.lnd-top .logo { width: 26px; height: 26px; fill: none; stroke: var(--acc); stroke-width: 2; }
.lnd-who { margin-left: auto; display: flex; align-items: center; gap: 11px; }
.lnd-whot { text-align: right; }
.lnd-whot .n { font-size: 12.5px; font-weight: 600; color: var(--txt); }
.lnd-whot .m { font-size: 11px; color: var(--txt-3); }
.lnd-av {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  font: 600 12px var(--sans); letter-spacing: .04em;
  color: #cfe3ff; background: var(--acc-soft);
  box-shadow: inset 0 0 0 1px rgba(59,130,246,.35);
}
.lnd-av.big { width: 56px; height: 56px; font-size: 18px; }
.lnd-body { flex: 1; display: grid; grid-template-columns: 226px 1fr; min-height: 0; }
.lnd-nav {
  display: flex; flex-direction: column; gap: 3px;
  padding: 18px 12px; border-right: 1px solid var(--line); background: var(--panel);
}
.lnd-spacer { flex: 1; }
.lnd-tab {
  display: flex; align-items: center; gap: 10px;
  appearance: none; cursor: pointer; text-align: left;
  border: 1px solid transparent; background: transparent; color: var(--txt-2);
  font: 500 12.5px var(--sans); padding: 9px 12px; border-radius: var(--r-md);
}
.lnd-tab svg {
  width: 16px; height: 16px; flex: none; fill: none;
  stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.lnd-tab:hover { background: var(--raised); color: var(--txt); }
.lnd-tab.is-on { background: var(--acc-soft); color: #cfe3ff; border-color: rgba(59,130,246,.3); }
.lnd-tab.go { background: var(--acc); border-color: var(--acc); color: #fff; justify-content: center; }
.lnd-tab.go:hover { background: #2f76ee; }
.lnd-tab.out { color: var(--txt-3); }
.lnd-tab.out:hover { background: rgba(248,113,113,.12); color: #fca5a5; }
.proj-name .pill.seat { color: #6ee7b7; background: rgba(52,211,153,.16); }
.proj-name .pill.warn { color: #fcd34d; background: rgba(245,158,11,.16); }
.lnd-pane { overflow-y: auto; padding: 26px 30px 40px; }
.lnd-card { max-width: 940px; margin: 0 auto 22px; }
.lnd-card > header { margin-bottom: 14px; }
.lnd-card h2 { margin: 0; font-size: 17px; font-weight: 600; color: var(--txt); }
.lnd-card > header p { margin: 3px 0 0; font-size: 12.5px; color: var(--txt-3); }
.lnd-prof { display: flex; align-items: center; gap: 15px; margin: 4px 0 18px; }
.lnd-pn { font-size: 16px; font-weight: 600; color: var(--txt); }
.lnd-pm { margin-top: 2px; font-size: 12.5px; color: var(--txt-3); }
.lnd-fields { margin: 0 0 14px; }
.set-row {
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  padding: 11px 13px; margin-bottom: 8px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--r-md);
}
.set-row:hover { border-color: var(--line-2); }
.set-t { flex: 1; min-width: 0; }
.set-n { font-size: 12.5px; font-weight: 600; color: var(--txt); }
.set-m { margin-top: 2px; font-size: 11.5px; color: var(--txt-3); }

@media (max-width: 780px) {
  .lnd-body { grid-template-columns: 1fr; }
  .lnd-nav { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .lnd-spacer { display: none; }
  .lnd-pane { padding: 18px 14px 30px; }
}

/* ═════════════════════════════════════════════════════ project browser ═══ */
.proj-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 14px; }
.proj-bar .btn { width: auto; }
.proj-list { display: flex; flex-direction: column; gap: 8px; }
.proj-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 11px 13px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--r-md);
}
.proj-row.is-current { border-color: var(--acc); background: color-mix(in srgb, var(--acc) 7%, var(--panel-2)); }
.proj-main { min-width: 180px; flex: 1 1 240px; }
.proj-name {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--txt);
  overflow-wrap: anywhere;
}
.proj-name .pill {
  font: 600 8.5px var(--sans); letter-spacing: .08em; text-transform: uppercase;
  color: var(--acc); background: color-mix(in srgb, var(--acc) 16%, transparent);
  border-radius: 999px; padding: 2px 7px;
}
.proj-meta { margin-top: 3px; font: 11px var(--mono); color: var(--txt-3); }
.proj-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.proj-acts .btn { width: auto; padding: 5px 10px; font-size: 11.5px; }
.note.bad { color: #fca5a5; }

/* export chooser, floated under the button that opened it */
.exp-menu {
  position: fixed; z-index: 120; width: 284px;
  background: var(--panel); border: 1px solid var(--line-2);
  border-radius: var(--r-md); overflow: hidden;
  box-shadow: 0 18px 44px -14px rgba(0,0,0,.85);
}
.exp-item {
  display: block; width: 100%; text-align: left; appearance: none; cursor: pointer;
  border: 0; border-bottom: 1px solid var(--line); background: transparent;
  padding: 9px 12px; color: var(--txt);
}
.exp-item:last-child { border-bottom: 0; }
.exp-item:hover:not(.off) { background: var(--raised); }
.exp-item .k { display: block; font: 600 12px var(--sans); }
.exp-item .s { display: block; margin-top: 2px; font-size: 10.5px; color: var(--txt-3); }
.exp-item.off { cursor: not-allowed; opacity: .5; }
.exp-item.off .s { color: #fca5a5; }

/* who a sealed file is addressed to */
.seal-list { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.seal-row {
  display: flex; align-items: center; gap: 11px; cursor: pointer;
  padding: 9px 11px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--r-md);
}
.seal-row:hover { border-color: var(--line-2); }
.seal-t { min-width: 0; }
.seal-n { font-size: 12.5px; font-weight: 600; color: var(--txt); overflow-wrap: anywhere; }
.seal-m { margin-top: 2px; font: 10.5px var(--mono); color: var(--txt-3); }

kbd {
  font: 10px var(--mono); color: var(--txt);
  background: var(--raised); border: 1px solid var(--line-2);
  border-bottom-width: 2px; border-radius: 4px; padding: 1px 5px;
}

/* ══════════════════════════════════════════════════════ narrow screens ═══ */
@media (max-width: 1180px) {
  :root { --pal-w: 214px; --insp-w: 280px; }
  .brand { min-width: 0; }
  .brand-txt { display: none; }
}
/* The inspector used to be hidden outright below this width, which left no way
   to edit a parameter on a small screen. It now just narrows — the container
   query above stacks each field — and can be folded to its rail by hand. */
@media (max-width: 940px) {
  :root { --pal-w: 200px; --insp-w: 300px; }
}

/* ── licensing screen ────────────────────────────────────────────────────
   A ledger, so it reads as rows of equal weight: who, what they hold, what
   you can do about it. The state column carries colour because that is the
   column an admin scans. */
.lic-find {
  flex: 1 1 18rem;
  min-width: 0;
  padding: .5rem .7rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--txt);
  font: inherit;
  font-size: .9rem;
}
.lic-find:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }

.lic-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 10rem auto;
  gap: .6rem 1rem;
  align-items: center;
  padding: .65rem .2rem;
  border-bottom: 1px solid var(--line);
}
.lic-row:last-child { border-bottom: 0; }

.lic-who { min-width: 0; }
.lic-who .n {
  font-weight: 600;
  font-size: .93rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lic-who .m {
  color: var(--txt-3);
  font-size: .8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lic-st { display: flex; flex-direction: column; gap: .1rem; }
.lic-st .v { font-size: .86rem; font-weight: 600; color: var(--txt-2); }
.lic-st .m { font-size: .76rem; color: var(--txt-3); font-variant-numeric: tabular-nums; }
.lic-st.ok   .v { color: var(--ok); }
.lic-st.warn .v { color: var(--warn); }

.lic-acts { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.lic-grant {
  padding: .35rem .5rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--txt-2);
  font: inherit;
  font-size: .82rem;
}

@media (max-width: 46rem) {
  .lic-row { grid-template-columns: minmax(0, 1fr) auto; }
  .lic-st { grid-column: 1 / -1; flex-direction: row; gap: .5rem; align-items: baseline; }
  .lic-acts { grid-column: 1 / -1; justify-content: flex-start; }
}
