:root {
  --bg: #f5f3ee; --surface: #ffffff; --surface-2: #f8f7f3;
  --ink: #1d1c1a; --ink-2: #57544e; --ink-3: #8f8b83;
  --line: #e7e3da; --line-2: #d6d1c6;
  --accent: #a8432b; --accent-ink: #ffffff; --accent-soft: #f6e8e2;
  --blue: #2c4a7a;
  --pass: #2f7d4f; --pass-soft: #e3f1e8; --warn: #a8700f; --warn-soft: #f8eed8; --fail: #b3322c; --fail-soft: #f9e2df;
  --hm-diag: #ebe8e1; --wheel-veil: rgba(255, 255, 255, .55); --pt-ring: #fff;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(30, 25, 15, .12), 0 1px 3px rgba(30, 25, 15, .08);
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121211; --surface: #1b1b19; --surface-2: #222220; --ink: #ecebe7; --ink-2: #b4b1a9; --ink-3: #7c7972;
    --line: #2b2a27; --line-2: #3a3935; --accent: #e07a5c; --accent-ink: #1a0e0a; --accent-soft: #35221d; --blue: #8fb0e6;
    --pass: #6fc08d; --pass-soft: #1d3326; --warn: #e2b04f; --warn-soft: #3a3020; --fail: #ef7d74; --fail-soft: #3d2120;
    --hm-diag: #2a2a28; --wheel-veil: rgba(27, 27, 25, .45); --pt-ring: rgba(255,255,255,.6); --shadow: 0 8px 30px rgba(0,0,0,.5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121211; --surface: #1b1b19; --surface-2: #222220; --ink: #ecebe7; --ink-2: #b4b1a9; --ink-3: #7c7972;
  --line: #2b2a27; --line-2: #3a3935; --accent: #e07a5c; --accent-ink: #1a0e0a; --accent-soft: #35221d; --blue: #8fb0e6;
  --pass: #6fc08d; --pass-soft: #1d3326; --warn: #e2b04f; --warn-soft: #3a3020; --fail: #ef7d74; --fail-soft: #3d2120;
  --hm-diag: #2a2a28; --wheel-veil: rgba(27, 27, 25, .45); --pt-ring: rgba(255,255,255,.6); --shadow: 0 8px 30px rgba(0,0,0,.5); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.pad { padding: 8px 10px; }
.mono, .n { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sans { font-family: var(--sans) !important; }
.grow { flex: 1; }
hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
kbd { font-family: var(--mono); font-size: 11px; color: var(--ink-3); margin-left: 6px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .2s ease; }
.side-off .shell { grid-template-columns: 0 minmax(0, 1fr); }
.side-off .side { visibility: hidden; padding: 0; border: 0; overflow: hidden; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 14px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { display: flex; gap: 9px; align-items: center; font-weight: 700; letter-spacing: -.01em; padding: 0 4px; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; flex: none; background: conic-gradient(from 200deg, #d32b2b, #ef8a1d, #e3d12a, #2fb34f, #1aa0c8, #2846c7, #6b2fb3, #d32b2b); }
.ds-list { display: flex; flex-direction: column; gap: 1px; }
.ds { display: flex; align-items: flex-start; gap: 8px; padding: 7px 8px 7px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.ds:hover { background: var(--surface-2); }
.ds.on { background: var(--accent-soft); font-weight: 600; }
.ds-n { flex: 1; min-width: 0; white-space: normal; overflow-wrap: anywhere; line-height: 1.32; }
.ds-c { padding-top: 2px; font-size: 11px; color: var(--ink-3); font-family: var(--mono); }
.ds-x { opacity: 0; border: 0; background: none; cursor: pointer; color: var(--ink-3); padding: 2px 4px; border-radius: 5px; font-size: 11px; }
.ds:hover .ds-x { opacity: 1; }
.ds-x:hover { color: var(--fail); background: var(--fail-soft); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.credit { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 11.5px; color: var(--ink-3); line-height: 1.35; padding-left: 4px; }
.credit a { color: var(--ink-2); text-decoration: none; }
.credit a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.credit > a { font-weight: 500; }
.empty-credit { margin: 34px 0 0 !important; font-size: 12.5px; color: var(--ink-3) !important; }
.empty-credit a { color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.empty-credit a:hover { color: var(--accent); text-decoration-color: currentColor; }
.link { background: none; border: 0; color: var(--ink-2); cursor: pointer; padding: 0; font-size: 12.5px; text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.link:hover { color: var(--ink); text-decoration-color: currentColor; }
.link.dot::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--warn); margin-left: 4px; vertical-align: 1px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-2); background: var(--surface); border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 500; font-size: 13px; white-space: nowrap; transition: .12s; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn.block { width: 100%; }
.iconbtn { display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; color: var(--ink-2); }
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 11px; font-size: 12.5px; cursor: pointer; color: var(--ink-2); border-radius: 6px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); font-weight: 500; }
.ck { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.ck input { accent-color: var(--accent); }

/* ---------- popovers ---------- */
.menu { position: relative; display: inline-flex; }
.pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 40; min-width: 220px; }
.ws-meta .pop { left: 0; right: auto; min-width: 320px; padding: 14px 16px; }
.menu-pop button, .menu-pop .ck, .menu-pop .range { display: flex; width: 100%; text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; align-items: center; justify-content: space-between; }
.menu-pop .ck { justify-content: flex-start; }
.menu-pop button:hover, .menu-pop .ck:hover { background: var(--surface-2); }
.menu-pop .range { gap: 10px; color: var(--ink-2); cursor: default; }
.menu-pop .range input { width: 110px; accent-color: var(--accent); }
.pop.settings { width: 320px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.pop.settings label, .pop.settings .alt { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-3); }
.pop.settings select, .pop.settings input { font-size: 13px; border: 1px solid var(--line-2); border-radius: 7px; padding: 6px 8px; background: var(--surface-2); color: var(--ink); width: 100%; }
.pop.settings .row2 { display: flex; gap: 12px; }
.pop.settings .row2 > label { flex: 1; }
.pop.settings .lc { display: flex; align-items: center; gap: 4px; color: var(--ink); }
.pills { display: flex; flex-wrap: wrap; gap: 4px; }
.pill { border: 1px solid var(--line-2); border-radius: 99px; padding: 3px 10px; font-size: 12px; cursor: pointer; background: var(--surface); color: var(--ink-2); }
.pill.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.setbtn { font-weight: 400; color: var(--ink-2); }
.setbtn b { color: var(--ink); font-weight: 600; }
.setbtn .caret { font-size: 10px; color: var(--ink-3); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; margin: 0; }
.kv dt { color: var(--ink-3); white-space: nowrap; }
.kv dd { margin: 0; }
.warn-box { margin-top: 12px; background: var(--warn-soft); border-radius: 8px; padding: 8px 12px; font-size: 12.5px; }
.warn-box ul { margin: 4px 0 0; padding-left: 16px; }

/* ---------- empty ---------- */
.main { min-width: 0; }
.empty { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.empty-card { max-width: 480px; text-align: center; }
.empty-strip { height: 10px; border-radius: 5px; margin: 0 auto 26px; width: 220px; background: linear-gradient(90deg, #37353d, #56343a, #673834, #b36a4d, #e8a33d, #4b7f8f, #2e5a7a, #5b5865); }
.empty h1 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 8px; }
.empty p { color: var(--ink-2); margin: 0 0 22px; }
.empty-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.dropveil { position: fixed; inset: 0; z-index: 90; background: color-mix(in srgb, var(--bg) 80%, transparent); display: grid; place-items: center; pointer-events: none; }
.dropveil div { border: 2px dashed var(--accent); color: var(--accent); border-radius: 16px; padding: 40px 60px; font-size: 18px; font-weight: 600; background: var(--surface); }

/* ---------- workspace ---------- */
.workspace { padding: 14px clamp(16px, 2.2vw, 40px) 60px; width: 100%; }
.ws-head { display: flex; gap: 10px; align-items: center; }
.ws-title { min-width: 0; flex: 1; }
.title-input { font-size: 21px; font-weight: 700; letter-spacing: -.02em; border: 1px solid transparent; background: transparent; border-radius: 7px; padding: 0 6px; margin-left: -6px; width: 100%; }
.title-input:hover { border-color: var(--line); }
.title-input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.ws-meta { display: flex; gap: 12px; align-items: center; font-size: 12.5px; color: var(--ink-3); }
.ws-actions { display: flex; gap: 6px; align-items: center; }

.tabs { display: flex; gap: 2px; margin: 12px 0 18px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 9px 14px; cursor: pointer; color: var(--ink-3); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .count { font-size: 11px; background: var(--surface-2); color: var(--ink-2); border-radius: 99px; padding: 0 6px; margin-left: 5px; }
.tabs .count.fail { background: var(--fail-soft); color: var(--fail); }

/* ---------- panels ---------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-wide { grid-template-columns: minmax(0, 1.7fr) minmax(260px, 1fr); }
.ov2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); margin-top: 16px; }
@media (max-width: 1100px) { .g2, .g-wide, .ov2 { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-width: 0; }
.panel h3 { margin: 0 0 8px; font-size: 13.5px; font-weight: 600; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; }
.empty-panel { text-align: center; padding: 40px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.empty-chart { display: grid; place-items: center; height: 300px; }
.sq { max-width: min(100%, 62vh); margin: 0 auto; }

.facts { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.facts > * { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 16px; display: flex; flex-direction: column; min-width: 150px; text-align: left; font: inherit; }
.facts span { font-size: 12px; color: var(--ink-3); }
.facts b { font-size: 19px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.facts em { font-style: normal; font-size: 12px; color: var(--ink-2); }
.facts .qc-sum { cursor: pointer; flex: 1; }
.facts .qc-sum:hover { border-color: var(--ink-3); }
.facts .qc-sum b { font-size: 15px; font-weight: 500; padding-top: 3px; }
.facts .qc-sum i { font-style: normal; font-weight: 700; }
.facts i.pass { color: var(--pass); } .facts i.warn { color: var(--warn); } .facts i.fail { color: var(--fail); }

.palette { display: flex; border-radius: 8px; overflow: hidden; height: 64px; }
.palette .sw { flex: 1 1 0; min-width: 0; cursor: pointer; transition: flex .15s; }
.palette .sw:hover { flex-grow: 2.4; }

/* ---------- tables ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.search { border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 10px; background: var(--surface); width: 240px; }
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); max-height: calc(100vh - 200px); }
.tbl-wrap.flat { max-height: none; }
table.data { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.data th { position: sticky; top: 0; background: var(--surface); z-index: 2; text-align: right; font-weight: 500; font-size: 12px; color: var(--ink-3); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
table.data th.l, table.data td.l { text-align: left; }
table.data th.sorted { color: var(--ink); }
table.data th.sorted::after { content: " ↓"; }
table.data th.sorted.asc::after { content: " ↑"; }
table.data td { padding: 6px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.n { font-size: 12.5px; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data .chipcell { width: 44px; padding-right: 0; }
.swatch { display: block; width: 36px; height: 20px; border-radius: 5px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.role { font-size: 11px; padding: 1px 7px; border-radius: 5px; background: var(--surface-2); color: var(--ink-2); }
.role.standard { color: var(--blue); }
.flag { color: var(--warn); font-size: 10px; }
.dotc { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; }
.badge.pass { background: var(--pass-soft); color: var(--pass); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.fail { background: var(--fail-soft); color: var(--fail); }

/* ---------- charts ---------- */
.chart { display: block; max-width: 100%; height: auto; font-family: var(--sans); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .grid.v { stroke-dasharray: 2 3; }
.chart .frame { stroke: var(--line-2); }
.chart .axis0 { stroke: var(--ink-3); stroke-width: 1; }
.chart .tick { font-size: 10.5px; fill: var(--ink-3); font-family: var(--mono); }
.chart .axis-title, .chart .corner { font-size: 11px; fill: var(--ink-2); }
.chart .corner { font-size: 10px; fill: var(--ink-3); font-style: italic; }
.chart .pt { stroke: var(--pt-ring); stroke-width: 1.4; cursor: pointer; }
.chart .pt.std { stroke: var(--ink); stroke-width: 2; }
.chart .pt:hover { stroke: var(--ink); stroke-width: 2.2; }
.chart .pt.fail { stroke: var(--fail); stroke-width: 2.4; }
.chart .pt.warn { stroke: var(--warn); stroke-width: 2.4; }
.chart .pt-label { font-size: 10px; fill: var(--ink-2); font-family: var(--mono); }
.chart .pt-label { paint-order: stroke; stroke: var(--surface); stroke-width: 2.6px; stroke-linejoin: round; pointer-events: none; }
.chart .pt-leader { stroke: var(--ink-3); stroke-width: .8; opacity: .85; }
.chart .wheel-veil { fill: var(--wheel-veil); }
.chart .vector { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 2; }
.chart .tol { fill: color-mix(in srgb, var(--pass) 10%, transparent); stroke: var(--pass); stroke-dasharray: 4 3; }
.chart .tolband { fill: color-mix(in srgb, var(--pass) 10%, transparent); }
.chart .std-ref { stroke: var(--ink); stroke-width: 2; }
.chart .bar { stroke: var(--ink-3); stroke-width: .6; }
.chart .hbar-bg { fill: var(--surface-2); }
.chart .hm-v { font-size: 8.5px; font-family: var(--mono); }
.chart .hover-layer line { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }

.picker-head { display: flex; gap: 12px; align-items: center; margin: 14px 0 8px; font-size: 12.5px; }
.picker { display: flex; flex-wrap: wrap; gap: 5px; max-height: 150px; overflow: auto; padding: 1px; }
.picker button { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px 2px 3px; background: var(--surface); cursor: pointer; font-size: 12px; color: var(--ink-3); }
.picker button i { width: 16px; height: 16px; border-radius: 50%; opacity: .45; }
.picker button.on { border-color: var(--line-2); color: var(--ink); background: var(--surface-2); }
.picker button.on i { opacity: 1; }

.scale { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-3); }
.scale i { width: 90px; height: 7px; border-radius: 2px; }
.scale .seg { margin-left: 8px; }

/* ---------- compare ---------- */
.qc-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 14px; }
.qc-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.qc-head .big { width: 40px; height: 40px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); cursor: pointer; flex: none; }
.qc-head h3 { margin: 0; font-size: 15px; }
.qc-body { display: grid; grid-template-columns: minmax(0, 1fr) 240px 100px; gap: 18px; align-items: start; }
.qc-body.detail { grid-template-columns: minmax(0, 1fr); }
.qc-body.detail .qc-plot { display: none; }
@media (max-width: 1200px) { .qc-body { grid-template-columns: 1fr; } .qc-plot { max-width: 300px; } }
.qc-body .tbl-wrap { border: 0; border-radius: 0; }
.qc-spec { margin-top: 14px; }
.pair { display: flex; width: 44px; height: 20px; border-radius: 5px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.pair.sm { width: 34px; height: 14px; }
.pair i { flex: 1; }
.terms { color: var(--ink-2); font-size: 12.5px; text-align: left !important; white-space: normal !important; min-width: 130px; }

table.mini { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.mini th, table.mini td { padding: 5px 6px; border-bottom: 1px solid var(--line); text-align: right; font-family: var(--mono); font-weight: 400; }
table.mini th { font-family: var(--sans); color: var(--ink-3); font-size: 11.5px; }
table.mini th:first-child, table.mini td:first-child { text-align: left; }
table.mini tr:last-child td { border-bottom: 0; }
table.mini tr.cur td { font-weight: 600; color: var(--ink); }

/* ---------- drawer ---------- */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(500px, 100vw); background: var(--surface); border-left: 1px solid var(--line); box-shadow: -10px 0 40px rgba(0,0,0,.12); z-index: 50; overflow: auto; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.drawer-in { padding: 18px 22px 40px; }
.d-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.d-head h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.d-close { border: 0; background: var(--surface-2); border-radius: 8px; width: 30px; height: 30px; cursor: pointer; font-size: 18px; color: var(--ink-2); flex: none; }
.d-swatch { height: 96px; border-radius: 10px; margin: 14px 0 12px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); display: flex; align-items: flex-end; justify-content: space-between; padding: 9px 12px; font-family: var(--mono); font-size: 12px; }
.d-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 10px; }
.d-grid div { background: var(--surface-2); border-radius: 8px; padding: 6px 9px; }
.d-grid small { display: block; font-size: 11px; color: var(--ink-3); font-style: italic; }
.d-grid b { font-family: var(--mono); font-weight: 500; font-size: 14px; }
.d-note { border-left: 3px solid var(--accent); padding: 4px 10px; color: var(--ink-2); font-size: 13px; }
.d-sec { border-top: 1px solid var(--line); padding: 10px 0; }
.d-sec summary { cursor: pointer; font-size: 13px; font-weight: 500; color: var(--ink-2); list-style: none; display: flex; justify-content: space-between; }
.d-sec summary::after { content: "+"; color: var(--ink-3); }
.d-sec[open] summary::after { content: "–"; }
.d-sec[open] summary { margin-bottom: 10px; color: var(--ink); }
.d-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.d-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ink-3); }
.d-form input:not([type=checkbox]), .d-form select, .d-form textarea { border: 1px solid var(--line-2); border-radius: 7px; padding: 6px 8px; background: var(--surface-2); font-size: 13px; color: var(--ink); }
.d-form .full { grid-column: 1 / -1; }
.d-form label.ck { flex-direction: row; }
pre.raw { font-size: 11px; background: var(--surface-2); padding: 10px; border-radius: 8px; overflow: auto; max-height: 260px; white-space: pre-wrap; word-break: break-all; margin: 0; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 9px 16px; border-radius: 10px; font-size: 13px; z-index: 99; box-shadow: var(--shadow); max-width: 80vw; }
.toast.err { background: var(--fail); color: #fff; }
.tip { position: fixed; pointer-events: none; background: var(--ink); color: var(--surface); font-size: 12px; padding: 7px 9px; border-radius: 8px; z-index: 98; font-family: var(--mono); line-height: 1.5; max-width: 300px; box-shadow: var(--shadow); }
.tip i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---------- 3D ---------- */
.v3-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.v3-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.v3-sel { border: 1px solid var(--line-2); border-radius: 8px; padding: 5px 8px; background: var(--surface); font-size: 12.5px; max-width: 240px; }
.v3-slot { position: relative; height: calc(100vh - 210px); min-height: 480px; border-radius: 8px; overflow: hidden; }
.v3-host { position: absolute; inset: 0; }
.v3-msg { display: grid; place-items: center; height: 100%; padding: 20px; text-align: center; }
.lab3d-canvas { display: block; touch-action: none; }
.lab3d-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lab3d-labels span { position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 11px; color: var(--lab3d-text, var(--ink-2)); will-change: transform; }
.lab3d-labels .ax { font-family: var(--mono); font-size: 10.5px; opacity: .8; }
.lab3d-labels .ax.strong { font-weight: 700; font-size: 13px; font-family: var(--sans); opacity: 1; }
.lab3d-labels .ax.red { color: #c8473a; font-weight: 600; font-size: 12px; opacity: 1; }
.lab3d-labels .ax.green { color: #3c9a5c; font-weight: 600; font-size: 12px; opacity: 1; }
.lab3d-labels .ax.yellow { color: #c79a12; font-weight: 600; font-size: 12px; opacity: 1; }
.lab3d-labels .ax.blue { color: #3f6fc4; font-weight: 600; font-size: 12px; opacity: 1; }
.lab3d-labels .pt { font-size: 11.5px; font-weight: 500; text-shadow: 0 0 3px var(--surface), 0 0 3px var(--surface); }
.v3-wrap:fullscreen { border-radius: 0; padding: 12px; }
.v3-wrap:fullscreen .v3-slot { height: auto; flex: 1; min-height: 0; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .workspace { padding: 12px; }
  .setbtn { display: none; }
}

/* ---------- dialogs (assets/js/dialog.js) ---------- */
.dlg { border: 0; padding: 0; background: transparent; color: var(--ink); max-width: min(440px, calc(100vw - 32px)); width: 100%; overflow: visible; }
.dlg::backdrop { background: rgba(20, 18, 14, .38); backdrop-filter: blur(2px); }
.dlg[open] { animation: dlg-in .16s ease-out; }
.dlg[open]::backdrop { animation: dlg-fade .16s ease-out; }
.dlg.closing { animation: dlg-out .14s ease-in forwards; }
.dlg.closing::backdrop { animation: dlg-fade .14s ease-in reverse forwards; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes dlg-out { to { opacity: 0; transform: translateY(4px) scale(.98); } }
@keyframes dlg-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .dlg[open], .dlg.closing, .dlg::backdrop { animation: none !important; } }
.dlg-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.dlg-main { display: flex; gap: 14px; padding: 20px 22px 16px; }
.dlg-icon { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); }
.dlg-danger .dlg-icon { background: var(--fail-soft); color: var(--fail); }
.dlg-warn .dlg-icon { background: var(--warn-soft); color: var(--warn); }
.dlg-body { min-width: 0; flex: 1; }
.dlg-body h2 { margin: 2px 0 6px; font-size: 16px; font-weight: 600; letter-spacing: -.005em; }
.dlg-body p { margin: 0 0 8px; color: var(--ink-2); font-size: 13.5px; }
.dlg-item { display: flex; gap: 10px; align-items: center; margin: 10px 0 12px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.dlg-item .strip { flex: none; width: 34px; height: 34px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink-3); }
.dlg-item b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-item small { display: block; color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-item > div { min-width: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px; background: var(--surface-2); border-top: 1px solid var(--line); }
.btn.danger { background: var(--fail); border-color: var(--fail); color: #fff; }
.btn.danger:hover { filter: brightness(1.07); }
.dlg .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- brand subtitle & top-right links ---------- */
.brand-t { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-t b { font-weight: 700; }
.brand-t small { font-size: 11px; font-weight: 400; color: var(--ink-3); letter-spacing: 0; white-space: nowrap; }
.topnav { display: flex; gap: 2px; align-items: center; }
.topnav a { color: var(--ink-2); text-decoration: none; font-size: 13px; padding: 6px 10px; border-radius: 7px; }
.topnav a:hover { color: var(--ink); background: var(--surface-2); }
.topnav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.ws-actions .topnav { margin-right: 6px; padding-right: 8px; border-right: 1px solid var(--line); }
.main { position: relative; }
.topnav.corner { position: absolute; top: 14px; right: 18px; z-index: 5; }
.main:has(#ws:not([hidden])) .topnav.corner { display: none; }

.file-ill { font-size: 12px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; line-height: 1.45; }
.file-ill b { color: var(--ink); }
.file-ill .ok { color: var(--pass); font-weight: 700; }
.file-ill .link { font-size: 12px; color: var(--accent); margin-left: 2px; }
.ill-flag { font-style: normal; color: var(--warn); font-size: 9px; margin-left: 3px; vertical-align: 2px; }
