:root {
  --bg: #0f1216;
  --panel: #161a20;
  --panel-2: #1b2027;
  --line: #262d36;
  --line-soft: #1f252d;
  --text: #d8dee7;
  --muted: #8a94a3;
  --dim: #5f6a78;
  --accent: #4da3ff;
  --accent-2: #7cc0ff;
  --accent-dim: rgba(77, 163, 255, 0.14);
  --warn: #ffb454;
  --danger: #ff6b6b;
  --ok: #4ade80;
  --canvas: #0f1216;
  --title-1: #171c23;
  --title-2: #12161b;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "SF Mono", monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 12px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }
svg { display: block; }

#app {
  height: 100vh;
  display: grid;
  grid-template-rows: 36px auto auto 1fr auto;
  grid-template-columns: minmax(0, 1fr);
}

/* ---------- title bar ---------- */
#titlebar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  background: linear-gradient(180deg, var(--title-1), var(--title-2));
  border-bottom: 1px solid var(--line);
  user-select: none;
}
.brand { display: flex; align-items: center; gap: 8px; cursor: pointer; border-radius: 6px; padding: 2px 6px 2px 2px; margin-left: -2px; }
.brand:hover { background: var(--hover, rgba(255,255,255,.06)); }
.brand .logo { width: 20px; height: 20px; display: block; }
.brand-name { font-weight: 650; letter-spacing: 0.2px; font-size: 13px; }
.brand-tag { color: var(--dim); font-size: 10.5px; letter-spacing: 0.3px; text-transform: uppercase; }
.doc-name { color: var(--muted); font-size: 11.5px; padding-left: 14px; border-left: 1px solid var(--line); }
.title-actions { margin-left: auto; display: flex; gap: 6px; }
.chip {
  font-size: 10.5px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  letter-spacing: 0.2px;
}
.chip.ok { color: var(--ok); border-color: rgba(74, 222, 128, 0.25); background: rgba(74, 222, 128, 0.07); }
.chip.warn { color: var(--warn); border-color: rgba(255, 180, 84, 0.3); background: rgba(255, 180, 84, 0.08); }
.chip.err { color: var(--danger); border-color: rgba(255, 107, 107, 0.3); background: rgba(255, 107, 107, 0.08); }

/* ---------- ribbon ---------- */
#ribbon { background: var(--panel); border-bottom: 1px solid var(--line); user-select: none; }
.tabs { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--line-soft); }
.tab {
  padding: 7px 14px 6px;
  color: var(--muted);
  font-size: 11.5px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-2); border-bottom-color: var(--accent); }

.ribbon-body { height: 84px; display: flex; overflow: hidden; min-width: 0; }
.tab-panel { display: none; align-items: stretch; padding: 0 4px; flex: 1 1 auto; min-width: 0; overflow: hidden; }
.tab-panel.active { display: flex; }
.group { display: flex; flex-direction: column; padding: 5px 10px 4px; border-right: 1px solid var(--line-soft); }
.group.grow { flex: 1; }
.group-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--dim);
  margin-bottom: 3px;
  padding-left: 2px;
}
.group-items { display: flex; gap: 2px; align-items: flex-start; }
.hint-text { color: var(--muted); font-size: 11px; max-width: 330px; line-height: 1.5; padding: 4px 2px; }

.rb {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 58px;
  height: 48px;
  border-radius: 6px;
  color: var(--muted);
  border: 1px solid transparent;
}
.rb svg { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.rb svg.fill { fill: currentColor; stroke: none; }
.rb span { font-size: 10px; letter-spacing: 0.1px; white-space: nowrap; }
.rb:hover { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.rb:active { transform: translateY(1px); }
.rb.active { background: var(--accent-dim); color: var(--accent-2); border-color: rgba(77, 163, 255, 0.35); }
.rb.primary { background: linear-gradient(180deg, #2f7fd6, #2568b3); color: #fff; border-color: #3d8fe0; }
.rb.primary:hover { background: linear-gradient(180deg, #3a8ee6, #2b74c4); }
.rb.primary svg { stroke: none; fill: #fff; }
.rb:disabled { opacity: 0.35; cursor: default; }
.rb:disabled:hover { background: none; border-color: transparent; color: var(--muted); }

.slider-wrap { display: flex; align-items: center; gap: 8px; padding: 12px 2px 0; }
input[type="range"] { width: 130px; accent-color: var(--accent); }
.slider-val { font-family: var(--mono); font-size: 11px; color: var(--muted); min-width: 34px; }

/* ---------- workspace ---------- */
#workspace { display: grid; grid-template-columns: 232px minmax(0, 1fr) 286px; min-height: 0; }

.panel { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
#left-panel { border-right: 1px solid var(--line); }
#right-panel { border-left: 1px solid var(--line); }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--dim);
  border-bottom: 1px solid var(--line-soft);
  background: var(--panel-2);
  flex: none;
}
.panel-head .count { color: var(--muted); font-family: var(--mono); font-size: 10px; letter-spacing: 0; }
.panel-body { overflow: auto; flex: 1; min-height: 0; }
#right-panel .panel-body { flex: 0 1 auto; max-height: 46%; }
#right-panel .panel-body:last-child { flex: 1 1 auto; max-height: none; }

/* ---------- viewport ---------- */
#viewport { position: relative; min-width: 0; background: var(--canvas); overflow: hidden; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
#canvas.tool-select { cursor: default; }
#canvas.panning { cursor: grabbing; }

.hud {
  position: absolute;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.6px;
  color: var(--dim);
  pointer-events: none;
  user-select: none;
}
.hud-tl { top: 10px; left: 12px; color: var(--muted); }
.hud-tr { top: 10px; right: 12px; }
.hud-bl { bottom: 10px; left: 12px; display: flex; gap: 14px; }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-swatch { width: 14px; height: 3px; border-radius: 2px; }

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  color: var(--muted);
  background: radial-gradient(ellipse at center, rgba(77, 163, 255, 0.05), transparent 60%);
}
.empty-state h2 { margin: 0; font-size: 17px; font-weight: 600; color: var(--text); }
.empty-state p { margin: 0 0 10px; font-size: 12px; }
.empty-state kbd { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-family: var(--mono); font-size: 10.5px; }

.btn {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
}
.btn:hover { border-color: var(--dim); }
.btn.primary { background: linear-gradient(180deg, #2f7fd6, #2568b3); border-color: #3d8fe0; color: #fff; }
.btn.primary:hover { background: linear-gradient(180deg, #3a8ee6, #2b74c4); }

/* ---------- tree ---------- */
.tree-section { border-bottom: 1px solid var(--line-soft); }
.tree-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--dim);
  cursor: default;
}
.tree-head .n { margin-left: auto; font-family: var(--mono); letter-spacing: 0; }
.tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 18px;
  color: var(--muted);
  cursor: pointer;
  border-left: 2px solid transparent;
}
.tree-item:hover { background: var(--panel-2); color: var(--text); }
.tree-item.selected { background: var(--accent-dim); color: var(--accent-2); border-left-color: var(--accent); }
.tree-item .id { font-family: var(--mono); font-size: 10.5px; color: var(--dim); min-width: 22px; }
.tree-item.selected .id { color: var(--accent-2); }
.tree-item .meta { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--dim); }
.tree-empty { padding: 6px 18px 8px; color: var(--dim); font-size: 11px; font-style: italic; }

/* ---------- properties ---------- */
.prop-empty { padding: 14px 12px; color: var(--dim); font-size: 11.5px; line-height: 1.6; }
.prop-title { display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px; }
.prop-title .badge {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent-2);
  background: var(--accent-dim);
  border: 1px solid rgba(77, 163, 255, 0.3);
  border-radius: 4px;
  padding: 1px 6px;
}
.prop-title .name { font-weight: 600; font-size: 12px; }
.field { display: flex; align-items: center; gap: 8px; padding: 3px 12px; }
.field label { flex: 0 0 74px; color: var(--muted); font-size: 11px; }
.field input, .field select {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 7px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  outline: none;
}
.field input:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(77, 163, 255, 0.15); }
.field input[readonly] { color: var(--dim); background: transparent; border-color: transparent; }
.field .unit { flex: 0 0 auto; color: var(--dim); font-size: 10px; font-family: var(--mono); }
.prop-actions { padding: 8px 12px 12px; display: flex; gap: 6px; }
.prop-actions .btn { padding: 4px 10px; font-size: 11px; }
.prop-actions .btn.danger { color: var(--danger); border-color: rgba(255, 107, 107, 0.3); }
.prop-actions .btn.danger:hover { background: rgba(255, 107, 107, 0.1); }

/* ---------- results ---------- */
.res-empty { padding: 14px 12px; color: var(--dim); font-size: 11.5px; line-height: 1.6; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line-soft); margin: 8px 10px; border: 1px solid var(--line-soft); border-radius: 6px; overflow: hidden; }
.stat { background: var(--panel); padding: 7px 9px; }
.stat .k { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--dim); }
.stat .v { display: block; font-family: var(--mono); font-size: 12.5px; color: var(--text); margin-top: 1px; }
.stat .v small { color: var(--dim); font-size: 9.5px; }
.res-table-wrap { padding: 0 10px 10px; }
.res-table-title { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--dim); margin: 8px 0 4px; }
table.res { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 10px; }
table.res th { text-align: right; color: var(--dim); font-weight: 500; padding: 3px 4px; border-bottom: 1px solid var(--line); }
table.res th:first-child, table.res td:first-child { text-align: left; }
table.res td { text-align: right; padding: 3px 4px; color: var(--muted); border-bottom: 1px solid var(--line-soft); }
table.res tr:hover td { color: var(--text); background: var(--panel-2); }
table.res td.pos { color: var(--accent-2); }
table.res td.neg { color: var(--warn); }

/* ---------- footer ---------- */
#footer { border-top: 1px solid var(--line); background: var(--panel); }
#cmdline {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  height: 30px;
  border-bottom: 1px solid var(--line-soft);
}
#cmdline .prompt { color: var(--accent); font-family: var(--mono); font-size: 14px; }
#cmdInput {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text);
  padding: 4px 0;
}
#cmdInput::placeholder { color: var(--dim); }
.cmd-hint { color: var(--dim); font-size: 10px; font-family: var(--mono); }

#statusbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 24px;
  padding: 0 10px;
  font-size: 10.5px;
  color: var(--dim);
  font-family: var(--mono);
}
#statusbar .spacer { flex: 1; }
.sb-item { color: var(--dim); }
.sb-item.on { color: var(--accent-2); }
#statusMsg { color: var(--muted); font-family: -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 11px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 16px; bottom: 64px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 9px 12px;
  border-radius: 7px;
  background: #1e242c;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  color: var(--text);
  font-size: 11.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.18s ease-out;
}
.toast { display: flex; align-items: center; gap: 10px; font-size: 12.5px; transform-origin: bottom right; }
.toast .toast-msg { flex: 1; }
.toast .toast-act { padding: 4px 10px; font-size: 11.5px; white-space: nowrap; }
.toast .toast-x { opacity: .6; }
.toast.out { animation: toast-out .12s ease-in forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px) scale(.97); } }
.toast.warn { border-left-color: var(--warn); }
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 12, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
/* dialogs ship with [hidden]; .open (set by open*()) must beat it */
.modal-backdrop.open { display: flex !important; }
.modal {
  width: 560px;
  max-width: calc(100vw - 40px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.modal-body { padding: 14px 16px 18px; color: var(--muted); font-size: 12px; }
.modal-body h4 { margin: 12px 0 6px; color: var(--text); font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; }
.modal-body h4:first-child { margin-top: 0; }
.modal-body p { margin: 3px 0; }
.modal-body kbd { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-family: var(--mono); font-size: 10.5px; color: var(--text); }
.modal-body .mono { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.icon-btn { width: 26px; height: 26px; border-radius: 5px; color: var(--muted); font-size: 16px; line-height: 1; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* ---------- load cases & factors ---------- */
.case-bar { display: flex; align-items: flex-end; gap: 6px; padding-top: 4px; }
.case-bar select {
  height: 30px;
  min-width: 132px;
  max-width: 190px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 11.5px;
  padding: 0 6px;
}
.case-bar select:focus { outline: none; border-color: var(--accent); }
.rb.small { padding: 4px 7px 3px; }
.rb.small svg { width: 15px; height: 15px; }
.rb.small span { font-size: 9px; }
.mini-field {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 0 6px 2px;
  font-size: 10.5px;
  color: var(--dim);
}
.mini-field input {
  width: 52px;
  height: 26px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  padding: 0 5px;
}
.mini-field input:focus { outline: none; border-color: var(--accent); }

.modal.narrow { width: 470px; }
.modal-note { color: var(--dim); font-size: 11px; line-height: 1.55; margin: 0 0 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--dim); }
table.factors { width: 100%; border-collapse: collapse; font-size: 11.5px; }
table.factors th {
  text-align: left;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--dim);
  font-weight: 500;
  padding: 0 6px 5px;
}
table.factors td { padding: 3px 6px; border-top: 1px solid var(--line-soft); color: var(--text); }
table.factors td:first-child { color: var(--muted); }
table.factors input {
  width: 74px;
  height: 26px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  padding: 0 5px;
}
table.factors input:focus { outline: none; border-color: var(--accent); }

.res-view { display: flex; align-items: center; gap: 8px; padding: 9px 10px 2px; }
.res-view label { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--dim); }
.res-view select {
  flex: 1;
  height: 27px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  padding: 0 5px;
}
.res-view select:focus { outline: none; border-color: var(--accent); }
.res-note { padding: 8px 10px 0; color: var(--dim); font-size: 10.5px; line-height: 1.5; }
table.res.env th { padding: 0 3px 4px; font-size: 9px; }
table.res.env td { padding: 3px 3px; }
.env-cell { display: flex; flex-direction: column; line-height: 1.3; }
.env-cell b { font-weight: 500; color: var(--text); font-size: 10.5px; }
.env-cell span { color: var(--dim); font-size: 9.5px; }

/* ================= report ================= */
#reportOverlay { position: fixed; inset: 0; z-index: 60; background: #e8ecf1; display: flex; flex-direction: column; }
.rpt-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.rpt-bar-title { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.rpt-bar-actions { display: flex; gap: 8px; }
#report { flex: 1; width: 100%; border: 0; background: #e5e7eb; display: block; }
#report .rpt-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #111827; padding-bottom: 6px; }
#report .rpt-brand { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
#report .rpt-sub { font-size: 10px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.1em; }
#report .rpt-stamp { font-size: 10.5px; color: #6b7280; }
#report h1 { font-size: 21px; margin: 14px 0 2px; font-weight: 650; }
#report .rpt-meta { font-size: 10.5px; color: #6b7280; margin-bottom: 6px; }
#report h2 { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; margin: 20px 0 7px; padding-bottom: 3px; border-bottom: 1px solid #d1d5db; color: #111827; }
#report h3 { font-size: 11.5px; margin: 13px 0 4px; font-weight: 600; color: #374151; }
#report .rpt-table { width: 100%; border-collapse: collapse; font-size: 10.5px; margin-bottom: 6px; }
#report .rpt-table th { text-align: left; background: #f3f4f6; border-bottom: 1px solid #cbd5e1; padding: 3px 6px; font-weight: 600; color: #374151; }
#report .rpt-table td { border-bottom: 1px solid #e5e7eb; padding: 3px 6px; font-variant-numeric: tabular-nums; }
#report .rpt-table td.num, #report .rpt-table th.num { text-align: right; }
#report .rpt-fig { border: 1px solid #d1d5db; padding: 4px; margin: 4px 0 8px; background: #fff; }
#report .rpt-fig img { display: block; max-width: 100%; max-height: 88mm; margin: 0 auto; }
#report .rpt-note { font-size: 10.5px; color: #6b7280; margin: 4px 0; }
#report .rpt-foot { margin-top: 20px; border-top: 1px solid #d1d5db; padding-top: 6px; font-size: 9.5px; color: #6b7280; line-height: 1.5; }
#report .rpt-table, #report .rpt-fig { page-break-inside: avoid; }

@media print {
  @page { size: A4; margin: 13mm; }
  html, body { height: auto !important; overflow: visible !important; background: #fff !important; }
  #app, .modal-backdrop, #fileInput, .rpt-bar { display: none !important; }
  #reportOverlay { position: static; background: #fff; display: block !important; }
  #report { width: auto; max-width: none; margin: 0; padding: 0; box-shadow: none; overflow: visible; font-size: 11px; }
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2a323c; border-radius: 6px; border: 2px solid var(--panel); }
::-webkit-scrollbar-thumb:hover { background: #35404c; }
::-webkit-scrollbar-track { background: transparent; }

/* ================= Framelysis UI extensions ================= */

/* dynamic input tooltip at the cursor */
.dyn-input {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  transform: translate(14px, 14px);
  background: rgba(15, 18, 22, 0.94);
  border: 1px solid var(--accent);
  border-radius: 5px;
  padding: 3px 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent-2);
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.2px;
}
.dyn-input .dim { color: var(--dim); }
.dyn-input .warn { color: var(--warn); }

/* command autocomplete */
#cmdline { position: relative; }
.cmd-suggest {
  position: absolute;
  left: 22px;
  bottom: 30px;
  min-width: 320px;
  max-width: 620px;
  max-height: 232px;
  overflow: auto;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 -8px 26px rgba(0, 0, 0, 0.5);
  z-index: 40;
  padding: 3px;
}
.cmd-suggest .sg {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
}
.cmd-suggest .sg:hover, .cmd-suggest .sg.sel { background: var(--accent-dim); }
.cmd-suggest .sg b { color: var(--accent-2); font-weight: 600; min-width: 74px; }
.cmd-suggest .sg span { color: var(--dim); font-size: 10.5px; }
.cmd-suggest .sg em { color: var(--muted); font-style: normal; margin-left: auto; font-size: 10px; }

/* ribbon select */
.rb-select {
  height: 30px;
  min-width: 150px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 11.5px;
  padding: 0 6px;
  margin-top: 8px;
}
.rb-select:focus { outline: none; border-color: var(--accent); }

/* status bar tool chip */
.sb-tool {
  color: var(--accent-2);
  background: var(--accent-dim);
  border: 1px solid rgba(77, 163, 255, 0.28);
  border-radius: 4px;
  padding: 0 6px;
  font-size: 9.5px;
  letter-spacing: 0.6px;
  line-height: 16px;
}
.sb-item.on { color: var(--accent-2); }
.sb-item.warn { color: var(--warn); }

/* load editor dialog */
.modal.wide { width: 620px; }
.load-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 18px;
  margin-bottom: 10px;
}
.load-grid .field { padding: 3px 0; }
.load-grid .field label { flex: 0 0 62px; }
.load-preview {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--warn);
  background: rgba(255, 180, 84, 0.07);
  border: 1px solid rgba(255, 180, 84, 0.22);
  border-radius: 6px;
  padding: 7px 10px;
  margin: 4px 0 12px;
  min-height: 30px;
  line-height: 1.4;
}
.load-list-head {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--dim);
  margin: 4px 0 5px;
}
.load-list { max-height: 168px; overflow: auto; border: 1px solid var(--line-soft); border-radius: 6px; }
.load-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
}
.load-row:last-child { border-bottom: 0; }
.load-row:hover { background: var(--panel-2); color: var(--text); }
.load-row.sel { background: var(--accent-dim); color: var(--accent-2); }
.load-row .tag {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--warn);
  border: 1px solid rgba(255, 180, 84, 0.3);
  border-radius: 3px;
  padding: 0 4px;
  flex: none;
}
.load-row .txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.load-row .del { color: var(--dim); font-size: 13px; line-height: 1; padding: 0 3px; }
.load-row .del:hover { color: var(--danger); }
.load-empty { padding: 10px; color: var(--dim); font-size: 11px; font-style: italic; }

/* tree: load rows */
.tree-item .tag {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--warn);
  border: 1px solid rgba(255, 180, 84, 0.28);
  border-radius: 3px;
  padding: 0 3px;
  flex: none;
}
.tree-item .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-item.sub { padding-left: 30px; }

/* properties: load summary */
.prop-desc {
  margin: 2px 12px 8px;
  padding: 6px 9px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--warn);
  background: rgba(255, 180, 84, 0.06);
  border: 1px solid rgba(255, 180, 84, 0.2);
  border-radius: 5px;
  line-height: 1.45;
}
.prop-sub {
  padding: 8px 12px 2px;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--dim);
}
.prop-list { padding: 0 12px 8px; }
.prop-list .pl-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
}
.prop-list .pl-row:hover { background: var(--panel-2); color: var(--text); }
.prop-list .pl-row.sel { background: var(--accent-dim); color: var(--accent-2); }
.prop-list .pl-row .txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 10px; }

/* hint text emphasis */
.hint-text b { color: var(--muted); font-weight: 600; }
.hint-text code { font-family: var(--mono); color: var(--accent-2); }

/* results: numeric labels legend */
.res-legend { display: flex; flex-wrap: wrap; gap: 10px; padding: 4px 10px 8px; }
.res-legend .lg { display: flex; align-items: center; gap: 5px; font-size: 10px; color: var(--dim); }
.res-legend .sw { width: 12px; height: 3px; border-radius: 2px; }


/* ---- tabulated results modal ---- */
.table-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.table-tabs .seg {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 6px; padding: 5px 10px; font-size: 11px; cursor: pointer;
}
.table-tabs .seg:hover { color: var(--text); border-color: var(--line-2, var(--line)); }
.table-tabs .seg.on { color: #fff; background: var(--accent); border-color: var(--accent); }
.table-scroll { max-height: 52vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.table-scroll table.res { width: 100%; }
.table-scroll table.res thead th { position: sticky; top: 0; background: var(--panel-2); z-index: 1; }

/* GRASP member-load window: palette of the ten load types */
.load-types { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 10px 0 8px; }
.lt-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px; border: 1px solid var(--line); border-radius: 6px; background: transparent; color: var(--text-dim, #93a1b3); font: 10.5px/1.2 inherit; cursor: pointer; text-align: center; }
.lt-card svg { width: 64px; height: 30px; stroke: #ffb454; fill: none; stroke-width: 1.4; }
.lt-card:hover { border-color: #ffb45488; color: var(--text, #dbe3ec); }
.lt-card.on { border-color: #4da3ff; background: rgba(77,163,255,.12); color: var(--text, #dbe3ec); }

/* ---- v1.2 ribbon: stacked small buttons (Office style), no scrollbars ---- */
.stack { display: flex; flex-direction: column; gap: 1px; }
.rb.sm { flex-direction: row; justify-content: flex-start; gap: 6px; width: auto; min-width: 92px; height: 21px; padding: 0 6px; border-radius: 4px; }
.rb.sm svg { width: 14px; height: 14px; }
.rb.sm span { font-size: 10.5px; white-space: nowrap; }
.group-items { gap: 4px; align-items: center; height: 100%; }
.group { padding: 4px 8px 3px; flex: 0 0 auto; }
.tabs { align-items: center; }
.tab-collapse { margin-left: auto; color: var(--dim); width: 26px; height: 22px; border-radius: 4px; transition: transform .15s; }
.tab-collapse:hover { color: var(--text); background: var(--panel-2); }
#ribbon.collapsed .ribbon-body { display: none; }
#ribbon.collapsed .tab-collapse { transform: rotate(180deg); }
.stack .mini-field { height: 21px; padding: 0 6px; }
.stack .mini-field input { height: 19px; width: 44px; }
/* narrow windows: drop small-button labels to icons, then hide group labels */
@media (max-width: 1360px) and (hover: hover) { .rb.sm { min-width: 0; } .rb.sm span { display: none; } .rb.sm { width: 26px; justify-content: center; padding: 0; } .stack .mini-field span { display: none; } }
@media (max-width: 1100px) { .rb { width: 48px; } .group { padding: 4px 5px 3px; } }

/* ---- collapsible side panels ---- */
.panel-toggle { position: absolute; top: 50%; z-index: 5; width: 14px; height: 44px; margin-top: -22px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 42px; text-align: center; cursor: pointer; padding: 0; }
.panel-toggle:hover { color: var(--accent-2); background: var(--panel-2); }
#toggleLeft { left: 0; border-left: none; border-radius: 0 6px 6px 0; }
#toggleRight { right: 0; border-right: none; border-radius: 6px 0 0 6px; }
#workspace { transition: grid-template-columns .15s; }
#workspace.hide-left { grid-template-columns: 0 minmax(0, 1fr) 286px; }
#workspace.hide-right { grid-template-columns: 232px minmax(0, 1fr) 0; }
#workspace.hide-left.hide-right { grid-template-columns: 0 minmax(0, 1fr) 0; }
#workspace.hide-left #left-panel, #workspace.hide-right #right-panel { overflow: hidden; border: none; }

/* ---- generic GRASP-style dialogs ---- */
.form-grid { display: grid; grid-template-columns: 150px 1fr; gap: 6px 10px; align-items: center; }
.form-grid label { color: var(--muted); font-size: 11.5px; }
.form-grid input, .form-grid select, .wiz input, .wiz select { height: 28px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; color: var(--text); font-family: var(--mono); font-size: 11.5px; padding: 0 7px; min-width: 0; }
.form-grid input:focus, .form-grid select:focus, .wiz input:focus { outline: none; border-color: var(--accent); }
.form-grid input[type=checkbox] { height: 16px; width: 16px; accent-color: var(--accent); }
.wiz-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wiz-card { border: 1px solid var(--line); border-radius: 8px; padding: 8px; text-align: center; color: var(--muted); font-size: 11px; background: var(--panel-2); cursor: pointer; }
.wiz-card svg { width: 100%; height: 70px; stroke: var(--text); fill: none; stroke-width: 1.3; }
.wiz-card.on { border-color: var(--accent); background: var(--accent-dim); color: var(--accent-2); }
.wiz-cards.sec { grid-template-columns: repeat(4, 1fr); }
.wiz-cards.sec svg { height: 44px; fill: #b06b5a; stroke: none; }
.wiz-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; margin: 10px 0; }
.wiz-row label { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--muted); font-size: 11.5px; }
.wiz-row input { width: 90px; }
.wiz-list { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px; }
.wiz-list input { width: 64px; }
.wiz-sub { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: var(--dim); margin-top: 8px; }
.wiz-steps { color: var(--dim); font-size: 10.5px; margin-left: 10px; font-weight: 400; }
.wiz-prev { display: block; margin: 8px auto 0; background: var(--canvas); border: 1px solid var(--line); border-radius: 6px; }

/* ---------- v1.3 settings menu, light theme, accents, animations ---------- */
body.light {
  --bg: #e6eaf0; --panel: #f3f5f9; --panel-2: #e9edf3; --line: #c9d1dc; --line-soft: #d9dfe8;
  --text: #1f2a3a; --muted: #4a5668; --dim: #6f7b8c; --canvas: #edf0f5; --title-1: #f3f5f9; --title-2: #e9edf3; --hover: rgba(20,40,80,.07);
  --warn: #c27400; --danger: #d33a3a; --ok: #15994a;
}
body.accent-teal { --accent: #2dd4bf; --accent-2: #5eead4; --accent-dim: rgba(45,212,191,.14); }
body.accent-violet { --accent: #a78bfa; --accent-2: #c4b5fd; --accent-dim: rgba(167,139,250,.15); }
body.accent-amber { --accent: #f5a524; --accent-2: #fbbf24; --accent-dim: rgba(245,165,36,.15); }
body.accent-rose { --accent: #fb7185; --accent-2: #fda4af; --accent-dim: rgba(251,113,133,.15); }
body.light.accent-blue, body.light:not([class*=accent-]) { --accent: #1f74d1; --accent-2: #1f74d1; --accent-dim: rgba(31,116,209,.12); }
body.light .rb.primary, body.light .btn.primary { background: var(--accent); border-color: var(--accent); }
body:not(.accent-blue):not(.light) .rb.primary, body[class*=accent-]:not(.accent-blue) .btn.primary { background: var(--accent); border-color: var(--accent); color: #0b0e12; }

.hamburger { width: 28px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); border: 1px solid transparent; }
.hamburger:hover, .hamburger[aria-expanded=true] { background: var(--panel-2); border-color: var(--line); color: var(--text); }
.hamburger svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
#titlebar { position: relative; }
.settings-menu { position: absolute; top: 34px; right: 8px; z-index: 120; width: 236px; padding: 10px 12px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 16px 40px rgba(0,0,0,.35); transform-origin: top right; }
.sm-head { font-weight: 650; margin-bottom: 6px; }
.sm-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); margin: 8px 0 5px; }
.sm-seg { display: flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.sm-seg button { flex: 1; padding: 5px 0; color: var(--muted); font-size: 11px; }
.sm-seg button.on { background: var(--accent-dim); color: var(--accent-2); }
.sm-swatches { display: flex; gap: 8px; }
.sm-swatches button { width: 22px; height: 22px; border-radius: 50%; background: var(--sw); border: 2px solid transparent; box-shadow: 0 0 0 1px var(--line); }
.sm-swatches button.on { border-color: var(--panel); box-shadow: 0 0 0 2px var(--sw); }
.sm-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; cursor: pointer; }
.sm-switch { appearance: none; width: 30px; height: 17px; border-radius: 9px; background: var(--line); position: relative; cursor: pointer; margin: 0; }
.sm-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; transition: left .15s; }
.sm-switch:checked { background: var(--accent); }
.sm-switch:checked::after { left: 15px; }
.sm-foot { margin-top: 10px; padding-top: 7px; border-top: 1px solid var(--line-soft); color: var(--dim); font-size: 10.5px; }

/* subtle motion, only when Animations is on (also honours the OS reduced-motion setting) */
body.anim .rb, body.anim .btn, body.anim .tab, body.anim .tree-item, body.anim .hamburger, body.anim .lt-card { transition: background-color .14s, color .14s, border-color .14s, transform .1s; }
body.anim .tab-panel.active { animation: fl-fade .18s ease-out; }
body.anim .modal-backdrop.open { animation: fl-fade .16s ease-out; }
body.anim .modal-backdrop.open .modal { animation: fl-pop .2s cubic-bezier(.16,1,.3,1); }
body.anim .settings-menu:not([hidden]) { animation: fl-pop .16s ease-out; }
body.anim #reportOverlay:not([hidden]) { animation: fl-fade .2s ease-out; }
body.anim #workspace { transition: grid-template-columns .22s ease; }
body.anim .chip { transition: color .2s, background-color .2s, border-color .2s; }
body:not(.anim) *, body:not(.anim) *::before, body:not(.anim) *::after { animation: none !important; transition: none !important; }
@keyframes fl-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fl-pop { from { opacity: 0; transform: translateY(-4px) scale(.95); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { body.anim *, body.anim *::before, body.anim *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; } }
body.light .chip { background: var(--panel-2); color: var(--muted); border-color: var(--line); }
body.light.accent-teal { --accent: #0f9488; --accent-2: #0f766e; --accent-dim: rgba(15,148,136,.12); }
body.light.accent-violet { --accent: #7c3aed; --accent-2: #6d28d9; --accent-dim: rgba(124,58,237,.10); }
body.light.accent-amber { --accent: #c26a00; --accent-2: #a35900; --accent-dim: rgba(194,106,0,.12); }
body.light.accent-rose { --accent: #e11d48; --accent-2: #be123c; --accent-dim: rgba(225,29,72,.10); }
body.light[class*=accent-] .rb.primary, body.light[class*=accent-] .btn.primary { color: #fff; }

/* status bar toggles (v1.4) */
.sb-btn { background: none; border: 1px solid transparent; border-radius: 4px; padding: 1px 6px; font: inherit; cursor: pointer; }
.sb-btn:hover { border-color: var(--line); color: var(--text); }
.sb-btn:active { transform: scale(.97); }
.sb-units { color: var(--dim); background: transparent; appearance: none; -webkit-appearance: none; }
.sb-units option { background: var(--panel, #1b2027); color: var(--text); }

/* Number inputs: no native spinners; the value is edited by typing, arrow keys,
   or Alt+drag / wheel (see app.js nudge). */
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.field input[type=number] { font-family: var(--mono); text-align: right; cursor: text; }
.field input[type=number]:hover:not(:focus) { border-color: var(--line-2, #3a4350); cursor: ns-resize; }
#canvas.xhair { cursor: none; }
#canvas.xhair.panning { cursor: grabbing; }
body.accent-green { --accent: #4ade80; --accent-2: #86efac; --accent-dim: rgba(74,222,128,.14); }
body.light.accent-green { --accent: #15994a; --accent-2: #15803d; --accent-dim: rgba(21,153,74,.10); }

/* ---------- Settings dialog (v1.4) ---------- */
.modal.settings-dlg { width: min(720px, 94vw); max-width: none; }
.set-wrap { display: flex; min-height: 360px; border-top: 1px solid var(--line-soft, var(--line)); }
.set-nav { width: 170px; padding: 10px 8px; border-right: 1px solid var(--line-soft, var(--line)); display: flex; flex-direction: column; gap: 2px; }
.set-nav button { text-align: left; padding: 7px 10px; border-radius: 6px; color: var(--muted); font-size: 12px; position: relative; }
.set-nav button:hover { background: var(--panel-2); color: var(--text); }
.set-nav button.on { background: var(--accent-dim); color: var(--accent-2); }
.set-body { flex: 1; padding: 6px 18px 12px; overflow: auto; max-height: 60vh; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line-soft, var(--line)); }
.set-row:last-child { border-bottom: 0; }
.set-lab { color: var(--text); font-size: 12.5px; }
.set-lab small { display: block; color: var(--dim); font-size: 11px; margin-top: 2px; }
.set-ctl { display: flex; align-items: center; gap: 8px; }
.set-ctl input[type=range] { width: 150px; accent-color: var(--accent); }
.set-ctl input[type=number], .set-ctl select { width: 120px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 4px 7px; font-size: 12px; }
.set-ctl input[type=number] { width: 70px; }
.set-val { min-width: 44px; color: var(--dim); font-family: var(--mono); font-size: 11px; }
.set-actions { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line-soft, var(--line)); }
.set-actions .set-ver { flex: 1; text-align: center; color: var(--dim); font-size: 10.5px; }
body.anim .set-row { animation: fl-rise .2s ease-out both; animation-delay: calc(var(--i) * 30ms); }
@keyframes fl-rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
body.density-compact .rb span { font-size: 10px; }
body.density-compact .rb { padding-top: 2px; padding-bottom: 2px; }
body.density-comfy .rb { padding-top: 6px; padding-bottom: 6px; }
body.density-comfy .tree-item, body.density-comfy .field { padding-top: 3px; padding-bottom: 3px; }

/* v1.4 motion (from "UI Improvement" notes): ease-out entrances, no bounce,
   press scale .97, popovers grow from .95 at their trigger, 30 ms list stagger,
   success pulse, exits ~20 % shorter than entrances, mouse leaves canvas quietly. */
body.anim .rb:active, body.anim .btn:active, body.anim .tab:active, body.anim .sb-btn:active { transform: scale(.97); }
body.anim .rb { transition: background-color .14s ease-out, color .14s ease-out, transform .08s ease-out; }
body.anim select, body.anim .cmd-suggest:not([hidden]) { transform-origin: top; }
body.anim .cmd-suggest:not([hidden]) { animation: fl-pop .16s cubic-bezier(.16,1,.3,1); transform-origin: bottom left; }
body.anim .toast { animation: toast-in .2s cubic-bezier(.16,1,.3,1); }
body.anim .toast.out { animation: toast-out .14s ease-in forwards; }
body.anim .sm-switch::after { transition: left .16s cubic-bezier(.16,1,.3,1), width .16s; }
body.anim .sm-switch:active::after { width: 15px; }   /* knob stretches while pressed */
body.anim .stat .v { transition: color .2s; }
@media (prefers-reduced-motion: reduce) { body.anim *, body.anim *::before, body.anim *::after { animation: none !important; transition: none !important; } }

/* ---------- Start page (v1.4) ---------- */
.start { position: fixed; inset: 0; z-index: 900; display: grid; grid-template-columns: 340px 1fr; background: var(--bg); }
.start[hidden] { display: none; }
body.anim .start:not([hidden]) { animation: fl-fade .2s ease-out; }
body.anim .start.out { animation: start-out .16s ease-in forwards; }
@keyframes start-out { to { opacity: 0; transform: scale(.99); } }
.start-side { background: var(--panel); border-right: 1px solid var(--line); padding: 26px 22px; display: flex; flex-direction: column; gap: 6px; overflow: auto; }
.start-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.start-brand img { width: 44px; height: 44px; }
.start-brand b { display: block; font-size: 19px; letter-spacing: .3px; }
.start-brand span { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.start-sec { color: var(--dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; margin: 14px 0 4px; }
.start svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.start-big { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 13.5px; font-weight: 600; }
.start-big:hover { filter: brightness(1.1); }
.start-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--text); font-size: 12.5px; text-align: left; }
.start-link:hover { background: var(--panel-2); }
.start-link kbd { margin-left: auto; color: var(--dim); font: 10.5px var(--mono); }
.start-tpl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.start-tpl button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 11.5px; background: var(--panel-2); }
.start-tpl button:hover { border-color: var(--accent); color: var(--text); }
.start-tpl svg { width: 60px; height: 40px; stroke-width: 2.2; color: var(--accent-2); }
.start-foot { margin-top: auto; padding-top: 16px; display: flex; justify-content: space-between; color: var(--dim); font-size: 11px; }
.start-foot label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.start-main { padding: 34px 44px; overflow: auto; }
.start-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 12px; max-width: 900px; }
.start-head h2 { font-size: 15px; font-weight: 600; margin: 0; }
.start-clear { color: var(--dim); font-size: 11px; }
.start-clear:hover { color: var(--text); }
.start-recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; max-width: 900px; margin-bottom: 34px; }
.start-card { text-align: left; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 0; overflow: hidden; }
.start-card:hover { border-color: var(--accent); }
.start-card .thumb { height: 104px; background: var(--canvas-bg, #11151c); display: flex; align-items: center; justify-content: center; }
.start-card .thumb svg { width: 86%; height: 84%; stroke: var(--accent-2); stroke-width: 1.4; }
.start-card .meta { padding: 8px 10px; }
.start-card .meta b { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.start-card .meta span { color: var(--dim); font-size: 10.5px; }
body.anim .start-card { animation: fl-rise .2s ease-out both; animation-delay: calc(var(--i) * 30ms); }
.start-empty { color: var(--dim); font-size: 12px; padding: 18px 0; }
.start-learn { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; max-width: 900px; }
.start-learn div { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: var(--panel); }
.start-learn b { display: block; font-size: 12.5px; margin-bottom: 4px; }
.start-learn span { color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.start-learn code { font: 11px var(--mono); color: var(--accent-2); }
.set-ctl .sm-seg button { flex: none; padding: 5px 12px; }

/* ---------- v1.4.1 ---------- */
#footer { position: relative; }
#footer.hide-footer { border-top: 0; }
#footer.hide-footer #cmdline, #footer.hide-footer #statusbar { display: none; }
.footer-toggle { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); width: 46px; height: 11px; line-height: 9px; padding: 0; font-size: 8px; color: var(--dim); background: var(--panel); border: 1px solid var(--line); border-bottom: 0; border-radius: 6px 6px 0 0; z-index: 2; }
.footer-toggle:hover { color: var(--text); }
.res-table-wrap { overflow-x: auto; }
.start-sub { color: var(--dim); font-size: 11px; }
.start-cmds { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 6px 14px; max-width: 900px; margin-bottom: 34px; }
.cmd-row { display: grid; grid-template-columns: 170px 1fr; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.cmd-row code { font: 11.5px var(--mono); color: var(--accent-2); white-space: normal; overflow-wrap: anywhere; min-width: 0; }   /* a long command wraps in its column instead of running into the description */
.cmd-row span { color: var(--muted); font-size: 11.5px; min-width: 0; overflow-wrap: anywhere; }
.credit { margin-top: 12px; color: var(--dim); font-size: 10.5px; text-align: center; }
.credit em { font-style: normal; opacity: .8; }
.set-foot-credit { color: var(--dim); font-size: 10.5px; }

/* v1.4.2: tab strip wraps instead of spilling out of the Tabulated results dialog */
.table-tabs { flex-wrap: wrap; }
.table-tabs .seg { white-space: nowrap; }
#tableModal .modal.wide { width: min(960px, 94vw); }
#tableModal .table-scroll { max-width: 100%; }

/* v1.5 structure-type indicator: a glowing chip in the title bar and a glow on the active Frame/Truss button */
.chip.type { font-weight: 700; letter-spacing: .08em; }
.chip.type.frame { color: var(--accent-2); border-color: var(--accent); background: var(--accent-dim); box-shadow: 0 0 10px var(--accent-dim), 0 0 3px var(--accent); }
.chip.type.truss { color: var(--warn); border-color: var(--warn); background: rgba(255,180,84,.12); box-shadow: 0 0 10px rgba(255,180,84,.35), 0 0 3px var(--warn); }
body.light .chip.type.truss { background: rgba(194,116,0,.10); box-shadow: 0 0 10px rgba(194,116,0,.25); }
.rb.glow { box-shadow: 0 0 0 1px var(--accent), 0 0 12px var(--accent-dim); }
body.anim .chip.type { transition: box-shadow .25s, color .2s, border-color .2s, background-color .2s; }

/* v1.5 — tablets and phones */
#canvas { touch-action: none; }
@media (pointer: coarse) {
  .rb { min-height: 34px; }
  .panel-toggle { width: 26px; height: 44px; font-size: 14px; }
  .tab { padding-top: 8px; padding-bottom: 8px; }
}
@media (max-width: 760px) {
  #workspace, #workspace.hide-left, #workspace.hide-right, #workspace.hide-left.hide-right { grid-template-columns: 0 minmax(0, 1fr) 0; position: relative; }
  #left-panel, #right-panel { position: absolute; top: 0; bottom: 0; width: min(82vw, 300px); z-index: 20; box-shadow: 0 0 24px rgba(0,0,0,.45); }
  #left-panel { left: 0; } #right-panel { right: 0; }
  #viewport { grid-column: 2; }
  #workspace.hide-left #left-panel, #workspace.hide-right #right-panel { display: none; }
  .panel-toggle { z-index: 30; }
  .tab-panel.active { overflow-x: auto; scrollbar-width: none; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
}

@media (max-width: 760px) {
  .brand-tag, .doc-name, #dofChip, #statusChip { display: none; }
  #titlebar { gap: 6px; }
  .cmd-hint, #cmdHint { display: none; }
  #statusbar { overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
  #statusbar .sb-tool, #statusMsg, #sbCursor, #sbSel { display: none; }
  #statusbar .spacer { display: none; }
  .hud-tl { right: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .hud-tr { display: none; }
}


/* v1.5.2 — ribbon spacing, phones (Poco F6 Pro) and tablets (Xiaomi Pad 7) */
.group.grow { flex: 0 0 auto; }                       /* no stretched empty groups */
#resultSetSelect { margin-top: 6px; min-width: 170px; }
@media (min-width: 1500px) {                           /* wide screens: use the room, don't leave a void */
  .group { padding: 4px 14px 3px; }
  .rb { width: 66px; }
  .rb.sm { min-width: 124px; height: 22px; }
  .rb.sm span { font-size: 11px; }
  .group-items { gap: 8px; }
}
/* swipe the ribbon sideways on touch screens instead of clipping it */
@media (pointer: coarse), (max-width: 1000px) {
  .tab-panel.active { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tab-panel.active::-webkit-scrollbar { display: none; }
  .group { flex-shrink: 0; }
}
@media (pointer: coarse) {
  .rb.sm { height: 26px; }
  .stack { gap: 2px; }
  input, select, textarea { font-size: 16px; }         /* stops mobile browsers zooming on focus */
  .rb-select, .stack .mini-field input { font-size: 13px; }
}
/* phone portrait: compact chrome so the canvas gets the screen */
@media (max-width: 760px) {
  .ribbon-body { height: 76px; }
  .group-label { display: none; }
  .group { padding: 4px 4px; }
  .rb { width: 52px; }
  #cmdline { display: none; }
}
/* phone landscape (short screens): panels become drawers, slim ribbon, no command line */
@media (max-height: 520px) and (pointer: coarse) {
  #workspace, #workspace.hide-left, #workspace.hide-right, #workspace.hide-left.hide-right { grid-template-columns: 0 minmax(0, 1fr) 0; position: relative; }
  #left-panel, #right-panel { position: absolute; top: 0; bottom: 0; width: min(46vw, 300px); z-index: 20; box-shadow: 0 0 24px rgba(0,0,0,.45); }
  #left-panel { left: 0; } #right-panel { right: 0; }
  #viewport { grid-column: 2; }
  #workspace.hide-left #left-panel, #workspace.hide-right #right-panel { display: none; }
  .panel-toggle { z-index: 30; }
  .ribbon-body { height: 62px; }
  .group-label { display: none; }
  .rb { height: 44px; min-height: 0; }
  .tab { padding-top: 5px; padding-bottom: 5px; }
  #cmdline, .brand-tag, .doc-name, #statusMsg, #sbTool { display: none; }
}

/* phones: stacked small buttons don't fit the short ribbon -> lay them out in a row as icon buttons */
@media (max-width: 760px), (max-height: 520px) and (pointer: coarse) {
  .stack { flex-direction: row; gap: 2px; }
  .rb.sm { width: 40px; min-width: 0; height: 44px; justify-content: center; padding: 0; }
  .rb.sm svg { width: 18px; height: 18px; }
  .rb.sm span { display: none; }
  .stack .mini-field { height: 34px; }
  .hud-tl { display: none; }
}


/* v1.6 — document tabs (AutoCAD-style file tabs under the ribbon) */
.doc-tabs { display: flex; align-items: flex-end; gap: 2px; padding: 4px 8px 0; background: var(--bg); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; min-height: 31px; user-select: none; }
.doc-tabs::-webkit-scrollbar { display: none; }
.doc-tab { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; max-width: 220px; height: 27px; padding: 0 6px 0 10px; border: 1px solid transparent; border-bottom: 0; border-radius: 7px 7px 0 0; color: var(--muted); font-size: 12px; cursor: pointer; position: relative; top: 1px; }
.doc-tab:hover { background: var(--panel-2); color: var(--text); }
.doc-tab.on { background: var(--panel); border-color: var(--line); color: var(--text); }
.doc-tab.on::before { content: ''; position: absolute; left: 8px; right: 8px; top: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.doc-tab svg { width: 13px; height: 13px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; opacity: .7; }
.doc-tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-tab .dot { display: none; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: none; }
.doc-tab.dirty .dot { display: block; }
.doc-tab.dirty:hover .dot, .doc-tab.dirty.on .dot { display: none; }
.doc-x { width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center; color: var(--dim); font-size: 15px; line-height: 1; flex: none; opacity: 0; }
.doc-tab:hover .doc-x, .doc-tab.on .doc-x { opacity: 1; }
.doc-x:hover { background: var(--line); color: var(--text); }
.doc-new { flex: none; width: 27px; height: 25px; margin-left: 2px; border-radius: 6px; color: var(--muted); font-size: 17px; line-height: 1; align-self: center; }
.doc-new:hover { background: var(--panel-2); color: var(--text); }
body.anim .doc-tab { transition: background .12s ease-out, color .12s ease-out; }

/* v1.6 — start page examples */
.start-hint { color: var(--dim); font-size: 11px; padding: 0 10px 6px 38px; line-height: 1.4; }
.ex-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ex-grid .start-card .thumb { height: 84px; }
.ex-grid .start-card .meta span { font-size: 10px; }

/* v1.6 — tablets, phones, web */
@media (pointer: coarse) {
  .doc-tab { height: 34px; font-size: 13px; }
  .doc-x { opacity: 1; width: 26px; height: 26px; }
  .doc-new { width: 36px; height: 32px; }
}
@media (max-width: 1000px) {
  .start { grid-template-columns: minmax(0, 1fr); grid-auto-rows: max-content; overflow: auto; }
  .start > * { min-width: 0; }
  .start-cmds { grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); }
  .start-side { border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .start-main { padding: 22px 18px 40px; overflow: visible; }
  .start-foot { margin-top: 12px; }
}
@media (max-width: 760px) {
  .doc-tabs { padding: 3px 4px 0; }
  .doc-tab { max-width: 150px; padding: 0 4px 0 8px; }
  .start-side { padding: 18px 16px; }
  .ex-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .start-cmds { grid-template-columns: 1fr; }
  .start-learn { grid-template-columns: 1fr; }
}
@media (max-height: 520px) and (pointer: coarse) {
  .doc-tab { height: 28px; }
  .doc-tabs { min-height: 0; }
}


/* v1.6 — web device prompt and per-device layout (body.dev-phone / dev-tablet / dev-pc) */
.dev-ask { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; padding: 16px; background: rgba(5, 9, 18, .62); backdrop-filter: blur(6px); }
body.anim .dev-ask { animation: fl-fade .18s ease-out both; }
body.anim .dev-ask .dev-card { animation: fl-pop .2s ease-out both; }
.dev-ask.out { opacity: 0; transition: opacity .14s ease-in; }
.dev-card { width: min(640px, 100%); max-height: 100%; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 26px 26px 22px; text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.dev-logo { width: 48px; height: 48px; }
.dev-card h2 { margin: 10px 0 6px; font-size: 20px; }
.dev-card p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.dev-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.dev-opts button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 10px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); }
.dev-opts button:hover, .dev-opts button:focus-visible { border-color: var(--accent); outline: none; }
.dev-opts button.sug { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.dev-opts svg { width: 40px; height: 40px; fill: none; stroke: var(--accent-2); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.dev-opts b { font-size: 14px; }
.dev-opts span { color: var(--dim); font-size: 11.5px; line-height: 1.4; }
.dev-opts i { position: absolute; top: 8px; right: 8px; font-style: normal; font-size: 10px; color: var(--accent-2); }
body.anim .dev-opts button { transition: border-color .12s ease-out, transform .1s ease-out; }
body.anim .dev-opts button:active { transform: scale(.97); }
@media (max-width: 520px) { .dev-opts { grid-template-columns: 1fr; } .dev-opts button { flex-direction: row; text-align: left; padding: 12px 14px; } .dev-opts button span { flex: 1; } .dev-opts svg { width: 30px; height: 30px; } .dev-opts i { top: 4px; } .dev-card { padding: 20px 16px 16px; } }

/* phone + tablet: touch-sized controls even when the browser reports a mouse */
body.dev-phone .rb, body.dev-tablet .rb { min-height: 34px; }
body.dev-phone .panel-toggle, body.dev-tablet .panel-toggle { width: 26px; height: 44px; font-size: 14px; }
body.dev-phone .tab, body.dev-tablet .tab { padding-top: 8px; padding-bottom: 8px; }
body.dev-phone .tab-panel.active, body.dev-tablet .tab-panel.active { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
body.dev-phone input, body.dev-phone select, body.dev-tablet input, body.dev-tablet select { font-size: 16px; }
body.dev-phone .doc-tab, body.dev-tablet .doc-tab { height: 34px; font-size: 13px; }
body.dev-phone .doc-x, body.dev-tablet .doc-x { opacity: 1; width: 26px; height: 26px; }
/* phone: canvas first — drawer panels, compact ribbon, no command line or hints */
body.dev-phone #workspace, body.dev-phone #workspace.hide-left, body.dev-phone #workspace.hide-right, body.dev-phone #workspace.hide-left.hide-right { grid-template-columns: 0 minmax(0, 1fr) 0; position: relative; }
body.dev-phone #left-panel, body.dev-phone #right-panel { position: absolute; top: 0; bottom: 0; width: min(82vw, 300px); z-index: 20; box-shadow: 0 0 24px rgba(0,0,0,.45); }
body.dev-phone #left-panel { left: 0; } body.dev-phone #right-panel { right: 0; }
body.dev-phone #viewport { grid-column: 2; }
body.dev-phone #workspace.hide-left #left-panel, body.dev-phone #workspace.hide-right #right-panel { display: none; }
body.dev-phone .panel-toggle { z-index: 30; }
body.dev-phone .group-label, body.dev-phone #cmdline, body.dev-phone .brand-tag, body.dev-phone .doc-name, body.dev-phone #dofChip, body.dev-phone .hud-tr, body.dev-phone #statusMsg, body.dev-phone #sbCursor { display: none; }
body.dev-phone .ribbon-body { height: 76px; }
body.dev-phone .group { padding: 4px; }
/* pc: keyboard-first — command line always on, smaller hit targets */
body.dev-pc #cmdline { display: flex; }

/* v1.6 web — GitHub links (title bar + device prompt) */
.gh-link { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); font-size: 11.5px; text-decoration: none; }
.gh-link svg { width: 14px; height: 14px; }
.gh-link:hover { color: var(--text); border-color: var(--accent); }
.gh-link[hidden] { display: none; }
body.anim .gh-link { transition: color .12s ease-out, border-color .12s ease-out; }
@media (max-width: 760px) { .gh-link span { display: none; } .gh-link { padding: 0 6px; } }
.dev-gh { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 12px 14px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: 12px; text-align: left; text-decoration: none; line-height: 1.45; }
.dev-gh svg { width: 22px; height: 22px; flex: none; color: var(--text); }
.dev-gh b { color: var(--text); }
.dev-gh span { flex: 1; }
.dev-gh em { font-style: normal; color: var(--accent-2); font-size: 15px; }
.dev-gh:hover { border-color: var(--accent); border-style: solid; color: var(--text); }

/* v1.6 — ribbon auto-fit (fitRibbon in app.js): never clip the last group at the window edge */
.tab-panel.fit-1 .group { padding-left: 7px; padding-right: 7px; }
.tab-panel.fit-1 .rb { width: 54px; }
.tab-panel.fit-1 .group-items { gap: 2px; }
.tab-panel.fit-2 .rb.sm { width: 26px; min-width: 0; justify-content: center; padding: 0; }
.tab-panel.fit-2 .rb.sm span, .tab-panel.fit-2 .stack .mini-field span { display: none; }
.tab-panel.fit-2 .rb { width: 50px; }
.tab-panel.fit-scroll { overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tab-panel.fit-scroll .group { flex-shrink: 0; }

/* groups never squeeze into each other; fitRibbon measures the real width and steps down instead */
#ribbon .tab-panel .group { flex-shrink: 0; }
#ribbon .tab-panel .group.grow { flex: 0 0 auto; }
#ribbon .group-items > *, #ribbon .stack { flex-shrink: 0; }

/* v1.6.1 — phones: keep clear of the notch / status bar / home indicator, and give the title bar room to breathe */
#app { height: 100dvh; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); box-sizing: border-box; }
@media (max-width: 760px), (max-height: 520px) and (pointer: coarse) {
  #app { padding-top: max(env(safe-area-inset-top), 6px); grid-template-rows: 44px auto auto 1fr auto; }
  #titlebar { padding: 0 12px; }
}
body.dev-phone #app { padding-top: max(env(safe-area-inset-top), 6px); grid-template-rows: 44px auto auto 1fr auto; }
.start { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
@media (max-width: 760px) { .start-side { padding-top: 26px; } }

/* v1.6.2 update reminder (installed apps) */
.upd-bar { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  max-width: calc(100vw - 24px); padding: 9px 12px 9px 16px; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); font-size: 12.5px; }
.upd-bar .upd-msg b { color: var(--accent-2); font-weight: 600; }
.upd-bar .btn { padding: 5px 12px; font-size: 12px; white-space: nowrap; }
@media (pointer: coarse) { .upd-bar { top: calc(8px + env(safe-area-inset-top)); } .upd-bar .btn { padding: 8px 14px; } }

/* v1.7 run analysis loading screen */
.run-ov { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(8, 10, 14, .45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: run-in .16s ease-out; }
.run-ov.out { animation: run-out .18s ease-in forwards; }
.run-card { width: min(320px, calc(100vw - 48px)); padding: 22px 24px 18px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 18px 50px rgba(0, 0, 0, .45); text-align: center; color: var(--text); }
.run-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.run-step { font-size: 12.5px; color: var(--muted); min-height: 18px; }
.run-bar { height: 4px; margin: 14px 0 10px; background: var(--line); border-radius: 4px; overflow: hidden; }
.run-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), #ff3b3b); animation: run-fill var(--run-ms, .9s) cubic-bezier(.3, .7, .4, 1) forwards; }
.run-meta { font-size: 11.5px; color: var(--dim); font-family: var(--mono); }
@keyframes run-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes run-out { to { opacity: 0; } }
@keyframes run-fill { to { width: 100%; } }
body.light .run-ov { background: rgba(240, 244, 248, .55); }

/* Android app: MainActivity pads the WebView by the system bars, so the page must not add the same
   safe-area inset again (that was a status-bar-sized gap above the start page and the title bar,
   and the same at the bottom). The web build and the desktop app are unaffected. */
html.android-app body #app, html.android-app .start { padding: 0; }
html.android-app body.dev-phone #app { padding-top: 0; }
html.android-app .upd-bar { top: 8px; }

/* v1.8 touch screens (iPad, phones): there are no hover tooltips, so every ribbon button keeps
   its name and the ribbon scrolls sideways instead (a tester on iPad could not tell what the
   icon-only buttons did). Tablets: icon with the label beside it; phones: label under the icon. */
@media (hover: none) {
  #ribbon .rb.sm span, #ribbon .tab-panel.fit-2 .rb.sm span { display: inline; }
  #ribbon .stack .mini-field span, #ribbon .tab-panel.fit-2 .stack .mini-field span { display: inline; }
  #ribbon .rb.sm { width: auto; min-width: 0; padding: 0 8px; justify-content: flex-start; }
}
@media (hover: none) and (max-width: 760px), (hover: none) and (max-height: 520px) and (pointer: coarse) {
  #ribbon .rb.sm { flex-direction: column; justify-content: center; gap: 2px; min-width: 46px; padding: 0 6px; }
  #ribbon .rb.sm span { display: block; font-size: 9.5px; }
}

/* v1.8.1 load combination factors: the table scrolls inside the dialog instead of spilling out of it
   (NSCP 2015 adds ten or more combination columns). The case names stay pinned on the left. */
.modal.factors-modal { width: min(980px, calc(100vw - 24px)); max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); display: flex; flex-direction: column; }
.modal.factors-modal .modal-body { min-height: 0; overflow-y: auto; }
#factorsTable { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
#factorsTable table.factors { width: max-content; min-width: 100%; }
#factorsTable table.factors th:first-child, #factorsTable table.factors td:first-child { position: sticky; left: 0; z-index: 1; background: var(--panel); }
#factorsTable table.factors .combo-name { width: auto; min-width: 96px; }
/* v1.8.1 the factors table is a list: combinations down, loads across */
#factorsTable table.factors-list th:not(:first-child) { text-align: center; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#factorsTable table.factors-list td input[type="number"] { width: 68px; }
#factorsTable table.factors-list tr.fixed-set td:first-child { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
#factorsTable table.factors-list tr.fixed-set + tr:not(.fixed-set) td { border-top: 1px solid var(--line); }
@media (max-width: 600px) {
  #factorsTable table.factors-list .combo-name { width: 124px; min-width: 0; }
  #factorsTable table.factors-list td input[type="number"] { width: 50px; }
  #factorsTable table.factors-list td, #factorsTable table.factors-list th { padding-left: 3px; padding-right: 3px; }
}

/* ======================================================================
   v1.8.2 — Liquid Glass (body.glass; Settings > Appearance > Liquid Glass)
   Floating, rounded, translucent surfaces over soft colour glows. Without
   body.glass nothing below applies and the flat look is unchanged. The canvas
   (#viewport) stays opaque: only its frame is rounded, so panning costs the same.
   ====================================================================== */
body.glass {
  --g-fill: rgba(28, 34, 46, .52);
  --g-fill-strong: rgba(26, 32, 44, .80);
  --g-hover: rgba(255, 255, 255, .07);
  --g-border: rgba(255, 255, 255, .10);
  --g-line: rgba(255, 255, 255, .07);
  --g-hi: inset 0 1px 0 rgba(255, 255, 255, .18);
  --g-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --g-blur: blur(22px) saturate(170%);
  --g-bg:
    radial-gradient(60vmax 50vmax at 0% 0%, rgba(56, 132, 255, .34), transparent 62%),
    radial-gradient(55vmax 45vmax at 100% 0%, rgba(139, 92, 246, .28), transparent 60%),
    radial-gradient(70vmax 40vmax at 50% 110%, rgba(245, 158, 11, .18), transparent 62%),
    #0b0e14;
  background: var(--g-bg);
}
body.glass.light {
  --g-fill: rgba(255, 255, 255, .55);
  --g-fill-strong: rgba(255, 255, 255, .82);
  --g-hover: rgba(255, 255, 255, .55);
  --g-border: rgba(255, 255, 255, .75);
  --g-line: rgba(20, 40, 80, .08);
  --g-hi: inset 0 1px 0 rgba(255, 255, 255, .9);
  --g-shadow: 0 10px 30px rgba(30, 50, 90, .14), 0 0 0 1px rgba(20, 40, 80, .05);
  --g-bg:
    radial-gradient(60vmax 50vmax at 0% 0%, rgba(77, 163, 255, .38), transparent 62%),
    radial-gradient(55vmax 45vmax at 100% 0%, rgba(167, 139, 250, .34), transparent 60%),
    radial-gradient(70vmax 40vmax at 50% 110%, rgba(251, 191, 36, .28), transparent 62%),
    #e9edf4;
}
/* phones, tablets and low-power devices: lighter blur (the costly part); glass-lite: none at all */
@media (max-width: 760px), (pointer: coarse) { body.glass { --g-blur: blur(12px) saturate(140%); } }
body.glass.dev-phone, body.glass.dev-tablet { --g-blur: blur(12px) saturate(140%); }
body.glass.glass-lite { --g-blur: none; --g-fill: rgba(28, 34, 46, .92); }
body.glass.glass-lite.light { --g-fill: rgba(250, 251, 253, .92); }

/* the floating layout */
body.glass #app { padding: 8px; row-gap: 8px; background: transparent; }
html.android-app body.glass #app, html.android-app body.glass.dev-phone #app { padding: 6px; }
@media (max-width: 760px), (max-height: 520px) and (pointer: coarse) { body.glass #app { padding: max(env(safe-area-inset-top), 6px) 6px max(env(safe-area-inset-bottom), 6px); row-gap: 6px; } }
body.glass.dev-phone #app { padding: max(env(safe-area-inset-top), 6px) 6px max(env(safe-area-inset-bottom), 6px); row-gap: 6px; }

body.glass #titlebar, body.glass #ribbon, body.glass .panel, body.glass #footer, body.glass .toast, body.glass .upd-bar,
body.glass .settings-menu, body.glass .cmd-suggest, body.glass .panel-toggle {
  background: var(--g-fill);
  -webkit-backdrop-filter: var(--g-blur); backdrop-filter: var(--g-blur);
  border: 1px solid var(--g-border);
  box-shadow: var(--g-hi), var(--g-shadow);
}
body.glass #titlebar { border-radius: 16px; }
body.glass #ribbon { border-radius: 18px; overflow: hidden; }
body.glass #footer { border-radius: 14px; overflow: hidden; }
body.glass .panel { border-radius: 18px; overflow: hidden; }
body.glass #left-panel, body.glass #right-panel { border: 1px solid var(--g-border); }
body.glass .panel-head { background: transparent; border-bottom-color: var(--g-line); }
body.glass .tabs { border-bottom-color: var(--g-line); }
body.glass .group { border-right-color: var(--g-line); }
body.glass #cmdline { border-bottom-color: var(--g-line); }
body.glass #footer.hide-footer { border: 0; box-shadow: none; background: transparent; }

/* workspace: panels float beside a framed canvas */
body.glass #workspace { column-gap: 8px; }
body.glass #workspace.hide-left #viewport { margin-left: -8px; }
body.glass #workspace.hide-right #viewport { margin-right: -8px; }
body.glass #workspace.hide-left #left-panel, body.glass #workspace.hide-right #right-panel { visibility: hidden; box-shadow: none; }
body.glass #viewport { border-radius: 18px; border: 1px solid var(--g-border); box-shadow: var(--g-shadow); }
body.glass .panel-toggle { border-radius: 10px; }
body.glass #toggleLeft { left: 4px; border: 1px solid var(--g-border); }
body.glass #toggleRight { right: 4px; border: 1px solid var(--g-border); }
@media (max-width: 760px), (max-height: 520px) and (pointer: coarse) {
  body.glass #workspace { column-gap: 0; }
  body.glass #app #workspace #viewport { margin: 0; }
  body.glass #left-panel, body.glass #right-panel { top: 6px; bottom: 6px; background: var(--g-fill-strong); }
  body.glass #left-panel { left: 6px; } body.glass #right-panel { right: 6px; }
}
body.glass.dev-phone #workspace { column-gap: 0; }
body.glass.dev-phone #app #workspace #viewport { margin: 0; }
body.glass.dev-phone #left-panel, body.glass.dev-phone #right-panel { top: 6px; bottom: 6px; background: var(--g-fill-strong); }

/* document tabs: glass pills on the glow */
body.glass .doc-tabs { background: transparent; border-bottom: 0; padding: 0 4px; min-height: 0; }
body.glass .doc-tab { border-radius: 999px; border: 1px solid transparent; top: 0; }
body.glass .doc-tab:hover { background: var(--g-hover); }
body.glass .doc-tab.on { background: var(--g-fill); -webkit-backdrop-filter: var(--g-blur); backdrop-filter: var(--g-blur); border-color: var(--g-border); box-shadow: var(--g-hi), 0 4px 14px rgba(0, 0, 0, .18); }
body.glass .doc-tab.on::before { left: 50%; right: auto; width: 14px; margin-left: -7px; top: auto; bottom: 2px; height: 2px; }
body.glass .doc-new { border-radius: 999px; }
body.glass .doc-new:hover { background: var(--g-hover); }

/* ribbon: glass pills, accent glow on the active tool, glossy Run capsule */
body.glass .rb { border-radius: 12px; }
body.glass .rb:hover { background: var(--g-hover); border-color: var(--g-border); box-shadow: var(--g-hi); }
body.glass .rb.active {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 0 16px color-mix(in srgb, var(--accent) 38%, transparent);
}
body.glass .rb.primary, body.glass.light .rb.primary {
  position: relative; overflow: hidden; border-radius: 16px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 72%, #fff), var(--accent) 52%, color-mix(in srgb, var(--accent) 78%, #000));
  border-color: color-mix(in srgb, var(--accent) 65%, #fff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent);
}
body.glass .rb.primary::before { content: ""; position: absolute; left: 3px; right: 3px; top: 2px; height: 45%; border-radius: 13px 13px 10px 10px; background: linear-gradient(180deg, rgba(255, 255, 255, .45), rgba(255, 255, 255, 0)); pointer-events: none; }
body.glass .rb.primary:hover { filter: brightness(1.08); }
body.glass .sb-btn, body.glass .chip { border-radius: 999px; }
body.glass .btn { border-radius: 10px; }
body.glass .btn:not(.primary) { background: var(--g-hover); border-color: var(--g-border); box-shadow: var(--g-hi); }
body.glass .btn.primary { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 4px 12px color-mix(in srgb, var(--accent) 35%, transparent); }

/* dialogs, menus, toasts */
body.glass .modal-backdrop { background: rgba(5, 8, 12, .38); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
body.glass.light .modal-backdrop { background: rgba(200, 210, 225, .35); }
body.glass .modal, body.glass .dev-card, body.glass .run-card {
  background: var(--g-fill-strong);
  -webkit-backdrop-filter: var(--g-blur); backdrop-filter: var(--g-blur);
  border: 1px solid var(--g-border);
  border-radius: 22px;
  box-shadow: var(--g-hi), 0 24px 60px rgba(0, 0, 0, .45);
}
body.glass.light .modal, body.glass.light .dev-card, body.glass.light .run-card { box-shadow: var(--g-hi), 0 24px 60px rgba(30, 50, 90, .22); }
body.glass .modal-head { border-bottom-color: var(--g-line); }
body.glass .settings-menu, body.glass .cmd-suggest { border-radius: 16px; background: var(--g-fill-strong); }
body.glass .toast { border-radius: 14px; border-left: 3px solid var(--accent); background: var(--g-fill-strong); }
body.glass .toast.warn { border-left-color: var(--warn); }
body.glass .toast.error { border-left-color: var(--danger); }
body.glass .toast.ok { border-left-color: var(--ok); }
body.glass .upd-bar { border-radius: 16px; border-left: 3px solid var(--accent); background: var(--g-fill-strong); }

/* start page sits on the same glow */
body.glass .start { background: var(--g-bg); }
body.glass .start-side { background: var(--g-fill); -webkit-backdrop-filter: var(--g-blur); backdrop-filter: var(--g-blur); border-right-color: var(--g-border); }
body.glass .start-card { border-radius: 14px; background: var(--g-fill); border-color: var(--g-border); box-shadow: var(--g-hi); }

/* ======================================================================
   v1.8.2 — motion. All of it only with body.anim (Settings > Animations);
   the reduced-motion rules above switch it off too.
   ====================================================================== */
/* ribbon tab indicator (moveTabIndicator in app.js) slides between tabs */
.tabs { position: relative; }
.tabs .tab { position: relative; z-index: 1; }
.tabs .tab-ind { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; display: block;
  background: linear-gradient(var(--accent), var(--accent)) center bottom / calc(100% - 8px) 2px no-repeat; }
.tabs:has(.tab-ind) .tab.active { border-bottom-color: transparent; }
body.glass .tabs .tab-ind { background: color-mix(in srgb, var(--accent) 16%, var(--g-hover)); border: 1px solid var(--g-border); border-radius: 999px; box-shadow: var(--g-hi), 0 0 12px color-mix(in srgb, var(--accent) 22%, transparent); transform-origin: left; }
body.glass .tabs .tab { border-bottom-color: transparent; }
body.glass .tabs { padding-top: 4px; padding-bottom: 4px; }
body.anim .tabs .tab-ind { transition: transform .34s cubic-bezier(.34, 1.36, .64, 1), width .34s cubic-bezier(.34, 1.36, .64, 1), height .2s; }

/* ribbon panel fades and slides in */
body.anim .tab-panel.active { animation: fl-panel .24s cubic-bezier(.16, 1, .3, 1); }
@keyframes fl-panel { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* buttons spring when pressed */
body.anim .rb, body.anim .btn, body.anim .tab, body.anim .sb-btn, body.anim .doc-tab, body.anim .start-card {
  transition: background-color .14s ease-out, color .14s ease-out, border-color .14s, box-shadow .2s, transform .38s cubic-bezier(.34, 1.56, .64, 1);
}
body.anim .rb:active, body.anim .btn:active, body.anim .tab:active, body.anim .sb-btn:active, body.anim .doc-tab:active, body.anim .start-card:active { transform: scale(.94); transition-duration: .14s, .14s, .14s, .2s, .07s; }

/* dialogs and menus: spring open, fade closed (.closing: see the observer in app.js) */
body.anim .modal-backdrop.open { animation: fl-fade .18s ease-out; }
body.anim .modal-backdrop.open .modal { animation: fl-spring .38s cubic-bezier(.34, 1.4, .64, 1); }
.modal-backdrop.closing { display: flex !important; pointer-events: none; animation: fl-fade-out .15s ease-in forwards; }
.modal-backdrop.closing .modal { animation: fl-shrink .15s ease-in forwards; }
body.anim .settings-menu:not([hidden]), body.anim .cmd-suggest:not([hidden]) { animation: fl-spring .3s cubic-bezier(.34, 1.4, .64, 1); }
body.anim .dev-ask .dev-card { animation: fl-spring .38s cubic-bezier(.34, 1.4, .64, 1) both; }
@keyframes fl-spring { from { opacity: 0; transform: translateY(8px) scale(.92); } 60% { opacity: 1; } to { opacity: 1; transform: none; } }
@keyframes fl-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes fl-shrink { to { transform: scale(.97); } }

/* toasts slide in from the side with a little spring */
body.anim .toast { animation: toast-spring .36s cubic-bezier(.34, 1.4, .64, 1); }
body.anim .toast.out { animation: toast-out .14s ease-in forwards; }
@keyframes toast-spring { from { opacity: 0; transform: translateX(24px) scale(.96); } to { opacity: 1; transform: none; } }

/* side panels: smoother width change; drawers on phones slide in */
body.anim #workspace { transition: grid-template-columns .3s cubic-bezier(.22, 1, .36, 1); }
@keyframes drawer-l { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes drawer-r { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 760px), (max-height: 520px) and (pointer: coarse) {
  body.anim #workspace:not(.hide-left) #left-panel { animation: drawer-l .26s cubic-bezier(.22, 1, .36, 1); }
  body.anim #workspace:not(.hide-right) #right-panel { animation: drawer-r .26s cubic-bezier(.22, 1, .36, 1); }
}

/* result overlays crossfade (crossfadeCanvas in app.js) */
.canvas-xfade { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; animation: fl-fade-out .22s ease-out forwards; }

/* ======================================================================
   v1.8.2 — Run screen built from the Framelysis mark (RUN_LOGO in app.js)
   ====================================================================== */
.run-logo-wrap { position: relative; width: 104px; height: 104px; margin: 2px auto 14px; display: grid; place-items: center; }
@property --rl-a { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
.run-halo { position: absolute; inset: 5px; border-radius: 24px; padding: 2px;
  background: conic-gradient(from var(--rl-a), transparent 0 55%, color-mix(in srgb, var(--accent) 85%, #fff) 80%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
  animation: run-spin 1.1s linear infinite; opacity: .9; }
.run-logo { width: 92px; height: 92px; overflow: visible; filter: drop-shadow(0 8px 20px rgba(0, 0, 0, .35)); }
.run-logo .rl-s1 { stop-color: #1d2f55; } .run-logo .rl-s2 { stop-color: #0b1427; }
.run-logo .rl-tile { stroke: color-mix(in srgb, var(--accent) 45%, transparent); stroke-width: .8; }
.run-logo .rl-wedge { fill: color-mix(in srgb, var(--accent) 38%, transparent); }
.run-logo .rl-defl { fill: none; stroke: color-mix(in srgb, var(--accent) 70%, #fff); stroke-width: 1.3; stroke-dasharray: 2 1.7; stroke-linecap: round; }
.run-logo .rl-load path { fill: none; stroke: #b9d8ff; stroke-width: 1.15; stroke-linecap: round; stroke-linejoin: round; }
.run-logo .rl-frame { fill: none; stroke: #f2f7ff; stroke-width: 5.6; stroke-linecap: round; stroke-linejoin: round; }
.run-logo .rl-base { stroke: #f2f7ff; stroke-width: 3.2; stroke-linecap: round; }
.run-logo .rl-hatch { stroke: #f2f7ff; stroke-opacity: .7; stroke-width: 1.8; stroke-linecap: round; }
.run-logo .rl-react { fill: none; stroke: #ffd08a; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.run-logo .rl-node { fill: #fff; }
.run-logo .rl-sheen { fill: rgba(255, 255, 255, .14); }
body.light .run-logo { filter: drop-shadow(0 8px 18px rgba(30, 60, 120, .18)); }
body.light .run-logo .rl-s1 { stop-color: #ffffff; } body.light .run-logo .rl-s2 { stop-color: #e4edf9; }
body.light .run-logo .rl-tile { stroke: color-mix(in srgb, var(--accent) 30%, transparent); }
body.light .run-logo .rl-wedge { fill: color-mix(in srgb, var(--accent) 18%, transparent); }
body.light .run-logo .rl-defl { stroke: color-mix(in srgb, var(--accent) 70%, transparent); }
body.light .run-logo .rl-load path { stroke: color-mix(in srgb, var(--accent) 75%, transparent); }
body.light .run-logo .rl-frame, body.light .run-logo .rl-base { stroke: var(--accent); }
body.light .run-logo .rl-hatch { stroke: var(--accent); }
body.light .run-logo .rl-react { stroke: #c26a00; }
body.light .run-logo .rl-node { fill: var(--accent); }
body.light .run-logo .rl-sheen { fill: rgba(255, 255, 255, .7); }
/* the sequence: tile pops, frame draws, load drops, wedges grow, arms deflect, reactions answer */
.run-ov .run-logo { animation: rl-pop .42s cubic-bezier(.34, 1.56, .64, 1) both; }
.run-ov .rl-frame { stroke-dasharray: 100; stroke-dashoffset: 100; animation: rl-draw .42s .08s cubic-bezier(.65, 0, .35, 1) forwards; }
.run-ov .rl-base, .run-ov .rl-hatch { animation: rl-in .2s .04s both; }
.run-ov .rl-udl { transform-box: fill-box; transform-origin: left; animation: rl-grow .2s .42s ease-out both; }
.run-ov .rl-arr { animation: rl-drop .22s calc(.48s + var(--i) * .05s) cubic-bezier(.34, 1.56, .64, 1) both; }
.run-ov .rl-wedge { transform-box: fill-box; transform-origin: left top; animation: rl-wedge .28s .62s ease-out both; }
.run-ov .rl-defl { animation: rl-in .2s .66s both, rl-flow .6s .66s linear infinite; }
.run-ov .rl-react { animation: rl-in .18s .74s both, rl-pulse .5s .74s ease-in-out infinite alternate; }
.run-ov .rl-node { transform-box: fill-box; transform-origin: center; animation: rl-pop .3s .46s cubic-bezier(.34, 1.56, .64, 1) both; }
.run-ov .rl-sheen { animation: rl-sheen 1.1s .15s ease-in-out infinite; }
@keyframes rl-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
@keyframes rl-draw { to { stroke-dashoffset: 0; } }
@keyframes rl-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rl-grow { from { transform: scaleX(0); } to { transform: none; } }
@keyframes rl-drop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes rl-wedge { from { opacity: 0; transform: scale(.2, .2); } to { opacity: 1; transform: none; } }
@keyframes rl-flow { to { stroke-dashoffset: -7.4; } }
@keyframes rl-pulse { from { stroke-opacity: .55; } to { stroke-opacity: 1; } }
@keyframes rl-sheen { from { transform: rotate(20deg) translateX(0); } to { transform: rotate(20deg) translateX(120px); } }
@keyframes run-spin { to { --rl-a: 360deg; } }
.run-ov .run-card { animation: fl-spring .38s cubic-bezier(.34, 1.4, .64, 1); }
body.glass .run-ov { background: rgba(8, 10, 14, .28); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
body.glass.light .run-ov { background: rgba(230, 236, 245, .35); }
