/* ============================================================
   openUBMC Studio · Power & Fan Template
   Dark theme, PTO primary blue accent (#4369ef)
   ============================================================ */

:root {
  --bg:           #101010;
  --bg-elev-1:    #161616;
  --bg-elev-2:    #1c1c1c;
  --bg-elev-3:    #262626;
  --border:       rgba(255,255,255,0.08);
  --border-strong:rgba(255,255,255,0.13);
  --text:         #e6e8ef;
  --text-mute:    #98a0b8;
  --text-dim:     #5a6280;
  --placeholder:  #343549;
  --accent:       #4369ef;
  --accent-hi:    #5a92e6;
  --accent-soft:  rgba(67,105,239,0.14);
  --ok:           #04d793;
  --warn:         #f5b454;
  --err:          #f06570;

  --radius:       6px;
  --radius-lg:    10px;

  --font-sans:    ui-sans-serif, -apple-system, "SF Pro Text", "Helvetica Neue",
                  "Segoe UI", system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono:    ui-monospace, "JetBrains Mono", "SF Mono", "Cascadia Code",
                  Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }

/* ---------- Shell chrome ---------- */
.shell { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.tabbar {
  height: 44px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  padding: 0 16px;
  background: var(--bg);
  user-select: none;
  flex-shrink: 0;
}
.tabbar .brand {
  display: flex; align-items: center; gap: 8px;
  padding-right: 16px;
  margin-right: 8px;
  border-right: 1px solid var(--border);
  color: var(--text-mute);
  font-size: 12px;
  letter-spacing: 0.02em;
}
.tabbar .brand .dot {
  width: 8px; height: 8px; border-radius: 2px;
  background: linear-gradient(135deg, #34d399 0%, #4f6ef7 100%);
}
.tabs { display: flex; align-items: stretch; }
.tab {
  display: inline-flex; align-items: center;
  padding: 0 14px;
  font-size: 12.5px;
  color: var(--text-mute);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color .12s, border-color .12s;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.tab .badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

/* ---------- Main page ---------- */
.page { flex: 1; padding: 0; display: flex; flex-direction: column; overflow: hidden; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
}
.toolbar-title { display: flex; align-items: baseline; gap: 12px; }
.toolbar-title h1 { margin: 0; font-size: 14.5px; font-weight: 600; }
.toolbar-title .meta { font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); }
.toolbar-status { display: flex; align-items: center; gap: 10px; justify-content: center; }
.toolbar-actions { display: flex; align-items: center; gap: 8px; }

.save-pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok);
  animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(52,211,153,0.6); }
  70%  { box-shadow: 0 0 0 8px rgba(52,211,153,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s, transform .04s;
  user-select: none;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-secondary {
  background: #161720;
  color: var(--text-mute);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { color: var(--text); background: var(--bg-elev-3); }
.btn-ghost {
  background: transparent;
  color: var(--text-mute);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { color: var(--text); border-color: var(--border-strong); }
.btn-green {
  background: var(--ok); color: #07120c;
  font-weight: 600;
}
.btn-green:hover:not(:disabled) { background: var(--accent-hi); }

/* ---------- Segmented control ---------- */
.seg {
  display: inline-flex;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 2px;
  font-size: 11.5px;
}
.seg button {
  background: transparent; border: 0;
  color: var(--text-mute);
  padding: 5px 11px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
}
.seg button.active { background: var(--bg-elev-3); color: var(--text); }

/* ---------- Validate button badge ---------- */
.validate-btn { position: relative; }
.validate-btn .err-count {
  position: absolute;
  top: -5px; right: -5px;
  background: var(--err); color: #fff;
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 5px; border-radius: 999px;
  border: 1px solid var(--bg);
  min-width: 16px; text-align: center;
  line-height: 1.3;
}

/* ---------- Two-pane layout ---------- */
.editor-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
@media (max-width: 1080px) {
  .editor-layout { grid-template-columns: 1fr; }
  .yaml-pane { max-height: 40vh; }
}

/* ---------- YAML pane ---------- */
.yaml-pane {
  border-right: 1px solid var(--border);
  background: var(--bg-elev-1);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.yaml-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  gap: 8px;
  flex-shrink: 0;
}
.yaml-head .lbl {
  font-size: 12px; color: var(--text-mute);
  font-weight: 600;
}
.yaml-head .lbl .filename {
  font-family: var(--font-mono);
  font-weight: 400; color: var(--text-dim);
  margin-left: 6px; font-size: 11px;
}
.yaml-head .actions { display: flex; gap: 6px; }
.yaml-head .actions button {
  background: transparent;
  color: var(--text-mute);
  border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 4px;
  font-size: 11px; cursor: pointer;
  font-family: inherit;
}
.yaml-head .actions button:hover { color: var(--text); border-color: var(--border-strong); }
.yaml-head .actions button.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}
.yaml-body {
  flex: 1; display: flex; overflow: hidden;
  background: var(--bg-elev-1);
}
.yaml-gutter {
  background: var(--bg);
  padding: 12px 8px 12px 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px; line-height: 1.7;
  text-align: right;
  user-select: none;
  border-right: 1px solid var(--border);
  overflow-y: hidden;
  min-width: 38px;
  flex-shrink: 0;
}
.yaml-code {
  flex: 1;
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--text);
  overflow: auto;
  white-space: pre;
  cursor: text;
  -webkit-user-select: text;
  margin: 0;
}
/* YAML syntax tokens */
.yaml-code .yk { color: #e6e8ef; }
.yaml-code .yv { color: #34d399; }
.yaml-code .yn { color: #f5b454; }
.yaml-code .ys { color: #f59e6b; }
.yaml-code .yc { color: #5a6280; font-style: italic; }
.yaml-code .yp { color: #6b87ff; }
.yaml-code .yb { color: #a78bfa; }
.yaml-code .fold-toggle {
  display: inline-block;
  cursor: pointer;
  color: var(--text-dim);
  font-family: var(--font-mono);
  user-select: none;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  padding: 0 5px;
  margin-right: 4px;
  font-size: 10.5px;
  line-height: 1.4;
}
.yaml-code .fold-toggle:hover {
  background: var(--bg-elev-3);
  color: var(--accent); border-color: var(--accent);
}
.yaml-code .fold-content.collapsed { display: none; }
.yaml-code .fold-summary { color: var(--text-dim); font-style: italic; }
.yaml-code .fold-summary.hidden { display: none; }

/* ---------- Form pane ---------- */
.form-pane {
  overflow-y: auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.form-pane-inner {
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
  padding: 0 22px 120px;
}

/* === Sticky header bar (step-flow + entity nav) === */
.sticky-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  margin: 0 -22px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

/* === Step flow indicator (inside sticky-bar) === */
.step-flow {
  display: flex;
  gap: 6px;
  padding: 7px 0 6px;
  font-size: 10.5px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.step-flow .arrow { color: var(--text-dim); opacity: 0.7; }
.step-hint { color: var(--text-dim); }

/* Nav toggle button */
.nav-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 11px;
  padding: 1px 7px;
  cursor: pointer;
  line-height: 1.4;
  transition: color .12s, border-color .12s, transform .2s;
  font-family: inherit;
  margin-left: 4px;
  flex-shrink: 0;
}
.nav-toggle:hover { color: var(--accent); border-color: var(--accent); }
.nav-toggle.nav-closed { transform: rotate(-90deg); }

/* === Quick-nav (entity chips, inside sticky-bar) === */
.quick-nav {
  display: grid;
  gap: 0;
  overflow: hidden;
  transition: max-height .22s ease, padding .22s ease;
  max-height: 400px;
  padding: 8px 0 6px;
}
.quick-nav.nav-collapsed {
  max-height: 0;
  padding: 0;
}
.qn-rows { display: grid; gap: 4px; }
.qn-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 10px;
  align-items: center;
  font-size: 11.5px;
}
.qn-label {
  color: var(--text-mute);
  font-family: var(--font-mono);
  display: flex; gap: 4px; align-items: baseline;
  white-space: nowrap;
}
.qn-label b { color: var(--text); font-weight: 600; }
.qn-pills { display: flex; gap: 4px; flex-wrap: wrap; }
.qn-pill {
  background: var(--bg-elev-3);
  color: var(--text);
  border: none;
  border-radius: 4px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  transition: all .1s;
  line-height: 1.4;
}
.qn-pill:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.qn-pill.warn::after {
  content: "!";
  color: var(--warn);
  margin-left: 4px;
  font-weight: 700;
}
.qn-add {
  background: var(--bg-elev-3);
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  line-height: 1.4;
  font-family: inherit;
}
.qn-add:hover { color: var(--accent); background: var(--accent-soft); }

/* === Section block === */
.section {
  margin: 18px 0 4px;
  scroll-margin-top: var(--sticky-h, 110px);
}
.section-head {
  display: flex; align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.section-head .h {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.section-head .subt {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 11.5px;
  margin-left: 6px;
  font-family: var(--font-mono);
}
.section-head .order {
  color: var(--text-mute);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-elev-3);
  padding: 3px 8px;
  border-radius: 4px;
}
.section-head .count {
  background: var(--bg-elev-3);
  color: var(--text-mute);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
}
.section-head .spacer { flex: 1; }
.section-head .add-btn {
  background: var(--bg-elev-3);
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 5px 11px;
  border-radius: 4px;
  font-size: 11.5px;
  font-family: inherit;
}
.section-head .add-btn:hover { color: var(--accent); background: var(--accent-soft); }

/* === Global config (compact grid) === */
.global-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}
.field-mini {
  display: flex; flex-direction: column; gap: 3px;
  min-width: 0;
}
.field-mini .lab {
  font-size: 11px;
  color: var(--text);
  font-family: inherit;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
}
.field-mini input, .field-mini select {
  background: var(--bg);
  border: none;
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 5px 7px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  width: 100%;
}
.field-mini input:focus, .field-mini select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* === Compact row === */
.row-list { display: flex; flex-direction: column; gap: 6px; }
.row-compact {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  scroll-margin-top: calc(var(--sticky-h, 110px) + 20px);
  transition: border-color .12s, background .12s;
  flex-wrap: wrap;
}
.row-compact:hover { border-color: var(--border-strong); }
.row-compact.active {
  border-color: var(--accent);
  background: var(--bg-elev-3);
}
.row-compact.has-issue { border-color: rgba(240,101,112,0.45); }

.row-id {
  flex: 0 0 auto;
  min-width: 32px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-mute);
  background: var(--bg-elev-3);
  padding: 6px 0;
  border-radius: 4px;
  align-self: flex-end;
  user-select: none;
}
.cell {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
  flex-shrink: 1;
}
.cell-lbl {
  font-size: 11px;
  color: var(--text);
  font-family: inherit;
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
}
/* Codename annotation (YAML key / unit) shown beside the translated label */
.cell-lbl .code, .field-mini .lab .code {
  font-style: normal;
  font-weight: 400;
  font-size: 9px;
  color: var(--text-dim);
  opacity: 0.75;
  font-family: var(--font-mono);
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
}

/* ── Segmented pill selectors (visualised enum options) ── */
.pillset { display: flex; flex-wrap: wrap; gap: 4px; }
.pill {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  font-family: inherit;
  line-height: 1.4;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.pill:hover { border-color: var(--border-strong); color: var(--text); }
.pill.on { color: #fff; font-weight: 500; background: #4b5772; border-color: #4b5772; }
.pill.p-green.on  { background: #1f9e6b; border-color: #1f9e6b; }
.pill.p-blue.on   { background: #3b82f6; border-color: #3b82f6; }
.pill.p-amber.on  { background: #c9851a; border-color: #c9851a; }
.pill.p-red.on    { background: #d6454b; border-color: #d6454b; }
.pill.p-orange.on { background: #db7632; border-color: #db7632; }
.pill.p-purple.on { background: #8257e6; border-color: #8257e6; }
.pill.p-cyan.on   { background: #0e96a6; border-color: #0e96a6; }

/* ── One-line tool intro bar ── */
.intro-bar {
  margin: 0 0 12px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev-1);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-dim);
}
.intro-bar b { color: var(--text); font-weight: 500; }
.intro-bar code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text);
  background: var(--bg-elev-3);
  padding: 0 4px;
  border-radius: 3px;
}

/* ── Section explanation line ── */
.section-desc {
  margin: -2px 0 12px;
  padding-left: 2px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
}
.section-desc b { color: var(--text); font-weight: 500; }
.cell input, .cell select {
  background: var(--bg);
  border: none;
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 5px 7px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  width: 100%;
  min-width: 0;
}
.cell input:focus, .cell select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.row-del {
  align-self: flex-end;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 4px;
  line-height: 1;
  font-size: 13px;
}
.row-del:hover { color: var(--err); background: rgba(240,101,112,0.08); }

/* === Policy row === */
.row-policy { flex-direction: column; align-items: stretch; gap: 8px; }
.row-policy .top { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.row-policy .curve-mini {
  width: 130px; height: 44px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  align-self: flex-end;
  flex-shrink: 0;
}
.row-policy .curve-mini svg { display: block; width: 100%; height: 100%; }
.row-policy .arrays {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 10px;
  padding-left: 40px;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}
@media (min-width: 1100px) {
  .row-policy .arrays { grid-template-columns: repeat(4, 1fr); }
}
.row-policy .arrays .cell input {
  font-size: 11.5px;
  font-family: var(--font-mono);
}

/* === Area row: multi-chip pickers === */
.row-area { flex-wrap: wrap; }
.chip-multi {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 5px;
  min-height: 28px;
}
.chip-multi:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.chip-multi .chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--bg-elev-3);
  color: var(--text);
  border: none;
  border-radius: 3px;
  padding: 2px 4px 2px 6px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.3;
}
.chip-multi .chip .x {
  cursor: pointer;
  color: var(--text-dim);
  margin-left: 2px;
  line-height: 1;
  padding: 0 2px;
}
.chip-multi .chip .x:hover { color: var(--err); }
.chip-multi .add-mini {
  position: relative;
  background: var(--bg-elev-3);
  border: none;
  color: var(--text-dim);
  border-radius: 3px;
  padding: 2px 7px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.3;
}
.chip-multi .add-mini:hover { color: var(--accent); border-color: var(--accent); border-style: solid; }
.chip-multi .add-menu {
  position: absolute;
  top: calc(100% + 4px); left: 0;
  background: var(--bg-elev-1);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 4px;
  z-index: 10;
  min-width: 200px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  display: none;
}
.chip-multi.menu-open .add-menu { display: block; }
.chip-multi .add-menu .opt {
  padding: 5px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  display: flex; justify-content: space-between;
  align-items: baseline;
  gap: 6px;
}
.chip-multi .add-menu .opt:hover { background: var(--bg-elev-3); }
.chip-multi .add-menu .opt.disabled { color: var(--text-dim); cursor: not-allowed; }
.chip-multi .add-menu .opt .meta {
  color: var(--text-dim); font-size: 10.5px; font-family: var(--font-mono);
}

/* === Server diagram === */
.server-diagram {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
}
@media (max-width: 720px) { .server-diagram { grid-template-columns: 1fr; } }
.server-svg-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  min-width: 280px;
}
.server-svg-wrap svg { display: block; width: 100%; height: auto; max-width: 380px; margin: 0 auto; }
.server-side { font-size: 11.5px; color: var(--text-mute); }
.server-side .lbl {
  font-size: 10.5px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.server-side .legend-row { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.server-side .legend-row .sw {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
}
.server-side .hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
  line-height: 1.5;
}
/* SVG elements */
.sd-chassis { fill: var(--bg-elev-1); stroke: var(--border-strong); stroke-width: 1; }
.sd-hw { fill: #161620; stroke: var(--border); stroke-width: 0.5; }
.sd-hw-label { font-family: var(--font-mono); font-size: 8px; fill: var(--text-dim); text-anchor: middle; }
.sd-zone-label { font-family: var(--font-mono); font-size: 7px; fill: var(--text-dim); text-anchor: middle; }
.sd-fan {
  fill: #1e1f2e; stroke: #2a2b42; stroke-width: 1;
  cursor: pointer;
  transition: fill .15s, stroke .15s;
}
.sd-fan:hover { stroke: var(--accent); }
.sd-fan.in-area { fill: var(--accent); stroke: #2da280; }
.sd-fan.other-area { fill: rgba(52,211,153,0.25); stroke: rgba(52,211,153,0.4); }
.sd-fan.orphan { fill: rgba(240,101,112,0.18); stroke: rgba(240,101,112,0.5); }
.sd-fan-id {
  font-family: var(--font-mono); font-size: 8px;
  font-weight: 700; text-anchor: middle; pointer-events: none;
  fill: var(--text-mute);
}
.sd-fan.in-area + .sd-fan-id { fill: #07120c; }
.sd-fan-name {
  font-family: var(--font-mono); font-size: 7.5px; fill: var(--text-dim);
  text-anchor: middle; pointer-events: none;
}
.sd-fan-name.active { fill: var(--accent); }
.fan-group { cursor: pointer; }

/* === CSR drawer === */
.csr-drawer {
  position: fixed;
  left: 420px; right: 0; bottom: 0;
  height: 44px;
  background: var(--bg-elev-1);
  border-top: 1px solid var(--border);
  transition: height .25s cubic-bezier(.4,0,.2,1);
  z-index: 20;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.csr-drawer.open { height: 380px; }
@media (max-width: 1080px) { .csr-drawer { left: 0; } }

.csr-handle {
  height: 44px;
  padding: 0 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  background: var(--bg-elev-1);
  flex-shrink: 0;
}
.csr-handle:hover { background: var(--bg-elev-2); }
.csr-handle .ttl {
  font-size: 12.5px; font-weight: 600;
  color: var(--text);
}
.csr-handle .ttl-meta {
  font-size: 11px; color: var(--text-dim);
  font-family: var(--font-mono); margin-left: 8px;
}
.csr-handle .center { display: flex; align-items: center; gap: 8px; justify-content: center; }
.csr-handle .right { display: flex; gap: 6px; align-items: center; }
.csr-handle .caret-up { color: var(--text-dim); transition: transform .2s; }
.csr-drawer.open .csr-handle .caret-up { transform: rotate(180deg); }

.csr-body {
  flex: 1; overflow: auto;
  padding: 12px 18px 18px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.csr-code {
  background: var(--bg-elev-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  color: var(--text);
  white-space: pre;
  overflow: auto;
  margin: 0;
}
.csr-code .ck { color: #6b87ff; }
.csr-code .cv { color: #34d399; }
.csr-code .cs { color: #f59e6b; }
.csr-code .cn { color: #f5b454; }

/* === Error popover === */
.err-popover-wrap { position: relative; }
.err-popover {
  position: absolute;
  top: calc(100% + 6px); right: 0;
  width: 360px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--bg-elev-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 8px;
  z-index: 30;
  box-shadow: 0 16px 40px rgba(0,0,0,0.6);
  display: none;
}
.err-popover.open { display: block; }
.err-popover .err-item {
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  display: grid; gap: 4px;
}
.err-popover .err-item:hover { background: var(--bg-elev-2); }
.err-popover .err-item .where {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-mute);
}
.err-popover .err-item.severity-warn .where { color: var(--warn); }
.err-popover .err-item.severity-error .where { color: var(--err); }
.err-popover .err-item .msg { color: var(--text); }
.err-popover .err-item .sev {
  font-size: 10px; color: var(--text-dim); font-family: var(--font-mono);
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: 60px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-elev-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0,0,0,0.55);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* === Curve expanded chart === */
.curve-expanded {
  padding: 10px 0 6px 40px;
  border-top: 1px dashed var(--border);
  margin-top: 4px;
  overflow: hidden;
}
.btn-curve-toggle {
  align-self: flex-end;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 3px;
  padding: 4px 9px;
  font-size: 10.5px;
  cursor: pointer;
  font-family: var(--font-mono);
  white-space: nowrap;
  line-height: 1.3;
}
.btn-curve-toggle:hover { color: var(--accent); border-color: var(--accent); }
.btn-curve-toggle.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* === Scrollbars === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a3b5a; }
::-webkit-scrollbar-track { background: transparent; }
