/*
  TV Tracker styles
  Version 113
  Keep this file focused on visual styling only.
*/

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

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ui-icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  pointer-events: none;
}

/* ═══════════════════════════════════════════
   TOKENS
═══════════════════════════════════════════ */
:root {
  --bg:        #0d0d0f;
  --bg2:       #131316;
  --bg3:       #1a1a1f;
  --bg4:       #222228;
  --border:    #2a2a32;
  --border2:   #383844;
  --accent:    #00c2ff;
  --accent2:   #0088cc;
  --accent-dim:rgba(0,194,255,0.12);
  --text:      #e8e8f0;
  --text2:     #9090a8;
  --text3:     #606075;
  --fav:       #ffb800;
  --good:      #00c896;
  --mid:       #ffa000;
  --bad:       #ff3d3d;
  --sidebar-w: 260px;
  --detail-w:  320px;
  --header-h:  52px;
  --radius:    6px;
  --trans:     .18s ease;
}

/* ═══════════════════════════════════════════
   RESET
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}

/* ═══════════════════════════════════════════
   HEADER
═══════════════════════════════════════════ */
header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 50;
  position: relative;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
  text-transform: uppercase;
  flex-shrink: 0;
  user-select: none;
}
.logo span { color: var(--text2); font-weight: 400; }

/* Hamburger menu */
.ham-menu {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: 260px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 12px 0;
  z-index: 400;
  transform: translateX(-100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  box-shadow: 4px 4px 24px rgba(0,0,0,0.4);
  overflow: hidden;
}
.ham-menu.open { transform: translateX(0); }
.ham-menu-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ham-menu-logo .logo-big {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--accent);
  text-transform: uppercase;
  line-height: 1;
}
.ham-menu-logo .logo-big span { color: var(--text2); font-weight: 400; }
.ham-menu-logo .logo-sub {
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 2px;
  text-transform: uppercase;
}
.ham-scrim {
  position: fixed; inset: 0;
  top: var(--header-h);
  z-index: 399;
  display: none;
}
.ham-scrim.show { display: block; }

/* Ham menu items */
.ham-section {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.ham-section:last-child { border-bottom: none; }
.ham-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  transition: background var(--trans), color var(--trans);
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  font-family: 'Inter', sans-serif;
  text-align: left;
}
.ham-item:hover  { background: var(--bg3); color: var(--text); }
.ham-item:active { background: var(--bg4); }
.ham-item-icon   { font-size: 16px; width: 20px; display:flex; align-items:center; justify-content:center; flex-shrink: 0; opacity: .7; }

.search-wrap { flex: 1; max-width: 360px; position: relative; }

.search-wrap input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  padding: 7px 12px 7px 34px;
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--trans);
}
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap input::placeholder { color: var(--text3); }
.search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  font-size: 15px;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.search-x {
  position: absolute;
  right: 8px;
  top: 0; bottom: 0;
  margin: auto 0;
  height: 20px;
  z-index: 10;
  background: none;
  border: none;
  color: var(--text3);
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--trans);
}
.search-x:hover { color: var(--text); }
.search-x.on { opacity: 1; pointer-events: auto; }
.header-actions { margin-left: auto; display: flex; gap: 8px; }

.btn-icon {
  width: 34px; height: 34px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  font-size: 17px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--trans);
  flex-shrink: 0;
  user-select: none;
}
.btn-icon:hover  { background: var(--bg4); color: var(--accent); border-color: var(--accent); }
.btn-icon.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

/* ═══════════════════════════════════════════
   APP BODY
═══════════════════════════════════════════ */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ═══════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

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

.cat-list { overflow-y: auto; flex: 1; padding: 6px 0; }

.cat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  cursor: pointer;
  border-left: 2px solid transparent;
  font-size: 15px;
  font-weight: 500;
  transition: background var(--trans), border-color var(--trans), color var(--trans);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.cat-item:hover  { background: var(--bg3); }
.cat-item.active { background: var(--accent-dim); border-left-color: var(--accent); color: var(--accent); }

.cat-icon  { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.cat-name  { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-count {
  font-size: 11px;
  font-family: 'Inter', sans-serif;
  color: var(--text3);
  background: var(--bg4);
  padding: 1px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}
.cat-item.active .cat-count { background: var(--accent2); color: #fff; }

/* ═══════════════════════════════════════════
   CHANNEL LIST
═══════════════════════════════════════════ */
.channel-list-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.list-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  flex: 1 1 0;
  min-width: 0;
}
.toolbar-title,
.toolbar-center {
  flex: 1 1 0;
  min-width: 0;
}
.toolbar-title {
  display: flex;
  align-items: center;
}
.toolbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
.toolbar-actions {
  flex-shrink: 0;
}
.toolbar-search {
  width: clamp(140px, 24vw, 240px);
  height: 28px;
  position: relative;
  flex-shrink: 0;
}
.toolbar-search input {
  width: 100%;
  height: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  padding: 0 28px 0 30px;
  outline: none;
  transition: border-color var(--trans);
}
.toolbar-search input:focus { border-color: var(--accent); }
.toolbar-search input::placeholder { color: var(--text3); }
.toolbar-search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  font-size: 14px;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cat-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text2);
  text-transform: uppercase;
  flex: 0 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sort-btn {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text2);
  padding: 0 10px;
  height: 28px;
  line-height: 1;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  cursor: pointer;
  transition: all var(--trans);
  white-space: nowrap;
}
.sort-btn:hover { color: var(--accent); border-color: var(--accent); }
.sort-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}
.back-btn {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text2);
  padding: 0 10px;
  height: 28px;
  line-height: 1;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  cursor: pointer;
  transition: all var(--trans);
  white-space: nowrap;
  max-width: 45vw;
  overflow: hidden;
  text-overflow: ellipsis;
  display: none;
}
.back-btn::before {
  content: '';
  width: 14px;
  height: 14px;
  display: inline-block;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M15 18 9 12 15 6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M15 18 9 12 15 6' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.back-btn:hover { color: var(--accent); border-color: var(--accent); }
.back-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}
.back-btn:active { background: var(--bg4); }
@media (max-width: 768px) {
  .back-btn { display: inline-flex; }
  .toolbar-title { display: none; }
  .toolbar-center { flex: 1 1 auto; }
  .toolbar-actions { flex: 0 0 auto; }
  #catLabelDesktop { display: none; }
  .toolbar-search { flex: 1; min-width: 0; width: auto; }
}
.sort-opt {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text2);
  cursor: pointer;
  transition: background var(--trans), color var(--trans);
}
.sort-opt:hover { background: var(--bg4); color: var(--accent); }
.sort-opt.active { color: var(--accent); font-weight: 700; }

.channels { overflow-y: auto; flex: 1; }

.ch-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--trans), opacity var(--trans);
  position: relative;
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.ch-item:hover  { background: var(--bg3); }
.ch-item.active { background: var(--accent-dim); }
.ch-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
}
.ch-item.drag-ghost { opacity: .3; pointer-events: none; }

/* Drag handle */
.drag-handle {
  display: flex;
  flex-direction: column;
  gap: 2.5px;
  padding: 10px 8px;
  cursor: grab;
  flex-shrink: 0;
  opacity: .3;
  transition: opacity var(--trans);
  touch-action: none;
  margin-left: 4px;
}
.drag-handle:hover { opacity: .8; }
.drag-handle:active { cursor: grabbing; }
.drag-handle span {
  display: block;
  width: 14px;
  height: 1.5px;
  background: var(--text2);
  border-radius: 1px;
}

/* Drop placeholder */
.drop-placeholder {
  background: var(--accent-dim);
  border: 1.5px dashed var(--accent);
  border-radius: 4px;
  pointer-events: none;
  flex-shrink: 0;
}

/* Drag preview (floating clone) */
.drag-preview {
  position: fixed;
  z-index: 800;
  pointer-events: none;
  border-radius: 8px;
  background: var(--bg2);
  border: 1px solid var(--accent);
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  opacity: .95;
  overflow: hidden;
  transition: none;
}
.drag-badge {
  position: absolute;
  top: -8px; right: -8px;
  width: 20px; height: 20px;
  background: var(--accent);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Inter', sans-serif;
}

.ch-logo {
  width: 36px; height: 36px;
  border-radius: 6px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: var(--bg4);
  border: 1px solid var(--border);
}
.ch-logo img { width: 100%; height: 100%; object-fit: contain; padding: 8%; }
.ch-logo.has-logo { background: transparent; border-color: transparent; }

.ch-fav {
  font-size: 15px;
  color: var(--text3);
  cursor: pointer;
  flex-shrink: 0;
  transition: color var(--trans), transform var(--trans);
  width: 22px;
  text-align: center;
  padding: 4px 0;
}
.ch-fav.on  { color: var(--fav); }
.ch-fav:hover { transform: scale(1.3); }

.ch-info { flex: 1; min-width: 0; }
.ch-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ch-meta {
  font-size: 12px;
  color: var(--text3);
  display: flex;
  gap: 8px;
  margin-top: 1px;
  align-items: center;
}

/* Checkbox */
.ch-checkbox {
  width: 20px; height: 20px;
  border: 1.5px solid var(--border2);
  border-radius: 4px;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center; justify-content: center;
  transition: all var(--trans);
  background: transparent;
  user-select: none;
  -webkit-user-select: none;
  margin-right: 4px;
}
.ch-checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
}
.ch-checkbox.checked::after {
  content: '✓';
  font-size: 10px;
  color: #000;
  font-weight: 700;
  line-height: 1;
}
/* Show checkboxes only when selection is active */
body.has-selection .ch-checkbox { display: flex; }
/* Select-all checkbox always visible */
#selectAllBox { display: flex !important; }

/* Select-all toolbar */
.select-toolbar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--accent-dim);
  flex-shrink: 0;
}
.select-toolbar.show { display: flex; }
.select-toolbar .sel-count {
  font-size: 13px; font-weight: 600; color: var(--accent); flex: 1;
}
.select-toolbar button {
  font-family: 'Inter', sans-serif;
  font-size: 13px; font-weight: 600;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: all var(--trans);
}
.sel-btn-move {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text2);
}
.sel-btn-move:hover { border-color: var(--accent); color: var(--accent); }
.sel-btn-cancel {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text3);
}
.sel-btn-cancel:hover { color: var(--text); }

/* Quality badges — uniform size */
.quality-badge {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  width: 50px;
  text-align: center;
  padding: 5px 0;
  border-radius: 3px;
  letter-spacing: 0.5px;
  user-select: none;
  flex-shrink: 0;
}
.q-uhd  { background: rgba(0,200,150,0.15); color: var(--good); border: 1px solid rgba(0,200,150,0.3); }
.q-fhd { background: rgba(0,194,255,0.12); color: var(--accent); border: 1px solid rgba(0,194,255,0.25); }
.q-hd  { background: rgba(255,160,0,0.12); color: var(--mid);  border: 1px solid rgba(255,160,0,0.25); }
.q-sd  { background: rgba(255,61,61,0.12);  color: var(--bad);  border: 1px solid rgba(255,61,61,0.25); }
.q-fps { background: rgba(255,117,241,0.12); color: #ff75f1; border: 1px solid rgba(255,117,241,0.3); }

.var-q-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--mid);
  display: inline-block;
  flex-shrink: 0;
}

/* Empty state */
.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text3);
  font-size: 14px;
}
.empty-icon { font-size: 40px; opacity: .3; }

/* ═══════════════════════════════════════════
   DETAIL PANEL
═══════════════════════════════════════════ */
.detail {
  width: var(--detail-w);
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.detail-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.detail-ch-name { font-size: 20px; font-weight: 700; line-height: 1.2; }
.detail-ch-sub  {
  font-size: 13px;
  color: var(--text3);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text3);
  text-transform: uppercase;
  margin-bottom: 6px;
}

/* Source items */
.sources-list { display: flex; flex-direction: column; gap: 6px; }
.source-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
}
.source-dot  { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.source-name { flex: 1; font-weight: 500; }
.source-add {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: transparent;
  border: 1px dashed var(--border2);
  border-radius: var(--radius);
  color: var(--text3);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--trans);
}
.source-add:hover { color: var(--accent); border-color: var(--accent); }

/* Quality + Stab buttons */
.q-btn {
  flex: 1;
  padding: 7px 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text2);
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  cursor: pointer;
  transition: all var(--trans);
  text-align: center;
}
.q-btn:hover     { border-color: var(--accent); color: var(--accent); }
.q-btn.sel-4k    { background: rgba(0,200,150,0.15); color: var(--good);   border-color: var(--good); }
.q-btn.sel-fhd   { background: rgba(0,194,255,0.12); color: var(--accent); border-color: var(--accent); }
.q-btn.sel-hd    { background: rgba(255,160,0,0.12); color: var(--mid);   border-color: var(--mid); }
.q-btn.sel-sd    { background: rgba(255,61,61,0.12);  color: var(--bad);   border-color: var(--bad); }

/* Tags */
.tags-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 4px 10px;
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  transition: all var(--trans);
}
.tag:hover { border-color: var(--accent); color: var(--accent); }
.tag.on    { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.tag-add {
  padding: 4px 10px;
  background: transparent;
  border: 1px dashed var(--border2);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text3);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all var(--trans);
}
.tag-add:hover { color: var(--accent); border-color: var(--accent); }

.tags-manager-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 12px;
}
.tag-row {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tag-row:hover { border-color: var(--border2); }
.tag-row.dragging {
  opacity: .45;
  border-color: var(--accent);
}
.tag-row-handle {
  width: 18px;
  flex-shrink: 0;
  color: var(--text3);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  user-select: none;
}
.tag-row-handle:active { cursor: grabbing; }
.tag-row-name {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag-row-actions {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}
.tag-row-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text3);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--trans);
}
.tag-row-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.tag-row-btn.danger:hover {
  color: var(--bad);
  border-color: var(--bad);
}
.tag-row-input {
  flex: 1;
  min-width: 0;
  height: 28px;
  background: var(--bg4);
  border: 1px solid var(--accent);
  border-radius: 5px;
  color: var(--accent);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 0 8px;
  outline: none;
}

/* Notes */
.notes-area {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  line-height: 1.6;
  padding: 10px 12px;
  resize: none;
  min-height: 100px;
  outline: none;
  transition: border-color var(--trans);
}
.notes-area:focus { border-color: var(--accent); }
.notes-area::placeholder { color: var(--text3); }

/* Save button */
.save-btn {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #000;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background var(--trans), transform .1s;
  text-transform: uppercase;
}
.save-btn:hover  { background: #33d0ff; }
.save-btn:active { transform: scale(.98); }

/* No selection */
.no-sel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text3);
  font-size: 13px;
  text-align: center;
  padding: 20px;
}
.no-sel-icon { font-size: 36px; opacity: .25; margin-bottom: 6px; }

/* ═══════════════════════════════════════════
   MODALS
═══════════════════════════════════════════ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.overlay.show { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 12px;
  width: 90%;
  max-width: 380px;
  padding: 20px;
  transform: translateY(20px);
  transition: transform .2s;
}
.overlay.show .modal { transform: translateY(0); }

.modal-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 16px;
  color: var(--accent);
  text-transform: uppercase;
}
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text3);
  text-transform: uppercase;
  margin-bottom: 5px;
}
.field input, .field select {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--trans);
}
.field input:focus, .field select:focus { border-color: var(--accent); }
.field select option { background: var(--bg3); }

.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.btn-cancel {
  flex: 1; padding: 9px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--trans);
}
.btn-cancel:hover { border-color: var(--border2); }
.btn-ok {
  flex: 1; padding: 9px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #000;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .5px;
  cursor: pointer;
  transition: background var(--trans);
  text-transform: uppercase;
}
.btn-ok:hover { background: #33d0ff; }

/* ═══════════════════════════════════════════
   CONTEXT MENU
═══════════════════════════════════════════ */
.ctx-menu {
  position: fixed;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 5px 0;
  z-index: 900;
  min-width: 190px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.7);
  opacity: 0;
  transform: scale(0.9);
  transform-origin: top left;
  transition: opacity .14s ease, transform .14s ease;
  pointer-events: none;
}
.ctx-menu.show {
  opacity: 1;
  transform: scale(1);
  pointer-events: all;
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background .1s;
}
.ctx-item:active { background: var(--bg4); }
.ctx-item.danger { color: var(--bad); }
.ctx-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
  color: var(--text3);
  flex-shrink: 0;
  font-style: normal;
}
.ctx-item.danger .ctx-icon { color: var(--bad); }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ═══════════════════════════════════════════
   TOAST
═══════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  color: var(--text);
  z-index: 999;
  transition: transform .25s ease;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ═══════════════════════════════════════════
   ACCENT LINE
═══════════════════════════════════════════ */
.accentline {
  position: fixed;
  top: var(--header-h); left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.35;
  pointer-events: none;
  z-index: 49;
}

/* ═══════════════════════════════════════════
   MOBILE — STACK NAVIGATION
   Level 0: Sidebar (categories)
   Level 1: Channel list
   Level 2: Detail
═══════════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; --detail-w: 0px; }

  .app-body {
    overflow: hidden;
    position: relative; /* anchor for absolute children */
  }

  /* All three panels fill the app-body exactly */
  .sidebar,
  .channel-list-wrap,
  .detail {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    border: none;
    will-change: transform;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
  }

  /* Explicit backgrounds so panels fully cover each other */
  .sidebar           { background: var(--bg2); }
  .channel-list-wrap { background: var(--bg);  }
  .detail            { background: var(--bg2); }

  /* Default positions — sidebar visible, others off-screen right */
  .sidebar            { z-index: 10; transform: translateX(0);    }
  .channel-list-wrap  { z-index: 20; transform: translateX(100%); }
  .detail             { z-index: 30; transform: translateX(100%); }

  /* Level 1: channels in, sidebar peeked left */
  body.nav-1 .sidebar           { transform: translateX(-28%); }
  body.nav-1 .channel-list-wrap { transform: translateX(0);    }
  body.nav-1 .detail            { transform: translateX(100%); }

  /* Level 2: detail in, channels peeked left */
  body.nav-2 .sidebar           { transform: translateX(-100%); }
  body.nav-2 .channel-list-wrap { transform: translateX(-28%);  }
  body.nav-2 .detail            { transform: translateX(0);     }

  /* Back arrow button — only visible on mobile inside toolbar */
  .mob-back-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--accent);
    font-size: 24px;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
    padding: 0;
    margin-right: 2px;
  }
  .mob-back-btn:active { opacity: .6; }

  /* Back buttons — only visible on mobile */
  .mob-back {
    display: flex !important;
    align-items: center;
    gap: 6px;
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
    background: var(--bg2);
    user-select: none;
    -webkit-user-select: none;
    transition: background var(--trans);
  }
  .mob-back-btn { display: flex; }
}

/* Hide back button on desktop */
.mob-back-btn { display: none; }

@media (max-width: 768px) {
  #btnMenu { display: none !important; }
}
