/* Hector Studio — Authentic VS Code Object-Centric Workbench
   Dark (default on desktop) & Light (default on web daylight), zero external dependencies. */
:root {
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --font-ui: "DM Sans", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-code: "JetBrains Mono", "Cascadia Mono", "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
  --t1: 11px;
  --t2: 12px;
  --t3: 13px;
  --t4: 16px;
  --radius: 4px;
  --line: 1px;
  --row: 24px;
  --code-line: 20px;
}

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1e1e1e;
  --surface: #252526;
  --surface-2: #2d2d30;
  --hover: #2a2d2e;
  --selected: #04395e;
  --selected-text: #ffffff;
  --border: #3c3c3c;
  --text: #d4d4d4;
  --text-2: #9d9d9d;
  --text-3: #6f6f6f;
  --accent: #3794ff;
  --accent-bg: #0e639c;
  --accent-text: #ffffff;
  --error: #f14c4c;
  --warning: #cca700;
  --success: #73c991;
  --info: #3794ff;
  --activity: #333333;
  --title: #323233;
  --statusbar: #252526;
  --current-line: #282828;
  --gutter: #858585;
  --gutter-active: #c6c6c6;
  --k: #569cd6;
  --ty: #4ec9b0;
  --st: #ce9178;
  --nu: #b5cea8;
  --co: #6a9955;
  --ev: #dcdcaa;
  --df: #9cdcfe;
  --op: #d4d4d4;
  --shadow: 0 6px 22px rgba(0, 0, 0, .48);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f4f5f7;
  --surface-2: #e9ecf1;
  --hover: #eaecef;
  --selected: #cce4f7;
  --selected-text: #0f172a;
  --border: #d8dee6;
  --text: #1f2328;
  --text-2: #57606a;
  --text-3: #8c959f;
  --accent: #005fb8;
  --accent-bg: #005fb8;
  --accent-text: #ffffff;
  --error: #c72e2e;
  --warning: #8f6a00;
  --success: #1f7a3f;
  --info: #005fb8;
  --activity: #eceff4;
  --title: #e6e9ef;
  --statusbar: #f4f5f7;
  --current-line: #f5f7fa;
  --gutter: #8a949e;
  --gutter-active: #1f2328;
  --k: #0000d6;
  --ty: #1f7a8c;
  --st: #a31515;
  --nu: #098658;
  --co: #53803f;
  --ev: #795e26;
  --df: #0b5394;
  --op: #1f2328;
  --shadow: 0 8px 24px rgba(15, 23, 42, .14);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: grid;
  grid-template-rows: 36px minmax(0, 1fr) 24px;
  background: var(--bg);
  color: var(--text);
  font: var(--t3)/1.4 var(--font-ui);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: var(--line) solid var(--accent);
  outline-offset: -1px;
}
svg.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mono { font-family: var(--font-code); }
.muted { color: var(--text-2); }
.grow { flex: 1 1 auto; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-3) 45%, transparent);
  border: 2px solid transparent;
  background-clip: content-box;
  border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--text-3) 80%, transparent);
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-corner { background: transparent; }

/* ---------- Titlebar ---------- */
#titlebar {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(200px, 480px) minmax(160px, 1fr);
  align-items: center;
  gap: var(--s3);
  padding: 0 var(--s3);
  background: var(--title);
  border-bottom: var(--line) solid var(--border);
  min-width: 0;
}
.title-left, .title-right {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
}
.title-right { justify-content: flex-end; }
.title-center { display: flex; justify-content: center; min-width: 0; }
.product-mark {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius);
  background: var(--accent-bg);
  color: var(--accent-text);
  font: 700 12px var(--font-code);
  flex: none;
}
#titlebar .product { font-weight: 600; white-space: nowrap; font-size: var(--t3); }
#titlebar .project { color: var(--text-2); font-size: var(--t2); min-width: 0; }
.command-box {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: min(460px, 100%);
  height: 24px;
  padding: 0 var(--s2);
  background: var(--bg);
  border: var(--line) solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: var(--t2);
}
.command-box:hover { border-color: var(--accent); color: var(--text); }
.command-box kbd { margin-left: auto; }
kbd {
  font: var(--t1) var(--font-ui);
  color: var(--text-2);
  border: var(--line) solid var(--border);
  border-radius: var(--radius);
  padding: 0 var(--s1);
  background: var(--surface);
}
.tool {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  height: 24px;
  padding: 0 var(--s2);
  border-radius: var(--radius);
  color: var(--text);
  font-size: var(--t2);
  white-space: nowrap;
  text-decoration: none;
  border: var(--line) solid transparent;
}
.tool:hover:not(:disabled) { background: var(--hover); border-color: var(--border); }
.tool:disabled { color: var(--text-3); cursor: not-allowed; opacity: .55; }
.tool.primary { background: var(--accent-bg); color: var(--accent-text); border-color: var(--accent-bg); }
.tool.primary:hover:not(:disabled) { background: var(--accent); color: var(--accent-text); border-color: var(--accent); filter: brightness(1.06); }
.tool.secondary { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.tool.secondary:hover:not(:disabled) { background: var(--hover); border-color: var(--accent); }
.tool.danger { background: color-mix(in srgb, var(--error) 16%, transparent); border-color: var(--error); color: var(--error); }
.tool.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--error) 24%, transparent); border-color: var(--error); }
.tool.icon-only { width: 26px; padding: 0; justify-content: center; }

/* ---------- Workbench Frame ---------- */
#workbench {
  display: grid;
  grid-template-columns: 48px var(--side, 276px) 4px minmax(0, 1fr);
  min-height: 0;
}
#workbench.no-side { grid-template-columns: 48px minmax(0, 1fr); }
#workbench.no-side #sidebar, #workbench.no-side #sash-side { display: none; }

#activity {
  display: flex;
  flex-direction: column;
  background: var(--activity);
  border-right: var(--line) solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
#activity::-webkit-scrollbar { display: none; }
#activity button {
  position: relative;
  width: 48px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  color: var(--text-2);
}
#activity button svg.icon { width: 20px; height: 20px; }
#activity button:hover { color: var(--text); }
#activity button.on { color: var(--text); background: color-mix(in srgb, var(--bg) 25%, transparent); }
#activity button.on::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--accent);
}
#activity .badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 8px;
  background: var(--accent-bg);
  color: var(--accent-text);
  font-size: 9px;
  font-weight: 600;
  line-height: 15px;
  text-align: center;
}
#activity .badge.bad { background: var(--error); color: #fff; }
#activity .spacer { flex: 1; }

#sidebar {
  background: var(--surface);
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sash { background: transparent; z-index: 2; }
.sash-v { cursor: col-resize; border-left: var(--line) solid var(--border); }
.sash-h { cursor: row-resize; height: 4px; border-top: var(--line) solid var(--border); }
.sash:hover, .sash.drag { background: var(--accent); border-color: var(--accent); }

#center {
  display: grid;
  grid-template-rows: 35px minmax(0, 1fr) 4px var(--panel, 240px);
  min-width: 0;
  min-height: 0;
}
#center.no-panel { grid-template-rows: 35px minmax(0, 1fr) 0 0; }
#center.no-panel #panel, #center.no-panel #sash-panel { display: none; }
#center.max-panel { grid-template-rows: 35px 0 0 minmax(0, 1fr); }
#center.max-panel #stage, #center.max-panel #sash-panel { visibility: hidden; }

/* ---------- Sidebar Model Explorer ---------- */
.side-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
  height: 35px;
  padding: 0 var(--s2) 0 var(--s3);
  font-size: var(--t1);
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-2);
  flex: none;
}
.side-filter {
  padding: 0 var(--s2) var(--s2);
  flex: none;
}
.field {
  height: 26px;
  padding: 0 var(--s2);
  background: var(--bg);
  border: var(--line) solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
  font-size: var(--t2);
}
.side-filter .field { width: 100%; height: 24px; }
textarea.field { height: auto; min-height: 80px; padding: var(--s2); font-family: var(--font-code); resize: vertical; }
select.field { padding-right: var(--s3); }

.section { display: flex; flex-direction: column; min-height: 0; border-top: var(--line) solid var(--border); }
.section[data-section="model"] { flex: 1 1 auto; }
.section[data-section="files"] { flex: 0 1 200px; }
.section.closed { flex: none; }
.section.closed .section-body { display: none; }
.section-head {
  display: flex;
  align-items: center;
  gap: var(--s1);
  width: 100%;
  height: 24px;
  padding: 0 var(--s2) 0 var(--s1);
  font-size: var(--t1);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  text-align: left;
  cursor: pointer;
  user-select: none;
  flex: none;
}
.section-head .count { font-weight: 400; color: var(--text-2); text-transform: none; letter-spacing: 0; }
.section-body { overflow: auto; min-height: 0; flex: 1 1 auto; padding-bottom: var(--s2); }

.tree-row {
  display: flex;
  align-items: center;
  gap: var(--s1);
  height: var(--row);
  padding-right: var(--s2);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  width: 100%;
  text-align: left;
}
.tree-row:hover { background: var(--hover); }
.tree-row.on { background: var(--selected); color: var(--selected-text); }
.tree-toggle { width: 16px; height: 20px; display: grid; place-items: center; flex: none; }
.tree-row > button.label, .tree-row > span.label {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}
.tree-row .tail { margin-left: auto; padding-left: var(--s2); font-size: var(--t1); color: var(--text-2); flex: none; }
.tree-row.on .tail { color: inherit; opacity: .85; }
.tree-row .tail.err { color: var(--error); }
.tree-row .tail.warn { color: var(--warning); }
.tree-row.has-err .label { color: var(--error); }
.chev { width: 14px; height: 14px; flex: none; color: var(--text-2); transition: transform .08s; }
.chev.open { transform: rotate(90deg); }
.chev.none { visibility: hidden; }
.ok { color: var(--success); }
.bad { color: var(--error); }
.warn { color: var(--warning); }
.info { color: var(--info); }
.empty { padding: var(--s3) var(--s4); color: var(--text-2); font-size: var(--t2); line-height: 1.5; }
.empty b { color: var(--text); font-weight: 600; }

/* ---------- Tabs & Stage ---------- */
#tabs {
  display: flex;
  background: var(--surface);
  border-bottom: var(--line) solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
#tabs::-webkit-scrollbar { display: none; }
.tab {
  display: flex;
  align-items: center;
  gap: var(--s2);
  height: 34px;
  padding: 0 var(--s2) 0 var(--s3);
  border-right: var(--line) solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  flex: none;
  position: relative;
  user-select: none;
  font-size: var(--t2);
}
.tab:hover { color: var(--text); }
.tab.on { background: var(--bg); color: var(--text); }
.tab.on::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--accent); }
.tab .name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.tab .dirty { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: none; }
.tab.is-dirty .dirty { display: block; }
.tab.is-dirty .close { display: none; }
.tab.is-dirty:hover .dirty { display: none; }
.tab.is-dirty:hover .close { display: grid; }
.tab .close { width: 16px; height: 16px; display: grid; place-items: center; border-radius: var(--radius); visibility: hidden; }
.tab:hover .close, .tab.on .close { visibility: visible; }
.tab .close:hover { background: var(--hover); }

#stage { position: relative; min-height: 0; min-width: 0; background: var(--bg); overflow: hidden; }
.view { position: absolute; inset: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); }
.view-bar {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 36px;
  padding: var(--s1) var(--s4);
  border-bottom: var(--line) solid var(--border);
  background: var(--surface);
  font-size: var(--t2);
  flex-wrap: wrap;
}
.view-bar h2 { font-size: var(--t3); font-weight: 600; margin: 0 var(--s2) 0 0; white-space: nowrap; }
.view-body { overflow: auto; min-height: 0; padding: var(--s4); position: relative; }
.view-body.flush { padding: 0; display: flex; flex-direction: column; }

/* ---------- Welcome / Home ---------- */
.home { height: 100%; overflow: auto; padding: 28px 36px; max-width: 1120px; }
.home h1 { margin: 0 0 var(--s2); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.home h2 { font-size: 13px; margin: 22px 0 8px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.home-verdict { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin: 0 0 var(--s3); font-size: var(--t3); }
.home-counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--s3);
  border-block: var(--line) solid var(--border);
  padding: var(--s4) 0;
  margin: var(--s3) 0;
}
.home-counts button {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  border: var(--line) solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-2);
  text-align: left;
}
.home-counts button:hover { border-color: var(--accent); color: var(--text); }
.home-counts strong { color: var(--text); font-size: 20px; font-weight: 600; font-family: var(--font-code); }
.home-actions { display: flex; gap: var(--s2); flex-wrap: wrap; margin: var(--s3) 0; }

/* ---------- Object Pages ---------- */
.obj { position: absolute; inset: 0; overflow: auto; padding-bottom: var(--s5); }
.obj-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-bottom: var(--line) solid var(--border);
  background: var(--surface);
  font-size: var(--t2);
}
.obj-head h1 { font: 600 var(--t4) var(--font-code); margin: 0 var(--s2) 0 0; }
.obj-sec { border-bottom: var(--line) solid var(--border); }
.obj-sec > summary.section-head { height: 30px; padding: 0 var(--s4); }
.obj-body { padding: var(--s2) var(--s4) var(--s3) var(--s5); }
.obj-note { color: var(--text-2); font-size: var(--t2); line-height: 1.5; padding: var(--s1) 0; }
.obj-row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  min-height: 26px;
  padding: 2px var(--s2);
  margin: 0 calc(-1 * var(--s2));
  text-align: left;
  font-size: var(--t2);
  border-radius: var(--radius);
}
.obj-row:hover { background: var(--hover); }
.obj-row .mono { min-width: 120px; }
.obj-code {
  margin: var(--s1) 0;
  padding: var(--s2);
  background: var(--surface);
  border: var(--line) solid var(--border);
  border-radius: var(--radius);
  font: var(--t2)/var(--code-line) var(--font-code);
  overflow-x: auto;
}
.obj-code .l { min-height: 20px; white-space: pre; }
.obj-code .n { display: inline-block; width: 34px; padding-right: var(--s2); text-align: right; color: var(--gutter); user-select: none; }

/* ---------- Source Editor ---------- */
.editor-wrap { display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100%; }
.editor-bar {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s2) var(--s4);
  background: var(--surface);
  border-bottom: var(--line) solid var(--border);
  font-size: var(--t2);
  flex-wrap: wrap;
}
.code-scroll { overflow: auto; position: relative; font: var(--t3)/var(--code-line) var(--font-code); background: var(--bg); }
.code-body { display: grid; grid-template-columns: auto minmax(0, 1fr); min-height: 100%; min-width: max-content; padding: var(--s2) 0; }
.gutter { position: sticky; left: 0; z-index: 3; background: var(--bg); color: var(--gutter); text-align: right; user-select: none; padding: 0 var(--s3); min-width: 54px; }
.gutter div { height: var(--code-line); }
.gutter div.cur { color: var(--gutter-active); }
.code-area { position: relative; min-width: 0; }
.code-area pre, .code-area textarea { margin: 0; padding: 0 var(--s5) 0 0; border: 0; font: inherit; white-space: pre; tab-size: 2; }
.code-area pre { position: relative; pointer-events: none; min-height: 100%; }
.code-area pre .l { height: var(--code-line); }
.code-area pre .l.cur { background: var(--current-line); }
.code-area textarea {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
  outline: none;
  z-index: 2;
}
.code-area textarea::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); color: transparent; }

.tk-k { color: var(--k); font-weight: 500; }
.tk-ty { color: var(--ty); }
.tk-st { color: var(--st); }
.tk-nu { color: var(--nu); }
.tk-co { color: var(--co); font-style: italic; }
.tk-ev { color: var(--ev); }
.tk-df { color: var(--df); }
.tk-op { color: var(--op); }
.tk-decl { color: var(--ty); font-weight: 700; }
.tk-hole { color: var(--error); font-weight: 600; }

/* ---------- Badges / Pills / Cards / Tables ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--surface-2);
  border: var(--line) solid var(--border);
  color: var(--text);
  font-size: var(--t1);
  font-family: var(--font-code);
  white-space: nowrap;
  flex-shrink: 0;
}
.pill.ok { border-color: var(--success); color: var(--success); }
.pill.bad { border-color: var(--error); color: var(--error); }
.pill.warn { border-color: var(--warning); color: var(--warning); }
.pill.accent { border-color: var(--accent); color: var(--accent); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s3); margin-bottom: var(--s4); }
.card {
  border: var(--line) solid var(--border);
  border-radius: var(--radius);
  padding: var(--s3);
  background: var(--surface);
  min-width: 0;
}
.card .n { font: 600 var(--t4)/1.3 var(--font-code); }
.card .t { color: var(--text-2); font-size: var(--t1); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.callout {
  padding: var(--s2) var(--s3);
  border: var(--line) solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: var(--t2);
  margin-bottom: var(--s3);
}
.callout.warn { border-left-color: var(--warning); }
.callout.bad { border-left-color: var(--error); }

.table-scroll { overflow-x: auto; margin-bottom: var(--s3); border: var(--line) solid var(--border); border-radius: var(--radius); }
table.data { border-collapse: collapse; width: 100%; font-size: var(--t2); }
table.data th {
  text-align: left;
  font-weight: 600;
  color: var(--text-2);
  font-size: var(--t1);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 6px var(--s3);
  border-bottom: var(--line) solid var(--border);
  background: var(--surface);
  white-space: nowrap;
}
table.data td {
  padding: 6px var(--s3);
  border-bottom: var(--line) solid color-mix(in srgb, var(--border) 60%, transparent);
  vertical-align: top;
  overflow-wrap: anywhere;
}
table.data tr:last-child td { border-bottom: 0; }
table.data tr.click:hover td { background: var(--hover); cursor: pointer; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.code-pre {
  margin: var(--s2) 0;
  padding: var(--s2) var(--s3);
  background: var(--surface);
  border: var(--line) solid var(--border);
  border-radius: var(--radius);
  font: var(--t2)/1.45 var(--font-code);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 260px;
  overflow: auto;
}

/* ---------- Split / Semantic Graph ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; flex: 1 1 auto; min-height: 0; }
.split > .main { overflow: auto; min-width: 0; min-height: 0; padding: var(--s3); position: relative; }
.split > .inspector { border-left: var(--line) solid var(--border); overflow: auto; background: var(--surface); padding: var(--s3); }
.split.no-insp { grid-template-columns: minmax(0, 1fr); }
.split.no-insp > .inspector { display: none; }

svg.graph { display: block; font: var(--t2) var(--font-ui); user-select: none; }
svg.graph .node { cursor: pointer; }
svg.graph .node rect { fill: var(--surface); stroke: var(--border); stroke-width: 1.2; rx: 5; }
svg.graph .node:hover rect { stroke: var(--accent); }
svg.graph .node.on rect { stroke: var(--accent); stroke-width: 2; fill: color-mix(in srgb, var(--selected) 45%, var(--surface)); }
svg.graph .node.kind rect { stroke: var(--ty); }
svg.graph .node.event rect { stroke: var(--ev); }
svg.graph .node.law rect { stroke: var(--success); }
svg.graph .node.hole rect { stroke: var(--error); stroke-dasharray: 4 3; }
svg.graph .node.ghost rect { stroke-dasharray: 4 3; opacity: .82; }
svg.graph .node text { fill: var(--text); font-weight: 600; font-size: 12px; dominant-baseline: central; }
svg.graph .node text.sub { fill: var(--text-2); font-size: 11px; font-weight: 400; }
svg.graph .edge path { fill: none; stroke: var(--text-3); stroke-width: 1.3; }
svg.graph .edge.hi path { stroke: var(--accent); stroke-width: 2; }
svg.graph .edge text {
  fill: var(--text-2);
  font-size: 11px;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 4px;
}
svg.graph marker path { fill: var(--text-3); }
svg.graph .lane-label { fill: var(--text-2); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Live & Timeline Scrubber ---------- */
.live-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--s3); margin-bottom: var(--s4); }
.actor-card {
  border: var(--line) solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: var(--s3);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.actor-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.row-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border: var(--line) solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font: var(--t2) var(--font-code);
  margin: 2px 4px 2px 0;
}
.row-chip:hover { border-color: var(--accent); color: var(--accent); }
.actor-form { display: flex; flex-wrap: wrap; gap: var(--s1); align-items: center; padding-top: var(--s1); border-top: var(--line) solid var(--border); }
.actor-form .field { width: 108px; height: 24px; }

.timeline-grid { display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); gap: var(--s3); min-height: 280px; }
.step-list { border: var(--line) solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: auto; max-height: 420px; }
.step-item {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  padding: 6px var(--s2);
  border-bottom: var(--line) solid color-mix(in srgb, var(--border) 50%, transparent);
  text-align: left;
  font: var(--t2) var(--font-code);
}
.step-item:hover { background: var(--hover); }
.step-item.on { background: var(--selected); color: var(--selected-text); }
.step-item.future { opacity: .55; }
.step-item.hit { border-left: 3px solid var(--warning); }

/* ---------- Heatmap & Morph Bar ---------- */
.morph-bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; border: var(--line) solid var(--border); margin: var(--s2) 0; }
.morph-fill { height: 100%; background: var(--accent); transition: width .2s ease; }
.morph-fill.fallback { background: var(--warning); }
.morph-fill.completed { background: var(--success); }

.heatmap-wrap { display: flex; flex-direction: column; gap: 3px; overflow-x: auto; padding: var(--s2) 0; }
.heatmap-row { display: flex; align-items: center; gap: 3px; }
.heatmap-day { width: 32px; font: var(--t1) var(--font-code); color: var(--text-2); flex: none; }
.heatmap-cell { width: 14px; height: 14px; border-radius: 2px; background: var(--surface-2); border: var(--line) solid color-mix(in srgb, var(--border) 55%, transparent); flex: none; }
.heatmap-cell.level-1 { background: color-mix(in srgb, var(--accent) 25%, var(--surface)); }
.heatmap-cell.level-2 { background: color-mix(in srgb, var(--accent) 48%, var(--surface)); }
.heatmap-cell.level-3 { background: color-mix(in srgb, var(--accent) 72%, var(--surface)); }
.heatmap-cell.level-4 { background: var(--accent); }
.heatmap-cell.prewarm { box-shadow: inset 0 0 0 1.5px var(--warning); }
.heatmap-cell.current { outline: 2px solid var(--text); }

/* ---------- Bottom Panel ---------- */
#panel { display: grid; grid-template-rows: 32px minmax(0, 1fr); background: var(--bg); min-height: 0; }
#panel.has-scope { grid-template-rows: auto 32px minmax(0, 1fr); }
.selection-scope {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 3px var(--s4);
  background: var(--surface);
  border-bottom: var(--line) solid var(--border);
  font-size: var(--t2);
}
.panel-tabs {
  display: flex;
  align-items: center;
  gap: var(--s4);
  padding: 0 var(--s3) 0 var(--s4);
  border-bottom: var(--line) solid var(--border);
}
.ptab {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  font-size: var(--t1);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-2);
  border-bottom: 2px solid transparent;
}
.ptab:hover { color: var(--text); }
.ptab.on { color: var(--text); border-bottom-color: var(--accent); }
.panel-tools { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }
.panel-body { overflow: auto; min-height: 0; padding: var(--s2) var(--s4); font-size: var(--t2); }

/* ---------- Statusbar ---------- */
#status {
  display: flex;
  align-items: stretch;
  background: var(--statusbar);
  border-top: var(--line) solid var(--border);
  font-size: var(--t1);
  color: var(--text-2);
  min-width: 0;
  overflow: hidden;
}
#status .item {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  padding: 0 var(--s2);
  white-space: nowrap;
  height: 100%;
  flex: none;
}
#status button.item:hover { background: var(--hover); color: var(--text); }
#status .right { margin-left: auto; display: flex; min-width: 0; }
#status .verdict { color: #fff; font-weight: 600; padding: 0 var(--s3); }
#status .verdict.v0 { background: #1f7a3f; }
#status .verdict.v1, #status .verdict.v2 { background: #b3261e; }
#status .verdict.v3 { background: #8f6a00; }
#status .verdict.vq { background: var(--surface-2); color: var(--text); }

/* ---------- Command Palette & Toast ---------- */
#overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, .35);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 48px;
}
.palette {
  width: min(640px, calc(100vw - 32px));
  background: var(--surface);
  border: var(--line) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.palette input {
  width: 100%;
  height: 36px;
  padding: 0 var(--s3);
  border: 0;
  border-bottom: var(--line) solid var(--border);
  background: var(--bg);
  outline: none;
}
.palette .list { max-height: 360px; overflow: auto; padding: var(--s1) 0; }
.palette .opt {
  display: flex;
  align-items: center;
  gap: var(--s2);
  width: 100%;
  height: 28px;
  padding: 0 var(--s3);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.palette .opt.on, .palette .opt:hover { background: var(--selected); color: var(--selected-text); }
.palette .opt .detail { color: var(--text-2); font-size: var(--t2); margin-left: auto; overflow: hidden; text-overflow: ellipsis; padding-left: var(--s3); }
.palette .opt.on .detail { color: inherit; opacity: .85; }

.toast {
  position: fixed;
  right: var(--s4);
  bottom: 36px;
  z-index: 50;
  max-width: 440px;
  padding: var(--s2) var(--s3);
  background: var(--surface);
  border: var(--line) solid var(--border);
  border-left: 3px solid var(--error);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: var(--t2);
}
.toast.good { border-left-color: var(--success); }

@media (max-width: 900px) {
  #titlebar { grid-template-columns: auto minmax(0, 1fr) auto; }
  #workbench { grid-template-columns: 44px minmax(0, 1fr); }
  #workbench:not(.no-side) #sidebar {
    position: fixed;
    left: 44px;
    top: 36px;
    bottom: 24px;
    width: 260px;
    z-index: 25;
    border-right: var(--line) solid var(--border);
    box-shadow: var(--shadow);
  }
  #sash-side { display: none; }
  .split, .timeline-grid { grid-template-columns: 1fr; }
  .split > .inspector { border-left: 0; border-top: var(--line) solid var(--border); }
}
