:root {
  --bg: #f3f5f6;
  --surface: #ffffff;
  --surface-2: #eef1f3;
  --surface-3: #e4e9ec;
  --border: #dbe1e5;
  --text: #121a1f;
  --muted: #5d6a72;
  --accent: #0d9488;
  --accent-ink: #ffffff;
  --accent-soft: #d5f5ef;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --fail: #b91c1c;
  --fail-soft: #fee2e2;
  --code-bg: #f7f9fa;
  --log-bg: #0f1719;
  --log-fg: #d7e3e6;
  --wave-hi: #0d9488;
  --wave-bus: #2563eb;
  --wave-x: #dc2626;
  --grid: #e8edef;
  --user-bubble: #e6f6f3;
  --panel-h: 290px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1316;
    --surface: #131b1f;
    --surface-2: #19242a;
    --surface-3: #223037;
    --border: #253239;
    --text: #e2e9ec;
    --muted: #8d9ea6;
    --accent: #2dd4bf;
    --accent-ink: #042f2e;
    --accent-soft: #113a35;
    --ok: #4ade80;
    --ok-soft: #12301f;
    --warn: #fbbf24;
    --warn-soft: #3a2c0c;
    --fail: #f87171;
    --fail-soft: #3b1515;
    --code-bg: #0f1619;
    --log-bg: #0a0f11;
    --wave-hi: #2dd4bf;
    --wave-bus: #60a5fa;
    --wave-x: #f87171;
    --grid: #1c282d;
    --user-bubble: #16312d;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); overflow: hidden;
  font: 13px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, select, textarea, input { font: inherit; color: inherit; }
code, pre { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }

/* ---------- header */
.top {
  height: 48px; display: flex; align-items: center; gap: 16px; padding: 0 14px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 190px; }
.logo { width: 24px; height: 24px; }
.logo rect { fill: var(--accent); }
.logo g { stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
.name { font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.sub { color: var(--muted); font-weight: 500; }
.actions { flex: 1; display: flex; gap: 8px; }
.run {
  display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 6px; padding: 6px 14px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer;
}
.run svg { width: 12px; height: 12px; fill: currentColor; }
.run:disabled { opacity: .6; cursor: progress; }
.status { display: flex; gap: 6px; }
.pill { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.on { background: var(--ok-soft); color: var(--ok); }
.pill.off { background: var(--warn-soft); color: var(--warn); }

/* ---------- grid */
.ide {
  height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: var(--left-w, 220px) minmax(0, 1fr) var(--right-w, 400px);
  grid-template-rows: minmax(0, 1fr) var(--panel-h);
}
.explorer { grid-column: 1; grid-row: 1 / 3; border-right: 1px solid var(--border); background: var(--surface); position: relative; min-width: 0; }
.explorer-scroll { height: 100%; overflow: auto; display: flex; flex-direction: column; }
.editor-area { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.panel { grid-column: 2; grid-row: 2; border-top: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; position: relative; }
.chat { grid-column: 3; grid-row: 1 / 3; border-left: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; }

@media (max-width: 1100px) {
}
@media (max-width: 860px) {
  body { overflow: auto; }
  .ide { display: flex; flex-direction: column; height: auto; }
  .explorer, .chat { border: 0; border-bottom: 1px solid var(--border); }
  .explorer { max-height: 220px; }
  .editor-area { height: 60vh; }
  .panel { height: 380px; }
  .chat { height: 80vh; }
  .brand { min-width: 0; }
  .status .pill:last-child { display: none; }
  .resizer, .vresizer { display: none; }
}

/* ---------- section heads / icons */
.sec-head {
  display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 6px 12px;
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.icons { display: flex; gap: 2px; }
.icon { border: 0; background: transparent; width: 24px; height: 24px; border-radius: 5px; cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.icon:hover { background: var(--surface-2); color: var(--text); }
.icon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- explorer */
.files, .templates { list-style: none; margin: 0 0 8px; padding: 0 6px; }
.files li, .templates li {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 5px; cursor: pointer; white-space: nowrap;
}
.files li:hover, .templates li:hover { background: var(--surface-2); }
.files li.active { background: var(--accent-soft); }
.files .fi { width: 16px; font: 600 9px "JetBrains Mono", monospace; color: var(--accent); }
.files .fn { flex: 1; overflow: hidden; text-overflow: ellipsis; font-family: "JetBrains Mono", monospace; font-size: 12.5px; }
.files .tag { font-size: 9.5px; font-weight: 600; padding: 0 5px; border-radius: 3px; background: var(--surface-3); color: var(--muted); }
.files .tag.top { background: var(--accent-soft); color: var(--accent); }
.files .dot-err { width: 7px; height: 7px; border-radius: 50%; background: var(--fail); }
.files .dot-warn { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.files .x { visibility: hidden; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0 2px; }
.files li:hover .x { visibility: visible; }
.templates li { color: var(--muted); }
.templates li b { color: var(--text); font-weight: 500; }
.explorer-foot { margin-top: auto; padding: 10px 12px; font-size: 11.5px; }

/* ---------- editor */
.editor-bar, .review-bar {
  height: 34px; display: flex; align-items: center; gap: 8px; padding: 0 12px;
  border-bottom: 1px solid var(--border); background: var(--surface-2); flex: none;
}
.fname { font-family: "JetBrains Mono", monospace; font-size: 12.5px; }
.badges .tag { font-size: 10px; padding: 1px 6px; border-radius: 3px; background: var(--surface-3); color: var(--muted); margin-left: 4px; }
.review-bar { background: var(--accent-soft); }
.rv-title { font-weight: 600; }
.rv-file { font-family: "JetBrains Mono", monospace; font-size: 12px; }
.editor { flex: 1; min-height: 0; position: relative; }
.loading { padding: 20px; color: var(--muted); }

button.ghost {
  border: 1px solid var(--border); background: var(--surface); border-radius: 5px; padding: 3px 10px; cursor: pointer; font-size: 12px;
}
button.ghost:hover { border-color: var(--accent); }
button.ghost.danger:hover { border-color: var(--fail); color: var(--fail); }
button.primary { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 6px; font-weight: 600; cursor: pointer; }
button.primary.sm { padding: 4px 12px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- panel */
.resizer { position: absolute; top: -3px; left: 0; right: 0; height: 6px; cursor: row-resize; z-index: 5; }
.panel-head { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); padding: 0 8px; flex: none; overflow-x: auto; }
.ptabs { display: flex; }
.ptab {
  border: 0; background: transparent; padding: 8px 10px; cursor: pointer; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.ptab.active { color: var(--text); border-bottom-color: var(--accent); }
.count { font-size: 10.5px; background: var(--surface-3); border-radius: 999px; padding: 0 6px; margin-left: 2px; }
.count.err { background: var(--fail-soft); color: var(--fail); }
.runline { margin-left: auto; display: flex; gap: 10px; align-items: center; font-size: 12px; white-space: nowrap; }
.chk { display: inline-flex; align-items: center; gap: 5px; }
.pbody { flex: 1; min-height: 0; overflow: auto; padding: 10px 12px; }
.empty { color: var(--muted); padding: 18px 4px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.zoom { display: flex; gap: 4px; }

.problems .pr {
  display: grid; grid-template-columns: 16px minmax(120px, 200px) 1fr auto; gap: 8px; align-items: baseline;
  padding: 3px 6px; border-radius: 4px; cursor: pointer; font-size: 12.5px;
}
.problems .pr:hover { background: var(--surface-2); }
.problems .loc { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--muted); }
.problems .code { font-size: 11px; color: var(--muted); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-weight: 600; font-size: 12px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.fail { background: var(--fail-soft); color: var(--fail); }
.wave { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.wave svg { display: block; }
.wave text { font: 11px "JetBrains Mono", ui-monospace, monospace; fill: var(--text); }
.wave .lab { fill: var(--muted); }
.logbox { margin-top: 8px; }
.logbox summary { cursor: pointer; color: var(--muted); }
.log {
  background: var(--log-bg); color: var(--log-fg); padding: 10px; border-radius: 6px; overflow: auto;
  max-height: 260px; font-size: 12px; line-height: 1.5; white-space: pre-wrap; margin: 6px 0 0;
}
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.metric { background: var(--surface-2); border-radius: 6px; padding: 10px 12px; }
.metric .v { font-size: 20px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.metric .k { color: var(--muted); font-size: 11.5px; }
.cells { columns: 2 220px; column-gap: 24px; margin: 6px 0 12px; }
.bar { display: grid; grid-template-columns: 88px 1fr 30px; gap: 8px; align-items: center; font-size: 11.5px; margin: 2px 0; break-inside: avoid; }
.bar .n { font-family: "JetBrains Mono", monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .track { background: var(--surface-2); border-radius: 3px; height: 7px; }
.bar .fill { background: var(--accent); height: 7px; border-radius: 3px; }
.bar .c { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- status dots */
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; border: 1.5px solid var(--border); display: inline-block; }
.dot.running { border-color: var(--accent); border-top-color: transparent; animation: spin .8s linear infinite; }
.dot.ok { background: var(--ok); border-color: var(--ok); }
.dot.warn { background: var(--warn); border-color: var(--warn); }
.dot.fail { background: var(--fail); border-color: var(--fail); }
.dot.info { background: var(--muted); border-color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .dot.running { animation: none; } }

/* ---------- chat */
.chat-head { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 100%; }
.msg.user { align-self: flex-end; background: var(--user-bubble); padding: 8px 11px; border-radius: 10px 10px 2px 10px; white-space: pre-wrap; max-width: 90%; }
.msg.assistant { line-height: 1.55; }
.msg.assistant p { margin: 0 0 8px; }
.msg.assistant pre { background: var(--code-bg); border: 1px solid var(--border); padding: 8px; border-radius: 6px; overflow-x: auto; font-size: 12px; }
.msg.assistant code { background: var(--surface-2); padding: 0 4px; border-radius: 3px; font-size: 12px; }
.msg.assistant pre code { background: transparent; padding: 0; }
.msg.assistant ul { margin: 0 0 8px; padding-left: 18px; }
.msg .err { color: var(--fail); }
.welcome { color: var(--muted); }
.welcome b { color: var(--text); }
.steps { list-style: none; padding: 0; margin: 4px 0 8px; font-size: 12px; color: var(--muted); }
.steps li { display: flex; align-items: center; gap: 7px; padding: 1px 0; }
.steps .sd { margin-left: auto; font-size: 11.5px; }

.proposal { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-top: 6px; }
.proposal .ph { padding: 8px 10px; background: var(--surface-2); font-weight: 600; display: flex; justify-content: space-between; }
.proposal .pf { padding: 6px 10px 0; font-family: "JetBrains Mono", monospace; font-size: 12px; }
.proposal .pf div { display: flex; gap: 8px; }
.proposal .add { color: var(--ok); }
.proposal .del { color: var(--fail); }
.proposal .checks { padding: 8px 10px; display: grid; gap: 3px; font-size: 12px; }
.proposal .checks div { display: flex; align-items: center; gap: 7px; }
.proposal .cmp { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0 10px 8px; }
.proposal .cmp div { background: var(--surface-2); border-radius: 5px; padding: 5px 7px; font-size: 11.5px; }
.proposal .cmp b { display: block; font-size: 13px; font-variant-numeric: tabular-nums; }
.good { color: var(--ok); }
.bad { color: var(--fail); }
.proposal .pa { display: flex; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.proposal .state { padding: 8px 10px; border-top: 1px solid var(--border); font-weight: 500; }
.proposal .state.accepted { color: var(--ok); }
.proposal .state.rejected { color: var(--muted); }

.composer { border-top: 1px solid var(--border); padding: 8px 10px 10px; flex: none; }
.quick { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; }
.qa { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 2px 9px; font-size: 11.5px; cursor: pointer; color: var(--muted); }
.qa:hover { color: var(--text); border-color: var(--accent); }
.sel-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; background: var(--accent-soft); color: var(--accent); border-radius: 4px; padding: 1px 4px 1px 8px; margin-bottom: 6px; }
.sel-chip button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 14px; line-height: 1; }
.input-row { display: flex; gap: 6px; align-items: flex-end; }
.input-row textarea {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--surface); outline: none; min-height: 60px;
}
.input-row textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.send { width: 38px; height: 38px; display: grid; place-items: center; }
.send svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- resizable layout */
.vresizer { position: absolute; top: 0; bottom: 0; width: 7px; cursor: col-resize; z-index: 6; touch-action: none; }
.vresizer.right { right: -4px; }
.vresizer.left { left: -4px; }
.vresizer::after, .resizer::after { content: ""; position: absolute; background: var(--accent); opacity: 0; transition: opacity .15s; }
.vresizer::after { top: 0; bottom: 0; left: 3px; width: 2px; }
.resizer::after { left: 0; right: 0; top: 2px; height: 2px; }
.vresizer:hover::after, .vresizer.active::after, .resizer:hover::after, .resizer.active::after { opacity: 1; }
.resizer { touch-action: none; }
body.resizing { user-select: none; cursor: col-resize; }
body.resizing iframe, body.resizing .editor { pointer-events: none; }
.panel-head .icons { margin-left: 4px; }
.panel[data-mode="min"] .pbody { display: none; }
.panel[data-mode="min"] .ptab.active { border-bottom-color: transparent; }

/* ---------- schematic viewer */
.sch-body { height: 100%; }
.pp[data-pp="schematic"]:not(.hidden) { height: 100%; }
.pbody:has(.pp[data-pp="schematic"]:not(.hidden)) { padding: 0; }
.viewer {
  position: relative; width: 100%; height: 100%; min-height: 180px; overflow: hidden; cursor: grab; touch-action: none;
  background-color: #fbfcfc;
  background-image: radial-gradient(circle, #d6dde0 1px, transparent 1.2px); background-size: 18px 18px;
}
.viewer.dragging { cursor: grabbing; }
.viewer .stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.viewer .stage svg { display: block; }
.viewer-tools {
  position: absolute; right: 10px; top: 10px; display: flex; align-items: center; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); cursor: default;
}
.vt { border: 0; background: transparent; height: 26px; min-width: 26px; border-radius: 5px; display: grid; place-items: center; cursor: pointer; color: var(--text); padding: 0 4px; }
.vt:hover { background: var(--surface-2); }
.vt svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.vt.txt { font-size: 11.5px; font-weight: 600; }
.vt-sep { width: 1px; height: 16px; background: var(--border); margin: 0 3px; }
.zoom-label { min-width: 42px; text-align: center; font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--muted); }
.viewer-hint { position: absolute; left: 10px; bottom: 8px; font-size: 11px; color: #7b878d; pointer-events: none; }
.sch-body.fullscreen { position: fixed; inset: 0; z-index: 50; background: var(--surface); }
.sch-body.fullscreen .viewer { height: 100vh; }

/* ---------- dialog */
.modal-back {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: rgba(8, 14, 17, .45); opacity: 0; transition: opacity .15s;
}
.modal-back.in { opacity: 1; }
.modal {
  width: min(420px, 100%); background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 18px 14px; box-shadow: 0 18px 50px rgba(0, 0, 0, .3);
  transform: translateY(6px) scale(.98); transition: transform .15s;
}
.modal-back.in .modal { transform: none; }
.modal h3 { margin: 0 0 6px; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.modal p { margin: 0 0 12px; color: var(--muted); }
.modal input {
  width: 100%; border: 1px solid var(--border); border-radius: 7px; padding: 8px 10px; background: var(--surface);
  font-family: "JetBrains Mono", monospace; font-size: 13px; outline: none; margin-top: 4px;
}
.modal input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-err { min-height: 18px; color: var(--fail); font-size: 12px; margin-top: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.modal-actions button { padding: 6px 14px; font-size: 13px; }
button.primary.danger { background: var(--fail); color: #fff; }
@media (prefers-reduced-motion: reduce) { .modal-back, .modal, .toast { transition: none !important; } }

/* ---------- toasts */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 8px; max-width: min(520px, calc(100vw - 32px));
  background: var(--text); color: var(--surface); font-size: 12.5px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s;
}
.toast.in { opacity: 1; transform: none; }

/* ---------- interact */
.ia-wrap { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 16px; }
@media (max-width: 860px) { .ia-wrap { grid-template-columns: 1fr; } }
.ia-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.ia-head .section-title { margin: 0; }
.ia-ports { display: grid; gap: 6px; }
.ia-port { display: grid; grid-template-columns: minmax(70px, 120px) 1fr; align-items: center; gap: 8px; }
.ia-port .pn { font-family: "JetBrains Mono", monospace; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ia-port .pn small { color: var(--muted); }
.ia-port input[type=text] {
  width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; background: var(--surface);
  font: 12.5px "JetBrains Mono", monospace; outline: none;
}
.ia-port input[type=text]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ia-port input.bad { border-color: var(--fail); }
.switch { position: relative; width: 38px; height: 20px; border-radius: 999px; border: 0; background: var(--surface-3); cursor: pointer; padding: 0; }
.switch::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: left .12s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { left: 20px; }
.switch-row { display: flex; align-items: center; gap: 8px; font: 12px "JetBrains Mono", monospace; color: var(--muted); }
.ia-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0 6px; }
.ia-run { display: inline-flex; align-items: center; gap: 4px; }
.ia-run input { width: 58px; border: 1px solid var(--border); border-radius: 5px; padding: 3px 6px; background: var(--surface); font-size: 12px; }
.ia-out-val { display: flex; align-items: center; gap: 8px; }
.ia-out-val .val { font: 600 15px "JetBrains Mono", monospace; letter-spacing: .02em; }
.ia-out-val .val.changed { color: var(--accent); }
.led { width: 14px; height: 14px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--border); flex: none; }
.led.on { background: var(--ok); border-color: var(--ok); box-shadow: 0 0 8px var(--ok); }
.led.x { background: var(--fail); border-color: var(--fail); }
.radix { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.radix button { border: 0; background: transparent; padding: 2px 8px; font-size: 11.5px; cursor: pointer; color: var(--muted); }
.radix button.active { background: var(--accent); color: var(--accent-ink); }
.ia-hist { max-height: 200px; overflow: auto; font: 11.5px "JetBrains Mono", monospace; }
.ia-hist table { border-collapse: collapse; width: 100%; }
.ia-hist th, .ia-hist td { text-align: left; padding: 2px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.ia-hist th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--surface); }
#ia-wave { margin-bottom: 6px; }

/* ---------- viewer additions */
.viewer .stage.svgmode { inset: 0; width: 100%; height: 100%; transform: none !important; }
.viewer .stage.svgmode svg { width: 100%; height: 100%; display: block; }
.viewer .stage img { pointer-events: none; user-select: none; -webkit-user-drag: none; }
.viewer .hires { position: absolute; pointer-events: none; user-select: none; opacity: 0; transition: opacity .15s; }
.viewer .hires.show { opacity: 1; }
.viewer-busy { position: absolute; left: 10px; top: 10px; font-size: 11px; color: #9fb0b8; background: rgba(0,0,0,.45); padding: 2px 8px; border-radius: 4px; pointer-events: none; }
.legend { margin-top: 8px; }
.legend summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.legend ul { margin: 6px 0 0; padding-left: 16px; font-size: 12px; color: var(--muted); }
.legend li { margin: 3px 0; }
.legend b { color: var(--text); font-weight: 500; }

/* ---------- constraints */
.cons-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 6px; padding: 5px 10px; cursor: pointer; font-size: 12px; color: var(--muted);
}
.cons-btn:hover { border-color: var(--accent); color: var(--text); }
.cons-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.modal.wide { width: min(560px, 100%); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 12.5px; }
.form-grid small { color: var(--muted); font-weight: 400; font-size: 11.5px; }
.form-grid input { margin: 0; }
.unit { display: flex; align-items: center; gap: 6px; }
.unit input { flex: 1; }
.unit span { color: var(--muted); font-size: 12px; min-width: 28px; }

.cons-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.cchip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; background: var(--surface-2); }
.cchip.ok { background: var(--ok-soft); color: var(--ok); }
.cchip.fail { background: var(--fail-soft); color: var(--fail); }
.section-title { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
.critpath summary { cursor: pointer; color: var(--muted); margin-top: 8px; }

/* ---------- layout tab */
.pbody:has(.pp[data-pp="layout"]:not(.hidden)) { padding: 0; }
.pp[data-pp="layout"]:not(.hidden) { height: 100%; }
.layout-wrap { display: grid; grid-template-columns: minmax(240px, 300px) 1fr; height: 100%; }
.layout-side { padding: 10px 12px; overflow: auto; border-right: 1px solid var(--border); }
.layout-side p { margin: 0 0 10px; }
.lay-btn { width: 100%; padding: 8px 12px; margin-bottom: 8px; }
.lay-view { position: relative; min-height: 0; }
.lay-view.fullscreen { position: fixed; inset: 0; z-index: 50; }
.lay-view.fullscreen .viewer { height: 100vh; }
.viewer.dark { background-color: #0b0f12; background-image: radial-gradient(circle, #1d2930 1px, transparent 1.2px); }
.viewer.dark .viewer-hint { color: #6f8089; }
.viewer .stage img { display: block; image-rendering: auto; }
.small-metrics { grid-template-columns: 1fr 1fr; gap: 6px; margin: 8px 0; }
.small-metrics .metric { padding: 7px 9px; }
.small-metrics .metric .v { font-size: 15px; }
.lay-dl { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.ghost-a { border: 1px solid var(--border); border-radius: 5px; padding: 3px 10px; font-size: 12px; color: var(--text); text-decoration: none; }
.ghost-a:hover { border-color: var(--accent); }
@media (max-width: 860px) { .layout-wrap { grid-template-columns: 1fr; } .lay-view { height: 320px; } }

.busy-card { border: 1px solid var(--warn); background: var(--warn-soft); border-radius: 8px; padding: 10px 12px; display: grid; gap: 6px; }
.busy-card b { color: var(--warn); }
.busy-card span { color: var(--text); font-size: 12.5px; }
.busy-card details summary { cursor: pointer; color: var(--muted); font-size: 11.5px; }
.busy-card code { display: block; white-space: pre-wrap; font-size: 11px; color: var(--muted); margin-top: 4px; }
.busy-card button { justify-self: start; }
