/* ===========================================================================
   CivilKit Studio - professional dark theme for 3D structural FEM
   Brand: DM Sans + CivilKit "ink" neutral scale + tight heading tracking.
   Fonts vendored locally for fully-offline use.
   =========================================================================== */
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400 700;            /* variable font, covers 400-700 */
  font-display: swap;
  src: url("vendor/fonts/dmsans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("vendor/fonts/dmsans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
:root {
  /* CivilKit "ink" neutral scale (from the marketing site uno.config) */
  --ink-900: #0e0e0e; --ink-800: #171d21; --ink-700: #2e2e2e; --ink-600: #5a5a5a;
  --ink-500: #888888; --ink-400: #afafaf; --ink-300: #dddddd; --ink-200: #e9e9e9;
  --ink-100: #f5f5f5; --ink-50: #f9f9fa;
  --tint-primary: #eef4f8;
  --track-tightest: -0.04em;
  --bg-0: #0c0e12;       /* app background */
  --bg-1: #14171d;       /* panels */
  --bg-2: #1b1f27;       /* panel headers / raised */
  --bg-3: #232833;       /* inputs / hover */
  --bg-4: #2c323e;       /* active */
  --line: #2a3038;       /* borders */
  --line-2: #363d49;
  --txt-0: #e7ebf2;      /* primary text */
  --txt-1: #aab2c0;      /* secondary */
  --txt-2: #6b7686;      /* muted */
  --accent: #5b9bd5;     /* CivilKit steel-blue accent (from tint-primary family) */
  --accent-2: #3f7fbf;
  --accent-soft: #1c3450;
  --ok: #46d39a;
  --warn: #ffb74d;
  --danger: #ff5c6c;
  --viewport: #11141a;
  --shadow: 0 6px 24px rgba(0,0,0,.45);
  --radius: 7px;
  --h-top: 48px;
  --h-status: 26px;
  --w-left: 264px;
  --w-right: 300px;
  --h-bottom: 230px;
  font-synthesis: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg-0);
  color: var(--txt-0);
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
/* Tight tracking on headings/labels per CivilKit (tracking-tightest). */
.panel-title, .insp-section h4, .modal-title, .sum-card .num, .res-tab,
.brand .name .wordmark { letter-spacing: var(--track-tightest); }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333a46; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #3f4756; }

/* ---- App grid ----------------------------------------------------------- */
#app {
  display: grid;
  grid-template-rows: var(--h-top) 1fr var(--h-status);
  grid-template-columns: var(--w-left) 1fr var(--w-right);
  grid-template-areas:
    "top top top"
    "left center right"
    "status status status";
  height: 100vh;
  width: 100vw;
}

/* ---- Top toolbar -------------------------------------------------------- */
#toolbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  background: linear-gradient(180deg, #181c23, #131720);
  border-bottom: 1px solid var(--line);
  /* Above the panel resizers (z 40) and viewport overlays (z 50) so open dropdown menus
     don't get bled through by the left/right resize handles; still below toasts (100) and
     modals (200+). */
  z-index: 60;
}
.brand { display: flex; align-items: center; gap: 9px; padding-right: 8px; }
.brand .logo {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(150deg, var(--ink-700), var(--ink-900));
  border: 1px solid #3a4150;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px;
  letter-spacing: -0.03em;
  box-shadow: 0 2px 8px rgba(0,0,0,.5);
}
.brand .name { display: flex; flex-direction: column; line-height: 1.05; }
.brand .name .wordmark { font-weight: 600; font-size: 14px; color: var(--txt-0); }
.brand .name .wordmark b { font-weight: 700; }
.brand .name .wordmark .mid { color: var(--accent); margin: 0 4px; font-weight: 700; }
.brand .name small { color: var(--txt-2); font-weight: 500; font-size: 10px; letter-spacing: .3px; text-transform: uppercase; }
.tb-sep { width: 1px; height: 24px; background: var(--line-2); margin: 0 4px; }
.tb-spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 11px;
  background: var(--bg-3); border: 1px solid var(--line-2);
  border-radius: 6px; cursor: pointer; color: var(--txt-0);
  transition: background .12s, border-color .12s, transform .05s;
  white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--bg-4); border-color: #444c5a; }
.btn:active { transform: translateY(1px); }
.btn.icon { padding: 0; width: 30px; justify-content: center; }
.btn.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: var(--accent-2); color: #fff; font-weight: 600;
  box-shadow: 0 1px 6px rgba(47,111,224,.35);
}
.btn.primary:hover { filter: brightness(1.08); }
.btn .ic { font-size: 14px; line-height: 1; opacity: .9; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
/* working state: a spinner after the label + block clicks (belt-and-suspenders with [disabled]) */
.btn.busy { pointer-events: none; opacity: .7; }
.btn.busy::after {
  content: ''; display: inline-block; width: 11px; height: 11px; margin-left: 7px;
  vertical-align: -1px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: ck-spin .6s linear infinite;
}
@keyframes ck-spin { to { transform: rotate(360deg); } }

select.tb-select {
  height: 30px; padding: 0 26px 0 10px; background: var(--bg-3);
  border: 1px solid var(--line-2); border-radius: 6px; cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23aab2c0' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
  min-width: 0; max-width: 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
select.tb-select:hover { border-color: #444c5a; }

.units-note {
  font-size: 11px; color: var(--txt-2); padding: 0 4px;
  border: 1px dashed var(--line-2); border-radius: 5px; height: 26px;
  display: inline-flex; align-items: center; padding: 0 8px;
}

.anal-opts {
  display: inline-flex; align-items: center; gap: 6px;
}
.anal-opts input {
  width: 56px; height: 26px; padding: 0 6px;
  background: var(--bg-3); border: 1px solid var(--line-2);
  border-radius: 5px; color: var(--txt-1); font-size: 12px;
}
.anal-opts input.hidden { display: none; }

/* ---- Panels (left/right) ----------------------------------------------- */
.panel {
  background: var(--bg-1);
  display: flex; flex-direction: column;
  overflow: hidden;
}
#left  { grid-area: left;  border-right: 1px solid var(--line); }
#right { grid-area: right; border-left: 1px solid var(--line); }
.panel-title {
  height: 32px; display: flex; align-items: center; gap: 7px;
  padding: 0 12px; font-size: 11px; font-weight: 700; letter-spacing: .8px;
  text-transform: uppercase; color: var(--txt-1);
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.panel-title .ic { color: var(--accent); }
.panel-body { flex: 1; overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; }

/* ---- Model tree --------------------------------------------------------- */
.tree-group { border-bottom: 1px solid var(--line); }
.tree-head {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; cursor: pointer; user-select: none;
  color: var(--txt-1); font-weight: 600;
}
.tree-head:hover { background: var(--bg-2); }
.tree-head .twist { width: 10px; transition: transform .15s; color: var(--txt-2); font-size: 10px; }
.tree-head.collapsed .twist { transform: rotate(-90deg); }
.tree-head .count {
  margin-left: auto; font-size: 11px; color: var(--txt-2);
  background: var(--bg-3); border-radius: 10px; padding: 1px 8px; font-weight: 600;
}
.tree-head .gic { color: var(--accent); width: 14px; text-align: center; }
.tree-items { display: block; }
.tree-head.collapsed + .tree-items { display: none; }
.tree-item {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 12px 4px 30px; cursor: pointer; color: var(--txt-1);
  font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tree-item:hover { background: var(--bg-2); color: var(--txt-0); }
.tree-item.selected { background: var(--accent-soft); color: #fff; }
.tree-item.multi-selected { box-shadow: inset 3px 0 0 #ffa94d; }
.tree-item .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.tree-item .sub { color: var(--txt-2); font-size: 11px; margin-left: auto; }
.tree-item.selected .sub { color: #cdddff; }

/* ---- Inspector ---------------------------------------------------------- */
.insp-empty { padding: 24px 16px; color: var(--txt-2); text-align: center; font-size: 12px; }
.insp-empty .big { font-size: 26px; opacity: .4; margin-bottom: 8px; }
.insp-section { border-bottom: 1px solid var(--line); padding: 10px 12px 12px; }
.insp-section h4 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--txt-2); margin-bottom: 9px; font-weight: 700;
}
.insp-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 5px; font-weight: 700; font-size: 12px;
  background: var(--accent-soft); color: #cfe0ff; margin-bottom: 2px;
}
.field-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.field-row label { width: 64px; color: var(--txt-1); font-size: 12px; flex: none; }
.fld-unit { color: var(--txt-2); font-size: 11px; flex: none; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.field-grid .fg { display: flex; flex-direction: column; gap: 3px; }
.field-grid .fg span { font-size: 10px; color: var(--txt-2); text-transform: uppercase; letter-spacing: .5px; }
/* member-load editor */
.mload { border: 1px solid var(--line); border-radius: 6px; padding: 7px 8px; margin-bottom: 7px; background: var(--bg-2); }
.mload-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.mload-row .mload-type { width: 96px; flex: none; }
.mload-row .mload-lc { flex: 1; }
.mload-row .mload-del { margin-left: auto; background: none; border: none; cursor: pointer; opacity: .65; font-size: 13px; }
.mload-row .mload-del:hover { opacity: 1; }
.mload-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-bottom: 4px; }
.mload-fields .fg { display: flex; flex-direction: column; gap: 3px; }
.mload-fields .fg span { font-size: 10px; color: var(--txt-2); }
.mload-fields .fld { height: 26px; }
input.fld, select.fld {
  width: 100%; height: 28px; padding: 0 8px; background: var(--bg-3);
  border: 1px solid var(--line-2); border-radius: 5px; outline: none;
  transition: border-color .12s, background .12s;
}
input.fld:focus, select.fld:focus { border-color: var(--accent); background: #1e242e; }
input.fld:hover, select.fld:hover { border-color: #444c5a; }
select.fld { cursor: pointer; }

/* ---- keyboard focus visibility (a11y) ---------------------------------- */
/* Consistent on-brand ring for keyboard users; mouse/touch activation stays
   ring-free (:focus-visible heuristics). Covers buttons, menu items, tabs,
   links, fields and anything explicitly tab-focusable. */
a:focus-visible, button:focus-visible, select:focus-visible,
input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 5px;
}
a:focus:not(:focus-visible), button:focus:not(:focus-visible),
select:focus:not(:focus-visible), [tabindex]:focus:not(:focus-visible) {
  outline: none;
}

.restraint-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.chk {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 5px 7px; background: var(--bg-3); border: 1px solid var(--line-2);
  border-radius: 5px; user-select: none; font-size: 12px;
}
.chk:hover { border-color: #444c5a; }
.chk:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chk.on { background: var(--accent-soft); border-color: var(--accent-2); color: #fff; }
.chk input { display: none; }
.chk .box {
  width: 13px; height: 13px; border-radius: 3px; border: 1px solid var(--line-2);
  display: grid; place-items: center; font-size: 10px; flex: none;
}
.chk.on .box { background: var(--accent); border-color: var(--accent); color: #fff; }

.preset-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; margin-bottom: 9px; }
.chip {
  padding: 4px 10px; background: var(--bg-3); border: 1px solid var(--line-2);
  border-radius: 20px; cursor: pointer; font-size: 11px; color: var(--txt-1);
}
.chip:hover { background: var(--bg-4); color: var(--txt-0); }

.insp-actions { display: flex; gap: 6px; padding: 10px 12px; }
.insp-actions .btn { flex: 1; justify-content: center; }
.btn.danger { background: #2a1418; border-color: #5a2630; color: #ff8a96; }
.btn.danger:hover { background: #3a181e; }

.kv { display: flex; justify-content: space-between; padding: 3px 0; font-size: 12px; }
.kv .k { color: var(--txt-2); }
.kv .v { color: var(--txt-0); font-variant-numeric: tabular-nums; font-family: "SF Mono", ui-monospace, monospace; }
/* About modal: these kv rows carry prose, not numbers. Use a 2-column grid (aligned labels +
   wrapping value column) and the proportional UI font so long descriptions read cleanly. */
.about-body .kv { display: grid; grid-template-columns: 132px 1fr; gap: 2px 14px; align-items: start; }
.about-body .kv .v { font-family: inherit; font-variant-numeric: normal; text-align: left; line-height: 1.5; }
.about-body .kv .k { line-height: 1.5; }

/* ---- Center viewport ---------------------------------------------------- */
#center { grid-area: center; position: relative; background: var(--viewport); overflow: hidden; }
#viewport { position: absolute; inset: 0; }
#viewport canvas { display: block; }

/* Box (rubber-band) select rectangle + its viewport toggle */
.box-select-rect {
  position: fixed; z-index: 50; pointer-events: none;
  border: 1px solid var(--accent, #5b9bd5); background: rgba(91,155,213,0.18);
}
.lasso-select-path {
  fill: rgba(91,155,213,0.16); stroke: var(--accent, #5b9bd5);
  stroke-width: 1.5; stroke-dasharray: 5 3; stroke-linejoin: round;
}
.vp-toggle {
  margin-top: 6px; margin-right: 4px; pointer-events: auto; display: inline-block;
  padding: 4px 9px; font-size: 12px; border-radius: 6px; cursor: pointer;
  background: var(--bg-2, #1e2127); color: var(--txt-1, #c7cdd6); border: 1px solid var(--bd, #3a4150);
}
.vp-toggle:hover { background: var(--bg-3, #232833); }
.vp-toggle.active { background: var(--accent, #5b9bd5); color: #fff; border-color: var(--accent, #5b9bd5); }
.vp-check { display: inline-flex; align-items: center; gap: 5px; }
.vp-check input { margin: 0; cursor: pointer; }
/* collapsed selection-tools dropdown: one trigger button, popover holds box/lasso/front-only */
.vp-select-group { position: relative; display: inline-block; margin-top: 6px; }
.vp-select-group .caret { font-size: 10px; opacity: 0.7; }
.vp-select-pop {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 7;
  display: flex; flex-direction: column; gap: 4px; padding: 6px; min-width: 132px;
  background: var(--bg-2, #1e2127); border: 1px solid var(--bd, #3a4150);
  border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.vp-select-pop.hidden { display: none; }
.vp-select-pop .vp-toggle { margin: 0; width: 100%; text-align: left; }

/* Multi-select bulk-action bar - floats at the top-centre of the viewport while a set is active */
.bulk-bar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 7px 12px; border-radius: 8px;
  background: var(--bg-2, #1e2127); border: 1px solid var(--accent, #5b9bd5);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4); font-size: 12px; color: var(--txt-0, #e7ebf0);
}
.bulk-bar .bulk-n { font-weight: 700; color: #ffa94d; }
.bulk-bar .bulk-act { display: flex; align-items: center; gap: 4px; }
.bulk-bar select { background: var(--bg-3, #232833); color: inherit; border: 1px solid var(--bd, #3a4150); border-radius: 4px; padding: 2px 4px; }
.bulk-bar .bulk-btn { padding: 3px 9px; background: var(--bg-3, #232833); color: inherit; border: 1px solid var(--bd, #3a4150); border-radius: 4px; cursor: pointer; }
.bulk-bar .bulk-btn:hover { background: var(--accent, #5b9bd5); color: #fff; border-color: var(--accent, #5b9bd5); }

.vp-overlay { position: absolute; pointer-events: none; }
.vp-top-left  { top: 10px; left: 12px; }
.vp-top-right { top: 10px; right: 12px; display: flex; gap: 6px; pointer-events: auto; }
/* Bottom overlays (legend, deformed-scale panel) hug the top edge of the docked
   results panel so they never overlap its tabs. Drop to the collapsed height
   when the results panel is collapsed. */
/* Legend sits above the deformed-scale panel: on a narrow centre area (both side panels
   open) the wide deform panel can overlap the legend, and its interactive contour-mode
   buttons must stay clickable. The legend has an opaque background so the overlap reads
   cleanly. */
.vp-bottom-left { bottom: calc(var(--h-bottom) + 14px); left: 12px; z-index: 6; }
.vp-bottom-right { bottom: calc(var(--h-bottom) + 14px); right: 12px; z-index: 5; }
/* Only the actual controls capture clicks; the (often-empty) overlay box stays pointer-events:none
   so you can orbit/drag the model THROUGH the transparent area around the legend + deform panel. */
.vp-bottom-right > * { pointer-events: auto; }
#center:has(#results.collapsed) .vp-bottom-left,
#center:has(#results.collapsed) .vp-bottom-right { bottom: 47px; }

.vp-chip {
  background: rgba(20,23,29,.82); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px;
  font-size: 11px; color: var(--txt-1); box-shadow: var(--shadow);
}
.vp-chip b { color: var(--txt-0); }
.vp-chip[role="button"] { cursor: text; pointer-events: auto; }  /* parent .vp-overlay is pointer-events:none */
.vp-chip[role="button"]:hover { border-color: var(--accent); }
.vp-chip-edit { background: var(--bg-2, #1e2127); border: 1px solid var(--accent); border-radius: 4px;
  color: var(--txt-0); font-size: 11px; font-family: inherit; padding: 1px 4px; width: 14ch; outline: none; }

.vp-btns { display: flex; background: rgba(20,23,29,.82); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 6px; overflow: hidden; box-shadow: var(--shadow); }
.vp-btns button {
  background: transparent; border: none; border-left: 1px solid var(--line);
  color: var(--txt-1); height: 30px; padding: 0 11px; cursor: pointer; font-size: 12px;
}
.vp-btns button:first-child { border-left: none; }
.vp-btns button:hover { background: var(--bg-3); color: var(--txt-0); }
.vp-btns button.active { background: var(--accent-soft); color: #fff; }

/* deform controls */
.deform-panel {
  display: flex; align-items: center; gap: 12px;
  background: rgba(20,23,29,.86); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px;
  box-shadow: var(--shadow); pointer-events: auto;
}
.deform-panel.hidden { display: none; }
.dp-sep { width: 1px; height: 20px; background: var(--line-2); }

/* Colour-by-section legend (bottom-right): a swatch + section name per distinct section */
.section-legend {
  background: rgba(20,23,29,.86); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; margin-bottom: 8px;
  box-shadow: var(--shadow); pointer-events: auto; max-height: 40vh; overflow: auto;
  width: fit-content; min-width: 130px; margin-left: auto;   /* size to content + pin to the far right even when the deform panel widens the row */
}
.section-legend.hidden { display: none; }
.section-legend .seclg-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; font-size: 12px; color: var(--txt-1); white-space: nowrap; }
.section-legend .seclg-sw { width: 18px; height: 4px; border-radius: 2px; flex: 0 0 auto; }
.section-legend .seclg-nm { font-variant-numeric: tabular-nums; }
.dp-lbl { font-size: 11px; color: var(--txt-2); text-transform: uppercase; letter-spacing: .5px; }
.diag-modes { display: flex; gap: 3px; }
.diag-mode { font-size: 11px; min-width: 26px; padding: 3px 6px; border: 1px solid var(--line-2); background: var(--bg-3);
  color: var(--txt-2); border-radius: 5px; cursor: pointer; }
.diag-mode:hover { background: var(--bg-4); color: var(--txt-0); }
.diag-mode.active { background: var(--accent-soft); border-color: var(--accent-2); color: var(--txt-0); }
.deform-panel label { font-size: 11px; color: var(--txt-2); text-transform: uppercase; letter-spacing: .5px; }
.deform-panel input[type=range] { width: 130px; accent-color: var(--accent); cursor: pointer; }
.deform-panel .val { font-variant-numeric: tabular-nums; color: var(--txt-0); min-width: 38px; font-size: 12px; }
.toggle {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px;
  color: var(--txt-1); text-transform: none; letter-spacing: 0;
}
.toggle .sw { width: 30px; height: 17px; border-radius: 10px; background: var(--bg-4); position: relative; transition: background .15s; }
.toggle .sw::after { content:""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle.on .sw { background: var(--accent); }
.toggle.on .sw::after { left: 15px; }

/* legend */
.legend {
  background: rgba(20,23,29,.86); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
  box-shadow: var(--shadow); font-size: 11px; min-width: 150px;
  pointer-events: auto; /* legend now has interactive contour-mode buttons */
}
.legend.hidden { display: none; }
.legend .lt { color: var(--txt-2); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; font-weight: 700; }
/* Stops MUST match ramp() in studio.js (0.00/0.40/0.70/1.00) so the legend colour
   reads the same value as the coloured members/plates. */
.legend .bar { height: 9px; border-radius: 4px; margin-bottom: 4px;
  background: linear-gradient(90deg,#2f6fe0 0%,#46d39a 40%,#ffd54d 70%,#ff5c6c 100%); }
.legend .scale { display: flex; justify-content: space-between; color: var(--txt-1); font-variant-numeric: tabular-nums; }
.leg-modes { display: flex; gap: 4px; margin-top: 8px; }
.leg-mode { flex: 1; font-size: 10px; padding: 3px 4px; border: 1px solid var(--line-2); background: var(--bg-3);
  color: var(--txt-2); border-radius: 5px; cursor: pointer; text-transform: uppercase; letter-spacing: .3px; }
.leg-mode:hover:not(:disabled) { background: var(--bg-4); color: var(--txt-0); }
.leg-mode.active { background: var(--accent-soft); border-color: var(--accent-2); color: var(--txt-0); }
.leg-mode:disabled { opacity: .4; cursor: not-allowed; }

/* viewcube */
#viewcube { position: absolute; top: 48px; right: 12px; width: 84px; height: 84px; pointer-events: auto; }

/* ---- Bottom results ----------------------------------------------------- */
#bottom {
  grid-area: status; /* placeholder, replaced below by JS layout note */
}
/* We actually mount results inside center as a docked panel */
#results {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--h-bottom);
  background: var(--bg-1); border-top: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 10;
  box-shadow: 0 -4px 16px rgba(0,0,0,.35);
}
#results.collapsed { height: 33px; }
.res-tabs { display: flex; align-items: center; height: 33px; background: var(--bg-2);
  border-bottom: 1px solid var(--line); padding: 0 6px; gap: 2px; flex: none;
  overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.res-tabs::-webkit-scrollbar { height: 0; }
.res-tab {
  height: 33px; padding: 0 14px; display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: none; color: var(--txt-2); cursor: pointer;
  font-size: 12px; font-weight: 600; border-bottom: 2px solid transparent;
  white-space: nowrap; flex: none;
}
.res-tab:hover { color: var(--txt-0); }
.res-tab.active { color: var(--txt-0); border-bottom-color: var(--accent); }
.res-tab .badge { font-size: 10px; background: var(--bg-4); border-radius: 8px; padding: 0 6px; color: var(--txt-1); }
.res-spacer { flex: 1; }
.res-toolbtn { background: transparent; border: none; color: var(--txt-2); cursor: pointer; padding: 4px 8px; border-radius: 5px; }
.res-toolbtn:hover { background: var(--bg-3); color: var(--txt-0); }
.res-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
#results.collapsed .res-body { display: none; }
.res-pane { display: none; padding: 0; }
.res-pane.active { display: block; }

/* Fill the panel on wide screens, but keep a readable floor: when the panel is too
   narrow the columns stop cramming and .res-body scrolls horizontally (touch-friendly,
   for the eventual iPad build) rather than clipping the last column. */
table.data { width: 100%; min-width: 680px; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
table.data thead th {
  position: sticky; top: 0; background: var(--bg-2); color: var(--txt-1);
  text-align: right; padding: 6px 12px; font-weight: 600; font-size: 11px;
  border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 2;
}
table.data thead th:first-child, table.data tbody td:first-child { text-align: left; }
table.data thead th.sortable { cursor: pointer; user-select: none; }
table.data thead th.sortable:hover { color: var(--txt-0); }
table.data thead th.sortable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
table.data thead th .sort-ind { font-size: 9px; opacity: 0.7; }
table.data thead th[aria-sort="ascending"] .sort-ind::after { content: ' \25B2'; }
table.data thead th[aria-sort="descending"] .sort-ind::after { content: ' \25BC'; }
table.data tbody td { padding: 5px 12px; text-align: right; border-bottom: 1px solid #1d222b;
  font-family: "SF Mono", ui-monospace, monospace; color: var(--txt-0); white-space: nowrap; }
table.data tbody tr:hover { background: var(--bg-2); }
table.data tbody tr.hot td { color: var(--warn); }
/* member force diagrams (inspector) */
.diag { margin: 8px 0; }
.diag-h { display: flex; justify-content: space-between; font-size: 11px; color: var(--txt-1); margin-bottom: 2px; }
.diag-pk { font-variant-numeric: tabular-nums; color: var(--txt-0); }
.diag-loc { color: var(--txt-2); font-weight: 400; }
.diag-pkdot { fill: var(--accent); stroke: var(--bg-2); stroke-width: 1; }
.diag-svg { width: 100%; height: 44px; display: block; background: var(--bg-2); border: 1px solid var(--line); border-radius: 5px; }
.diag-base { stroke: var(--line-2); stroke-width: 1; }
.diag-fill { fill: rgba(91, 155, 213, 0.28); stroke: var(--accent); stroke-width: 1.2; }

table.data tbody tr[data-sel-type] { cursor: pointer; }
table.data tbody tr.rowsel td { background: rgba(91, 155, 213, 0.18); box-shadow: inset 2px 0 0 #5b9bd5; }
.res-empty { padding: 28px; text-align: center; color: var(--txt-2); }

/* summary cards */
.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 10px; padding: 12px; }
.sum-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 11px 13px; }
.sum-card .lbl { font-size: 11px; color: var(--txt-2); text-transform: uppercase; letter-spacing: .5px; }
.sum-card .num { font-size: 20px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums;
  font-family: "SF Mono", ui-monospace, monospace; }
.sum-card .sub { font-size: 11px; color: var(--txt-2); margin-top: 2px; }
.sum-card.accent .num { color: var(--accent); }
.sum-card.ok .num { color: var(--ok); }
.sum-card.warn .num { color: var(--warn); }

/* pre-solve model overview (Summary tab) */
.ov-hint { padding: 10px 12px 0; color: var(--txt-2); font-size: 12px; }
.ov-h { margin: 4px 12px 6px; font-size: 13px; }
.ov-wrap .data { margin: 0 12px; width: calc(100% - 24px); }
.ov-total { padding: 8px 12px 14px; color: var(--txt-1); font-size: 13px; }
.ov-note { color: var(--txt-2); font-weight: 400; font-size: 12px; }
.insp-hint { color: var(--txt-2); font-size: 11px; margin: 2px 0 6px; line-height: 1.4; }

/* data sheets (Excel-style grid) */
.data-card { width: min(1040px, 95vw); max-height: 88vh; display: flex; flex-direction: column; }
.data-tabs { display: flex; gap: 4px; padding: 8px 14px 0; flex-wrap: wrap; }
.data-tab { padding: 6px 12px; border: 1px solid var(--line); border-bottom: 0; border-radius: 6px 6px 0 0; background: var(--bg-2); color: var(--txt-1); font-size: 13px; cursor: pointer; }
.data-tab.active { background: var(--bg-1); color: var(--txt-0); font-weight: 600; }
.data-bulk { display: flex; align-items: center; gap: 8px; padding: 8px 14px; flex-wrap: wrap; font-size: 12px; color: var(--txt-2); border-bottom: 1px solid var(--line); }
/* keep "Set <select>" / "to <input>" on one baseline-centred line (a select's baseline otherwise
   shoves the label text to the top, which reads as misalignment) */
.data-bulk label { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.data-bulk .fld { padding: 3px 6px; }
.data-bulk-n { font-weight: 600; color: var(--txt-1); min-width: 110px; }
.data-grid-wrap { overflow: auto; padding: 0 14px 14px; flex: 1; }
.ds-table { width: 100%; border-collapse: collapse; }
.ds-table th, .ds-table td { border: 1px solid var(--line); text-align: center; font-size: 12px; padding: 0; }
.ds-table th { background: var(--bg-2); padding: 5px 6px; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.ds-table td.ro { color: var(--txt-2); padding: 4px 8px; }
.ds-table input.ds-cell { width: 100%; box-sizing: border-box; border: 0; background: transparent; color: var(--txt-0); padding: 4px 6px; text-align: center; font: inherit; }
.ds-table input.ds-cell:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--bg-2); }
.ds-table input.ds-cell.err { outline: 2px solid #e0556a; outline-offset: -2px; }
.ds-table tr.ds-sel td { background: rgba(91, 155, 213, 0.10); }
.ds-table tr.ds-empty td { color: var(--txt-2); text-align: center; padding: 16px; font-style: italic; }
.data tr.row-total td { font-weight: 700; border-top: 2px solid var(--line); color: var(--txt-0); background: var(--bg-2); }
.react-eq { padding: 8px 12px; font-size: 12px; color: var(--txt-1); }
.ov-row { cursor: pointer; }
.ov-row:hover td { background: var(--bg-2); }

/* console log */
#log { padding: 8px 12px; font-family: "SF Mono", ui-monospace, monospace; font-size: 12px; }
#log .line { padding: 1px 0; color: var(--txt-1); }
#log .line .t { color: var(--txt-2); }
#log .line.ok { color: var(--ok); }
#log .line.warn { color: var(--warn); }
#log .line.err { color: var(--danger); }
#log .line.info { color: var(--accent); }

/* ---- Status bar --------------------------------------------------------- */
#status {
  grid-area: status; /* overlaps results which is inside center; status is full width below */
  display: none; /* we render statusbar separately */
}
#statusbar {
  grid-area: status; height: var(--h-status);
  display: flex; align-items: center; gap: 14px; padding: 0 12px;
  background: var(--bg-2); border-top: 1px solid var(--line);
  font-size: 11px; color: var(--txt-2); z-index: 40;
}
#statusbar .si { display: inline-flex; align-items: center; gap: 5px; }
#statusbar .si b { color: var(--txt-1); font-weight: 600; }
#statusbar .si.sb-warn, #statusbar .si.sb-warn b { color: var(--warn); }
#statusbar .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--txt-2); }
#statusbar .dot.ready { background: var(--ok); }
#statusbar .dot.busy { background: var(--warn); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
#statusbar .sb-spacer { flex: 1; }
/* live auto-size progress: sits just right of the spacer so its varying width is absorbed by the
   spacer and never shifts the left-hand stats (or the right group). Empty/idle = invisible. */
#statusbar #sb-progress { color: var(--warn); white-space: nowrap; font-variant-numeric: tabular-nums; }
#statusbar #sb-progress:empty { display: none; }

/* ---- 3D labels (CSS2D not used; we use sprite labels). hover tooltip ---- */
#hovertip {
  position: absolute; pointer-events: none; z-index: 50;
  background: rgba(20,23,29,.94); border: 1px solid var(--line-2);
  border-radius: 5px; padding: 4px 8px; font-size: 11px; color: var(--txt-0);
  box-shadow: var(--shadow); display: none; white-space: nowrap;
}

/* ---- modal / toast ------------------------------------------------------ */
#toast-wrap { position: fixed; top: 56px; left: 50%; transform: translateX(-50%); z-index: 100;
  display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--bg-2); border: 1px solid var(--line-2); border-left: 3px solid var(--accent);
  border-radius: 7px; padding: 9px 14px; box-shadow: var(--shadow); font-size: 12px;
  animation: toastin .2s ease; max-width: 380px;
}
.toast.ok { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast.err { border-left-color: var(--danger); }
@keyframes toastin { from { opacity: 0; transform: translateY(-8px); } }

/* ---- segmented toggle (render mode) ------------------------------------- */
.vp-btns.seg button.active { background: var(--accent-soft); color: #fff; }

/* ---- section properties panel (inspector) ------------------------------- */
.sec-prop-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.sec-prop-name {
  font-weight: 700; font-size: 13px; color: var(--txt-0); letter-spacing: -0.02em;
}
.sec-prop-cat { font-size: 11px; color: var(--txt-2); }
.sec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; margin-top: 8px; }
.sec-grid .kv { padding: 2px 0; }
.btn.assign { background: var(--accent-soft); border-color: var(--accent-2); color: #dcecff; }
.btn.assign:hover { background: #234469; }
.sec-warn {
  margin-top: 8px; font-size: 10.5px; line-height: 1.45; color: var(--warn);
  background: rgba(255,183,77,.08); border: 1px solid rgba(255,183,77,.25);
  border-radius: 6px; padding: 7px 9px;
}
.sec-warn b { color: var(--ok); }

/* ---- section browser modal --------------------------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: rgba(6,8,11,.62); backdrop-filter: blur(3px);
}
.modal-card {
  width: min(960px, 92vw); max-height: 86vh; display: flex; flex-direction: column;
  background: var(--bg-1); border: 1px solid var(--line-2); border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0,0,0,.6); overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.modal-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.modal-title .ic { color: var(--accent); }
.modal-x {
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--txt-1);
  width: 28px; height: 28px; border-radius: 7px; cursor: pointer; font-size: 13px;
}
.modal-x:hover { background: var(--bg-4); color: var(--txt-0); }
.modal-sub { padding: 10px 18px 0; color: var(--txt-1); font-size: 12px; }
.sec-pickers { display: flex; gap: 12px; padding: 12px 18px; flex-wrap: wrap; }
.sec-pick { display: flex; flex-direction: column; gap: 4px; }
.sec-pick > span { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--txt-2); }
.sec-pick .fld { height: 30px; min-width: 170px; }
.sec-pick.sec-search { flex: 1; min-width: 160px; }
.sec-pick.sec-search .fld { width: 100%; min-width: 0; }
.sec-list-wrap { flex: 1; overflow: auto; margin: 0 4px; border-top: 1px solid var(--line); }
.sec-table .sec-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.sec-table .sec-sort:hover { color: var(--txt-0); }
.sec-table .sec-sort.sorted { color: var(--accent); }
.sec-table .sec-sort.sorted[data-dir="asc"]::after { content: " ▲"; font-size: 9px; }
.sec-table .sec-sort.sorted[data-dir="desc"]::after { content: " ▼"; font-size: 9px; }
.sec-table tbody td { font-size: 11.5px; }
.sec-table tbody tr { cursor: pointer; }
.sec-table tbody tr:hover { background: var(--accent-soft); }
.sec-table tbody tr.is-current { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.sec-table tbody tr.is-current td:first-child { color: var(--accent); }
.sec-table .assign-mini {
  background: var(--accent); border: none; color: #fff; border-radius: 5px;
  padding: 3px 10px; cursor: pointer; font-size: 11px; font-weight: 600; font-family: inherit;
}
.sec-table .assign-mini:hover { filter: brightness(1.1); }
.modal-note {
  padding: 10px 18px; font-size: 10.5px; line-height: 1.5; color: var(--warn);
  background: rgba(255,183,77,.06); border-top: 1px solid var(--line);
}
.modal-note b { color: var(--ok); }

/* ---- File menu separator ----------------------------------------------- */
.menu-sep { height: 1px; background: var(--line); margin: 5px 8px; }

/* ---- AS 4100 design-check utilisation ---------------------------------- */
.util-ok { color: var(--ok); font-weight: 600; }
.util-over { color: var(--danger); font-weight: 700; }
/* "Failures only" filter on the design table */
.design-filter { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 11px;
  color: var(--txt-1); cursor: pointer; user-select: none; }
.design-filter-n { color: var(--danger); font-weight: 600; }
.res-pane.design-failures-only tbody tr.row-ok { display: none; }
/* mini utilisation bar in the design table: fill width = ratio, colour inherits
   the ok/over text colour via currentColor. Decorative only (aria-hidden). */
.util-cell { display: inline-flex; align-items: center; gap: 7px; }
.util-bar { display: inline-block; width: 40px; height: 6px; border-radius: 3px;
  background: var(--line); overflow: hidden; flex: 0 0 auto; }
.util-bar > i { display: block; height: 100%; min-width: 2px; border-radius: 3px;
  background: currentColor; }
.design-note { padding: 8px 12px; font-size: 10.5px; line-height: 1.5; color: var(--warn); }
.design-region-note { padding: 7px 12px; margin: 0; font-size: 11px; line-height: 1.5; color: var(--txt-1); background: var(--accent-soft, rgba(80,140,220,0.10)); border-left: 3px solid var(--accent, #4a90d9); }
.design-region-note b { color: var(--txt-0); }
.design-gov { padding: 7px 12px; font-size: 12px; color: var(--txt-1); border-bottom: 1px solid var(--line); }
.design-gov b { color: var(--txt-0); }
.design-svc { padding: 7px 12px; font-size: 11.5px; color: var(--txt-1); border-bottom: 1px solid var(--line); }
.design-svc b { color: var(--txt-0); }
.svc-pick { color: var(--accent); cursor: pointer; text-decoration: underline dotted; text-underline-offset: 2px; }
.svc-pick:hover { color: var(--txt-0); }
.svc-pick:focus-visible { outline: 2px solid var(--accent, #4a90d9); outline-offset: 2px; border-radius: 2px; }
.svc-limit { color: var(--txt-2); font-size: .92em; }
.bp-result { margin-top: 4px; }
/* load-case editor: read-only loads-count pill + how-to-add hint */
.lc-count { display: inline-block; min-width: 24px; padding: 1px 8px; border-radius: 10px;
  background: var(--bg-3); color: var(--txt-2); font-variant-numeric: tabular-nums; font-size: 12px; }
.lc-hint { margin-top: 10px; font-size: 11.5px; color: var(--txt-2); line-height: 1.5; }
.lc-hint b { color: var(--txt-1); font-weight: 600; }
/* collapsible inspector sections (connection design panels) */
details.insp-fold > summary { cursor: pointer; list-style: none; font-weight: 600; font-size: 12px;
  color: var(--txt-0); padding: 2px 0; display: flex; align-items: center; gap: 6px; }
details.insp-fold > summary::-webkit-details-marker { display: none; }
details.insp-fold > summary::before { content: '▸'; color: var(--txt-2); font-size: 10px; transition: transform .12s; }
details.insp-fold[open] > summary::before { transform: rotate(90deg); }
details.insp-fold > summary:hover { color: var(--accent); }
/* grouped sub-panels (connection & material checks): indent under the parent expander */
details.insp-group > details.insp-fold { margin: 4px 0 4px 8px; padding-left: 8px; border-left: 2px solid var(--line); }
details.insp-group > summary { font-size: 12.5px; }
.rel-end-lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--txt-2); margin: 6px 0 3px; }

/* ---- console clear button ---------------------------------------------- */
.res-pane[data-pane="log"] { position: relative; }
.log-clear {
  position: absolute; top: 6px; right: 10px; z-index: 2;
  background: var(--bg-3); border: 1px solid var(--line-2); color: var(--txt-1);
  border-radius: 5px; padding: 3px 9px; font-size: 11px; font-family: inherit; cursor: pointer;
}
.log-clear:hover { background: var(--bg-4); color: var(--txt-0); }

/* ---- Settings modal ---------------------------------------------------- */
.set-card { width: min(520px, 92vw); }
.combos-card { width: min(680px, 94vw); }
.combos-body { padding: 4px 18px 8px; max-height: 56vh; overflow: auto; }
.combos-tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.combos-tbl th { text-align: center; color: var(--txt-2); font-weight: 600; padding: 4px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.combos-tbl th:first-child { text-align: left; }
.combos-tbl td { padding: 4px 6px; border-bottom: 1px solid #1d222b; }
.combos-tbl .combo-name { width: 100%; min-width: 130px; }
.combos-tbl .combo-factor { width: 64px; text-align: right; }
.combos-tbl .combo-del { background: none; border: none; cursor: pointer; opacity: .65; font-size: 13px; }
.combos-tbl .combo-del:hover { opacity: 1; }
.set-body { padding: 6px 18px 14px; overflow: auto; }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.set-row:last-child { border-bottom: none; }
.set-label { display: flex; flex-direction: column; gap: 2px; }
.set-label > span { font-size: 12.5px; font-weight: 600; color: var(--txt-0); }
.set-label > small { font-size: 10.5px; color: var(--txt-2); }
.set-row .fld { height: 30px; min-width: 200px; max-width: 200px; }
/* two-column calculator modals (section / footing / retaining): numbers are short, so keep the inputs
   compact rather than letting a 3-char value float in a 200px field. */
.rw-split .set-row .fld, .sc-split .set-row .fld { min-width: 0; max-width: 130px; }
.set-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 18px; background: var(--bg-2); border-top: 1px solid var(--line);
}
.set-reset {
  background: transparent; border: 1px solid var(--line-2); color: var(--txt-1);
  border-radius: 7px; padding: 7px 12px; cursor: pointer; font-size: 12px; font-family: inherit;
}
.set-reset:hover { background: var(--bg-3); color: var(--txt-0); }
.set-done {
  background: var(--accent); border: none; color: #fff; font-weight: 600;
  border-radius: 7px; padding: 8px 18px; cursor: pointer; font-size: 12px; font-family: inherit;
}
.set-done:hover { filter: brightness(1.1); }

/* ---- tabbed Settings (General / Display / Language) --------------------- */
.set-tabs { display: flex; gap: 2px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.set-tab {
  background: none; border: none; color: var(--txt-2); cursor: pointer;
  font-size: 12.5px; font-weight: 600; font-family: inherit;
  padding: 9px 12px; margin-bottom: -1px; border-bottom: 2px solid transparent;
}
.set-tab:hover { color: var(--txt-0); }
.set-tab.active { color: var(--txt-0); border-bottom-color: var(--accent); }
.set-panel.hidden { display: none; }
.set-soon { color: var(--txt-2); }
.set-soon .muted { color: var(--txt-2); opacity: .6; font-size: 11px; }

/* ---- light viewport background mode ------------------------------------ */
body.lightvp .legend, body.lightvp .deform-panel, body.lightvp .vp-chip,
body.lightvp .vp-btns { /* keep overlays readable on light bg */ }

.hidden { display: none !important; }

/* ===== Resizable + collapsible panels (panels.js) ===== */
#left, #right { position: relative; overflow: hidden; }
.resizer { position: absolute; z-index: 40; background: transparent; transition: background .12s; }
.resizer-x { top: 0; bottom: 0; width: 7px; cursor: col-resize; }
.resizer-y { left: 0; right: 0; height: 7px; cursor: row-resize; }
#left  .resizer-x { right: 0; }
#right .resizer-x { left: 0; }
#results .resizer-y { top: 0; }
.resizer:hover { background: var(--accent); opacity: .4; }
body.resizing { user-select: none; }
body.resizing #viewport, body.resizing canvas, body.resizing iframe { pointer-events: none; }
.btn.off { opacity: .45; }

/* ===== Analysis report (report.js) ===== */
#report-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.55); overflow: auto; display: none; transition: padding-right .18s ease; }
/* when the designer panel is open, pad the report so the centred page shifts left and stays visible beside it */
#report-overlay.rd-open { padding-right: min(480px, 94vw); }
#report-overlay.show { display: block; }
#report-overlay .rp-actions { position: sticky; top: 0; display: flex; gap: 8px; justify-content: flex-end; padding: 12px; background: var(--bg-2,#1e2127); border-bottom: 1px solid var(--line); }
#report-overlay .rp-page { background: #fff; color: #111; max-width: 820px; margin: 16px auto; padding: 28px 34px; font: 13px/1.5 "DM Sans", system-ui, sans-serif; }
.rp-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #111; padding-bottom: 8px; }
.rp-brand { color: #5b9bd5; font-weight: 700; letter-spacing: -.02em; }
.rp-sub { color: #666; }
.rp-meta { display: flex; justify-content: space-between; margin: 10px 0; color: #333; }
.rp-img { display: block; max-width: 100%; border: 1px solid #ccc; margin: 10px 0; }
#report-overlay h2 { font-size: 15px; margin: 18px 0 6px; border-bottom: 1px solid #ccc; }
#report-overlay h3 { font-size: 13px; margin: 12px 0 4px; color: #222; }
.rp-tbl { width: 100%; border-collapse: collapse; margin: 4px 0 10px; font-size: 11.5px; }
.rp-tbl th, .rp-tbl td { border: 1px solid #ccc; padding: 3px 6px; text-align: right; }
.rp-tbl th:first-child, .rp-tbl td:first-child { text-align: left; }
.rp-tbl th { background: #f2f2f2; }
.rp-none { color: #888; font-style: italic; }
.rp-disc { margin-top: 16px; color: #666; font-size: 11px; }
.rp-lc { color: #5b9bd5; font-weight: 600; font-size: .8em; }
/* editable project title block (job no. / engineer / rev) for the submitted calc */
.rp-titleblock { display: grid; grid-template-columns: 2fr 1fr 1fr 0.6fr; gap: 10px;
  margin: 8px 0 14px; border: 1px solid #bbb; border-radius: 4px; padding: 8px 10px; }
.rp-tb { display: flex; flex-direction: column; font-size: 9.5px; color: #777; }
.rp-tb span { text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.rp-tb input { border: none; border-bottom: 1px solid #ccc; background: transparent;
  font: inherit; font-size: 12px; color: #111; padding: 2px 0; }
.rp-tb input:focus { outline: none; border-bottom-color: #5b9bd5; }
@media print { .rp-tb input { border-bottom-color: transparent; } }
/* detailed AS 4100 member calculation blocks in the report */
.rp-calc { margin: 8px 0 12px; break-inside: avoid; page-break-inside: avoid; }
.rp-calc h4 { margin: 10px 0 3px; font-size: 12px; color: #111; border-bottom: 1px solid #999; padding-bottom: 2px; }
.rp-calc-tbl td { font-size: 11px; }
/* typeset calc-sheet working inside the report: drop the on-screen panel chrome, keep the lines */
.rp-working { border: 0; background: transparent; }
.rp-working .dw-body { padding: 2px 0; }
.rp-working .dw-clause { color: #555; }
.rp-working .dw-eq .katex { color: #111; }
.rp-calc-tbl .rp-cv { white-space: nowrap; font-variant-numeric: tabular-nums; }
.rp-cl { color: #888; font-size: .82em; font-weight: 600; }
.rp-calc-tbl .rp-gov td { background: #eafaef; font-weight: 700; }
.rp-calc-tbl .rp-gov-over td { background: #fdecec; font-weight: 700; }

/* ===== Report graphs (BMD/SFD/AFD) + designer-driven sections (report_diagrams/report.js) ===== */
.rp-sec { display: block; }
.rp-sep { border-top: 2px dashed #bbb; margin: 16px 0; height: 0; }
.rp-cap { font-size: 11px; color: #555; margin: 2px 0 10px; }
.rp-note { font-size: 11px; color: #777; }
.rp-toc { border: 1px solid #ddd; background: #fafafa; padding: 8px 14px; margin: 10px 0; }
.rp-toc-h { font-weight: 700; font-size: 12px; margin-bottom: 4px; }
.rp-toc ol { margin: 0; padding-left: 18px; }
.rp-toc a { color: #1d4ed8; text-decoration: none; }
.rp-diag-member { margin: 10px 0 14px; page-break-inside: avoid; }
.rp-diag-mh { font-weight: 700; font-size: 12px; margin-bottom: 4px; }
.rp-diag-block { margin: 4px 0 8px; }
.rp-diag-cap { font-size: 11px; color: #444; }
.rp-diag { width: 100%; max-width: 620px; height: auto; border: 1px solid #e3e3e3; background: #fff; display: block; }
.rp-diag-base { stroke: #999; stroke-width: 1; }
.rp-diag-lbl { font: 10px "DM Sans", sans-serif; fill: #333; }
.rp-ubars { width: 100%; max-width: 620px; display: block; border: 1px solid #e3e3e3; background: #fff; margin: 6px 0; }
.rp-ubar-lbl, .rp-ubar-val { font: 10px "DM Sans", sans-serif; fill: #333; }

/* ===== Report designer panel (report_designer.js) ===== */
.rd-panel { position: fixed; top: 0; right: 0; width: min(480px, 94vw); max-width: 94vw; height: 100%; z-index: 250;
  background: var(--bg-1,#23262d); color: var(--fg,#e7e9ee); border-left: 1px solid var(--line,#3a3f4a);
  box-shadow: -8px 0 24px rgba(0,0,0,.35); display: none; flex-direction: column; }
.rd-panel.show { display: flex; }
.rd-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line,#3a3f4a); }
.rd-title-h { font-weight: 700; }
.rd-x { background: none; border: 0; color: inherit; font-size: 20px; cursor: pointer; line-height: 1; }
.rd-body { padding: 10px 14px; overflow: auto; }
.rd-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.rd-lbl { font-size: 12px; opacity: .85; }
.rd-sel { background: var(--bg-2,#1a1d23); color: inherit; border: 1px solid var(--line,#3a3f4a); border-radius: 4px; padding: 3px 6px; }
.rd-opts { gap: 14px; }
.rd-chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }
.rd-panes { display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px; }
.rd-pane { border: 1px solid var(--line,#3a3f4a); border-radius: 6px; padding: 6px; min-height: 200px; max-height: 52vh; overflow: auto; }
.rd-pane-h { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; opacity: .7; margin-bottom: 6px; }
.rd-grp { font-size: 10px; text-transform: uppercase; opacity: .55; margin: 6px 0 2px; }
.rd-avail { font-size: 12px; padding: 3px 5px; border-radius: 4px; cursor: pointer; }
.rd-avail:hover { background: var(--bg-2,#1a1d23); }
.rd-add { color: #4ade80; font-weight: 700; }
.rd-item { display: flex; align-items: center; gap: 4px; padding: 3px 2px; border-radius: 4px; }
.rd-item:hover { background: var(--bg-2,#1a1d23); }
.rd-item-sep { opacity: .8; font-style: italic; }
.rd-dragover { outline: 1px dashed #6ea8ff; }
.rd-drag { cursor: grab; opacity: .5; font-size: 11px; }
.rd-title { flex: 1 1 auto; min-width: 0; background: var(--bg-2,#1a1d23); color: inherit; border: 1px solid var(--line,#3a3f4a); border-radius: 4px; padding: 2px 5px; font-size: 12px; }
.rd-lvl { font-size: 11px; background: var(--bg-2,#1a1d23); color: inherit; border: 1px solid var(--line,#3a3f4a); border-radius: 4px; }
.rd-ctrls { display: inline-flex; gap: 2px; }
.rd-mini { background: none; border: 1px solid var(--line,#3a3f4a); color: inherit; border-radius: 3px; cursor: pointer; font-size: 10px; padding: 1px 4px; }
.rd-sep-lbl { flex: 1 1 auto; font-size: 11px; }
.rd-empty { font-size: 12px; opacity: .6; padding: 8px 4px; }
.rd-addsep { margin-top: 8px; }
.rd-foot { margin-top: 10px; }
.rd-panel .btn.sm { font-size: 11px; padding: 3px 8px; }
@media print {
  body * { visibility: hidden !important; }
  #report-overlay, #report-overlay * { visibility: visible !important; }
  #report-overlay { position: absolute; inset: 0; background: #fff; overflow: visible; }
  #report-overlay .rp-actions, .no-print, .rd-panel { display: none !important; }
  #report-overlay, #report-overlay.rd-open { padding-right: 0 !important; }
  #report-overlay .rp-page { margin: 0; max-width: none; }
  .rp-pagebreak { page-break-before: always; }
}

/* ===== Toolbar dropdown menus + shortcuts (toolbar.js) ===== */
.menu { position: relative; display: inline-flex; }
.menu-trigger { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  background: var(--bg-3, #232833); color: var(--text, #e8e8ea); border: 1px solid var(--line, #2c313a);
  border-radius: 7px; cursor: pointer; font: inherit; font-size: 13px; white-space: nowrap; }
.menu-trigger:hover { background: var(--bg-2, #1e2127); }
.menu .caret { opacity: .55; font-size: 10px; }
.menu-pop { position: absolute; top: calc(100% + 5px); left: 0; min-width: 210px; z-index: 130;
  background: var(--bg-2, #1e2127); border: 1px solid var(--line, #2c313a); border-radius: 9px;
  padding: 6px; display: none; box-shadow: 0 10px 28px rgba(0,0,0,.45); }
.menu.open .menu-pop { display: block; }
.menu-label { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-500, #6b6b6b); padding: 6px 8px 2px; }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; margin: 1px 0;
  background: none; border: none; color: var(--text, #e8e8ea); text-align: left; border-radius: 6px;
  cursor: pointer; font: inherit; font-size: 13px; text-decoration: none; white-space: nowrap; }
.menu-item:hover { background: var(--bg-3, #232833); }
.menu-item .kbd, .sc-key { margin-left: auto; font-size: 11px; color: var(--ink-400, #8a8a8a);
  border: 1px solid var(--line, #2c313a); border-radius: 4px; padding: 0 6px; min-width: 18px; text-align: center; }
/* toggle-state shortcut chips: full blue = on / final step, diagonal half-fill = intermediate cycle step */
.menu-item .kbd.kbd-on { color: #fff; border-color: var(--accent, #5b9bd5); background: var(--accent, #5b9bd5); }
.menu-item .kbd.kbd-half { color: #fff; border-color: var(--accent, #5b9bd5);
  background: linear-gradient(135deg, var(--accent, #5b9bd5) 0 50%, transparent 50% 100%); }
.menu-row { display: flex; gap: 4px; padding: 3px 4px; }
.menu-chip, .menu-row.seg button { flex: 1; padding: 6px 8px; background: var(--bg-3, #232833);
  border: 1px solid var(--line, #2c313a); color: var(--text, #e8e8ea); border-radius: 6px; cursor: pointer; font: inherit; font-size: 12px; }
.menu-chip:hover, .menu-row.seg button:hover { background: var(--bg-2, #1e2127); }
.menu-row.seg button.active { background: var(--accent, #5b9bd5); color: #fff; border-color: var(--accent, #5b9bd5); }
/* context menu (right-click desktop / long-press tablet) - one presenter, both input modes */
.ctx-menu { position: absolute; z-index: 250; min-width: 200px;
  background: var(--bg-2, #1e2127); border: 1px solid var(--line, #2c313a); border-radius: 8px;
  padding: 5px; box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.ctx-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 12px; margin: 1px 0;
  background: none; border: none; color: var(--text, #e8e8ea); text-align: left; border-radius: 6px;
  cursor: pointer; font: inherit; font-size: 13px; white-space: nowrap; }
.ctx-item:hover { background: var(--bg-3, #232833); }
.ctx-item .ic { width: 16px; text-align: center; opacity: .85; }
.ctx-sep { height: 1px; background: var(--line, #2c313a); margin: 4px 6px; }
@media (hover: none) and (pointer: coarse) { .ctx-item { min-height: 44px; } }
/* shortcuts overlay */
#sc-overlay { position: fixed; inset: 0; z-index: 240; background: rgba(0,0,0,.55); display: none; align-items: center; justify-content: center; }
#sc-overlay.show { display: flex; }
#sc-overlay .sc-card { background: var(--bg-2, #1e2127); border: 1px solid var(--line, #2c313a); border-radius: 12px; padding: 22px 26px; min-width: 320px; max-height: 86vh; overflow-y: auto; color: var(--text, #e8e8ea); }
#sc-overlay h3 { margin: 0 0 12px; font-size: 15px; letter-spacing: -.02em; }
#sc-overlay .sc-group { margin: 14px 0 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--accent, #6ea8fe); border-bottom: 1px solid var(--line, #2c313a); padding-bottom: 3px; }
#sc-overlay .sc-group:first-of-type { margin-top: 0; }
#sc-overlay .sc-row { display: flex; justify-content: space-between; gap: 24px; padding: 5px 0; font-size: 13px; }
#sc-overlay .sc-hint { margin-top: 14px; font-size: 11px; color: var(--ink-500, #6b6b6b); text-align: right; }

/* command palette */
#cmd-palette { position: fixed; inset: 0; z-index: 250; background: rgba(0,0,0,.5); display: none; align-items: flex-start; justify-content: center; }
#cmd-palette.show { display: flex; }
#cmd-palette .cmd-card { margin-top: 12vh; width: min(540px, 92vw); background: var(--bg-2, #1e2127); border: 1px solid var(--line, #2c313a);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
#cmd-palette .cmd-input { width: 100%; box-sizing: border-box; padding: 14px 16px; font-size: 15px; border: none; outline: none;
  background: transparent; color: var(--txt-0, #e8e8ea); border-bottom: 1px solid var(--line, #2c313a); }
#cmd-palette .cmd-list { max-height: 50vh; overflow: auto; padding: 6px; }
#cmd-palette .cmd-item { padding: 8px 12px; border-radius: 6px; font-size: 13px; color: var(--txt-1, #aab2c0); cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#cmd-palette .cmd-key { font-size: 11px; color: var(--txt-2, #6b7686); border: 1px solid var(--line-2, #363d49); border-radius: 4px; padding: 1px 6px; }
#cmd-palette .cmd-item.active { background: var(--accent-soft, #1c3450); color: var(--txt-0, #e8e8ea); }
#cmd-palette .cmd-empty { padding: 12px; color: var(--txt-2, #6b7686); font-size: 13px; }
#cmd-palette .cmd-hint { padding: 8px 14px; font-size: 11px; color: var(--txt-2, #6b7686); border-top: 1px solid var(--line, #2c313a); }
.design-govby { color: var(--txt-2); font-weight: 400; font-size: 11px; }
.design-mass { float: right; color: var(--txt-2); font-weight: 400; }
.design-mass b { color: var(--txt-1); }

/* Section profile thumbnails (library rows) + preview (section calculator/editor) */
.sec-thumb { display: inline-block; vertical-align: middle; margin-right: 8px; line-height: 0; }
.sec-thumb .sec-svg { vertical-align: middle; }
.sec-preview { display: flex; justify-content: center; padding: 6px 0 10px; }
.sec-preview .sec-svg { background: rgba(255,255,255,0.02); border-radius: 6px; }

/* Analysis report rollup */
.rp-rollup { padding: 8px 12px; border-radius: 4px; margin: 8px 0 12px; font-size: 12px; }
.rp-pass { background: #e6f4ea; color: #1e7e34; }
.rp-fail { background: #fce8e8; color: #c5221f; }


/* Respect the OS "reduce motion" preference (vestibular / motion-sickness a11y).
   Neutralise transitions + decorative animations (spinner, busy-dot pulse, toast
   slide-in). Loading state is still conveyed by the "Working…" label + disabled
   buttons, not by motion - so nothing functional is lost. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* AS 4100 "show the working" - clause-referenced derivation under the design table */
.design-working { margin: 8px 0 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg-1); }
.design-working > summary { cursor: pointer; padding: 7px 10px; font-size: 12px; font-weight: 600; color: var(--txt-1); user-select: none; }
.design-working .dw-copy { float: right; margin: -2px 0 0; padding: 1px 8px; font-size: 11px; font-weight: 500; cursor: pointer; color: var(--txt-1); background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px; }
.design-working .dw-copy:hover { color: var(--txt-0); border-color: var(--accent, #4a90d9); }
.design-working .dw-copy.copied { color: #46c46a; border-color: #46c46a; }
.design-working[open] > summary { border-bottom: 1px solid var(--line); }
.design-working .dw-body { padding: 6px 10px 8px; }
.design-working .dw-line { display: flex; gap: 10px; align-items: baseline; padding: 4px 0; border-bottom: 1px dotted var(--line); }
.design-working .dw-line:last-of-type { border-bottom: 0; }
.design-working .dw-clause { flex: 0 0 130px; color: var(--txt-2); font-size: 11px; white-space: nowrap; }
/* typeset (KaTeX) equation; falls back to monospace text when no LaTeX twin is present */
.design-working .dw-eq { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--txt-0); overflow-x: auto; }
.design-working .dw-eq .katex { font-size: 1.05em; color: var(--txt-0); }
.design-working .dw-foot { margin: 8px 0 0; font-size: 11px; color: var(--txt-2); }
