/* ═══════════════════════════════════════════════════════════
   Hologram AT Command Wrangler — Stylesheet
   Brand: hologram.io design system
   ═══════════════════════════════════════════════════════════ */

/* ── Design tokens ─────────────────────────────────────────── */

:root {
  /* Light mode (default) */
  --bg:              #ffffff;
  --surface:         #f4f5f7;
  --surface-raised:  #ffffff;
  --accent:          #BFFD11;
  --accent-hover:    #aae80e;
  --text:            #00040F;
  --text-muted:      #6b7280;
  --text-on-accent:  #00040F;
  --header-bg:       #2B2F3B;
  --header-text:     #ffffff;
  --border:          #dddfe4;
  --border-focus:    #BFFD11;
  --status-connected: #22c55e;
  --status-disconnected: #9ca3af;
  --terminal-bg:     #0d1117;
  --terminal-fg:     #c9d1d9;
  --terminal-cursor: #BFFD11;
  --terminal-echo:   #e6b450;
  --shadow-sm:       0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:       0 4px 16px rgba(0,0,0,0.12);
  --radius-sm:       4px;
  --radius-md:       10px;
  --radius-lg:       18px;
  --font-sans:       'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:       'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  --transition:      150ms ease;
}

[data-theme="dark"] {
  --bg:              #00040F;
  --surface:         #2B2F3B;
  --surface-raised:  #343842;
  --text:            #ffffff;
  --text-muted:      #9ca3af;
  --border:          #3d4251;
  --border-focus:    #BFFD11;
  --terminal-bg:     #000000;
  --terminal-fg:     #BFFD11;
  --shadow-sm:       0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:       0 4px 20px rgba(0,0,0,0.5);
}

/* ── Reset & base ──────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden; /* Terminal fills viewport */
}

body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  transition: background var(--transition), color var(--transition);
}

/* ── Header ────────────────────────────────────────────────── */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--header-bg);
  color: var(--header-text);
  padding: 0 20px;
  height: 52px;
  flex-shrink: 0;
  gap: 16px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.logo-mark {
  flex-shrink: 0;
  opacity: 0.95;
}

.logo-wordmark {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: #ffffff;
  white-space: nowrap;
}

.app-title {
  font-size: 13px;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
  padding-left: 10px;
  border-left: 1px solid rgba(255,255,255,0.2);
}

@media (max-width: 480px) {
  .app-title { display: none; }
}

/* ── Header stats + icon buttons ──────────────────────────── */

.header-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto; /* push to right, before theme toggle */
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  font-size: 12px;
  color: rgba(255,255,255,0.75);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-chip svg {
  opacity: 0.6;
  flex-shrink: 0;
}

#lineCount {
  font-weight: 600;
  color: #ffffff;
  min-width: 3ch;
  text-align: right;
}

.stat-label {
  opacity: 0.6;
}

/* Scrollback overflow warning — line count has exceeded the buffer size */
.stat-chip.overflow {
  background: rgba(234,179,8,0.18);   /* amber tint */
  border-color: rgba(234,179,8,0.5);
  color: #fde68a;                      /* amber-200 */
  transition: background var(--transition), border-color var(--transition),
              color var(--transition);
  cursor: help;
}

.stat-chip.overflow svg {
  opacity: 1;
  color: #fbbf24;                      /* amber-400 icon */
}

.stat-chip.overflow #lineCount {
  color: #fde68a;
}

/* Generic icon-only button for header toolbar */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition);
}

.icon-btn:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.3);
  color: #ffffff;
}

.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Scroll-lock button states */
#scrollLockBtn .icon-live   { display: block; }
#scrollLockBtn .icon-paused { display: none;  }

/* When user has scrolled away from live view */
#scrollLockBtn.paused {
  background: rgba(191,253,17,0.12);
  border-color: rgba(191,253,17,0.4);
  color: var(--accent);
}

#scrollLockBtn.paused:hover {
  background: rgba(191,253,17,0.22);
  border-color: rgba(191,253,17,0.6);
}

#scrollLockBtn.paused .icon-live   { display: none;  }
#scrollLockBtn.paused .icon-paused { display: block; }

/* ── Theme toggle ──────────────────────────────────────────── */

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-md);
  color: #ffffff;
  cursor: pointer;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}

.theme-toggle:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.35);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Show appropriate icon */
[data-theme="light"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun  { display: none;  }
[data-theme="dark"]  .icon-sun  { display: block; }
[data-theme="dark"]  .icon-moon { display: none;  }

/* ── Compat warning ────────────────────────────────────────── */

.compat-warning {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fef3c7;
  color: #92400e;
  padding: 10px 20px;
  font-size: 13px;
  border-bottom: 1px solid #fcd34d;
  flex-shrink: 0;
}

.compat-warning[hidden] { display: none; }

/* ── Connection bar ────────────────────────────────────────── */

.connection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
  transition: background var(--transition), border-color var(--transition);
}

.connection-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* ── Status indicator ──────────────────────────────────────── */

.connection-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-disconnected);
  transition: background 250ms ease;
  flex-shrink: 0;
}

.status-dot.connected {
  background: var(--status-connected);
  box-shadow: 0 0 0 2px rgba(34,197,94,0.25);
}

.status-text {
  color: var(--text);
  font-weight: 500;
}

/* ── Buttons ───────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  padding: 8px 16px;
  transition: background var(--transition), color var(--transition),
              opacity var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  line-height: 1;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Primary: lime-green fill */
.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: var(--shadow-sm);
}

/* Secondary: outlined */
.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface);
  border-color: var(--text-muted);
}

[data-theme="dark"] .btn-secondary {
  color: #ffffff;
  border-color: rgba(255,255,255,0.25);
}

[data-theme="dark"] .btn-secondary:hover:not(:disabled) {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.4);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-icon {
  flex-shrink: 0;
}

/* Disconnect state — outlined warning */
.btn-disconnect {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-disconnect:hover:not(:disabled) {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #fca5a5;
}

[data-theme="dark"] .btn-disconnect {
  color: #ffffff;
  border-color: rgba(255,255,255,0.25);
}

[data-theme="dark"] .btn-disconnect:hover:not(:disabled) {
  background: rgba(185,28,28,0.2);
  color: #fca5a5;
  border-color: #ef4444;
}

/* ── Terminal area (flex row: terminal + optional search drawer) ── */

.terminal-area {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;   /* anchor for toast */
}

/* ── Toast notification ──────────────────────────────────── */

.toast {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: rgba(0, 0, 0, 0.82);
  color: #ffffff;
  font-size: 13px;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 100;
  white-space: nowrap;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Terminal wrapper ──────────────────────────────────────── */

.terminal-wrapper {
  flex: 1;
  min-width: 0;   /* allow shrinking when search drawer is open */
  min-height: 0;
  background: var(--terminal-bg);
  padding: 4px;
  overflow: hidden;
  position: relative;
}

#terminal {
  width: 100%;
  height: 100%;
}

/* Xterm overrides */
.xterm-viewport::-webkit-scrollbar {
  width: 6px;
}
.xterm-viewport::-webkit-scrollbar-track {
  background: transparent;
}
.xterm-viewport::-webkit-scrollbar-thumb {
  background: rgba(191,253,17,0.3);
  border-radius: 3px;
}
.xterm-viewport::-webkit-scrollbar-thumb:hover {
  background: rgba(191,253,17,0.6);
}

/* ── Command input bar ─────────────────────────────────────── */

.command-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}

.cmd-input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  transition: border-color var(--transition), box-shadow var(--transition),
              background var(--transition);
  min-width: 0;
}

.cmd-input::placeholder {
  color: var(--text-muted);
}

.cmd-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(191,253,17,0.2);
}

.cmd-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Modal ─────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  animation: fadeIn 150ms ease;
}

.modal-backdrop[hidden] { display: none; }

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  z-index: 101;
  width: min(420px, calc(100vw - 32px));
  animation: slideUp 150ms ease;
  transition: background var(--transition), border-color var(--transition);
}

.modal[hidden] { display: none; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  transition: background var(--transition), color var(--transition);
}

.modal-close:hover {
  background: var(--surface);
  color: var(--text);
}

.modal-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.modal-body {
  padding: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 16px;
  align-items: center;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.form-select {
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 7px 10px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition),
              background var(--transition), color var(--transition);
  width: 100%;
  appearance: auto;
}

.form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(191,253,17,0.2);
}

.modal-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 16px;
  padding: 10px 12px;
  background: rgba(191,253,17,0.08);
  border: 1px solid rgba(191,253,17,0.25);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.modal-note[hidden] { display: none; }

[data-theme="dark"] .modal-note {
  background: rgba(191,253,17,0.05);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
}

/* ── Animations ────────────────────────────────────────────── */

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

/* ── Search drawer ─────────────────────────────────────────── */

.search-drawer {
  width: 280px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  overflow-y: auto;
  transition: background var(--transition), border-color var(--transition);
}

.search-drawer[hidden] {
  display: none;
}

.search-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.search-drawer-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* Close button inside the drawer — reuses .icon-btn but on light bg */
.search-drawer-close {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
}

.search-drawer-close:hover {
  background: var(--surface-raised);
  border-color: var(--border);
  color: var(--text);
}

/* ── Search input row ──────────────────────────────────────── */

.search-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.search-input {
  flex: 1;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 7px 10px;
  min-width: 0;
  transition: border-color var(--transition), box-shadow var(--transition),
              background var(--transition);
  /* Remove browser's default search-input decoration */
  appearance: none;
  -webkit-appearance: none;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(191,253,17,0.2);
}

/* Search & clear icon buttons inside drawer */
#searchGoBtn,
#searchClearBtn {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  flex-shrink: 0;
}

#searchGoBtn:hover,
#searchClearBtn:hover {
  background: var(--surface-raised);
  border-color: var(--border);
  color: var(--text);
}

#searchClearBtn[hidden] { display: none; }

/* ── Match counter ─────────────────────────────────────────── */

.search-meta {
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 2px;
}

.search-meta[hidden] { display: none; }

/* ── Nav buttons ───────────────────────────────────────────── */

.search-nav {
  display: flex;
  gap: 8px;
}

.search-nav[hidden] { display: none; }

.search-nav .btn {
  flex: 1;
}

/* ── Search toggle button active state ─────────────────────── */

#searchToggleBtn.active {
  background: rgba(191,253,17,0.12);
  border-color: rgba(191,253,17,0.4);
  color: var(--accent);
}

#searchToggleBtn.active:hover {
  background: rgba(191,253,17,0.22);
  border-color: rgba(191,253,17,0.6);
}

/* Search toggle button — Active Search mode enabled (persistent green) */
#searchToggleBtn.active-search-on {
  background: rgba(191,253,17,0.22);
  border-color: rgba(191,253,17,0.6);
  color: var(--accent);
}

#searchToggleBtn.active-search-on:hover {
  background: rgba(191,253,17,0.32);
  border-color: rgba(191,253,17,0.8);
}

/* Log to File button — logging active (persistent green) */
#logBtn.logging-on {
  background: rgba(191,253,17,0.22);
  border-color: rgba(191,253,17,0.6);
  color: var(--accent);
}

#logBtn.logging-on:hover {
  background: rgba(191,253,17,0.32);
  border-color: rgba(191,253,17,0.8);
}

/* ── Active Search toggle section ────────────────────────── */

.active-search-section {
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.active-search-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.active-search-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 10px;
}

.active-search-buttons {
  display: flex;
  gap: 8px;
}

.active-search-buttons .btn {
  flex: 1;
}

/* Selected state for Enable / Disable toggle buttons */
.active-search-btn-selected {
  background: rgba(191,253,17,0.12);
  border-color: rgba(191,253,17,0.4);
  color: var(--accent);
  font-weight: 600;
}

.active-search-btn-selected:hover:not(:disabled) {
  background: rgba(191,253,17,0.22);
  border-color: rgba(191,253,17,0.6);
}

/* ════════════════════════════════════════════════════════════
   COMMAND COLLECTIONS  (v0.8.0)
   ════════════════════════════════════════════════════════════ */

/* ── Collections drawer ────────────────────────────────────── */

.collections-drawer {
  width: 360px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow: hidden;
  transition: background var(--transition), border-color var(--transition);
}

.collections-drawer[hidden] { display: none; }

.collections-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px 9px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.drawer-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* Collections toggle button active state (mirrors search) */
#collectionsToggleBtn.active {
  background: rgba(191,253,17,0.12);
  border-color: rgba(191,253,17,0.4);
  color: var(--accent);
}

#collectionsToggleBtn.active:hover {
  background: rgba(191,253,17,0.22);
  border-color: rgba(191,253,17,0.6);
}

/* ── Filter row ─────────────────────────────────────────────── */

.collections-filter-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.collections-filter-input {
  flex: 1;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 5px 8px;
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--transition), box-shadow var(--transition),
              background var(--transition);
}

.collections-filter-input::placeholder { color: var(--text-muted); }

.collections-filter-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(191,253,17,0.2);
}

#collectionsFilterClearBtn {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  flex-shrink: 0;
  width: 26px;
  height: 26px;
}

#collectionsFilterClearBtn:hover {
  background: var(--surface-raised);
  border-color: var(--border);
  color: var(--text);
}

#collectionsFilterClearBtn[hidden] { display: none; }

/* ── Collection selector row ────────────────────────────────── */

.collections-select-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.collections-select {
  flex: 1;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px 6px;
  min-width: 0;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.collections-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(191,253,17,0.2);
}

/* Icon buttons in the selector row (manage, manual, export, import) */
.collections-select-row .icon-btn {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), opacity var(--transition);
}

.collections-select-row .icon-btn:hover:not(:disabled) {
  background: var(--surface-raised);
  border-color: var(--border);
  color: var(--text);
}

.collections-select-row .icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Mask-image icon utility ─────────────────────────────────── */

.icon-mask {
  display: inline-block;
  background-color: currentColor;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.icon-mask-directory {
  -webkit-mask-image: url('./design_assets/directory.png');
  mask-image: url('./design_assets/directory.png');
  width: 16px;
  height: 16px;
}

.icon-mask-website {
  -webkit-mask-image: url('./design_assets/website.png');
  mask-image: url('./design_assets/website.png');
  width: 16px;
  height: 16px;
}

.icon-mask-research {
  -webkit-mask-image: url('./design_assets/research.png');
  mask-image: url('./design_assets/research.png');
  width: 14px;
  height: 14px;
}

.icon-mask-searching {
  -webkit-mask-image: url('./design_assets/searching.png');
  mask-image: url('./design_assets/searching.png');
  width: 16px;
  height: 16px;
}

/* ── Tree hover action buttons ───────────────────────────────── */

.tree-hover-actions {
  display: none;
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border-radius: 4px;
  padding: 0 2px;
  z-index: 2;
}

.tree-item:hover .tree-hover-actions {
  display: flex;
}

.tree-hover-actions:focus-within {
  display: flex;
}

.tree-hover-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}

.tree-hover-btn:hover {
  background: var(--surface-raised);
  color: var(--text);
}

.tree-hover-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.tree-hover-btn svg {
  width: 12px;
  height: 12px;
}

.tree-hover-btn.tree-hover-delete:hover {
  color: #e53e3e;
}

[data-theme="dark"] .tree-hover-btn.tree-hover-delete:hover {
  color: #fc8181;
}

/* ── Tree container ──────────────────────────────────────────── */

.collections-tree {
  flex: 1;
  overflow-y: auto;
  padding: 4px 2px;
  outline: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(191,253,17,0.35) transparent;
}

.collections-tree::-webkit-scrollbar { width: 6px; }
.collections-tree::-webkit-scrollbar-track { background: transparent; }
.collections-tree::-webkit-scrollbar-thumb {
  background: rgba(191,253,17,0.35);
  border-radius: 3px;
}

/* ── Tree list / item ────────────────────────────────────────── */

.tree-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Each nested level is indented */
.tree-list .tree-list {
  padding-left: 14px;
}

.tree-item {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 26px;
  padding: 0 8px 0 4px;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  position: relative;
  margin: 1px 2px;
}

.tree-item:hover {
  background: color-mix(in srgb, var(--text) 8%, transparent);
}

.tree-item.selected {
  background: rgba(191,253,17,0.14);
}

.tree-item.focused {
  outline: 2px solid rgba(191,253,17,0.7);
  outline-offset: -2px;
}

/* Drag-and-drop indicators */
.tree-item.drag-over-above::before,
.tree-item.drag-over-below::after {
  content: '';
  position: absolute;
  left: 4px;
  right: 4px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
  pointer-events: none;
}

.tree-item.drag-over-above::before { top: -1px; }
.tree-item.drag-over-below::after  { bottom: -1px; }

.tree-item.drag-over-inside {
  outline: 2px solid rgba(191,253,17,0.7);
  outline-offset: -2px;
}

/* ── Tree toggle (expand/collapse arrow) ─────────────────────── */

.tree-toggle {
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
  color: var(--text);
  opacity: 0.45;
}

.tree-toggle.expanded { transform: rotate(90deg); }
.tree-toggle.leaf     { visibility: hidden; pointer-events: none; }

/* ── Tree node icon ───────────────────────────────────────────── */

.tree-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: var(--text);
  opacity: 0.55;
}

.tree-item[data-type="folder"] > .tree-icon {
  color: var(--accent);
  opacity: 0.9;
}

/* ── Tree label ───────────────────────────────────────────────── */

.tree-label {
  flex: 1;
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1;
}

.tree-label mark {
  background: rgba(191,253,17,0.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* Empty / placeholder message */
.tree-empty {
  padding: 16px 12px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  line-height: 1.5;
}

.tree-empty-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 4px 10px;
  font-size: 12px;
  font-style: normal;
  color: var(--accent);
  background: rgba(191,253,17,0.08);
  border: 1px solid rgba(191,253,17,0.3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.tree-empty-add-btn:hover {
  background: rgba(191,253,17,0.16);
  border-color: rgba(191,253,17,0.5);
}

/* ── Collections dialog (z-index above backdrop) ─────────────── */

#collectionsDialog {
  z-index: 102;
}

/* Danger OK button state */
#collDialogOk.danger {
  background: #e53e3e;
  border-color: #c53030;
  color: #fff;
}

#collDialogOk.danger:hover {
  background: #c53030;
  border-color: #9b2c2c;
}

/* Monospace field inside dialog */
.coll-field-monospace {
  font-family: var(--font-mono);
  font-size: 13px;
}

/* Confirm text in dialog body */
.coll-confirm-text {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
  margin: 0 0 4px;
}

/* ── Collections close button ────────────────────────────────── */

.collections-drawer-header .icon-btn {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
}

.collections-drawer-header .icon-btn:hover {
  background: var(--surface-raised);
  border-color: var(--border);
  color: var(--text);
}

/* ── Danger outline button (collection delete, etc.) ─────────── */

.btn-danger-outline {
  background: transparent;
  color: #e53e3e;
  border: 1px solid rgba(229,62,62,0.55);
}

.btn-danger-outline:hover:not(:disabled) {
  background: #fee2e2;
  color: #b91c1c;
  border-color: #c53030;
}

[data-theme="dark"] .btn-danger-outline {
  color: #fc8181;
  border-color: rgba(252,129,129,0.45);
}

[data-theme="dark"] .btn-danger-outline:hover:not(:disabled) {
  background: rgba(185,28,28,0.2);
  color: #fca5a5;
  border-color: #fc8181;
}

/* ════════════════════════════════════════════════════════════
   INFO PANELS DRAWER  (Phase 3)
   ════════════════════════════════════════════════════════════ */

/* ── Drawer container ─────────────────────────────────────────── */

.info-drawer {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow: hidden;
  transition: background var(--transition), border-color var(--transition);
}

.info-drawer[hidden] { display: none; }

.info-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px 9px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.info-drawer-header .icon-btn {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
}

.info-drawer-header .icon-btn:hover {
  background: var(--surface-raised);
  border-color: var(--border);
  color: var(--text);
}

/* ── Toggle button active state ───────────────────────────────── */

#infoPanelToggleBtn.active {
  background: rgba(191,253,17,0.12);
  border-color: rgba(191,253,17,0.4);
  color: var(--accent);
}

#infoPanelToggleBtn.active:hover {
  background: rgba(191,253,17,0.22);
  border-color: rgba(191,253,17,0.6);
}

/* ── Panel selector ───────────────────────────────────────────── */

.info-panel-select-row {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.info-panel-select {
  flex: 1;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 5px 8px;
  min-width: 0;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.info-panel-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(191,253,17,0.2);
}

/* ── Action bar ───────────────────────────────────────────────── */

.info-panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.info-panel-actions .btn { flex: 1; justify-content: center; }

/* ── Results area ─────────────────────────────────────────────── */

.info-panel-results {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(191,253,17,0.35) transparent;
}

.info-panel-results::-webkit-scrollbar { width: 6px; }
.info-panel-results::-webkit-scrollbar-track { background: transparent; }
.info-panel-results::-webkit-scrollbar-thumb {
  background: rgba(191,253,17,0.35);
  border-radius: 3px;
}

/* Empty / placeholder */
.info-panel-empty {
  padding: 20px 14px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  line-height: 1.5;
}

/* ── Result row (label/value pair) ────────────────────────────── */

.info-field {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 5px 14px;
  min-height: 28px;
}

.info-field:hover {
  background: color-mix(in srgb, var(--text) 5%, transparent);
}

.info-field-label {
  flex-shrink: 0;
  width: 110px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.info-field-value {
  flex: 1;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text);
  word-break: break-all;
  line-height: 1.4;
}

.info-field-value.placeholder {
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-style: italic;
}

.info-field-value.error {
  color: #e53e3e;
  font-family: var(--font-sans);
}

[data-theme="dark"] .info-field-value.error {
  color: #fc8181;
}

/* ── Spinner (during fetch) ───────────────────────────────────── */

.info-panel-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(191,253,17,0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: infoSpin 0.7s linear infinite;
  vertical-align: middle;
}

@keyframes infoSpin {
  to { transform: rotate(360deg); }
}

/* ── Screen-reader only utility ───────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
