@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design tokens ────────────────────────────────────────── */
:root {
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --sidebar-w: 320px;
  --detail-w: 420px;
}

[data-theme="light"] {
  --bg: #f8f7f4;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --surface-offset: #f1efe9;
  --border: rgba(40, 37, 29, 0.08);
  --text: #2c2a24;
  --text-muted: #5e5b52;
  --text-faint: #8e8b80;
  --primary: #007373;
  --primary-hover: #005959;
  --primary-hl: rgba(0, 115, 115, 0.08);
  --warning: #a05000;
  --error: #a82356;
  --success: #3c7a26;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(40,37,29,.05);
  --shadow-md: 0 8px 30px rgba(40,37,29,.06);
  --shadow-lg: 0 20px 40px rgba(40,37,29,.1);
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-blur: blur(12px);
  --badge-lep-bg: rgba(253, 171, 67, 0.15);
  --badge-lep-fg: #965600;
  --badge-act-bg: rgba(168, 111, 223, 0.15);
  --badge-act-fg: #7a36cf;
  --badge-sepp-bg: rgba(14, 116, 144, 0.12);
  --badge-sepp-fg: #0e7490;
  --tb-div-bg: rgba(56, 121, 237, 0.1);
  --tb-div-fg: #1548b0;
  --tb-sch-bg: rgba(168, 111, 223, 0.1);
  --tb-sch-fg: #7a36cf;
  /* Instrument-type accents (graph view) — aliases of the badge palette */
  --accent-act: #7a36cf;
  --accent-sepp: #007373;
  --accent-lep: #965600;
  /* Skeleton shimmer highlight (D-10) — theme-aware like every other token */
  --shimmer-hl: rgba(40, 37, 29, 0.05);
}

[data-theme="dark"] {
  --bg: #121314;
  --surface: #18191b;
  --surface-2: #1e2023;
  --surface-offset: #141516;
  --border: rgba(255, 255, 255, 0.06);
  --text: #e1e3e6;
  --text-muted: #9ba1a6;
  --text-faint: #6c7075;
  --primary: #00adb5;
  --primary-hover: #00ffd2;
  --primary-hl: rgba(0, 173, 181, 0.12);
  --warning: #fdab43;
  --error: #e84545;
  --success: #70af43;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 8px 30px rgba(0,0,0,.4);
  --shadow-lg: 0 20px 40px rgba(0,0,0,.5);
  --glass-bg: rgba(24, 25, 27, 0.85);
  --glass-blur: blur(12px);
  --badge-lep-bg: rgba(253, 171, 67, 0.15);
  --badge-lep-fg: #fdab43;
  --badge-act-bg: rgba(168, 111, 223, 0.15);
  --badge-act-fg: #c5a3f2;
  --badge-sepp-bg: rgba(34, 211, 238, 0.15);
  --badge-sepp-fg: #22d3ee;
  --tb-div-bg: rgba(56, 121, 237, 0.1);
  --tb-div-fg: #79a6fb;
  --tb-sch-bg: rgba(168, 111, 223, 0.1);
  --tb-sch-fg: #c5a3f2;
  /* Instrument-type accents (graph view) — aliases of the badge palette */
  --accent-act: #c5a3f2;
  --accent-sepp: #00adb5;
  --accent-lep: #fdab43;
  /* Skeleton shimmer highlight (D-10) — theme-aware like every other token */
  --shimmer-hl: rgba(255, 255, 255, 0.05);
}

/* ── Reset & General ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: 56px 1fr 24px;
  grid-template-columns: var(--sidebar-w) 4px 1fr 4px var(--detail-w);
  transition: background 0.3s ease;
}

button, input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── Top Bar ─────────────────────────────────────────────── */
#topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
#logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  background: none;
  border: none;
  text-align: left;
  outline: none;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin-left: -8px;
}
#logo:focus-visible {
  outline: 2px solid var(--primary);
}
#logo svg { color: var(--primary); }
#logo-text { font-family: var(--font-title); font-size: 16px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
#logo-sub { font-size: 11px; color: var(--text-muted); margin-top: -2px; }

#search-wrap {
  flex: 1;
  max-width: 500px;
  position: relative;
}
#search {
  width: 100%;
  height: 36px;
  padding: 0 14px 0 38px;
  background: var(--surface-offset);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  outline: none;
  transition: all 0.2s ease;
}
#search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-hl);
  background: var(--surface);
}
.top-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}
#search-results {
  position: absolute;
  top: 42px;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 350px;
  overflow-y: auto;
  display: none;
}
/* The JS toggles `.visible` (handleSearch / focus listener) — without this
   rule the dropdown stays display:none forever (CR-01). Mirrors the
   #demo-banner.visible pattern. */
#search-results.visible { display: block; }
.sr-item {
  padding: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.sr-item:hover { background: var(--surface-offset); }
.sr-type { font-size: 10px; font-weight: 700; color: var(--primary); text-transform: uppercase; margin-bottom: 2px; }
.sr-label { font-weight: 600; font-size: 13px; }
.sr-snippet { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.sr-snippet mark { background: var(--primary-hl); color: var(--primary); padding: 0 2px; border-radius: 2px; }

#topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}
#split-btn, #theme-btn {
  background: var(--surface-offset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
#split-btn:hover, #theme-btn:hover {
  background: var(--surface);
  border-color: var(--text-faint);
}
#split-btn.active {
  background: var(--primary-hl);
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Panel Resizers ────────────────────────────────────────── */
.resizer {
  grid-row: 2;
  width: 4px;
  background: var(--border);
  cursor: col-resize;
  transition: background 0.15s ease;
  z-index: 10;
}
.resizer:hover, .resizer.dragging {
  background: var(--primary);
}

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  grid-row: 2;
  grid-column: 1;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#sidebar-title {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.filter-row {
  display: flex;
  gap: 4px;
  background: var(--surface-offset);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.filter-btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 5px 0;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-muted);
}
.filter-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.instr-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s ease;
}
.instr-item:hover { background: var(--surface-offset); }
.instr-item.selected { background: var(--primary-hl); border-left: 4px solid var(--primary); }
.instr-name { font-weight: 600; line-height: 1.35; margin-bottom: 4px; }
.instr-meta { font-size: 10.5px; color: var(--text-muted); display: flex; gap: 8px; align-items: center; }
.badge { padding: 2px 8px; border-radius: 9999px; font-size: 9px; font-weight: 700; text-transform: uppercase; display: inline-block; }
.badge-sepp { background: var(--badge-sepp-bg); color: var(--badge-sepp-fg); }
.badge-lep { background: var(--badge-lep-bg); color: var(--badge-lep-fg); }
.badge-act { background: var(--badge-act-bg); color: var(--badge-act-fg); }
.badge-instrument { background: var(--primary-hl); color: var(--primary); }
.badge-clause { background: var(--surface-offset); color: var(--text-muted); }
.badge-subclause { background: var(--surface-offset); color: var(--text-faint); }
.badge-part { background: rgba(0, 128, 128, 0.1); color: var(--primary); }

/* ── Skeleton loading rows (D-10) ──────────────────────────────
   Geometry twin of .instr-item: padding 14px 16px + the same border —
   the 8 static rows in index.html are replaced in place by real rows
   with ZERO layout shift (smoke-asserted). No accent, no text colors:
   bars derive from --surface-offset with the theme-aware --shimmer-hl
   sweep only. */
.skeleton-row {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.skeleton-bar {
  height: 18px;
  border-radius: var(--radius-sm);
  background-color: var(--surface-offset);
  background-image: linear-gradient(90deg, transparent, var(--shimmer-hl), transparent);
  background-size: 200% 100%;
  background-repeat: no-repeat;
  background-position: -200% 0;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
.skeleton-bar.skeleton-meta {
  height: 15px;
  width: 40%;
  margin-top: 4px;
}
@keyframes skeleton-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  /* Static --surface-offset fill, no animation (UI-SPEC reduced-motion rule) */
  .skeleton-bar { animation: none; background-image: none; }
}

/* Tree view styling (now inside Sidebar) */
.tree-node { margin-bottom: 2px; }
.tree-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}
.tree-row:hover { background: var(--surface-offset); }
.tree-row.active { background: var(--primary-hl); }
.tree-row.active .tree-label { color: var(--primary); font-weight: 600; }
.tree-toggle { width: 14px; height: 14px; color: var(--text-faint); transition: transform 0.2s ease; }
.tree-toggle.open { transform: rotate(90deg); }
.tree-icon { width: 14px; height: 14px; color: var(--text-muted); }
.tree-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-num { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); margin-left: 4px; }
.tree-children { padding-left: 12px; border-left: 1px solid var(--border); margin-left: 6px; }

.tree-badge { font-size: 9px; font-weight: 700; padding: 1px 6px; border-radius: 4px; text-transform: uppercase; }
.tb-Part { background: rgba(0, 128, 128, 0.1); color: var(--primary); }
.tb-Division { background: var(--tb-div-bg); color: var(--tb-div-fg); }
.tb-Clause, .tb-Section { background: var(--surface-offset); color: var(--text-muted); }
.tb-Schedule { background: var(--tb-sch-bg); color: var(--tb-sch-fg); }
.tb-Zone { background: rgba(112, 175, 67, 0.1); color: var(--success); }

/* ── Main Content Viewport ────────────────────────────────── */
#main-container {
  grid-row: 2;
  grid-column: 3;
  display: flex;
  overflow: hidden;
  height: 100%;
}
.viewport {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
}
#main-compare { display: none; background: var(--surface-2); border-left: 1px solid var(--border); }

.vp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.vp-title { font-family: var(--font-title); font-size: 14px; font-weight: 600; color: var(--primary); }

/* ── Dashboard Landing ───────────────────────────────────── */
#dashboard-view {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.dash-header { margin-bottom: 8px; }
.dash-title { font-family: var(--font-title); font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}
.dash-card-num { font-family: var(--font-title); font-size: 20px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.dash-card-lbl { font-size: 11px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.02em; }

/* Dashboard Feeds */
.dash-feed-card h3 svg { color: var(--primary); }
.feed-item:hover {
  background: var(--surface) !important;
  border-color: var(--text-faint) !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ── Zoning Inspector ────────────────────────────────────── */
#zoning-inspector {
  display: none;
}
.zone-header-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.zi-code { font-family: var(--font-mono); font-size: 11px; color: var(--warning); font-weight: 600; text-transform: uppercase; margin-bottom: 4px; display: block; }
.zi-title { font-family: var(--font-title); font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.zi-objectives { font-size: 13px; line-height: 1.6; color: var(--text-muted); }

.zi-search-wrap { position: relative; margin-bottom: 20px; max-width: 400px; }
.zi-search { width: 100%; height: 34px; padding: 0 12px 0 34px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); outline: none; }
.zi-search:focus { border-color: var(--primary); }

.zi-card-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .zi-card-grid { grid-template-columns: repeat(3, 1fr); } }
.zi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}
.zi-card-title { font-family: var(--font-title); font-size: 12px; font-weight: 700; text-transform: uppercase; display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.bullet { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.bullet-without { background: var(--success); }
.bullet-with { background: var(--primary); }
.bullet-prohibited { background: var(--error); }

.zi-card-without { border-top: 3px solid var(--success); }
.zi-card-with { border-top: 3px solid var(--primary); }
.zi-card-prohibited { border-top: 3px solid var(--error); }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--surface-offset);
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}
.tag.match { background: var(--primary-hl); color: var(--primary); border-color: var(--primary); transform: scale(1.05); }

/* ── Detail Panel ────────────────────────────────────────── */
#detail {
  grid-row: 2;
  grid-column: 5;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
#detail-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.detail-tab {
  flex: 1;
  text-align: center;
  padding: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}
.detail-tab:focus { outline: none; }
.detail-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--surface);
}

#detail-views { flex: 1; overflow-y: auto; position: relative; }
.detail-panel-view { padding: 20px; display: none; height: 100%; }
.detail-panel-view.active { display: flex; flex-direction: column; }

#detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 80%;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
}

#detail-content { display: none; }

.detail-actions { display: flex; gap: 8px; margin-bottom: 20px; }
.action-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface-offset);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.action-btn:hover { background: var(--surface); border-color: var(--text-faint); }
.action-btn.active { background: var(--primary-hl); border-color: var(--primary); color: var(--primary); }

.detail-section { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.detail-section-title { font-family: var(--font-title); font-size: 10.5px; font-weight: 700; text-transform: uppercase; color: var(--text-faint); margin-bottom: 8px; }
.edge-item {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-offset);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.edge-item:hover { background: var(--primary-hl); transform: translateX(2px); }
.edge-rel { font-size: 9px; font-weight: 700; margin-bottom: 2px; }
.edge-label { font-weight: 600; font-size: 12px; }
.edge-raw { font-size: 11px; color: var(--text-faint); font-style: italic; margin-top: 2px; }

.rel-REFERENCES { color: var(--badge-act-fg); }
.rel-PREVAILS_OVER { color: var(--warning); }
.rel-DEFINES { color: var(--success); }

/* Instrument graph hint (always visible on the graph view) */
#graph-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  padding: 4px 14px;
  border-radius: var(--radius-full);
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
}

/* Graph view panel */
#graph-view-panel { display: flex; flex-direction: column; height: 100%; position: relative; flex: 1; }
#ego-canvas-wrap { flex: 1; position: relative; background: var(--surface-offset); border-radius: var(--radius-md); border: 1px solid var(--border); overflow: hidden; }
#ego-canvas { width: 100%; height: 100%; display: block; cursor: grab; }
#ego-canvas:active { cursor: grabbing; }
.graph-tip { font-size: 11px; color: var(--text-faint); margin-top: 6px; text-align: center; }

/* Comparative columns */
.compare-cols { display: flex; gap: 16px; flex: 1; }
.compare-col { flex: 1; display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 16px; overflow-y: auto; }
.comp-label { font-family: var(--font-title); font-size: 14px; font-weight: 600; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 12px; }
.comp-body { font-size: 12.5px; line-height: 1.6; color: var(--text-muted); }

/* ── Alert Modal & Toast Styling ───────────────────────────── */
.alert-trigger-btn:hover {
  color: var(--primary) !important;
}
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.3s ease;
}
.modal-overlay.active .modal-card {
  transform: scale(1);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 {
  font-family: var(--font-title);
  font-size: 16px;
  margin: 0;
  color: var(--text);
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 4px;
}
.modal-close:hover {
  color: var(--text);
}
.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-offset);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-weight: 500;
  font-size: 12.5px;
  cursor: pointer;
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-secondary {
  background: var(--surface-offset);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-weight: 500;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
}
.btn-secondary:hover {
  background: var(--surface-2);
}
.channel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-offset);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}
.channel-row:hover {
  border-color: var(--text-faint);
}
.channel-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.channel-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.toast.active {
  transform: translateY(0);
  opacity: 1;
}
.toast-success {
  border-left: 3px solid var(--success);
}
.toast-error {
  border-left: 3px solid var(--error);
}

/* ── Status Bar ────────────────────────────────────────── */
#statusbar {
  grid-row: 3;
  grid-column: 1 / -1;
  height: 24px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  font-size: 11px;
  color: var(--text-muted);
  z-index: 100;
}
.stat-item { display: flex; align-items: center; gap: 6px; }
.stat-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.stat-dot.loading { background: var(--warning); animation: pulse 1s ease infinite; }
.stat-dot.error { background: var(--error); }

/* ── Top warning banners (shared component class) ──────────────
   #demo-banner (localhost demo fallback, copy preserved) and
   #error-banner (D-09 deployed-origin honest failure) share this
   component verbatim. Shown via .visible — the display rule below
   is load-bearing (CR-01 lesson: a class toggle without its CSS
   rule fails silently; smoke asserts computed visibility). */
.top-banner {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 10000;
  align-items: center; justify-content: center; gap: 16px;
  padding: 10px 16px;
  background: var(--error); color: #ffffff;
  font-family: var(--font-body); font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-md);
}
.top-banner.visible { display: flex; }
.top-banner button {
  font-family: var(--font-body); font-size: 12px; font-weight: 600;
  padding: 4px 14px; border-radius: var(--radius-full);
  border: 1px solid rgba(255,255,255,0.6);
  background: rgba(255,255,255,0.15); color: #ffffff; cursor: pointer;
}
.top-banner button:hover { background: rgba(255,255,255,0.3); }
.top-banner button:focus-visible { outline: 2px solid #ffffff; outline-offset: 2px; }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .4 } }

/* ── In-list error / empty-state panel (D-09) ──────────────────
   Rendered into #instr-list in place of the skeleton rows when the
   probe ladder exhausts (or the service returns zero instruments).
   The Retry button is the screen's single primary action — the ONLY
   accent usage on this surface (UI-SPEC color rules). */
.list-state-panel {
  padding: 24px 16px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.list-state-heading {
  font-family: var(--font-title); font-size: 15px; font-weight: 700;
  line-height: 1.2; color: var(--text);
}
.list-state-body {
  font-size: 13.5px; line-height: 1.5; color: var(--text-muted);
}
.retry-btn {
  background: var(--primary-hl); color: var(--primary);
  border: 1px solid var(--primary); border-radius: var(--radius-sm);
  padding: 8px 16px; font-weight: 600; font-size: 12px;
  cursor: pointer; margin-top: 4px;
  transition: all 0.2s ease;
}
.retry-btn:hover { background: var(--primary); color: var(--bg); }
.retry-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── JS-emitted classes (WR-04) ────────────────────────────────
   Rules for classes rendered only from js/ modules — kept so the
   "class toggled, rule missing" defect class stays closed:
   .defined-term → highlightDefinedTerms (js/tree.js) clickable terms
   .no-results   → empty search-result panel (js/search.js)
   .crumb-sep    → breadcrumb separators (js/tree.js)             */
.defined-term {
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
  color: var(--primary);
}
.defined-term:hover { color: var(--primary-hover); }
.no-results { padding: 12px; font-size: 12px; color: var(--text-faint); }
.crumb-sep { color: var(--text-faint); }
