:root {
  --bg: #080808;
  --bg2: #0d0d0d;
  --bg3: #131313;
  --bg4: #1a1a1a;
  --border: #1f1f1f;
  --border2: #2c2c2c;
  --ir: #c850ff;
  --ir-dim: #6e1d96;
  --amber: #d4b06c;
  --amber-dim: #5f4a21;
  --accent: var(--ir);
  --accent2: var(--amber);
  --accent-dim: rgba(200,80,255,0.1);
  --green: #48bb78;
  --green-dim: rgba(72,187,120,0.1);
  --red: #f56565;
  --red-dim: rgba(245,101,101,0.12);
  --blue: #4299e1;
  --blue-dim: rgba(66,153,225,0.1);
  --text: #e8e8e8;
  --text2: #bdbdbd;
  --text3: #666666;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'DM Sans', sans-serif;
  --display: 'Bebas Neue', sans-serif;
  --r: 6px;
  --r2: 10px;
  --glow-ir: 0 0 18px #c850ff88, 0 0 60px #c850ff33;
  --glow-amb: 0 0 18px #d4b06c88, 0 0 60px #d4b06c33;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 4px
  );
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px;
}
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
  z-index: 1;
  background:
    radial-gradient(circle at top right, rgba(200, 80, 255, 0.08), transparent 36%),
    radial-gradient(circle at bottom left, rgba(255, 176, 32, 0.05), transparent 32%);
}

/* ── SCROLLBARS ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── TOPBAR ── */
.topbar { background: var(--bg2); border-bottom: 1px solid var(--border); padding: 0 20px; display: flex; align-items: center; gap: 12px; height: 48px; flex-shrink: 0; }
.logo { font-family: var(--display); font-size: 16px; color: var(--accent); letter-spacing: 1.5px; text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
.logo-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.35} }
.topbar-sep { height: 16px; width: 1px; background: var(--border2); flex-shrink: 0; }
.topbar-home { text-decoration: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.device-name { font-family: var(--mono); font-size: 11px; color: var(--text3); display: none; }
.badge { font-family: var(--mono); font-size: 11px; font-weight: 500; padding: 3px 10px; border-radius: 20px; background: var(--bg4); color: var(--text3); border: 1px solid var(--border); letter-spacing: 0.5px; }
.badge.connected { background: var(--green-dim); color: var(--green); border-color: rgba(72,187,120,0.3); }

.sidebar-toggle { display: flex; flex-shrink: 0; }
@media (min-width: 901px) {
  .sidebar.collapsed { --sidebar-width: 0px !important; min-width: 0; border-right: none; overflow: hidden; padding: 0; }
  .sidebar.collapsed ~ .sidebar-resize-handle { display: none; }
}

/* ── LAYOUT ── */
.main { display: flex; flex: 1; overflow: hidden; }

/* ── SIDEBAR ── */
.sidebar { --sidebar-width: 240px; width: var(--sidebar-width); min-width: 220px; flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; position: relative; transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.sidebar-resize-handle { width: 4px; cursor: col-resize; flex-shrink: 0; background: transparent; position: relative; z-index: 1; transition: background 0.15s; }
.sidebar-resize-handle:hover,
.sidebar-resize-handle.active { background: var(--accent); }
.sidebar-resizing { user-select: none; }
.sidebar-header { padding: 8px 10px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.sidebar-header-label { font-family: var(--mono); font-size: 10px; font-weight: 600; color: var(--text3); letter-spacing: 1.2px; text-transform: uppercase; flex: 1; padding-left: 4px; }
.sidebar-search { padding: 8px 10px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sidebar .sidebar-search-wrap { margin: 0; }
.sidebar-search-wrap input { font-size: 11px; padding: 6px 8px 6px 28px; }
.sidebar-search-wrap i { font-size: 12px; left: 8px; }
.sidebar-tree { flex: 1; overflow-y: auto; padding: 4px 0; }
.drag-hint { display: none; font-family: var(--mono); font-size: 10px; color: var(--accent); text-align: center; padding: 8px; border-top: 1px dashed var(--accent); background: var(--accent-dim); flex-shrink: 0; }
.drag-hint.visible { display: block; }

.sidebar-backdrop { position: fixed; inset: 0; z-index: 59; background: rgba(0,0,0,0.55); opacity: 0; pointer-events: none; transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.sidebar-backdrop.visible { opacity: 1; pointer-events: auto; }

/* ── CONTENT ── */
.content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.content-header { background: var(--bg2); border-bottom: 1px solid var(--border); padding: 0 20px; display: flex; align-items: center; height: 42px; flex-shrink: 0; }
.tab-btn { font-family: var(--mono); font-size: 11px; font-weight: 600; color: var(--text3); background: none; border: none; border-bottom: 2px solid transparent; padding: 0 14px; height: 42px; cursor: pointer; letter-spacing: 0.8px; transition: color 0.15s, border-color 0.15s; text-transform: uppercase; }
.tab-btn:hover { color: var(--text2); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }
.content-body { flex: 1; overflow-y: auto; padding: 20px 22px; }

/* LIBRARY SUB TABS */
.library-view-tabs { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.library-view-tab { font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; padding: 5px 10px; border-radius: var(--r); border: 1px solid var(--border2); background: var(--bg3); color: var(--text3); cursor: pointer; transition: all 0.15s; display: inline-flex; align-items: center; gap: 6px; }
.library-view-tab:hover { border-color: var(--accent); color: var(--text2); background: var(--bg4); }
.library-view-tab.active { border-color: rgba(200,80,255,0.35); color: var(--text); background: var(--accent-dim); }
.favorites-meta { font-family: var(--mono); font-size: 11px; color: var(--text3); }
.library-main-search { margin-bottom: 12px; }
.library-main-search input { font-size: 12px; }

/* ── LOG BAR ── */
.log-bar { background: var(--bg2); border-top: 1px solid var(--border); flex-shrink: 0; }
.log-bar-header { display: flex; align-items: center; gap: 8px; padding: 6px 14px; cursor: pointer; user-select: none; transition: background 0.1s; }
.log-bar-header:hover { background: var(--bg3); }
.log-bar-title { font-family: var(--mono); font-size: 10px; font-weight: 600; color: var(--text3); letter-spacing: 1.2px; text-transform: uppercase; flex: 1; }
.log-badge { font-family: var(--mono); font-size: 10px; color: var(--accent); background: var(--accent-dim); border: 1px solid rgba(200,80,255,0.3); border-radius: 10px; padding: 1px 7px; display: none; }
.log-badge.visible { display: inline-block; }
.log-bar-body { max-height: 0; overflow: hidden; transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.log-bar-body.open { max-height: 160px; }
.terminal { background: var(--bg); border-top: 1px solid var(--border); padding: 10px 14px; font-family: var(--mono); font-size: 11px; height: 130px; overflow-y: auto; line-height: 1.7; }
.term-sys { color: var(--text3); }
.term-err { color: var(--red); }
.term-out { color: var(--blue); }
.term-info { color: var(--green); }

/* ── BUTTONS ── */
.btn { font-family: var(--mono); font-size: 12px; font-weight: 500; padding: 7px 14px; border-radius: var(--r); border: 1px solid var(--border2); background: var(--bg4); color: var(--text2); cursor: pointer; transition: all 0.15s; letter-spacing: 0.3px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; text-decoration: none; }
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--text); background: var(--accent-dim); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #141619; font-weight: 700; }
.btn-accent:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: #141619; box-shadow: var(--glow-ir); }
.btn-green { background: var(--green-dim); border-color: rgba(72,187,120,0.35); color: var(--green); }
.btn-green:hover:not(:disabled) { background: rgba(72,187,120,0.2); border-color: var(--green); }
.btn-danger { background: var(--red-dim); border-color: rgba(245,101,101,0.3); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: rgba(245,101,101,0.2); border-color: var(--red); }
.btn-sm { padding: 4px 9px; font-size: 11px; }
.btn-icon { padding: 5px 7px; }
.btn-ghost { background: none; border-color: transparent; color: var(--text3); padding: 5px 7px; }
.btn-ghost:hover:not(:disabled) { background: var(--bg4); border-color: var(--border); color: var(--text2); }

#connectBtn { font-family: var(--mono); font-size: 12px; font-weight: 600; padding: 6px 16px; border-radius: var(--r); border: 1px solid rgba(200,80,255,0.35); background: rgba(200,80,255,0.08); color: var(--text); cursor: pointer; transition: all 0.15s; letter-spacing: 0.5px; text-transform: uppercase; white-space: nowrap; }
#connectBtn:hover { background: rgba(200,80,255,0.16); border-color: var(--accent); color: var(--text); }
#connectBtn.disconnect { border-color: rgba(245,101,101,0.35); background: var(--red-dim); color: var(--red); }
#connectBtn.disconnect:hover { background: rgba(245,101,101,0.2); border-color: var(--red); }

/* ── INPUTS ── */
input[type=text], textarea, select { font-family: var(--mono); font-size: 13px; background: var(--bg); border: 1px solid var(--border2); border-radius: var(--r); padding: 9px 12px; color: var(--text); outline: none; transition: border-color 0.15s; width: 100%; }
input[type=text]:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(200,80,255,0.07); }
input[type=text].err { border-color: var(--red); }
input[type=text].hex-input { letter-spacing: 1px; }
textarea { resize: vertical; min-height: 56px; font-family: var(--sans); font-size: 13px; }
select { cursor: pointer; }
label.field-label { display: block; font-family: var(--mono); font-size: 10px; color: var(--text3); letter-spacing: 1.2px; text-transform: uppercase; margin-bottom: 5px; font-weight: 600; }
.field-err { font-family: var(--mono); font-size: 11px; color: var(--red); margin-top: 4px; min-height: 15px; }
.field-group { margin-bottom: 14px; }

/* ── CARDS ── */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--r2); padding: 18px; margin-bottom: 14px; }
.card-title { font-family: var(--mono); font-size: 10px; font-weight: 600; color: var(--text3); letter-spacing: 1.2px; text-transform: uppercase; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card-title i { color: var(--accent); font-size: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ── SAVE FORM ── */
.save-form { background: var(--bg3); border: 1px solid var(--border2); border-radius: var(--r2); padding: 14px; margin-top: 12px; display: none; }
.save-form.open { display: block; animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:none; } }

/* ── SIGNAL BOX ── */
.signal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.signal-grid .signal-box { margin-bottom: 0; }
.signal-box { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--r2); padding: 10px 12px; margin-bottom: 6px; transition: border-color 0.15s; }
.signal-box:hover { border-color: var(--border2); }
.signal-box-header { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.signal-box-name { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signal-meta { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.signal-chip { font-family: var(--mono); font-size: 10px; padding: 2px 7px; border-radius: 4px; border: 1px solid var(--border); background: var(--bg4); color: var(--text2); white-space: nowrap; }
.signal-chip.addr { border-color: rgba(200,80,255,0.3); background: var(--accent-dim); color: var(--accent); }
.signal-chip.cmd { border-color: rgba(66,153,225,0.3); background: var(--blue-dim); color: var(--blue); }
.signal-chip.proto { border-color: rgba(72,187,120,0.2); background: var(--green-dim); color: var(--green); }
.signal-desc-view { font-size: 12px; color: var(--text3); font-style: italic; cursor: pointer; padding: 4px 6px; border-radius: 4px; transition: background 0.1s; margin: 4px 0; }
.signal-desc-view:hover { background: var(--bg4); color: var(--text2); }
.signal-actions { display: flex; gap: 6px; align-items: center; margin-top: 4px; }

/* ── ADD BUTTON BOX ── */
.add-btn-box { background: var(--bg3); border: 1px dashed var(--border2); border-radius: var(--r2); padding: 14px; margin-bottom: 8px; animation: fadeIn 0.15s ease; }
.add-btn-box-title { font-family: var(--mono); font-size: 10px; font-weight: 600; color: var(--accent); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }

/* ── TREE ── */
.tree-item { display: flex; align-items: center; gap: 5px; padding: 5px 8px; cursor: pointer; font-size: 12px; font-family: var(--mono); color: var(--text2); transition: background 0.1s, color 0.1s; user-select: none; position: relative; }
.tree-item:hover { background: var(--bg3); color: var(--text); }
.tree-item.active { background: var(--accent-dim); color: var(--text); }
.tree-item.drag-over { background: rgba(200,80,255,0.08); outline: 1px solid var(--accent); outline-offset: -1px; }
.tree-item.dragging { opacity: 0.4; }
.tree-item i { font-size: 13px; flex-shrink: 0; color: var(--text3); }
.tree-item.active i { color: var(--accent); }
.tree-item .ti-chevron-right { font-size: 10px; width: 12px; transition: transform 0.15s; }
.tree-item .ti-chevron-right.open { transform: rotate(90deg); }
.tree-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-actions { margin-left: auto; display: flex; gap: 1px; opacity: 0; transition: opacity 0.1s; flex-shrink: 0; }
.tree-item:hover .tree-actions { opacity: 1; }
.tree-act { background: none; border: none; color: var(--text3); cursor: pointer; padding: 2px 4px; border-radius: 3px; font-size: 12px; display: flex; align-items: center; transition: color 0.1s, background 0.1s; }
.tree-act:hover { color: var(--text); background: var(--bg4); }
.tree-act.del:hover { color: var(--red); }
.drag-handle { cursor: grab; color: var(--text3); font-size: 12px; padding: 2px 3px; opacity: 0; transition: opacity 0.1s; flex-shrink: 0; }
.tree-item:hover .drag-handle { opacity: 1; }
.drag-handle:active { cursor: grabbing; }

/* DRAG GHOST */
.drag-ghost { position: fixed; pointer-events: none; z-index: 9999; background: var(--bg2); border: 1px solid var(--accent); border-radius: var(--r); padding: 5px 10px; font-family: var(--mono); font-size: 12px; color: var(--text); white-space: nowrap; display: none; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }

/* UTILITY */
.text-red { color: var(--red); }
.icon-vm { vertical-align: -2px; margin-right: 6px; }
.icon-xs { font-size: 10px; }
.hidden-input { display: none; }
.pane-hidden { display: none; }
.irdb-nav .search-wrap-no-mb { margin: 0; }
.irdb-search-input { font-size: 11px; padding: 6px 8px 6px 28px; }
.card-title-space { justify-content: space-between; }
.transmit-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.save-form-actions { display: flex; gap: 8px; margin-top: 4px; }
.log-bar-icon { font-size: 13px; color: var(--text3); flex-shrink: 0; }
.clear-log-btn { margin-left: auto; margin-right: 4px; }
.log-chevron { font-size: 12px; color: var(--text3); transition: transform 0.2s; flex-shrink: 0; }
.modal-msg { color: var(--text2); font-size: 13px; margin-bottom: 4px; }
.modal-msg-lg { color: var(--text2); font-size: 13px; margin-bottom: 10px; line-height: 1.6; }
.modal-msg-md { color: var(--text2); font-size: 13px; margin-bottom: 14px; line-height: 1.5; }

/* ── SECTION ── */
.section-hdr { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title { font-family: var(--mono); font-size: 10px; font-weight: 600; color: var(--text3); letter-spacing: 1.2px; text-transform: uppercase; }
.remote-view-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.remote-view-title { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1 1 auto; max-width: 100%; overflow: hidden; }
.remote-view-title i { flex-shrink: 0; }
.remote-view-title-text {
  font-family: var(--mono);
  font-size: 13px;       /* Matches signal-box-name */
  font-weight: 600;      /* Matches signal-box-name */
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.remote-view-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ── BREADCRUMB ── */
.breadcrumb { font-family: var(--mono); font-size: 12px; color: var(--text3); margin-bottom: 16px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.breadcrumb a { color: var(--text2); cursor: pointer; transition: color 0.1s; text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--text3); }
.breadcrumb .cur { color: var(--accent); }

/* ── MODAL ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 100; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--bg2); border: 1px solid var(--border2); border-radius: var(--r2); padding: 22px; width: 400px; max-width: 92vw; }
.modal-title { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.modal-title i { color: var(--accent); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ── EMPTY STATE ── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 50px 20px; color: var(--text3); text-align: center; }
.empty-state i { font-size: 30px; opacity: 0.3; }
.empty-state p { font-family: var(--mono); font-size: 12px; line-height: 1.6; }

/* ── SEARCH ── */
.search-wrap { position: relative; margin-bottom: 14px; }
.search-wrap input { padding-left: 30px; }
.search-wrap i { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); font-size: 14px; color: var(--text3); pointer-events: none; }

/* ── SPINNER ── */
.spinner { width: 13px; height: 13px; border: 2px solid var(--border2); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; display: inline-block; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── REMOTE CARD ── */
.remote-card { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--r2); padding: 15px; margin-bottom: 8px; cursor: pointer; transition: border-color 0.15s, background 0.15s; display: flex; flex-direction: column; gap: 12px; min-height: 176px; }
.remote-card:hover { border-color: var(--accent); background: rgba(200,80,255,0.03); }
.remote-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.remote-card-title { display: flex; align-items: flex-start; gap: 10px; min-width: 0; flex: 1; }
.remote-card-icon { flex-shrink: 0; font-size: 15px; color: var(--accent); margin-top: 2px; }
.remote-card-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.remote-card-name { display: block; width: 100%; font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.35; letter-spacing: 0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remote-card-meta { font-family: var(--mono); font-size: 10px; color: var(--text3); letter-spacing: 0.14em; text-transform: uppercase; }
.remote-card-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; margin-left: auto; }
.remote-card-preview { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.remote-card-desc { font-size: 11px; color: var(--text3); font-style: italic; margin: 0; line-height: 1.4; cursor: pointer; transition: color 0.1s; }
.remote-card-desc:hover { color: var(--text2); }
.chip-row { display: flex; flex-wrap: wrap; gap: 4px; overflow: hidden; align-items: flex-start; align-content: flex-start; max-height: 50px; }
.chip-row.expanded { max-height: none; overflow: visible; }
.remote-card-preview-bottom { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 0; }
.remote-card-footer { display: flex; align-items: center; gap: 8px; }
.remote-card-more { padding-left: 10px; padding-right: 10px; }
.remote-card-more i { font-size: 11px; }
.remote-card-hidden { color: var(--text3); }
.remote-card-empty { color: var(--text3); }

/* ── FOLDER PREVIEW ── */
.folder-preview { display: flex; flex-direction: column; gap: 4px; }
.folder-preview-item { display: flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 11px; color: var(--text2); min-width: 0; }
.folder-preview-item i { font-size: 12px; flex-shrink: 0; color: var(--text3); }
.folder-preview-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-preview-more { font-family: var(--mono); font-size: 10px; color: var(--text3); margin-top: 2px; }

/* ── FOLDER SECTION ── */
.folder-section { margin-bottom: 16px; }
.folder-section-hdr { display: flex; align-items: center; gap: 6px; padding: 5px 0; border-bottom: 1px solid var(--border); margin-bottom: 8px; cursor: pointer; }
.folder-section-hdr:hover .folder-section-name { color: var(--text); }
.folder-section-name { font-family: var(--mono); font-size: 12px; color: var(--text2); flex: 1; transition: color 0.1s; }
.library-tree-wrap { display: block; }
.folder-children { margin-left: 14px; padding-left: 10px; border-left: 1px dashed var(--border2); margin-top: 6px; }

/* MAIN LIBRARY GRID */
.library-browser-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.library-browser-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.library-browser-right { display: flex; align-items: center; gap: 6px; }
.library-path { font-family: var(--mono); font-size: 11px; color: var(--text3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.library-path a { color: var(--text2); text-decoration: none; cursor: pointer; }
.library-path a:hover { color: var(--accent); }
.library-path .sep { color: var(--text3); }
.library-path .cur { color: var(--accent); }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; align-items: start; }
.remote-card-grid { margin: 0; }

/* ── FAVORITES LAYOUT ── */
.favorites-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.favorites-column { min-width: 0; }
.fav-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fav-signal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.fav-signal-item { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--r2); padding: 10px 12px; transition: border-color 0.15s; }
.fav-signal-item:hover { border-color: var(--border2); }
.fav-signal-top { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.fav-signal-name { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.fav-signal-actions { display: flex; gap: 6px; margin-top: 6px; }
.fav-signal-desc { font-size: 11px; color: var(--text3); font-style: italic; margin-top: 4px; line-height: 1.4; }

/* ── IRDB ── */
.irdb-layout { display: flex; gap: 12px; height: calc(100vh - 190px); overflow: hidden; }
.irdb-nav { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r2); background: var(--bg2); overflow: hidden; }
.irdb-nav-search { padding: 8px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.irdb-tree-body { flex: 1; overflow-y: auto; padding: 4px 0; }
.irdb-detail { flex: 1; overflow-y: auto; }
.irdb-source-link { font-family: var(--mono); font-size: 10px; color: var(--text3); text-decoration: none; transition: color 0.1s; }
.irdb-source-link:hover { color: var(--accent); }
.irdb-detail-btn-box { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--r2); padding: 12px 14px; margin-bottom: 7px; display: flex; flex-direction: column; gap: 8px; }
.irdb-detail-btn-name { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── HISTORY ── */
.folder-picker-tree { max-height: 240px; overflow-y: auto; border: 1px solid var(--border2); border-radius: var(--r); background: var(--bg); padding: 4px 0; }
.folder-picker-row { display: flex; align-items: center; gap: 6px; padding: 5px 8px; cursor: pointer; font-family: var(--mono); font-size: 11px; color: var(--text2); user-select: none; transition: background 0.1s, color 0.1s; }
.folder-picker-row:hover { background: var(--bg3); color: var(--text); }
.folder-picker-row.selected { background: var(--accent-dim); color: var(--text); }
.folder-picker-row i { font-size: 12px; color: var(--text3); flex-shrink: 0; }
.folder-picker-row.selected i { color: var(--accent); }
.folder-picker-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hist-list { max-height: 260px; overflow-y: auto; }
.hist-row { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--r2); padding: 10px 12px; margin-bottom: 6px; }
.hist-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.hist-ts { font-family: var(--mono); font-size: 10px; color: var(--text3); flex-shrink: 0; }
.hist-label { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 48px; left: -100%;
    width: 280px; max-width: 80vw;
    height: calc(100vh - 48px);
    z-index: 60;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }
  .sidebar.open { left: 0; }
  .sidebar-resize-handle { display: none; }
  .library-grid { grid-template-columns: 1fr; }
  .library-browser-left { flex-wrap: wrap; }
  .favorites-layout { grid-template-columns: 1fr; }
  .fav-grid { grid-template-columns: 1fr; }
  .fav-signal-grid { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .signal-grid { grid-template-columns: 1fr; }
  .irdb-layout { flex-direction: column; height: auto; }
  .irdb-nav { width: 100%; max-height: 220px; }
  .irdb-detail { min-height: 280px; }
  .content-header { padding: 0 10px; }
  .tab-btn { font-size: 10px; padding: 0 10px; letter-spacing: 0.5px; }
  .content-body { padding: 14px; }
  .transmit-actions { flex-direction: column; align-items: stretch; }
  .transmit-actions .btn { width: 100%; justify-content: center; }
  .card { padding: 14px; }
  .remote-card { min-height: auto; }
  .library-browser-toolbar { flex-direction: column; align-items: flex-start; }
  .library-browser-right { width: 100%; }
}

@media (max-width: 600px) {
  .topbar { padding: 0 10px; gap: 6px; }
  .topbar-sep { display: none; }
  .topbar-home span { display: none; }
  .topbar-right { gap: 6px; }
  #connectBtn { font-size: 10px; padding: 4px 8px; letter-spacing: 0.3px; }
  .badge { font-size: 10px; padding: 2px 6px; }
  .sidebar { width: 260px; }
  .content-body { padding: 10px; }
  .tab-btn { font-size: 9px; padding: 0 6px; letter-spacing: 0.3px; }
  .log-bar-body.open { max-height: 115px; }
  .terminal { font-size: 10px; padding: 6px 8px; height: 90px; }
  .log-bar-header { padding: 4px 8px; gap: 4px; }
  .library-view-tabs { gap: 4px; }
  .library-view-tab { font-size: 9px; padding: 4px 7px; }
  .remote-card { padding: 10px; }
  .remote-card-preview { gap: 4px; }
  .remote-view-actions { flex-wrap: wrap; }
  .breadcrumb { font-size: 10px; }
  .signal-box { padding: 8px 10px; }
  .signal-box-header { gap: 4px; }
  .signal-box-name { font-size: 12px; }
  .hist-list { max-height: 160px; }
  .hist-row { padding: 8px 10px; }
  .add-btn-box { padding: 10px; }
  .save-form { padding: 10px; }
  .irdb-detail-btn-box { padding: 10px; }
  .folder-picker-row { font-size: 10px; padding: 4px 6px; }
  .modal { padding: 16px; }
  .favorites-column { min-width: 0; }
}
