/* ============================================================================
   DAYA Studio - VSCode-style dark workbench
   ============================================================================ */
:root {
  --bg: #1e1e1e;            /* editor bg */
  --bg-2: #252526;          /* sidebar/panel */
  --bg-3: #2d2d30;          /* tabs/inputs */
  --activity: #333333;
  --titlebar: #1f1f2e;
  --status: #007acc;
  --ink: #d4d4d4;
  --ink-dim: #8a8f98;
  --line: #3a3d41;
  --line-2: #4b4f55;
  --accent: #4f8cff;
  --accent-2: #1f6feb;
  --accent-soft: #16324f;
  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --shadow: 0 8px 26px rgba(0,0,0,.45);
  --r: 8px;
  --title-h: 40px;
  --status-h: 24px;
  --titlebar-ink: #cfd3da;
}
/* ---------- light theme ---------- */
body.theme-light {
  --bg: #ffffff; --bg-2: #f3f3f5; --bg-3: #e8e8ec; --activity: #e7e7ea; --titlebar: #e4e4ea;
  --status: #007acc; --ink: #1f2329; --ink-dim: #5a616b; --line: #d6d8dd; --line-2: #c2c5cc;
  --accent: #1f6feb; --accent-2: #1f6feb; --accent-soft: #dbeafe;
  --good: #1a7f37; --warn: #9a6700; --bad: #cf222e;
  --shadow: 0 8px 26px rgba(0,0,0,.16); --titlebar-ink: #1f2329;
}
body.theme-light .project-name { background: rgba(0,0,0,.05); }
body.theme-light .act.active, body.theme-light .act:hover { color: #111; }
body.theme-light .exp-item:hover, body.theme-light .exp-col:hover, body.theme-light .rel-row:hover,
body.theme-light .zbtn:hover, body.theme-light .tbtn:hover { background: rgba(0,0,0,.07); }
body.theme-light .etab.active, body.theme-light .ptab.active, body.theme-light .modal h3 { color: #111; }
body.theme-light .canvas { background:
  radial-gradient(circle, #d4d7df 1.1px, transparent 1.1px) 0 0 / 24px 24px, var(--bg); }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: "Segoe UI", system-ui, Arial, sans-serif; font-size: 13px; overflow: hidden; }
h1,h2,h3,h4 { margin: 0 0 8px; } p { margin: 0 0 8px; }
.dim { color: var(--ink-dim); } .small { font-size: 11.5px; } .grow { flex: 1; } .hidden { display: none !important; }
.focus { border-left: 3px solid var(--accent); padding: 6px 10px; background: rgba(79,110,247,.08); border-radius: 4px; }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: #424449; border-radius: 6px; }
a, .link { color: var(--accent); cursor: pointer; }

button, input, select, textarea { font-family: inherit; font-size: 13px; }
input, select, textarea { background: var(--bg-3); color: var(--ink); border: 1px solid var(--line-2); border-radius: 6px; padding: 6px 9px; width: 100%; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: block; font-weight: 600; margin: 9px 0 4px; color: var(--ink-dim); }
.btn { border: 1px solid var(--line-2); background: var(--bg-3); color: var(--ink); border-radius: 6px; padding: 6px 11px; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: var(--accent); color: #fff; }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.primary:hover { background: var(--accent); }
.btn.tiny { padding: 3px 8px; font-size: 11.5px; }
.btn.danger { color: var(--bad); border-color: var(--bad); } .btn.danger:hover { background: #3a1d1d; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.tbtn { background: transparent; border: none; color: var(--titlebar-ink); font-size: 15px; cursor: pointer; padding: 4px 7px; border-radius: 6px; }
.tbtn:hover { background: rgba(255,255,255,.1); }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--ink-dim); position: sticky; top: 0; background: var(--bg-2); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); background: var(--bg-3); }
th.sortable .sort-rank { margin-left: 5px; font-size: 9px; font-weight: 700; color: var(--accent); vertical-align: middle; }
th.sortable .sort-icon { margin-left: 3px; font-size: 9px; opacity: .55; }
th.sortable.sorted .sort-icon, th.sortable.sorted .sort-rank { opacity: 1; }
th.sortable.sorted .sort-icon { color: var(--accent); }
.badge { font-size: 10px; padding: 1px 7px; border-radius: 999px; background: var(--bg-3); color: var(--ink-dim); font-weight: 600; }
.badge.key { background: var(--accent-soft); color: #79b8ff; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.chip.ok { background: #13331f; color: var(--good); } .chip.warn { background: #3a2f12; color: var(--warn); }

/* ---------- title bar ---------- */
.titlebar { height: var(--title-h); display: flex; align-items: center; justify-content: space-between; padding: 0 12px; background: var(--titlebar); border-bottom: 1px solid #000; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--accent-2); color: #fff; font-weight: 800; font-size: 12px; }
.project-name { width: 200px; background: rgba(255,255,255,.06); border-color: transparent; color: var(--titlebar-ink); font-weight: 600; padding: 4px 8px; }

/* ---------- menu bar (File / Edit / View / Window / Agent / Help) ---------- */
.menubar { display: flex; align-items: center; gap: 1px; margin-left: 6px; }
.menu-item { position: relative; }
.menu-btn { background: transparent; border: none; color: var(--titlebar-ink); padding: 4px 9px; border-radius: 5px; cursor: pointer; font-size: 12.5px; }
.menu-btn:hover, .menu-item.open .menu-btn { background: rgba(127,127,127,.2); }
.menu-list { position: absolute; top: 100%; left: 0; min-width: 224px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 5px; display: none; z-index: 80; }
.menu-item.open .menu-list { display: block; }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; width: 100%; background: transparent; border: none; color: var(--ink); padding: 6px 9px; border-radius: 6px; cursor: pointer; font-size: 12.5px; text-align: left; }
.menu-row:hover { background: var(--accent-2); color: #fff; }
.menu-row .menu-key { font-size: 11px; color: var(--ink-dim); }
.menu-row:hover .menu-key { color: #dbeafe; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }

/* ---------- find + export + welcome ---------- */
.find-results { max-height: 360px; overflow: auto; margin-top: 10px; }
.find-grp { margin-bottom: 10px; }
.find-ds { font-weight: 700; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.find-ds:hover, .find-row:hover { background: var(--bg-3); }
.find-row { font-size: 11.5px; padding: 2px 10px; color: var(--ink); cursor: pointer; border-radius: 5px; }
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
.welcome { max-height: 60vh; overflow: auto; }
.welcome h1 { font-size: 19px; color: #fff; } body.theme-light .welcome h1 { color: #111; }
.welcome h2 { font-size: 14px; margin-top: 14px; }
.titlebar-right { display: flex; align-items: center; gap: 6px; }
.model-pick { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-dim); margin: 0; font-weight: 600; }
.model-pick select { width: 175px; padding: 4px 7px; }

/* ---------- body grid ---------- */
.vs-body { --sidebar-w: 264px; --chat-w: 360px; display: grid; grid-template-columns: 48px var(--sidebar-w) minmax(0,1fr) 0; height: calc(100vh - var(--title-h) - var(--status-h)); transition: grid-template-columns .16s ease; }
.vs-body.chat-open { grid-template-columns: 48px var(--sidebar-w) minmax(0,1fr) var(--chat-w); }
.vs-body.side-hidden { grid-template-columns: 48px 0 minmax(0,1fr) 0; }
.vs-body.side-hidden.chat-open { grid-template-columns: 48px 0 minmax(0,1fr) var(--chat-w); }
.vs-body.resizing-chat, .vs-body.resizing-sidebar { transition: none; cursor: col-resize; user-select: none; }

/* ---------- activity bar ---------- */
.activitybar { background: var(--activity); display: flex; flex-direction: column; align-items: center; padding: 8px 0; gap: 4px; }
.act { width: 40px; height: 40px; border: none; background: transparent; color: #9da3ad; font-size: 18px; cursor: pointer; border-left: 2px solid transparent; border-radius: 0; display: grid; place-items: center; }
.act svg { width: 21px; height: 21px; }
.act:hover { color: #fff; }
.act.active { color: #fff; border-left-color: var(--accent); }

/* ---------- sidebar ---------- */
.sidebar { position: relative; background: var(--bg-2); border-right: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; }
.sidebar-resizer { position: absolute; z-index: 5; right: -4px; top: 0; width: 8px; height: 100%; cursor: col-resize; }
.sidebar-resizer::after { content: ''; position: absolute; right: 3px; top: 0; width: 1px; height: 100%; background: transparent; }
.sidebar-resizer:hover::after, .vs-body.resizing-sidebar .sidebar-resizer::after { background: var(--accent); }
.vs-body.side-hidden .sidebar-resizer { display: none; }
.sidebar-title { padding: 9px 14px; font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: var(--ink-dim); }
.explorer-scroll { flex: 1; overflow: auto; padding: 0 6px 8px; }
.exp-group { margin-bottom: 4px; }
.exp-head { display: flex; align-items: center; gap: 6px; padding: 5px 6px; font-weight: 700; font-size: 11px; letter-spacing: .4px; text-transform: uppercase; color: var(--ink-dim); cursor: pointer; user-select: none; }
.exp-head .caret { font-size: 10px; }
.exp-add { margin-left: auto; border: none; background: transparent; color: var(--accent); font-size: 14px; cursor: pointer; }
.exp-add.meta-rm, .exp-add.src-rm { color: var(--ink-dim); font-size: 13px; padding: 0 4px; }
.exp-add.meta-rm:hover, .exp-add.src-rm:hover { color: var(--bad); }
.meta-summary .link { font-size: inherit; padding: 0; border: none; background: transparent; cursor: pointer; }
.meta-summary .btn.ghost { padding: 0 4px; font-size: inherit; border: none; color: var(--bad); }
.meta-summary .btn.ghost:hover { background: transparent; text-decoration: underline; }
.exp-group.collapsed .exp-body, .exp-group.collapsed .exp-actions { display: none; }
.exp-actions { padding: 2px 6px 6px; }
.exp-filter { display: flex; gap: 4px; padding: 2px 6px 6px; }
.exp-filter input[type="search"] { flex: 1; min-width: 0; padding: 4px 7px; font-size: 11.5px; }
.exp-filter select { width: auto; max-width: 96px; padding: 4px 5px; font-size: 11px; flex: none; }
.exp-col-empty { font-size: 11px; color: var(--ink-dim); padding: 2px 6px 4px; font-style: italic; }
.exp-item { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 5px; cursor: pointer; font-size: 12.5px; }
.exp-item:hover { background: #2a2d2e; }
.exp-item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); flex: none; }
.exp-item-no-flex { padding: 3px 6px; border-radius: 5px; cursor: pointer; font-size: 12.5px; }
.exp-item-no-flex:hover { background: #2a2d2e; }
.exp-item-no-flex .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); flex: none; }
.exp-sub { padding-left: 16px; }
.exp-src { margin-bottom: 1px; }
.exp-src-head .caret { font-size: 10px; color: var(--ink-dim); flex: none; width: 10px; text-align: center; }
.exp-src.collapsed .exp-cols { display: none; }
.exp-col { font-size: 11.5px; color: var(--ink-dim); padding: 2px 6px; cursor: pointer; border-radius: 4px; }
.exp-col:hover { background: #2a2d2e; color: var(--ink); }
.tool-item { font-size: 11.5px; padding: 2px 6px; color: var(--ink-dim); }
.rel-row { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 5px; cursor: pointer; font-size: 11.5px; }
.rel-row:hover { background: #2a2d2e; } .rel-score { margin-left: auto; font-weight: 700; color: #79b8ff; }
.rel-consensus { border: 1px dashed var(--line-2); margin-bottom: 4px; font-weight: 600; }
.insp-nav { margin-bottom: 8px; }
.insp-back { color: var(--accent); border-color: transparent; background: transparent; padding-left: 0; }
.insp-back:hover { color: #fff; border-color: var(--accent); background: var(--bg-3); }

/* ---------- extensions view ---------- */
.sidebar-view { height: 100%; display: flex; flex-direction: column; }
.sidebar-view.hidden { display: none; }
.ext-scroll { flex: 1; overflow: auto; padding: 8px 10px; }
.ext-env { background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 9px; margin-bottom: 10px; font-size: 11.5px; }
.ext-env .kv2 { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; }
.ext-env code { background: var(--bg); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.ext-env .pill2 { font-size: 10px; padding: 1px 7px; border-radius: 999px; }
.ext-env .ok { background: #13331f; color: var(--good); } .ext-env .bad { background: #3a1d1d; color: var(--bad); }
.ext-env input { font-size: 11.5px; padding: 5px 7px; margin-top: 4px; }
.ext-env .row { display: flex; gap: 5px; margin-top: 6px; }
.ext-install { display: flex; gap: 6px; margin-bottom: 8px; }
.btn-spinner {
  display: inline-block; width: 12px; height: 12px; vertical-align: -2px;
  border: 2px solid color-mix(in srgb, currentColor 28%, transparent);
  border-top-color: currentColor; border-radius: 50%;
  animation: busy-spin .75s linear infinite;
}
#extInstallBtn { min-width: 64px; }
.ext-go { min-width: 64px; }
.ext-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; }
.ext-item .info { flex: 1; min-width: 0; }
.ext-item .name { font-weight: 700; font-size: 12.5px; }
.ext-item .desc { font-size: 11px; color: var(--ink-dim); }
.ext-item .ver { font-size: 10px; color: var(--good); }
.ext-badge { font-size: 9.5px; padding: 1px 7px; border-radius: 999px; }
.ext-badge.installed { background: #13331f; color: var(--good); }
.ext-log { font-family: "Cascadia Code", Consolas, monospace; font-size: 10.5px; white-space: pre-wrap; max-height: 160px; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px; margin-top: 6px; }

/* ---------- editor ---------- */
.editor { --panel-h: 230px; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.editor.resizing-panel { user-select: none; }
.editor.resizing-panel .canvas { pointer-events: none; }
.querybar { display: flex; gap: 7px; padding: 8px 10px; background: var(--bg-2); border-bottom: 1px solid var(--line); align-items: center; }
.querybar #queryMode { width: 110px; } .querybar #queryInput { flex: 1; } .querybar #targetSelect { width: 140px; } .querybar #layerInput { width: 56px; }
.progress-row { display: flex; align-items: center; gap: 10px; padding: 4px 10px 6px; background: var(--bg-2); border-bottom: 1px solid var(--line); font-size: 11px; }
.progress-row.hidden { display: none; }
.progress-stage { flex: 1; min-width: 0; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-row .progress-track { flex: 0 0 140px; height: 4px; border-radius: 2px; }
.progress-pct { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); min-width: 34px; text-align: right; }
.progress-elapsed { font-variant-numeric: tabular-nums; color: var(--ink-dim); min-width: 38px; text-align: right; }
.progress-track { height: 3px; background: var(--bg-3); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width .3s; }
.editor-tabs { display: flex; align-items: center; gap: 2px; padding: 4px 8px 0; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.etab { border: none; background: transparent; padding: 7px 13px; font-weight: 600; color: var(--ink-dim); cursor: pointer; border-top: 2px solid transparent; }
.etab.active { background: var(--bg); color: #fff; border-top-color: var(--accent); }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11px; color: var(--ink-dim); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 3px; vertical-align: middle; }

.canvas { position: relative; flex: 1; min-height: 160px; overflow: hidden; background:
  radial-gradient(circle, #2a2d33 1.1px, transparent 1.1px) 0 0 / 24px 24px, var(--bg); }
.viewport { position: absolute; inset: 0; transform-origin: 0 0; }
.edge-layer { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; }
.node-layer { position: absolute; inset: 0; }
.relation-layer { position: absolute; inset: 0; }
.relation-layer svg { width: 100%; height: 100%; }
.canvas-hint { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); color: var(--ink-dim); pointer-events: none; }
.zoom-controls { position: absolute; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 4px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 3px; box-shadow: var(--shadow); }
.zbtn { width: 26px; height: 26px; border: none; background: transparent; color: var(--ink); cursor: pointer; border-radius: 6px; font-size: 14px; }
.zbtn:hover { background: #2a2d2e; } .zlabel { font-size: 11px; color: var(--ink-dim); padding: 0 6px; min-width: 40px; text-align: center; }

/* build-mode nodes */
.node { position: absolute; width: 200px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 9px; box-shadow: var(--shadow); }
.node.connecting { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.node.disabled { opacity: .5; }
.node-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 6px 9px; background: linear-gradient(120deg, #233056, #2f54b0); color: #fff; border-radius: 9px 9px 0 0; cursor: grab; }
.node-head:active { cursor: grabbing; }
.node-title { font-weight: 700; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-connect { width: auto; padding: 0 5px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 6px; cursor: pointer; }
.node-body { padding: 7px 9px; }
.node-desc { margin: 0 0 6px; font-size: 11px; color: var(--ink-dim); }
.node-cols { display: flex; flex-wrap: wrap; gap: 4px; }
.col-chip { font-size: 10px; padding: 1px 6px; border-radius: 999px; background: var(--accent-soft); color: #79b8ff; }
.col-chip.more { background: var(--bg-3); color: var(--ink-dim); }
.node-meta { margin-top: 6px; font-size: 10px; color: var(--ink-dim); }
.edge-line { stroke: var(--accent); stroke-width: 2; opacity: .7; }
.edge-bg { fill: var(--bg-2); stroke: var(--line-2); }
.edge-text { font-size: 10px; fill: var(--ink); }

/* relation-mode svg */
.gnode { cursor: pointer; }
.gnode-c { fill: #6b7689; stroke: var(--bg); stroke-width: 1.5; }
.gnode-c.target { fill: var(--accent); } .gnode-c.bridge { fill: var(--good); } .gnode-c.suspicious { fill: var(--bad); }
.gnode-text { font-size: 11px; fill: var(--ink); text-anchor: middle; }
.gedge { stroke: #4b5566; }
.gedge.directCorrelation { stroke: var(--accent); } .gedge.nonlinearDependency { stroke: var(--good); }
.gedge.categoricalAssociation { stroke: var(--warn); } .gedge.identifierLink { stroke: var(--bad); stroke-dasharray: 4 3; }
.gedge.temporalRelation { stroke: #a371f7; }

/* ---------- panel ---------- */
.panel { position: relative; height: var(--panel-h); flex-shrink: 0; border-top: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; }
.panel-resizer { position: absolute; z-index: 5; left: 0; top: -4px; width: 100%; height: 8px; cursor: row-resize; }
.panel-resizer::after { content: ''; position: absolute; left: 0; top: 3px; width: 100%; height: 1px; background: transparent; }
.panel-resizer:hover::after, .editor.resizing-panel .panel-resizer::after { background: var(--accent); }
.panel-tabs { display: flex; gap: 2px; padding: 5px 8px 0; border-bottom: 1px solid var(--line); }
.ptab { position: relative; border: none; background: transparent; padding: 6px 12px; font-weight: 600; color: var(--ink-dim); cursor: pointer; font-size: 11px; letter-spacing: .4px; text-transform: uppercase; }
.ptab.active { color: #fff; border-bottom: 2px solid var(--accent); }
.ptab.updated::after { content: ''; position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.panel-body { flex: 1; overflow: auto; padding: 11px; }
.pane { display: none; } .pane.active { display: block; }
.metrics { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; margin: 8px 0; }
.metrics > div { background: var(--bg-3); border-radius: 7px; padding: 6px; } .metrics strong { display: block; font-size: 10px; color: var(--ink-dim); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 3px 10px; font-size: 12px; } .kv b { color: var(--ink-dim); font-weight: 600; }
.stage-list { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; }
.stage { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--ink-dim); padding: 2px 8px; border-radius: 999px; background: var(--bg-3); }
.stage .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--line-2); }
.stage.active { background: var(--accent-soft); color: #79b8ff; } .stage.active .dot { background: var(--accent); } .stage.done .dot { background: var(--good); }
.activity-log { display: grid; gap: 4px; }
.log-line { font-size: 11.5px; padding: 4px 8px; border-radius: 6px; background: var(--bg-3); }
.log-line.warning { border-left: 3px solid var(--bad); } .log-line .who { font-weight: 700; }
.timeline { display: grid; gap: 6px; }
.tl-item { border-left: 3px solid var(--line-2); padding: 4px 9px; background: var(--bg-3); border-radius: 0 7px 7px 0; }
.tl-item.system { border-color: var(--ink-dim); } .tl-item.target,.tl-item.consensus { border-color: var(--accent); }
.tl-item.agent { border-color: var(--good); } .tl-item.warning,.tl-item.guard { border-color: var(--bad); } .tl-item.peer,.tl-item.markov { border-color: var(--warn); }
.tl-meta { font-size: 10px; color: var(--ink-dim); } .tl-score { float: right; font-weight: 700; color: #79b8ff; }
.bars { display: grid; gap: 4px; margin-top: 6px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 64px; gap: 6px; align-items: center; font-size: 11.5px; }
.bar-track { background: var(--bg-3); border-radius: 5px; height: 13px; overflow: hidden; } .bar-fill { height: 100%; background: var(--accent); } .bar-val { text-align: right; }

/* ---------- chat ---------- */
.chat { position: relative; background: var(--bg-2); border-left: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
.vs-body:not(.chat-open) .chat { display: none; }
.chat-resizer { position: absolute; z-index: 5; left: -4px; top: 0; width: 8px; height: 100%; cursor: col-resize; }
.chat-resizer::after { content: ''; position: absolute; left: 3px; top: 0; width: 1px; height: 100%; background: transparent; }
.chat-resizer:hover::after, .vs-body.resizing-chat .chat-resizer::after { background: var(--accent); }
.chat-head { display: flex; align-items: center; gap: 6px; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.chat-messages { flex: 1; overflow: auto; padding: 11px; display: flex; flex-direction: column; gap: 9px; }
.msg { max-width: 92%; } .msg.user { align-self: flex-end; } .msg.assistant { align-self: flex-start; }
.bubble { padding: 8px 11px; border-radius: 11px; font-size: 12.5px; line-height: 1.45; white-space: pre-wrap; }
.msg.user .bubble { background: var(--accent-2); color: #fff; border-bottom-right-radius: 3px; }
.msg.assistant .bubble { background: var(--bg-3); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.msg .who { font-size: 10px; color: var(--ink-dim); margin-bottom: 2px; } .msg .intent { font-size: 9.5px; padding: 1px 6px; border-radius: 999px; background: var(--accent-soft); color: #79b8ff; margin-left: 6px; }
.msg-note { font-size: 11px; color: var(--ink-dim); margin-top: 6px; }
.chat-input { display: flex; gap: 7px; padding: 9px; border-top: 1px solid var(--line); } .chat-input textarea { flex: 1; }
.typing .thinking-live::after { content: '▋'; animation: blink 1s steps(2) infinite; } @keyframes blink { 50% { opacity: 0; } }
.thinking-live { color: var(--ink-dim); font-size: 12px; }

/* markdown inside assistant bubbles */
.msg.assistant .bubble p { margin: 0 0 6px; }
.msg.assistant .bubble p:last-child { margin-bottom: 0; }
.msg.assistant .bubble h3, .msg.assistant .bubble h4, .msg.assistant .bubble h5, .msg.assistant .bubble h6 { margin: 8px 0 4px; font-size: 13px; }
.msg.assistant .bubble ul, .msg.assistant .bubble ol { margin: 4px 0 6px; padding-left: 18px; }
.msg.assistant .bubble li { margin: 2px 0; }
.msg.assistant .bubble code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }
.md-pre { background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 8px; overflow: auto; margin: 6px 0; }
.md-pre code { background: none; padding: 0; font-size: 11px; }
.md-table { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 11.5px; }
.md-table th, .md-table td { border: 1px solid var(--line); padding: 4px 7px; white-space: nowrap; }
.md-table th { background: var(--bg-3); }

/* download button */
.dl-btn { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; margin-right: 8px; padding: 6px 11px; border-radius: 8px; background: var(--accent-2); color: #fff; font-weight: 600; text-decoration: none; font-size: 12px; }
.dl-btn:hover { background: var(--accent); }

/* openClaude coding sub-agent (collapsible code + output) */
.openclaude { margin-top: 8px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 7px; padding: 6px 9px; background: var(--bg); }
.openclaude > summary { cursor: pointer; color: var(--ink); font-size: 11.5px; font-weight: 600; list-style: none; }
.openclaude > summary::-webkit-details-marker { display: none; }
.openclaude > summary::before { content: '▸ '; color: var(--ink-dim); }
.openclaude[open] > summary::before { content: '▾ '; }
.oc-ok { color: var(--good); font-weight: 600; } .oc-bad { color: var(--warn); font-weight: 600; }
.oc-label { font-size: 10.5px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .04em; margin: 8px 0 3px; }
.oc-pre { background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 7px; margin: 0; font-size: 10.5px; line-height: 1.45; max-height: 240px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.oc-code { color: #9cdcfe; } .oc-err { color: var(--bad); }
.oc-engine { font-size: 9.5px; background: var(--accent-soft); color: var(--accent); padding: 1px 5px; border-radius: 4px; font-weight: 600; }
.oc-note { font-size: 11px; color: var(--warn); margin: 6px 0 2px; }

/* reasoning (collapsible) */
.reasoning { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 6px; }
.reasoning > summary { cursor: pointer; color: var(--ink-dim); font-size: 11px; list-style: none; }
.reasoning > summary::-webkit-details-marker { display: none; }
.reasoning > summary::before { content: '▸ '; }
.reasoning[open] > summary::before { content: '▾ '; }
.step { font-size: 11px; margin: 4px 0; line-height: 1.4; }
.step-ico { margin-right: 4px; }
.step-think { color: var(--ink-dim); font-style: italic; }
.step-tool b { color: #79b8ff; }
.step-obs { color: var(--good); }
.step-args { display: inline-block; background: var(--bg); padding: 1px 5px; border-radius: 4px; word-break: break-all; }
.step-code { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px; margin: 4px 0; font-size: 10.5px; max-height: 200px; overflow: auto; white-space: pre-wrap; }

/* ---------- status bar ---------- */
.statusbar { height: var(--status-h); background: var(--status); color: #fff; display: flex; align-items: center; gap: 14px; padding: 0 12px; font-size: 11.5px; }
.st-item { display: inline-flex; align-items: center; gap: 5px; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 60; }
.modal { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); width: min(620px,94vw); max-height: 88vh; overflow: auto; padding: 18px; }
.modal h3 { margin-top: 0; color: #fff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.modal-filter {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 0 8px;
}
.modal-filter input[type="search"] {
  flex: 1; min-width: 0; padding: 6px 9px; font-size: 12.5px;
}
.modal-filter select {
  width: auto; min-width: 7.5em; padding: 6px 8px; font-size: 12px; flex: none;
}
.modal-filter .dim { flex: none; min-width: 4.5em; text-align: right; }
.modal-table-wrap { max-height: 48vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
.modal-table-wrap table { margin: 0; }
.modal-table-wrap td.mm-desc { white-space: normal; max-width: 280px; line-height: 1.35; font-size: 11.5px; color: var(--ink-dim); }
.modal-table-wrap input[list] { font-size: 12px; }

/* ---------- global busy overlay ---------- */
body.busy-locked { overflow: hidden; }
.busy-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(1px);
}
.busy-overlay.hidden { display: none; }
.busy-panel {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  min-width: 220px; max-width: min(420px, 88vw);
  padding: 22px 26px; border-radius: var(--r);
  background: var(--bg-2); border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.busy-spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--line-2);
  border-top-color: var(--accent);
  animation: busy-spin .75s linear infinite;
}
.busy-message { color: var(--ink); font-size: 13px; font-weight: 600; text-align: center; }
@keyframes busy-spin { to { transform: rotate(360deg); } }
.mini-status { font-size: 11.5px; color: var(--ink-dim); margin-top: 8px; } .status-error { color: var(--bad); } .status-ok { color: var(--good); }
/* ---------- friendly model / API issue toasts ---------- */
.toast-root { position: fixed; right: 16px; bottom: calc(var(--status-h) + 14px); display: flex; flex-direction: column; gap: 10px; z-index: 1200; max-width: 340px; }
.toast { display: flex; align-items: flex-start; gap: 9px; padding: 11px 12px; border-radius: var(--r); font-size: 12.5px; line-height: 1.4; box-shadow: var(--shadow); animation: toast-in .18s ease-out; }
.toast-warn { background: #3a2f12; color: var(--ink); border: 1px solid var(--warn); border-left: 3px solid var(--warn); }
body.theme-light .toast-warn { background: #fff8e1; }
.toast-ico { color: var(--warn); font-weight: 700; font-size: 11px; line-height: 15px; width: 16px; height: 16px; text-align: center; border: 1.5px solid var(--warn); border-radius: 50%; flex-shrink: 0; }
.toast-body { flex: 1; min-width: 0; }
.toast-msg { color: var(--ink); }
.toast-detail { margin-top: 6px; }
.toast-detail summary { cursor: pointer; color: var(--ink-dim); font-size: 11.5px; }
.toast-tech { margin-top: 5px; padding: 7px 8px; background: rgba(0,0,0,.22); border-radius: 6px; color: var(--ink-dim); font-family: var(--mono, monospace); font-size: 11px; white-space: pre-wrap; word-break: break-word; max-height: 140px; overflow: auto; }

/* ---------- Daya natural-language notebooks ---------- */
.notebook-toolbar-title { font-weight: 700; color: var(--ink); }
.notebook-tabs { display: flex; align-items: stretch; min-width: 0; overflow-x: auto; }
.nb-tab { display: inline-flex; align-items: center; padding: 0; flex: 0 0 auto; }
.nb-tab-open, .nb-tab-close { border: 0; background: transparent; color: inherit; cursor: pointer; }
.nb-tab-open { padding: 7px 4px 7px 12px; font-weight: 600; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nb-tab-close { padding: 7px 9px 7px 5px; color: var(--ink-dim); }
.nb-tab-close:hover { color: var(--ink); }
.nb-exp-item.active { background: var(--accent-soft); }
.nb-exp-item .exp-add { margin-left: 0; font-size: 12px; opacity: .65; }
.nb-exp-item:hover .exp-add { opacity: 1; }
.notebook-layer { flex: 1; min-height: 0; overflow: hidden; background: var(--bg); }
.nb-scroll { height: 100%; overflow: auto; padding: 20px clamp(14px,4vw,54px) 70px; }
.nb-title-row { display: flex; align-items: flex-start; gap: 18px; max-width: 1040px; margin: 0 auto 18px; }
.nb-title-row h2 { font-size: 20px; margin-bottom: 3px; }
.nb-title-actions { display: flex; gap: 6px; margin-left: auto; }
.nb-cells { display: grid; gap: 14px; max-width: 1040px; margin: 0 auto; }
.nb-cell { display: grid; grid-template-columns: 48px minmax(0,1fr); scroll-margin: 14px; }
.nb-gutter { padding: 34px 8px 0 0; color: var(--ink-dim); text-align: right; font: 11px/1.4 "Cascadia Code",Consolas,monospace; }
.nb-cell-main { min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--bg-2); box-shadow: 0 3px 12px rgba(0,0,0,.14); overflow: hidden; }
.nb-cell:focus-within .nb-cell-main { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.nb-cell.status-running .nb-cell-main { border-left: 3px solid var(--accent); }
.nb-cell.status-completed .nb-cell-main { border-left: 3px solid var(--good); }
.nb-cell.status-failed .nb-cell-main { border-left: 3px solid var(--bad); }
.nb-cell.status-failed .nb-gutter, .nb-cell.status-failed .nb-status { color: var(--bad); }
.nb-cell.status-stale .nb-cell-main { border-left: 3px solid var(--warn); }
.nb-cell-head { height: 31px; display: flex; align-items: center; gap: 2px; padding: 2px 6px 2px 10px; border-bottom: 1px solid var(--line); background: var(--bg-3); }
.nb-status { color: var(--ink-dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; }
.nb-icon { border: 0; border-radius: 4px; background: transparent; color: var(--ink-dim); min-width: 25px; height: 24px; cursor: pointer; font-size: 11px; }
.nb-icon:hover { background: var(--line); color: var(--ink); }
.nb-icon.danger:hover { color: var(--bad); }
.nb-input { display: block; width: 100%; min-height: 62px; resize: vertical; border: 0; border-radius: 0; padding: 12px 14px; background: var(--bg-2); color: var(--ink); line-height: 1.5; font-size: 13.5px; }
.nb-input:focus { border: 0; outline: 0; }
.nb-output { border-top: 1px solid var(--line); padding: 13px 15px; background: var(--bg); line-height: 1.5; overflow: auto; }
.nb-output p:last-child { margin-bottom: 0; }
.nb-output code { background: var(--bg-3); padding: 1px 5px; border-radius: 4px; }
.nb-live { border-top: 1px solid var(--line); padding: 9px 14px; color: var(--ink-dim); }
.nb-live::after { content: '▋'; animation: blink 1s steps(2) infinite; }
.nb-stale-note { padding: 7px 14px; color: var(--warn); background: rgba(210,153,34,.08); border-top: 1px solid var(--line); font-size: 11.5px; }
.nb-error { border-left: 3px solid var(--bad); background: rgba(248,81,73,.08); border-radius: 0 6px 6px 0; padding: 9px 12px; }
.nb-context { border-top: 1px dashed var(--line); padding: 7px 14px 9px; font-size: 11px; color: var(--ink-dim); }
.nb-context > summary { cursor: pointer; user-select: none; }
.nb-context-grid { display: grid; grid-template-columns: 90px 1fr; gap: 4px 10px; margin: 8px 0; }
.nb-context-grid b { color: var(--ink); }
.nb-check { display: flex; align-items: center; gap: 7px; margin: 5px 0 0; font-weight: 400; }
.nb-check input { width: auto; }
.nb-empty { height: 100%; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--ink-dim); }
.nb-empty h2 { color: var(--ink); }
body.theme-light .nb-cell-main { box-shadow: 0 3px 12px rgba(0,0,0,.07); }
@media (max-width: 780px) {
  .nb-scroll { padding-left: 8px; padding-right: 8px; }
  .nb-cell { grid-template-columns: 34px minmax(0,1fr); }
  .nb-gutter { font-size: 9px; }
  .nb-icon[data-action="move-up"], .nb-icon[data-action="move-down"], .nb-icon[data-action="copy-cell"] { display: none; }
}
.toast-x { background: none; border: none; color: var(--ink-dim); font-size: 16px; line-height: 1; cursor: pointer; padding: 0 2px; flex-shrink: 0; }
.toast-x:hover { color: var(--ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.inline-fields { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 10px; }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.editor-sources { max-height: 280px; overflow: auto; border: 1px solid var(--line); border-radius: 7px; padding: 9px; }
.editor-col { font-weight: 400; display: flex; gap: 7px; align-items: center; margin: 0 0 4px; color: var(--ink); } .editor-col input { width: auto; }
@media (max-width: 980px) { .editor-grid { grid-template-columns: 1fr; } }

/* ---------- Patchbook: inline figures, live session, model gate ---------- */
/* A patch shows its chart where the analysis happened, the way a notebook does. */
.nb-figures { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; }
.nb-figure { margin: 0; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-2); padding: 8px; }
.nb-figure a { display: block; line-height: 0; }
.nb-figure img { max-width: 100%; max-height: 460px; height: auto; border-radius: 5px; background: #fff; }
.nb-figure figcaption { margin-top: 6px; font-size: 10.5px; color: var(--ink-dim); word-break: break-all; line-height: 1.3; }
.nb-display { margin: 10px 0; max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.nb-display-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.nb-display-table th, .nb-display-table td { padding: 5px 9px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.nb-display-text { margin: 10px 0; }
.oc-vars { margin: 8px 0 4px; font-size: 11px; color: var(--ink-dim); line-height: 1.7; }
.oc-vars code { background: var(--bg-3); padding: 1px 5px; border-radius: 4px; color: var(--ink); }
.oc-engine { font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.nb-kernel-state { font-size: 11px; color: var(--ink-dim); padding-left: 10px; white-space: nowrap; }

/* The graph views sit to the right of the patchbook tabs. */
.etab-divider { width: 1px; height: 18px; background: var(--line-2); margin: 0 8px; flex-shrink: 0; }

/* Running a patch needs a model, so the control says so instead of failing. */
.llm-gate { display: flex; align-items: center; gap: 9px; font-size: 11.5px; color: var(--warn); background: rgba(210,153,34,.1);
  border: 1px solid rgba(210,153,34,.35); border-radius: 999px; padding: 3px 5px 3px 11px; margin-left: 10px; }
.llm-gate.hidden { display: none; }
.btn.needs-key { opacity: .55; }
.btn.needs-key::after { content: ' 🔑'; }
.settings-gate { border: 1px solid rgba(210,153,34,.4); background: rgba(210,153,34,.1); color: var(--warn);
  border-radius: 7px; padding: 8px 11px; margin-bottom: 10px; font-size: 12px; }
#m-provider-note { margin: 4px 0 10px; }
#m-provider-note a { color: var(--accent); }

/* ---------- Permission prompt (paused patch) ---------- */
/* The run is blocked server-side while this is on screen, so it is deliberately
   loud and states the exact command. */
.nb-permission { margin: 10px 0; border: 1px solid var(--warn); border-left-width: 3px;
  background: rgba(210,153,34,.09); border-radius: 8px; padding: 11px 13px; }
.nb-permission-head { font-weight: 700; color: var(--ink); margin-bottom: 5px; }
.nb-permission-detail { margin: 0 0 8px; color: var(--ink-dim); font-size: 12px; line-height: 1.5; }
.nb-permission-cmd { margin: 0 0 9px; padding: 7px 9px; border-radius: 6px; background: var(--bg);
  border: 1px solid var(--line); font-family: "Cascadia Code", Consolas, monospace; font-size: 11.5px;
  white-space: pre-wrap; word-break: break-all; color: var(--ink); }
.nb-permission-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 6px; }
.nb-permission + .nb-live, .nb-permission ~ .dim { margin-top: 0; }

/* ---------- Patchbook Program mode ---------- */
/* The second way to run a patchbook: every patch becomes a section of ONE
   Python module that runs top to bottom under a debugger. The layout keeps the
   patches in the middle, the program's console beneath them, and what the agent
   is doing (plus the working directory) in a rail on the right. */
.pg-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; margin-right: 6px; }
.pg-switch-btn { border: 0; background: transparent; color: var(--ink-dim); cursor: pointer;
  padding: 4px 11px; font-size: 11.5px; font-weight: 600; }
.pg-switch-btn.active { background: var(--accent-soft); color: var(--accent); }
.pg-switch-btn:hover:not(.active) { background: var(--line); color: var(--ink); }

.pg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; max-width: 1360px;
  margin: 0 auto 12px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg-3); }
.pg-toolbar .btn[disabled] { opacity: .4; pointer-events: none; }
.pg-sep { width: 1px; height: 17px; background: var(--line-2); margin: 0 3px; }
.pg-busy { font-size: 11px; color: var(--accent); }
.pg-busy::after { content: '▋'; animation: blink 1s steps(2) infinite; }
.pg-warn { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--warn);
  border: 1px solid rgba(210,153,34,.4); border-radius: 999px; padding: 1px 7px; }

.pg-mode .nb-title-row, .pg-mode .nb-cells { max-width: none; }
.pg-split { display: grid; grid-template-columns: minmax(0,1fr) 320px; gap: 16px;
  max-width: 1360px; margin: 0 auto; align-items: start; }
.pg-main { min-width: 0; }

/* One patch's generated Python, line-numbered against the assembled program so
   the numbers match the traceback the repair agent is given. */
.pg-cell { border-top: 1px solid var(--line); background: var(--bg); }
.pg-cell-head { display: flex; align-items: center; gap: 8px; padding: 5px 12px;
  border-bottom: 1px solid var(--line); background: var(--bg-3); }
.pg-badge { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-dim);
  border: 1px solid var(--line-2); border-radius: 999px; padding: 1px 7px; }
.pg-cell.status-ready .pg-badge { color: var(--good); border-color: rgba(63,185,80,.45); }
.pg-cell.status-error .pg-badge, .pg-cell.status-stale .pg-badge { color: var(--warn); border-color: rgba(210,153,34,.45); }
.pg-cell.status-generating .pg-badge { color: var(--accent); border-color: var(--accent); }
.pg-empty { padding: 11px 14px; margin: 0; }
.pg-code { margin: 0; padding: 8px 0; list-style: decimal; background: var(--bg);
  font: 11.5px/1.55 "Cascadia Code", Consolas, monospace; overflow-x: auto; }
.pg-code li { padding: 0 12px 0 4px; white-space: pre; color: var(--ink);
  list-style-position: outside; margin-left: 52px; }
.pg-code li::marker { color: var(--ink-dim); font-size: 10px; }
.pg-code li.pg-active { background: var(--accent-soft); }
.pg-code li.pg-paused { background: rgba(210,153,34,.18); box-shadow: inset 2px 0 0 var(--warn); }
.pg-error { margin: 0; padding: 8px 13px; color: var(--bad); background: rgba(248,81,73,.08);
  border-top: 1px solid var(--line); font-size: 12px; }
.nb-cell.pg-executing .nb-cell-main { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* The program's real stdout/stderr, plus a box for programs that ask for input. */
.pg-console { margin-top: 14px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--bg-2); overflow: hidden; }
.pg-console-head { display: flex; align-items: center; gap: 9px; padding: 6px 11px;
  border-bottom: 1px solid var(--line); background: var(--bg-3); font-size: 12px; }
.pg-exit { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; padding: 1px 7px;
  border-radius: 999px; }
.pg-exit.ok { color: var(--good); border: 1px solid rgba(63,185,80,.45); }
.pg-exit.bad { color: var(--bad); border: 1px solid rgba(248,81,73,.45); }
.pg-console-body { margin: 0; padding: 11px 13px; max-height: 300px; min-height: 66px; overflow: auto;
  font: 11.5px/1.55 "Cascadia Code", Consolas, monospace; white-space: pre-wrap; word-break: break-word;
  color: var(--ink); }
.pg-stdin { display: flex; gap: 7px; padding: 7px 11px; border-top: 1px solid var(--line); }
.pg-stdin-input { flex: 1; min-width: 0; }

.pg-rail { display: grid; gap: 12px; position: sticky; top: 0; }
.pg-panel { border: 1px solid var(--line); border-radius: 9px; background: var(--bg-2); padding: 10px 12px; }
.pg-panel h4 { margin: 0 0 7px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-dim); }
.pg-panel h4 + h4 { margin-top: 12px; }
.pg-panel .btn { margin-top: 7px; }
.pg-revise { width: 100%; resize: vertical; }
.pg-activity { list-style: none; margin: 0; padding: 0; max-height: 230px; overflow: auto; font-size: 11.5px; }
.pg-activity li { padding: 3px 0; border-bottom: 1px solid var(--line); line-height: 1.45; color: var(--ink-dim); }
.pg-activity li b { color: var(--ink); text-transform: uppercase; font-size: 9.5px; letter-spacing: .05em;
  margin-right: 5px; }
.pg-activity li:last-child { border-bottom: 0; }
.pg-tree, .pg-changes { list-style: none; margin: 0; padding: 0; max-height: 210px; overflow: auto; font-size: 11.5px; }
.pg-tree li { padding: 2px 0; display: flex; gap: 6px; align-items: baseline; cursor: pointer; border-radius: 4px; }
.pg-tree li.pg-dir { cursor: default; color: var(--ink-dim); }
.pg-tree li:not(.pg-dir):hover { background: var(--line); }
.pg-changes li { padding: 3px 0; border-bottom: 1px solid var(--line); color: var(--ink-dim); }
.pg-changes li b { font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; margin-right: 5px; }
.pg-changes li.chg-created b { color: var(--good); }
.pg-changes li.chg-modified b { color: var(--accent); }
.pg-changes li.chg-deleted b { color: var(--bad); }

.pg-modal-note { margin: -4px 0 9px; word-break: break-all; }
.pg-modal-text { display: block; width: 100%; max-height: 52vh; min-height: 240px; overflow: auto;
  margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--bg); color: var(--ink); white-space: pre; resize: vertical;
  font: 11.5px/1.55 "Cascadia Code", Consolas, monospace; }
.pg-modal-secondary { margin-bottom: 10px; font-size: 11.5px; color: var(--ink-dim); }
.pg-modal-secondary > summary { cursor: pointer; user-select: none; margin-bottom: 7px; }
.pg-modal-secondary .pg-modal-text { min-height: 160px; }

@media (max-width: 1100px) {
  .pg-split { grid-template-columns: minmax(0,1fr); }
  .pg-rail { position: static; }
}

/* Every produced file is downloadable: a row action per file, a .zip for all. */
.pg-tree li { gap: 6px; }
.pg-file-name { cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-tree li .dim { flex-shrink: 0; }
.pg-dl { flex-shrink: 0; margin-left: 0; padding: 0 4px; border-radius: 4px; color: var(--ink-dim);
  text-decoration: none; opacity: 0; transition: opacity .12s; }
.pg-tree li:hover .pg-dl, .pg-dl:focus { opacity: 1; }
.pg-dl:hover { color: var(--accent); background: var(--line); }
.pg-panel h4 { display: flex; align-items: center; gap: 8px; }
.pg-zip { margin: 0 0 0 auto; text-transform: none; letter-spacing: 0; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }

/* ---------- Explorer: project files ---------- */
/* The Project Manager panel holds the project's entities; this one holds its
   files - uploads, each patchbook's working folder, and exports. */
.sidebar-title { display: flex; align-items: center; gap: 2px; }
.file-hint { padding: 0 10px 8px; margin: 0; line-height: 1.45; }
.file-scroll { flex: 1; min-height: 0; overflow: auto; padding: 0 4px 14px; }
.file-row { display: flex; align-items: center; gap: 7px; padding: 3px 6px; border-radius: 5px;
  cursor: default; user-select: none; white-space: nowrap; font-size: 12.5px; color: var(--ink); }
.file-row:hover { background: var(--bg-3); }
.file-row.selected { background: var(--accent-soft); color: var(--accent); }
.file-row.drop-target { outline: 1px dashed var(--accent); outline-offset: -1px; background: var(--accent-soft); }
.file-row.is-dir .file-name { font-weight: 600; }
.file-icon { flex-shrink: 0; font-size: 11px; letter-spacing: -1px; }
.file-name { overflow: hidden; text-overflow: ellipsis; }
.file-size { margin-left: auto; flex-shrink: 0; padding-left: 8px; }

/* ---------- Context menu ---------- */
.ctx-backdrop { position: fixed; inset: 0; z-index: 900; }
.ctx-menu { position: fixed; z-index: 901; min-width: 208px; padding: 5px; border: 1px solid var(--line-2);
  border-radius: 8px; background: var(--bg-2); box-shadow: 0 10px 34px rgba(0,0,0,.45); }
.ctx-item { display: block; width: 100%; text-align: left; border: 0; border-radius: 5px;
  background: transparent; color: var(--ink); padding: 6px 10px; font-size: 12.5px; cursor: pointer; }
.ctx-item:hover:not([disabled]) { background: var(--accent-soft); color: var(--accent); }
.ctx-item[disabled] { opacity: .38; cursor: default; }
.ctx-item.danger:hover:not([disabled]) { background: rgba(248,81,73,.14); color: var(--bad); }
.ctx-sep { height: 1px; margin: 4px 6px; background: var(--line); }

/* ---------- Drop-to-add overlay ---------- */
.drop-overlay { position: fixed; inset: 0; z-index: 950; display: grid; place-items: center;
  background: rgba(0,0,0,.45); backdrop-filter: blur(2px); pointer-events: none; }
.drop-overlay.hidden { display: none; }
.drop-panel { padding: 30px 46px; border: 2px dashed var(--accent); border-radius: 14px;
  background: var(--bg-2); text-align: center; box-shadow: 0 16px 50px rgba(0,0,0,.45); }
.drop-icon { font-size: 30px; color: var(--accent); }
.drop-title { margin-top: 8px; font-size: 15px; font-weight: 700; color: var(--ink); }
.drop-note { margin-top: 4px; font-size: 12px; color: var(--ink-dim); }
body.theme-light .ctx-menu { box-shadow: 0 10px 30px rgba(0,0,0,.16); }
body.theme-light .drop-overlay { background: rgba(255,255,255,.55); }

/* The working-directory listing is a file list: everything starts at the left
   edge and flows left to right, with the size following the name rather than
   being pushed to the far edge. */
.pg-files, .pg-tree, .pg-changes { text-align: left; direction: ltr; }
.pg-tree li { justify-content: flex-start; align-items: center; padding: 2px 4px; }
.pg-tree li > * { margin-left: 0; }
.pg-tree li .pg-file-name { flex: 0 1 auto; min-width: 0; }
.pg-tree li .dim { margin-left: 6px; }
.pg-tree li .pg-dl { margin-left: 4px; }
.pg-changes li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px; }
.pg-changes li .dim { margin-left: 0; }
