:root {
  --bg0: #14171c;
  --bg1: #1b2027;
  --panel: #262c35;
  --panel-2: #303844;
  --line: rgba(255, 255, 255, 0.09);
  --text: #ece8e0;
  --muted: #8f98a6;
  --accent: #d4a574;
  --danger: #d4776a;
  --fn: #e8c07a;
  --emp: #7eb8c9;
  --sk: #9bc4a8;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  --font: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --mono: "SF Mono", Menlo, Consolas, monospace;
  --side-w: min(280px, 32vw);
  --insp-w: min(300px, 28vw);
  --top-h: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg0);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
}

button, input, textarea, select {
  font: inherit;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
}

#app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr) var(--insp-w);
  grid-template-rows: var(--top-h) minmax(0, 1fr);
  height: 100vh;
  width: 100vw;
}

/* ——— top ——— */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--top-h);
  padding: 0 14px;
  background: #1f242c;
  border-bottom: 1px solid var(--line);
  min-width: 0;
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 1 auto;
  white-space: nowrap;
  overflow: hidden;
}

.brand strong,
.brand-home {
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: inherit;
  text-decoration: none;
}

.brand-home:hover {
  color: var(--accent);
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.status {
  color: var(--muted);
  font-size: 11px;
  margin-right: 6px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ——— buttons ——— */
.btn, .tool {
  border: 1px solid var(--line);
  background: #2a313c;
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}

.btn:hover, .tool:hover {
  background: #353d4a;
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.top-actions .btn {
  background: #2f3744 !important;
  color: #ece8e0 !important;
  font-size: 12px;
}

.topbar .status {
  display: none;
}

@media (min-width: 1200px) {
  .topbar .status { display: inline; }
}

.btn.primary {
  background: rgba(212, 165, 116, 0.2);
  border-color: rgba(212, 165, 116, 0.5);
  color: var(--accent);
}

.delete-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.delete-actions .btn {
  width: 100%;
}

.btn.danger, .danger {
  background: rgba(212, 119, 106, 0.12);
  border-color: rgba(212, 119, 106, 0.4);
  color: #f0b4ab;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* ——— side / inspector ——— */
.side, .inspector {
  background: var(--bg1);
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.side {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-x: hidden;
  overflow-y: auto;
}

.side > * {
  flex-shrink: 0;
}

.side .totals-block {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.inspector {
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.block h2,
.inspector > h2 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.insp-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  padding: 3px;
  flex: 0 0 auto;
}

.insp-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
}

.insp-tab.active {
  background: #2f3744;
  color: var(--text);
}

.insp-panel {
  min-height: 0;
  overflow: auto;
  flex: 1 1 auto;
}

.ai-mode {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 12px;
}

.ai-mode.ok {
  border-color: rgba(155, 196, 168, 0.45);
  background: rgba(155, 196, 168, 0.1);
}

.ai-mode.warn {
  border-color: rgba(232, 192, 122, 0.5);
  background: rgba(232, 192, 122, 0.1);
}

.ai-status {
  margin: 0 0 10px;
  font-size: 11px;
  color: var(--muted);
}

.ai-actions {
  margin-top: 8px;
}

.ai-actions .btn {
  flex: 1;
}

.ai-test-result {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.4;
}

.ai-test-result.ok {
  border-color: rgba(155, 196, 168, 0.45);
  background: rgba(155, 196, 168, 0.1);
}

.ai-test-result.warn {
  border-color: rgba(232, 192, 122, 0.5);
  background: rgba(232, 192, 122, 0.1);
}

.ai-test-result.err {
  border-color: rgba(224, 122, 122, 0.5);
  background: rgba(224, 122, 122, 0.1);
}

.ai-chat {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.ai-chat-turn {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.4;
  background: rgba(255, 255, 255, 0.03);
}

.ai-chat-q {
  color: var(--muted);
  margin-bottom: 6px;
}

.ai-chat-q strong,
.ai-chat-a strong {
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.75;
}

.ai-ask-wrap {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.ai-ask-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.ai-ask-hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.ai-ask-hint.ready {
  color: rgba(155, 196, 168, 0.95);
}

.ai-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
  cursor: pointer;
}

.ai-check input {
  width: auto;
  accent-color: var(--accent);
}

.ai-findings {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.ai-chip {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 9px;
  font-size: 11px;
  line-height: 1.35;
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
}

.ai-chip:hover { border-color: rgba(255, 255, 255, 0.2); }

.ai-chip .sev {
  display: inline-block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
  opacity: 0.85;
}

.ai-chip.high .sev, .ai-chip.critical .sev { color: #f0b4ab; }
.ai-chip.medium .sev { color: #e8c07a; }
.ai-chip.low .sev { color: #9bc4a8; }
.ai-chip.info .sev { color: #7eb8c9; }

.ai-advice {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
}

.ai-advice h2, .ai-advice h3 {
  margin: 12px 0 6px;
  font-size: 12px;
  color: var(--accent);
}

.ai-advice h2:first-child, .ai-advice h3:first-child { margin-top: 0; }

.ai-advice ul {
  margin: 6px 0;
  padding-left: 18px;
}

.ai-advice p { margin: 0 0 8px; }
.ai-advice strong { color: #fff; }
.ai-advice em { color: var(--muted); font-style: normal; }

.ai-advice.loading {
  color: var(--muted);
  font-style: italic;
}

.prio {
  display: inline-block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
  padding: 1px 6px;
  margin-right: 4px;
  border: 1px solid var(--line);
}
.prio.core { color: #f0b4ab; }
.prio.supporting { color: #e8c07a; }
.prio.optional { color: #9bc4a8; }

.board-item small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.wizard {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  max-height: 48%;
  overflow: auto;
  background: rgba(22, 26, 32, 0.96);
  border: 1px solid rgba(212, 165, 116, 0.35);
  border-radius: 14px;
  padding: 12px 14px 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.wizard-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.wizard-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.wstep {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
}

.wstep.now {
  background: rgba(212, 165, 116, 0.2);
  border-color: rgba(212, 165, 116, 0.55);
  color: var(--text);
}

.wstep.done { color: var(--text); }

.wizard h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.wizard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.wiz-row, .wiz-assign {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 6px 0;
}

.wiz-assign {
  display: block;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}

.wiz-assign small { color: var(--muted); }

.wiz-idx {
  width: 18px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.wizard input, .wizard select, .wizard textarea {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--text);
}

.wizard textarea { width: 100%; min-height: 72px; }

.sim-result, #wiz-sim-out {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.45;
}

.sim-verdict {
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  font-weight: 650;
}

.sim-verdict.critical { background: rgba(224, 106, 94, 0.18); color: #f0b4ab; }
.sim-verdict.high { background: rgba(224, 106, 94, 0.12); color: #f0b4ab; }
.sim-verdict.risk { background: rgba(232, 192, 122, 0.14); color: #e8c07a; }
.sim-verdict.ok { background: rgba(155, 196, 168, 0.12); color: #b7d7c4; }

.sim-result ul, #wiz-sim-out ul {
  margin: 4px 0 8px;
  padding-left: 16px;
}

.base-title {
  margin: 12px 0 6px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.base-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.base-item small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.board-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.board-row {
  display: flex;
  align-items: stretch;
  gap: 2px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.board-row:hover { background: rgba(255, 255, 255, 0.04); }
.board-row.active {
  background: rgba(212, 165, 116, 0.12);
  border-color: rgba(212, 165, 116, 0.35);
}

.board-item {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 7px 9px;
  border: none;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
}

.board-del {
  flex: 0 0 auto;
  width: 30px;
  min-width: 30px;
  border: 1px solid transparent;
  background: rgba(212, 119, 106, 0.08);
  color: var(--danger);
  cursor: pointer;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  font-weight: 700;
}

.board-del:hover {
  color: #fff;
  background: rgba(212, 119, 106, 0.45);
  border-color: rgba(212, 119, 106, 0.6);
}

#btn-del-board {
  color: var(--danger);
  border-color: rgba(212, 119, 106, 0.45);
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.tool.active {
  background: rgba(212, 165, 116, 0.18);
  border-color: rgba(212, 165, 116, 0.55);
  color: var(--accent);
}

.tool.accent-fn { border-color: rgba(232, 192, 122, 0.45); }
.tool.accent-emp { border-color: rgba(126, 184, 201, 0.45); }
.tool.accent-sk { border-color: rgba(155, 196, 168, 0.45); }
.tool.accent-fn.active,
.tool.accent-emp.active,
.tool.accent-sk.active {
  color: var(--text);
}

#btn-fit {
  grid-column: 1 / -1;
}

.legend {
  display: grid;
  gap: 7px;
  margin-bottom: 10px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.chip {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.chip.fn { background: var(--fn); border-radius: 3px; }
.chip.emp { background: var(--emp); border-radius: 50%; }
.chip.sk { background: var(--sk); border-radius: 4px; width: 22px; height: 12px; }
.chip.svc {
  background: #e0a890;
  width: 20px;
  height: 14px;
  clip-path: polygon(18% 0, 82% 0, 100% 50%, 82% 100%, 18% 100%, 0 50%);
}

.tool.accent-svc { border-color: rgba(224, 168, 144, 0.5); }

.swatches {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
}

.swatch.on { border-color: #fff6e8; }

.swatches input[type="color"] {
  width: 28px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

.totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.total-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 8px;
}

.total-card.wide {
  grid-column: 1 / -1;
}

.total-card .k {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.total-card .v {
  margin-top: 2px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.total-card.net .v { color: var(--accent); }
.total-card.neg .v { color: #f0b4ab; }

/* ——— canvas ——— */
.stage-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(900px 560px at 18% 0%, rgba(212, 165, 116, 0.05), transparent 55%),
    radial-gradient(700px 480px at 90% 85%, rgba(111, 157, 140, 0.06), transparent 50%),
    #181c22;
}

.stage-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
  opacity: 0.9;
}

.mode-pill {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  pointer-events: none;
  font-size: 11px;
  color: var(--muted);
  background: rgba(20, 23, 28, 0.82);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  backdrop-filter: blur(6px);
}

body.studio-mode .mode-pill {
  top: 58px;
}

.studio-bar {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(28, 24, 18, 0.94);
  border: 1px solid rgba(212, 165, 116, 0.45);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
}

.studio-bar[hidden] {
  display: none !important;
}

.studio-bar-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.studio-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1c1f24;
  background: var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
}

.studio-bar-main strong {
  font-size: 14px;
  color: var(--text);
}

.studio-sub {
  font-size: 11px;
  color: var(--muted);
}

.studio-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.lib-studio-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(212, 165, 116, 0.14);
  border: 1px solid rgba(212, 165, 116, 0.4);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 650;
}

.lib-studio-banner .lib-cta-sm {
  width: auto;
  margin-left: auto;
}

.lib-studio-active {
  border-color: rgba(240, 212, 168, 0.65) !important;
  box-shadow: inset 0 0 0 1px rgba(212, 165, 116, 0.25);
}

#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  z-index: 1;
}

#stage.panning { cursor: grabbing; }
#stage.linking { cursor: crosshair; }

/* ——— inspector fields ——— */
.field {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}

.field label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  outline: none;
}

.field input:focus,
.field textarea:focus {
  border-color: rgba(212, 165, 116, 0.55);
}

.field textarea {
  min-height: 68px;
  resize: vertical;
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.money-hint {
  font-size: 10px;
  color: var(--muted);
  margin: -4px 0 10px;
}

.empty-inspector {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

/* ——— modal ——— */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-backdrop.open { display: flex; }

.modal {
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.modal h3 { margin: 0 0 12px; font-size: 15px; }
.modal-body { display: flex; flex-direction: column; gap: 0; }
.modal-body .field { margin-bottom: 10px; }
.modal-body .field:last-child { margin-bottom: 0; }
.modal-body .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.modal .money-hint { margin: -4px 0 8px; font-size: 11px; opacity: 0.7; }

kbd {
  font-family: var(--mono);
  font-size: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 4px;
}

@media (max-width: 1200px) {
  :root {
    --side-w: 240px;
    --insp-w: 240px;
  }
}

@media (max-width: 1100px) {
  :root {
    --side-w: 220px;
    --insp-w: 220px;
  }
  .brand span { display: none; }
}

@media (max-width: 860px) {
  #app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--top-h) minmax(160px, 34vh) minmax(0, 1fr) minmax(140px, 28vh);
  }
  .topbar { grid-column: 1; }
  .side {
    grid-row: 2;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .stage-wrap { grid-row: 3; }
  .inspector {
    grid-column: 1;
    grid-row: 4;
    border-left: none;
    border-top: 1px solid var(--line);
  }
}

/* ——— library ——— */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.boards-mini .board-list {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 4px;
}

.boards-mini .board-item {
  font-size: 11px;
  padding: 4px 8px;
}

.boards-mini .board-del {
  width: 24px;
  font-size: 13px;
}

.tools-mini .tool-grid {
  grid-template-columns: repeat(3, 1fr);
}

.lib-cta-sticky {
  width: 100%;
  margin: 0;
}

.library {
  flex: 1 1 auto;
  min-height: 120px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 4px;
  padding-right: 2px;
}

.lib-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.lib-head .lib-cta-sm {
  width: auto;
  flex: 0 0 auto;
}

.lib-sec {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0;
  overflow: visible;
}

.lib-sec > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  user-select: none;
}

.lib-sec > summary::-webkit-details-marker { display: none; }

.lib-list {
  padding: 0 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.lib-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 6px;
  border-radius: 7px;
  background: var(--panel);
  border: 1px solid transparent;
  cursor: grab;
  font-size: 12px;
}

.lib-item:hover {
  border-color: rgba(212, 165, 116, 0.35);
}

.lib-item.dragging {
  opacity: 0.55;
}

.lib-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lib-meta {
  color: var(--muted);
  font-size: 10px;
}

.lib-empty {
  color: var(--muted);
  font-size: 11px;
  padding: 4px 6px;
}

.lib-tip {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.lib-start {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 14px 12px;
  background: rgba(212, 165, 116, 0.08);
  border: 1px dashed rgba(212, 165, 116, 0.45);
  border-radius: 12px;
}

.lib-start p {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
}

.lib-start-hint {
  color: var(--muted);
  font-size: 11px;
}

.lib-cta {
  border: 1px solid rgba(212, 165, 116, 0.55);
  background: rgba(212, 165, 116, 0.18);
  color: var(--accent);
  border-radius: 9px;
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  text-align: center;
}

.lib-cta:hover {
  background: rgba(212, 165, 116, 0.28);
  border-color: var(--accent);
}

.lib-cta-sm {
  padding: 7px 8px;
  font-size: 12px;
}

.lib-list > .lib-cta,
.lib-start > .lib-cta {
  width: 100%;
}

.lib-proc-actions,
.lib-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 2px 0 6px;
  padding-left: 4px;
}

.lib-add-row .lib-cta-sm {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 6px;
  font-size: 10px;
}

.lib-contour {
  border-color: rgba(126, 184, 201, 0.45);
  background: rgba(126, 184, 201, 0.08);
}

.lib-badge {
  flex: 0 0 auto;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lib-contour .lib-badge {
  color: #8ec4d2;
  border-color: rgba(126, 184, 201, 0.4);
}

.lib-add, .lib-mini, .lib-fold, .lib-x {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
  font-size: 13px;
  line-height: 1;
  border-radius: 4px;
}

.lib-add:hover, .lib-mini:hover, .lib-fold:hover {
  color: var(--accent);
  background: rgba(212, 165, 116, 0.12);
}

.lib-x:hover { color: var(--danger); }

.lib-pipe-title {
  flex: 1;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  font-weight: 650;
}

.block-toggle {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: 0 0 6px;
}

.block-toggle.closed::before { content: "▸ "; }
.block-toggle:not(.closed)::before { content: ""; }

.nav-dock {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 5;
  display: flex;
  gap: 4px;
  background: rgba(31, 36, 44, 0.92);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  backdrop-filter: blur(8px);
}

.nav-btn {
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  background: #2a313c;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.nav-btn:hover {
  border-color: rgba(212, 165, 116, 0.4);
  color: var(--accent);
}

.nav-btn.active {
  border-color: rgba(212, 165, 116, 0.55);
  color: var(--accent);
  background: rgba(212, 165, 116, 0.12);
}

.mode-pill {
  font-size: 11px;
  opacity: 0.85;
}

#sim-target {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--text);
}
