/* ============================================================
   LOCAL BENCH — 「纸与墨」工业工作台
   设计系统：OKLCH 色彩 · 4pt 间距 · 固定字号阶梯 · 指数缓动
   ============================================================ */

:root {
  color-scheme: light;

  /* 原始色板 —— 暖纸中性 + 陶土朱红强调 */
  --paper:          oklch(97.2% 0.009 82);
  --surface:        oklch(99.3% 0.004 82);
  --surface-sunk:   oklch(95.4% 0.010 82);
  --surface-hover:  oklch(96.2% 0.011 80);
  --ink:            oklch(23% 0.018 62);
  --ink-2:          oklch(42% 0.014 65);
  --ink-3:          oklch(57% 0.012 68);
  --line:           oklch(89.5% 0.009 78);
  --line-strong:    oklch(82% 0.012 75);
  --accent:         oklch(56% 0.175 38);
  --accent-hover:   oklch(49% 0.170 38);
  --accent-soft:    oklch(93.5% 0.035 40);
  --on-accent:      oklch(98.5% 0.007 80);
  --ok:             oklch(52% 0.125 155);
  --ok-soft:        oklch(93.5% 0.045 155);
  --err:            oklch(54% 0.190 25);
  --err-soft:       oklch(94% 0.038 25);
  --warn:           oklch(66% 0.135 72);
  --warn-soft:      oklch(94% 0.045 78);
  --info:           oklch(53% 0.105 250);
  --info-soft:      oklch(94% 0.030 250);

  /* 日志控制台 —— 冷墨，与主区形成材质对比 */
  --console-bg:     oklch(19.5% 0.014 255);
  --console-head:   oklch(22.5% 0.014 255);
  --console-ink:    oklch(90% 0.008 255);
  --console-dim:    oklch(66% 0.012 255);
  --console-faint:  oklch(48% 0.012 255);
  --console-line:   oklch(29% 0.012 255);
  --console-err:    oklch(72% 0.145 22);
  --console-warn:   oklch(81% 0.115 80);
  --console-sys:    oklch(74% 0.075 235);
  --console-ok:     oklch(76% 0.115 155);

  /* 语义层 */
  --bg: var(--paper);
  --panel: var(--surface);
  --text: var(--ink);
  --text-2: var(--ink-2);
  --text-3: var(--ink-3);
  --border: var(--line);
  --focus: var(--accent);

  /* 间距 · 4pt */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px;

  --r-sm: 4px; --r-md: 6px; --r-lg: 10px;
  --shadow-sm: 0 1px 2px oklch(30% 0.02 60 / 0.06);
  --shadow-md: 0 8px 28px oklch(28% 0.02 60 / 0.12), 0 1px 3px oklch(28% 0.02 60 / 0.08);

  --font-ui: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "Cascadia Code", "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 200ms;
  --console-h: 308px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:        oklch(17% 0.012 75);
  --panel:     oklch(20.5% 0.012 75);
  --surface-sunk:  oklch(15.5% 0.012 75);
  --surface-hover: oklch(24% 0.014 75);
  --text:      oklch(93% 0.010 80);
  --text-2:    oklch(76% 0.012 80);
  --text-3:    oklch(63% 0.012 80);
  --border:    oklch(29% 0.012 75);
  --line-strong: oklch(37% 0.014 75);
  --accent:    oklch(66% 0.150 38);
  --accent-hover: oklch(72% 0.145 38);
  --accent-soft: oklch(29% 0.055 38);
  --on-accent: oklch(16% 0.02 40);
  --ok:        oklch(70% 0.120 155);
  --ok-soft:   oklch(27% 0.045 155);
  --err:       oklch(70% 0.155 25);
  --err-soft:  oklch(28% 0.050 25);
  --warn:      oklch(78% 0.115 78);
  --warn-soft: oklch(30% 0.050 78);
  --info:      oklch(72% 0.095 250);
  --info-soft: oklch(28% 0.040 250);
  --shadow-sm: 0 1px 2px oklch(0% 0 0 / 0.25);
  --shadow-md: 0 12px 34px oklch(0% 0 0 / 0.45);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-kerning: normal;
  font-variant-numeric: tabular-nums;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
input, textarea, select { outline: none; }
::selection { background: var(--accent-soft); color: var(--text); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; }

.eyebrow {
  font-size: 10px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-3);
}

/* ---------------- Titlebar ---------------- */
.app { height: 100vh; display: grid; grid-template-rows: 58px minmax(0, 1fr); }

.titlebar {
  display: flex; align-items: center; gap: var(--s5);
  padding: 0 var(--s5) 0 var(--s4);
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  -webkit-app-region: drag;
  user-select: none;
}
.titlebar > * { -webkit-app-region: no-drag; }

.brand { display: flex; align-items: center; gap: 10px; min-width: 292px; }
.brand-mark { width: 28px; height: 28px; flex: none; }
.brand-word {
  font-size: 14px; font-weight: 800; letter-spacing: .09em;
  color: var(--text); white-space: nowrap;
}
.brand-word b { color: var(--accent); font-weight: 800; }
.brand-sub {
  font-size: 11px; color: var(--text-3); padding-left: 10px;
  border-left: 1px solid var(--border); white-space: nowrap;
}

.global-search {
  display: flex; align-items: center; gap: var(--s2);
  flex: 1; max-width: 420px; height: 34px; padding: 0 10px;
  background: var(--surface-sunk); border: 1px solid transparent;
  border-radius: var(--r-md); transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.global-search:focus-within { border-color: var(--accent); background: var(--panel); }
.global-search svg { width: 15px; height: 15px; stroke: var(--text-3); stroke-width: 1.7; stroke-linecap: round; flex: none; }
.global-search input { flex: 1; min-width: 0; border: none; background: none; font-size: 13px; }
.global-search input::placeholder { color: var(--text-3); opacity: 1; }
.global-search kbd {
  font: 11px var(--font-mono); color: var(--text-3);
  border: 1px solid var(--line-strong); border-radius: 3px;
  padding: 1px 5px; line-height: 1.4;
}

.titlebar-right { display: flex; align-items: center; gap: var(--s2); margin-left: auto; }
.demo-badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border: 1px dashed var(--warn); border-radius: var(--r-sm);
  background: var(--warn-soft); color: var(--warn);
  font-size: 10px; font-weight: 700; letter-spacing: .08em; white-space: nowrap;
}
.demo-badge[hidden] { display: none; }

.runtime-chip {
  display: flex; align-items: center; gap: 7px; height: 28px; padding: 0 11px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  background: var(--surface-sunk); border: 1px solid var(--border); border-radius: 999px;
  white-space: nowrap;
}
.runtime-chip.has-running { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.has-running .pulse { background: var(--ok); animation: breathe 2.4s var(--ease) infinite; }
@keyframes breathe { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--ok-soft); } 50% { opacity: .65; box-shadow: 0 0 0 4px transparent; } }

.icon-btn {
  display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: var(--r-md); color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.tiny { width: 22px; height: 22px; }
.icon-btn.tiny svg { width: 14px; height: 14px; }

.win-controls { display: none; gap: 2px; margin-left: var(--s2); padding-left: var(--s2); border-left: 1px solid var(--border); }
body[data-mode="electron"] .win-controls { display: flex; }
.win-controls button {
  width: 30px; height: 28px; border-radius: var(--r-sm); color: var(--text-2);
  font-size: 15px; line-height: 1; transition: background var(--dur) var(--ease);
}
.win-controls button:hover { background: var(--surface-hover); color: var(--text); }
.win-controls .win-close:hover { background: var(--err); color: var(--on-accent); }

/* ---------------- Shell / Sidebar ---------------- */
.shell { display: grid; grid-template-columns: 226px minmax(0, 1fr); min-height: 0; }

.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  padding: var(--s5) var(--s3) var(--s4);
  border-right: 1px solid var(--border);
  background: var(--surface-sunk);
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--s2) var(--s3); }
.cat-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; }
.cat-item {
  position: relative; display: flex; align-items: center; gap: var(--s2);
  width: 100%; height: 34px; padding: 0 var(--s2) 0 11px;
  border-radius: var(--r-md); color: var(--text-2); font-size: 13px; text-align: left;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.cat-item:hover { background: var(--surface-hover); color: var(--text); }
.cat-item.is-active { background: var(--panel); color: var(--text); font-weight: 650; box-shadow: var(--shadow-sm); }
.cat-item.is-active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 2px 2px 0; background: var(--accent);
}
.cat-swatch { width: 8px; height: 8px; border-radius: 2px; flex: none; background: var(--text-3); }
.cat-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count { font: 11px var(--font-mono); color: var(--text-3); }
.cat-actions { display: none; gap: 1px; }
.cat-item:hover .cat-actions, .cat-item:focus-within .cat-actions { display: flex; }
.cat-item:hover .cat-count { display: none; }
.cat-actions button { width: 20px; height: 22px; border-radius: 3px; color: var(--text-3); font-size: 13px; line-height: 1; }
.cat-actions button svg { width: 13px; height: 13px; }
.cat-actions button:hover { background: var(--line); color: var(--text); }
.cat-actions button.danger:hover { color: var(--err); }

.side-rule { height: 1px; margin: var(--s5) var(--s2) var(--s4); background: var(--border); }
.stats { display: flex; flex-direction: column; gap: 2px; padding: 0 var(--s2); }
.stat-row { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-2); padding: 4px 0; }
.stat-row b { font: 600 15px var(--font-mono); color: var(--text); }
.stat-row .stat-dot { width: 6px; height: 6px; border-radius: 50%; margin-right: 7px; display: inline-block; }
.side-bottom { margin-top: auto; padding: var(--s4) var(--s2) 0; }
.side-link {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: 9px 10px; font-size: 12px; color: var(--text-2);
  border: 1px dashed var(--line-strong); border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.side-link:hover { border-color: var(--accent); color: var(--accent); background: var(--panel); }
.storage { display: flex; align-items: center; gap: 7px; padding: var(--s4) 10px 0; font-size: 11px; color: var(--text-3); }
.storage-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }

/* ---------------- Main / Workspace ---------------- */
.main { display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; container-type: inline-size; }
.workspace { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }

.workspace-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s5);
  padding: var(--s5) var(--s6) var(--s4);
}
.view-heading h1 { margin: 3px 0 2px; font-size: 25px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.view-heading p { margin: 0; font-size: 12.5px; color: var(--text-3); }
.toolbar { display: flex; align-items: center; gap: var(--s2); flex: none; }

.segmented, .stream-tabs {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-sunk); border: 1px solid var(--border); border-radius: var(--r-md);
}
.segmented button, .stream-tabs button {
  padding: 5px 11px; font-size: 12px; color: var(--text-3); border-radius: var(--r-sm);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  white-space: nowrap;
}
.segmented button:hover, .stream-tabs button:hover { color: var(--text); }
.segmented button.is-active, .stream-tabs button.is-active {
  background: var(--panel); color: var(--text); font-weight: 650; box-shadow: var(--shadow-sm);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; padding: 0 14px; border-radius: var(--r-md);
  font-size: 12.5px; font-weight: 650; white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
              border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-outline { border: 1px solid var(--line-strong); color: var(--text-2); background: var(--panel); }
.btn-outline:hover { border-color: var(--text-3); color: var(--text); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-danger { color: var(--err); border: 1px solid var(--err-soft); }
.btn-danger:hover { background: var(--err-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

/* 卡片区上方的轻量结果条 */
.list-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  min-height: 34px; padding: 0 var(--s6);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  background: var(--surface-sunk);
}
.list-head .hint { margin: 0; }

.project-list {
  flex: 1; min-height: 0; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  /* 卡片内部是列向 flex，默认 auto 行高会按「首行内容」估算固有高度（176px），
     导致 195px 的实际内容溢出、页脚压到下边框上；显式 max-content 才能量准 */
  grid-auto-rows: max-content;
  gap: var(--s3); align-content: start;
  padding: var(--s4) var(--s6) var(--s5);
}

/* 卡片：小圆角 + 1px 边框 + 顶部状态条，避免「大圆角 + 重阴影」的通用卡片感 */
.project-row {
  position: relative; display: flex; flex-direction: column; gap: 7px;
  min-height: 176px; padding: var(--s4);
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--panel); cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease),
              transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.project-row:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.project-row.is-selected { border-color: var(--accent); background: var(--accent-soft); }
.project-row::before {
  content: ""; position: absolute; left: -1px; right: -1px; top: -1px; height: 3px;
  border-radius: var(--r-md) var(--r-md) 0 0;
  background: var(--border); transition: background var(--dur) var(--ease);
}
.project-row[data-status="running"]::before { background: var(--ok); }
.project-row[data-status="starting"]::before { background: var(--warn); }
.project-row[data-status="failed"]::before { background: var(--err); }
.project-row.is-selected::before { background: var(--accent); }

.card-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.prj-index { font: 11px var(--font-mono); color: var(--text-3); flex: none; }
.card-top .prj-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-top .status-badge { flex: none; margin-left: auto; }
.card-desc {
  flex: none; font-size: 12px; color: var(--text-2); line-height: 1.55; min-height: 2.9em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { flex: none; display: flex; align-items: center; gap: 7px; min-width: 0; }
.card-meta .cat-tag { flex: none; }
.prj-command { font: 10.5px var(--font-mono); color: var(--text-3); background: var(--surface-sunk); padding: 2px 6px; border-radius: 3px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* overflow:hidden 会让 flex item 的 min-height:auto 解析为 0，必须显式禁止收缩 */
.prj-path { flex: none; font: 10.5px var(--font-mono); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cat-tag {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 3px 9px; border-radius: 3px; font-size: 11.5px; font-weight: 600;
  background: var(--tag-bg, var(--surface-sunk)); color: var(--tag-ink, var(--text-2));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cat-tag[data-tone="clay"]   { --tag-bg: var(--accent-soft); --tag-ink: var(--accent); }
.cat-tag[data-tone="indigo"] { --tag-bg: var(--info-soft);   --tag-ink: var(--info); }
.cat-tag[data-tone="sage"]   { --tag-bg: var(--ok-soft);     --tag-ink: var(--ok); }
.cat-tag[data-tone="ochre"]  { --tag-bg: var(--warn-soft);   --tag-ink: var(--warn); }
.cat-tag[data-tone="slate"]  { --tag-bg: var(--surface-sunk);--tag-ink: var(--text-2); }

.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 650; white-space: nowrap;
}
.status-badge .s-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.status-badge[data-status="running"] { color: var(--ok); }
.status-badge[data-status="running"] .s-dot { background: var(--ok); animation: breathe 2.4s var(--ease) infinite; }
.status-badge[data-status="starting"] { color: var(--warn); }
.status-badge[data-status="starting"] .s-dot { background: var(--warn); }
.status-badge[data-status="failed"] { color: var(--err); }
.status-badge[data-status="failed"] .s-dot { background: var(--err); }
.status-badge[data-status="stopped"] { color: var(--text-3); }
.status-badge[data-status="stopped"] .s-dot { background: var(--text-3); }

.card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: auto; padding-top: var(--s3); border-top: 1px solid var(--border);
}
.last-start { font: 11.5px var(--font-mono); color: var(--text-2); white-space: nowrap; }
.card-foot .last-start small { display: inline; margin-left: 6px; font: 10px var(--font-ui); color: var(--text-3); }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.row-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 27px; padding: 0 9px; border-radius: var(--r-sm);
  font-size: 11.5px; font-weight: 650; color: var(--text-2);
  border: 1px solid var(--line-strong); background: var(--panel);
  transition: all var(--dur) var(--ease);
}
.row-btn:hover { border-color: var(--text-3); color: var(--text); }
.row-btn.run { color: var(--accent); border-color: var(--accent); }
.row-btn.run:hover { background: var(--accent); color: var(--on-accent); }
.row-btn.stop { color: var(--err); border-color: var(--line-strong); }
.row-btn.stop:hover { background: var(--err-soft); border-color: var(--err); }
.row-btn:disabled { opacity: .4; cursor: not-allowed; }
.row-btn.icon { width: 27px; padding: 0; }
.row-btn svg { width: 14px; height: 14px; flex: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.spin { animation: spin 900ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@container (max-width: 1000px) {
  .project-list { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); padding-inline: var(--s4); }
  .list-head { padding-inline: var(--s4); }
}
@container (max-width: 720px) {
  .project-list { grid-template-columns: 1fr; }
  .toolbar .segmented { display: none; }
}

/* ---------------- Empty state ---------------- */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: var(--s6); }
.empty[hidden] { display: none; }
.empty svg { width: 120px; height: 84px; margin-bottom: var(--s5); }
.empty svg rect, .empty svg circle { fill: var(--surface-sunk); stroke: var(--line-strong); stroke-width: 1.5; }
.empty svg .e-b { fill: var(--panel); }
.empty svg .e-c { fill: var(--accent-soft); stroke: var(--accent); }
.empty svg .e-line { fill: none; stroke: var(--text-3); stroke-width: 2; stroke-linecap: round; }
.empty svg .e-c + .e-line { stroke: var(--accent); }
.empty h2 { margin: 0 0 6px; font-size: 17px; }
.empty p { max-width: 46ch; margin: 0; font-size: 12.5px; color: var(--text-3); line-height: 1.7; }
.empty-actions { display: flex; gap: var(--s2); margin-top: var(--s5); }

/* ---------------- Console ---------------- */
.console {
  height: var(--console-h); min-height: 0; display: grid;
  grid-template-rows: 44px minmax(0, 1fr) 26px;
  background: var(--console-bg); color: var(--console-ink);
  border-top: 1px solid var(--console-line);
  transition: height 280ms var(--ease);
  overflow: hidden;
}
body.console-collapsed .console { height: 44px; }
body.console-collapsed .console-body, body.console-collapsed .console-foot { visibility: hidden; }
body.console-collapsed .collapse-btn { transform: rotate(180deg); }

.console-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  padding: 0 var(--s4) 0 var(--s5); background: var(--console-head);
  border-bottom: 1px solid var(--console-line);
}
.console-id { display: flex; align-items: center; gap: 9px; min-width: 0; }
.console-glyph { color: var(--accent); font-size: 15px; }
.console-title { font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--console-dim); }
.console-target {
  font-size: 12px; font-weight: 600; color: var(--console-ink);
  padding-left: 10px; border-left: 1px solid var(--console-line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px;
}
.console-state { font-size: 11px; font-weight: 650; }
.console-state[data-status="running"] { color: var(--console-ok); }
.console-state[data-status="failed"] { color: var(--console-err); }
.console-state[data-status="starting"] { color: var(--console-sys); }

.console-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.stream-tabs { background: transparent; border-color: var(--console-line); }
.stream-tabs button { color: var(--console-faint); font-size: 11px; padding: 4px 9px; }
.stream-tabs button:hover { color: var(--console-ink); }
.stream-tabs button.is-active { background: var(--console-line); color: var(--console-ink); box-shadow: none; }
.log-search {
  display: flex; align-items: center; gap: 5px; height: 26px; width: 148px; padding: 0 7px;
  border: 1px solid var(--console-line); border-radius: var(--r-sm);
  transition: border-color var(--dur) var(--ease);
}
.log-search:focus-within { border-color: var(--accent); }
.log-search svg { width: 12px; height: 12px; stroke: var(--console-faint); stroke-width: 1.8; stroke-linecap: round; flex: none; }
.log-search input { flex: 1; min-width: 0; border: none; background: none; color: var(--console-ink); font-size: 11.5px; }
.log-search input::placeholder { color: var(--console-faint); opacity: 1; }
.console-btn {
  height: 26px; padding: 0 9px; border-radius: var(--r-sm); font-size: 11px; font-weight: 600;
  color: var(--console-dim); border: 1px solid transparent;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  white-space: nowrap;
}
.console-btn:hover { background: var(--console-line); color: var(--console-ink); }
.console-btn.is-on { color: var(--console-ok); background: oklch(28% 0.03 155); }
.console-btn.is-paused { color: var(--console-sys); background: oklch(28% 0.035 235); }
.console-btn.collapse-btn { width: 26px; padding: 0; font-size: 15px; line-height: 1; transition: transform var(--dur) var(--ease); }

.console-body {
  overflow: auto; padding: 8px 0 14px;
  font: 12px/1.65 var(--font-mono); font-variant-ligatures: none;
  scroll-behavior: smooth;
}
.log-line {
  display: grid; grid-template-columns: 52px 70px 42px minmax(0, 1fr);
  gap: 8px; padding: 1px var(--s5) 1px var(--s4);
  animation: log-in 220ms var(--ease) both;
}
@keyframes log-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.log-line:hover { background: oklch(24% 0.014 255); }
.log-no, .log-time { color: var(--console-faint); user-select: none; }
.log-no { text-align: right; }
.log-tag { font-size: 10px; font-weight: 700; letter-spacing: .06em; color: var(--console-faint); padding-top: 1px; }
.log-text { color: var(--console-ink); white-space: pre-wrap; word-break: break-word; }
/* 级别按内容判定：stderr 里的普通 INFO 日志保持常规颜色，只有真报错才标红 */
.log-line[data-stream="system"] .log-tag { color: var(--console-sys); }
.log-line[data-stream="system"] .log-text { color: var(--console-sys); font-style: italic; }
.log-line[data-level="warn"] .log-tag { color: var(--console-warn); }
.log-line[data-level="warn"] .log-text { color: var(--console-warn); }
.log-line[data-level="error"] { background: oklch(24% 0.022 22 / .32); }
.log-line[data-level="error"] .log-tag { color: var(--console-err); }
.log-line[data-level="error"] .log-text { color: oklch(84% 0.075 22); }
.log-line mark { background: oklch(72% 0.16 85); color: oklch(20% 0.02 80); border-radius: 2px; }
.log-empty { display: grid; place-items: center; height: 100%; color: var(--console-faint); font-size: 12px; text-align: center; padding: var(--s4); }

.console-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--s5); border-top: 1px solid var(--console-line);
  font: 10.5px var(--font-mono); color: var(--console-faint);
}
#logHint { color: var(--console-sys); }

/* ---------------- Modal ---------------- */
.modal-root { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.modal-root[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: oklch(20% 0.02 60 / .46); animation: fade-in 180ms var(--ease) both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative; width: min(560px, calc(100vw - 40px)); max-height: min(760px, calc(100vh - 64px));
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-md); animation: modal-in 260ms var(--ease) both;
}
.modal.wide { width: min(760px, calc(100vw - 40px)); }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); padding: var(--s5) var(--s5) var(--s4); border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 4px 0 0; font-size: 19px; letter-spacing: -.01em; }
.modal-head p { margin: 5px 0 0; font-size: 12px; color: var(--text-3); line-height: 1.6; }
.modal-close { width: 28px; height: 28px; border-radius: var(--r-sm); color: var(--text-3); font-size: 19px; line-height: 1; flex: none; }
.modal-close:hover { background: var(--surface-hover); color: var(--text); }
.modal-body { padding: var(--s5); overflow-y: auto; min-height: 0; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5); border-top: 1px solid var(--border); background: var(--surface-sunk); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.modal-foot .foot-right { display: flex; gap: var(--s2); margin-left: auto; }

.field { margin-bottom: var(--s4); }
.field:last-child { margin-bottom: 0; }
.field-label { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.field-label .req { color: var(--accent); margin-left: 3px; }
.input, .textarea, .select {
  width: 100%; padding: 9px 11px; font-size: 13px;
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: 1; }
.input.mono, .textarea.mono { font-family: var(--font-mono); font-size: 12px; }
.textarea { resize: vertical; min-height: 68px; line-height: 1.6; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 15px) 51%, calc(100% - 10px) 51%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--s3); }
.form-grid .field-full { grid-column: 1 / -1; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }
.btn[hidden] { display: none; }
.image-field { display: flex; align-items: center; gap: var(--s3); }
.image-slot { width: 96px; height: 96px; flex: none; display: grid; place-items: center; overflow: hidden; border: 1px dashed var(--line-strong); border-radius: var(--r-md); background: var(--surface-sunk); color: var(--text-3); font-size: 12px; }
.image-slot img { width: 100%; height: 100%; object-fit: cover; }
.image-actions { display: flex; flex-direction: column; gap: var(--s2); align-items: flex-start; }
.cell-thumb { display: block; width: 34px; height: 34px; object-fit: cover; border: 1px solid var(--border); border-radius: var(--r-sm); }
.board-thumb { width: 28px; height: 28px; object-fit: cover; border: 1px solid var(--border); border-radius: var(--r-sm); vertical-align: middle; }
.input-row { display: flex; gap: var(--s2); }
.input-row .input { flex: 1; min-width: 0; }
.hint { margin-top: 6px; font-size: 11px; color: var(--text-3); line-height: 1.6; }
.inspect-note { display: flex; align-items: center; gap: 8px; margin-bottom: var(--s4); padding: 9px 11px; border-radius: var(--r-md); background: var(--info-soft); color: var(--info); font-size: 11.5px; }
.inspect-note svg { width: 15px; height: 15px; flex: none; }
.inspect-note b { font-weight: 700; }

/* 向导 / 目录浏览器 / 分析 */
.wizard-list { display: flex; flex-direction: column; gap: var(--s2); }
.wizard-item { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: var(--s3); padding: var(--s3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg); }
.wizard-item.is-off { opacity: .5; }
.wizard-item .wz-body { min-width: 0; display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.wizard-item .wz-full { grid-column: 1 / -1; }
.wizard-item .wz-path { font: 10.5px var(--font-mono); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wizard-item .input, .wizard-item .select { padding: 6px 9px; font-size: 12px; }
.wz-stack { font: 10px var(--font-mono); color: var(--info); background: var(--info-soft); padding: 1px 6px; border-radius: 3px; }
.checkbox { appearance: none; width: 16px; height: 16px; margin: 2px 0 0; border: 1.5px solid var(--line-strong); border-radius: 3px; background: var(--panel); flex: none; cursor: pointer; position: relative; }
.checkbox:checked { background: var(--accent); border-color: var(--accent); }
.checkbox:checked::after { content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid var(--on-accent); border-width: 0 2px 2px 0; transform: rotate(42deg); }

.browser-bar { display: flex; gap: var(--s2); margin-bottom: var(--s3); }
.browser-bar .input { flex: 1; }
.browser-crumbs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: var(--s3); }
.crumb { padding: 3px 8px; border-radius: 3px; background: var(--surface-sunk); color: var(--text-2); font: 11px var(--font-mono); }
.crumb:hover { background: var(--accent-soft); color: var(--accent); }
.browser-list { border: 1px solid var(--border); border-radius: var(--r-md); max-height: 300px; overflow-y: auto; }
.browser-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 11px; border-bottom: 1px solid var(--border); text-align: left; font-size: 12.5px; }
.browser-item:last-child { border-bottom: none; }
.browser-item:hover { background: var(--surface-hover); }
.browser-item .bi-icon { color: var(--accent); font-size: 14px; }
.browser-item .bi-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browser-item .bi-enter { color: var(--text-3); font-size: 11px; }
.browser-empty { padding: var(--s6); text-align: center; color: var(--text-3); font-size: 12px; }

.analysis-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); margin-bottom: var(--s5); }
.analysis-card { padding: var(--s3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg); }
.analysis-card b { display: block; font: 700 22px var(--font-mono); line-height: 1.2; }
.analysis-card span { font-size: 11px; color: var(--text-3); }
.analysis-sect { margin-bottom: var(--s4); }
.analysis-sect h3 { margin: 0 0 var(--s2); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.analysis-row { display: flex; align-items: center; gap: var(--s3); padding: 6px 0; font-size: 12px; }
.analysis-row .ar-name { width: 120px; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.analysis-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-sunk); overflow: hidden; }
.analysis-bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.analysis-row .ar-num { width: 30px; text-align: right; font: 11px var(--font-mono); color: var(--text-3); }
.categorize-bar { display: flex; align-items: center; gap: var(--s2); padding: var(--s3); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg); }
.categorize-bar .select { flex: 1; }

.cat-manage { display: flex; flex-direction: column; gap: 6px; }
.cat-manage-row { display: flex; align-items: center; gap: var(--s2); padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r-md); }
.cat-manage-row .cm-name { flex: 1; font-size: 12.5px; font-weight: 600; }
.cat-manage-row .cm-count { font: 11px var(--font-mono); color: var(--text-3); }
.tone-picker { display: flex; gap: 6px; }
.tone-dot { width: 22px; height: 22px; border-radius: 4px; border: 2px solid transparent; }
.tone-dot.is-active { border-color: var(--text); }
.tone-dot[data-tone="clay"] { background: var(--accent); }
.tone-dot[data-tone="indigo"] { background: var(--info); }
.tone-dot[data-tone="sage"] { background: var(--ok); }
.tone-dot[data-tone="ochre"] { background: var(--warn); }
.tone-dot[data-tone="slate"] { background: var(--text-3); }

.confirm-text { font-size: 13px; line-height: 1.75; color: var(--text-2); }
.confirm-text strong { color: var(--text); }
.confirm-warn { margin-top: var(--s3); padding: 10px 12px; border-radius: var(--r-md); background: var(--err-soft); color: var(--err); font-size: 11.5px; }

/* ---------------- Toasts ---------------- */
.toasts { position: fixed; right: var(--s5); bottom: var(--s5); z-index: 200; display: flex; flex-direction: column; gap: var(--s2); pointer-events: none; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; min-width: 240px; max-width: 380px;
  padding: 11px 14px; background: var(--panel); border: 1px solid var(--border);
  border-left: 3px solid var(--ok); border-radius: var(--r-md); box-shadow: var(--shadow-md);
  font-size: 12.5px; line-height: 1.5; animation: toast-in 260ms var(--ease) both;
  pointer-events: auto;
}
.toast[data-kind="error"] { border-left-color: var(--err); }
.toast[data-kind="info"] { border-left-color: var(--info); }
.toast.is-out { animation: toast-out 200ms var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }
.toast b { display: block; font-size: 12.5px; margin-bottom: 1px; }
.toast span { color: var(--text-3); font-size: 11.5px; }

@media (max-width: 1080px) {
  .brand-sub { display: none; }
  .brand { min-width: 150px; }
  .workspace-head { padding-inline: var(--s4); }
  .list-head, .project-list { padding-inline: var(--s4); }
  .console-tools .stream-tabs { display: none; }
  .global-search { max-width: 260px; }
}
@media (max-width: 880px) {
  .shell { grid-template-columns: 64px minmax(0, 1fr); }
  .sidebar { padding-inline: var(--s2); }
  .cat-label, .cat-count, .side-head .eyebrow, .stats, .side-bottom .side-link span:first-child, .storage, .side-rule { display: none; }
  .cat-item { justify-content: center; padding: 0; }
  .side-bottom .side-link { justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
