/* ── Channel Studio — minimal design system ─────────────────────────────── */

:root {
  --bg: #f6f6f7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --border: #e6e6ea;
  --border-strong: #d6d6dc;
  --text: #191a1e;
  --muted: #83868f;
  --faint: #b0b3bb;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --live: #e5484d;
  --live-soft: #fdecec;
  --ok: #2f9e63;
  --ok-soft: #e8f6ee;
  --warn: #b98b1d;
  --warn-soft: #fdf5e0;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.05), 0 8px 24px rgba(20, 20, 30, 0.06);
  --shadow-pop: 0 4px 12px rgba(20, 20, 30, 0.1), 0 16px 40px rgba(20, 20, 30, 0.14);
  --font: -apple-system, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #101116;
  --surface: #17181f;
  --surface-2: #1e1f28;
  --border: #262833;
  --border-strong: #33353f;
  --text: #ecedf1;
  --muted: #8f939e;
  --faint: #5b5e69;
  --accent: #6c63ff;
  --accent-soft: #232145;
  --live: #ef5b60;
  --live-soft: #3a1e22;
  --ok: #3dbf7c;
  --ok-soft: #16301f;
  --warn: #d9a834;
  --warn-soft: #33290f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-pop: 0 4px 12px rgba(0, 0, 0, 0.5), 0 16px 40px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

::selection { background: var(--accent-soft); }

/* ── Layout ─────────────────────────────────────────────────────────────── */

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: 0;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 10px 10px 16px;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--text);
  color: var(--surface);
  font-size: 12px;
}

.side-tools { display: flex; gap: 1px; }

.icon-btn {
  width: 27px; height: 27px;
  display: grid; place-items: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  transition: background 0.12s ease, color 0.12s ease;
  position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.bell { font-size: 11px; }
.bell-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--live);
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: background 0.1s ease;
  position: relative;
}
.channel-item:hover { background: var(--surface-2); }
.channel-item.active { background: var(--accent-soft); }
.channel-item.drop-target {
  background: var(--accent-soft);
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}
.channel-item.drop-above { box-shadow: 0 -2px 0 var(--accent); }

.channel-avatar {
  width: 30px; height: 30px;
  flex: none;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
}
.channel-avatar img { width: 100%; height: 100%; object-fit: cover; }

.channel-item-body { flex: 1; min-width: 0; }
.channel-item-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.channel-item-meta { font-size: 12px; color: var(--muted); }

.status-dot {
  width: 7px; height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--ok);
}
.status-dot.offline { background: var(--faint); }
.status-dot.warn { background: var(--warn); }

.system-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  min-height: 20px;
}
.system-meta { font-size: 11.5px; color: var(--faint); margin-left: auto; }
.queue-chip {
  border: none;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
}
.queue-chip.failed { background: var(--live-soft); color: var(--live); }

.new-channel-btn {
  margin: 6px 10px 10px;
  padding: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  transition: all 0.12s ease;
}
.new-channel-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.new-channel-btn .plus { font-size: 15px; }

.side-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ── Main area ──────────────────────────────────────────────────────────── */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.main-empty {
  flex: 1;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
}
.main-empty h2 { color: var(--text); font-size: 18px; font-weight: 600; margin: 0 0 6px; }
.main-empty p { margin: 0; font-size: 13.5px; }

.main-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 24px 0;
}

.head-avatar {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 17px;
  color: var(--muted);
  overflow: hidden;
  flex: none;
}
.head-avatar img { width: 100%; height: 100%; object-fit: cover; }

.head-body { flex: 1; min-width: 0; }
.head-title {
  font-size: 18px;
  font-weight: 650;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 8px;
}
.lcn {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  padding: 1px 6px;
}
.head-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; }
.head-meta #nowChipSlot { display: inline-flex; min-width: 0; overflow: hidden; }

.now-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px 2px 7px;
  border-radius: 99px;
  background: var(--live-soft);
  color: var(--live);
  font-weight: 550;
  font-size: 12px;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}
.now-chip .pulse {
  width: 6px; height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--live);
  animation: pulse 1.6s ease infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.now-chip .now-title { overflow: hidden; text-overflow: ellipsis; }
.now-chip .clear-live {
  border: none; background: none; color: var(--live);
  padding: 0 0 0 2px; font-size: 13px; line-height: 1;
}

.head-actions { display: flex; align-items: center; gap: 8px; }

.btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-weight: 500;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--text); }
.btn.primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn.primary:hover { opacity: 0.85; }
.btn.danger { color: var(--live); border-color: var(--live); background: transparent; }
.btn.danger:hover { background: var(--live-soft); }
.btn.subtle { border-color: transparent; background: transparent; color: var(--muted); }
.btn.subtle:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.switch {
  position: relative;
  width: 36px; height: 21px;
  border-radius: 99px;
  border: none;
  background: var(--faint);
  transition: background 0.15s ease;
  flex: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2.5px; left: 2.5px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch.on { background: var(--ok); }
.switch.on::after { transform: translateX(15px); }
.switch.small { width: 30px; height: 18px; }
.switch.small::after { width: 13px; height: 13px; top: 2.5px; }
.switch.small.on::after { transform: translateX(12px); }

/* ── Tabs ───────────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 2px;
  padding: 14px 24px 0;
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: 8px 14px 10px;
  border: none;
  background: none;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s ease;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--text); }

.tab-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  position: relative;
}

/* ── Library ────────────────────────────────────────────────────────────── */

.library-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px 6px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
  flex-wrap: wrap;
}

.search-box {
  flex: none;
  width: 210px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}
.search-box input {
  border: none;
  outline: none;
  background: none;
  flex: 1;
  min-width: 0;
  color: var(--text);
}
.search-box input::placeholder { color: var(--faint); }

.filter-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 5px 11px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 500;
}
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip.active { background: var(--text); color: var(--bg); }

.toolbar-spacer { flex: 1; }

.upload-panel {
  margin: 6px 24px 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
}
.upload-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 4px;
}
.upload-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 4px 10px;
  padding: 5px 0;
}
.upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-status { font-size: 12px; color: var(--muted); }
.upload-status.done { color: var(--ok); }
.upload-status.error { color: var(--live); }
.upload-cancel { border: none; background: none; color: var(--faint); padding: 0 4px; }
.upload-cancel:hover { color: var(--live); }
.upload-row .track { grid-column: 1 / -1; }
.track {
  height: 4px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
}
.fill, .progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.2s ease;
}

.trash-banner {
  margin: 6px 24px 0;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 14px;
  padding: 14px 24px 80px;
  user-select: none;
}

.tile {
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  cursor: default;
  transition: box-shadow 0.12s ease, border-color 0.12s ease;
  position: relative;
}
.tile:hover { box-shadow: var(--shadow); }
.media-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow);
}
.media-item.disabled-media .thumb, .media-item.disabled-media .row-thumb { opacity: 0.45; }
.media-item.disabled-media .tile-title { color: var(--muted); }
.media-item.cut { opacity: 0.5; }
.media-item.insert-before::before {
  content: "";
  position: absolute;
  left: -9px; top: 6px; bottom: 6px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
  z-index: 2;
}
.media-row.insert-before::before { left: 0; right: 0; top: -5px; bottom: auto; width: auto; height: 3px; }
.media-item.dragging { opacity: 0.4; }

.thumb {
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 22px;
  position: relative;
}
.thumb .duration {
  position: absolute;
  right: 6px; bottom: 6px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(12, 12, 18, 0.72);
  color: #fff;
  font-size: 11px;
  font-weight: 550;
  z-index: 1;
}
.badge {
  position: absolute;
  left: 6px; top: 6px;
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  z-index: 1;
}
.badge.ad { background: var(--warn-soft); color: var(--warn); }
.badge.bumper { background: var(--accent-soft); color: var(--accent); }
.badge.yt { background: rgba(255,255,255,0.92); color: #d33; }
.badge.remote { background: rgba(255,255,255,0.92); color: #0e7490; }
.badge.queued, .badge.processing { background: var(--warn-soft); color: var(--warn); }
.badge.failed { background: var(--live-soft); color: var(--live); }
.badge.live-now { background: var(--live); color: #fff; }

.tile-body { padding: 9px 11px 10px; }
.tile-title {
  font-weight: 550;
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-title input {
  width: 100%;
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 1px 4px;
  outline: none;
  font-size: 13px;
  font-weight: 550;
  background: var(--surface);
  color: var(--text);
}
.tile-meta {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  overflow: hidden;
}

/* List view */
.media-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 24px 80px;
  user-select: none;
}
.media-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  position: relative;
}
.row-thumb {
  width: 64px;
  aspect-ratio: 16/9;
  border-radius: 5px;
  overflow: hidden;
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 12px;
}
.row-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.media-row .badge { position: static; }
.media-row .duration { display: none; }
.row-title { flex: 1; min-width: 0; }
.row-cell { font-size: 12px; color: var(--muted); flex: none; width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-cell.num { text-align: right; width: 70px; }

.grid-empty {
  grid-column: 1 / -1;
  padding: 70px 20px;
  text-align: center;
  color: var(--muted);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
}
.grid-empty h3 { color: var(--text); font-weight: 600; margin: 0 0 6px; font-size: 15px; }
.grid-empty p { margin: 0 0 14px; font-size: 13px; }

.dup-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; }

/* ── Selection bar ──────────────────────────────────────────────────────── */

.selection-bar {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(calc(-50% + 124px));
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px 8px 16px;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-pop);
  z-index: 60;
  animation: rise 0.16s ease;
}
@keyframes rise { from { opacity: 0; transform: translateX(calc(-50% + 124px)) translateY(8px); } }
.selection-bar .count { font-weight: 600; margin-right: 8px; white-space: nowrap; }
.selection-bar button {
  border: none;
  background: transparent;
  color: var(--bg);
  opacity: 0.85;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 500;
  white-space: nowrap;
}
.selection-bar button:hover { background: rgba(128,128,128,0.25); opacity: 1; }
.selection-bar button.sel-danger { color: #ff9a9e; }
.selection-bar .sel-close { margin-left: 4px; font-size: 15px; padding: 6px 9px; }

/* ── Context menu ───────────────────────────────────────────────────────── */

.context-menu {
  position: fixed;
  z-index: 100;
  min-width: 190px;
  padding: 5px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  animation: menuIn 0.1s ease;
}
@keyframes menuIn { from { opacity: 0; transform: scale(0.98); } }

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  background: none;
  border-radius: 6px;
  text-align: left;
  font-size: 13px;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--live); }
.menu-item.danger:hover { background: var(--live-soft); }
.menu-item .kbd { color: var(--faint); font-size: 11.5px; }
.menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }
.menu-label { padding: 6px 10px 3px; font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: 0.04em; }

.menu-sub { position: relative; }
.menu-sub-list {
  display: none;
  position: absolute;
  left: calc(100% - 4px);
  top: -5px;
  min-width: 170px;
  max-height: 300px;
  overflow-y: auto;
  padding: 5px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  z-index: 2;
}
.menu-sub:hover .menu-sub-list { display: block; }
.menu-sub-list.flip-left { left: auto; right: calc(100% - 4px); }

/* ── Notice panel ───────────────────────────────────────────────────────── */

.notice-panel {
  position: fixed;
  left: 14px;
  top: 48px;
  width: 320px;
  max-height: 60vh;
  overflow-y: auto;
  z-index: 110;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-pop);
  animation: menuIn 0.1s ease;
}
.notice-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 6px;
  font-weight: 600;
}
.notice-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.notice-row.success { color: var(--ok); }
.notice-row.error { color: var(--live); }

/* ── Drop overlay & marquee ─────────────────────────────────────────────── */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(79, 70, 229, 0.06);
  display: grid;
  place-items: center;
  pointer-events: none;
}
.drop-overlay-inner {
  padding: 36px 56px;
  border-radius: 18px;
  border: 2px dashed var(--accent);
  background: var(--surface);
  text-align: center;
  color: var(--accent);
  font-weight: 600;
  font-size: 15px;
  box-shadow: var(--shadow-pop);
}
.drop-overlay-inner .drop-icon { font-size: 28px; margin-bottom: 6px; }
.drop-overlay-inner p { margin: 0; }

.marquee {
  position: fixed;
  z-index: 50;
  border: 1px solid var(--accent);
  background: rgba(79, 70, 229, 0.08);
  border-radius: 2px;
  pointer-events: none;
}

/* ── Live tab ───────────────────────────────────────────────────────────── */

.live-wrap {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  padding: 18px 24px 80px;
  max-width: 1060px;
}
.live-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.live-side { min-width: 0; }

.source-chip {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--live);
  background: var(--live-soft);
  border-radius: 5px;
  padding: 2px 7px;
  margin-left: 8px;
  vertical-align: 1px;
}

.now-card-body { display: flex; gap: 14px; align-items: center; }
.now-thumb {
  width: 180px;
  aspect-ratio: 16/9;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
}
.now-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.now-info { flex: 1; min-width: 0; }
.now-title-big {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.progress-track {
  height: 5px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill { background: var(--live); transition: width 1s linear; }

.takelive-row { align-items: flex-end; }

.upnext-list { display: flex; flex-direction: column; gap: 8px; }
.upnext-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border-radius: var(--radius-sm);
}
.upnext-row.on-air { background: var(--live-soft); }
.upnext-row.on-air .upnext-time { color: var(--live); font-weight: 700; }
.upnext-time { width: 42px; flex: none; font-size: 12px; color: var(--muted); font-weight: 550; }
.upnext-thumb {
  width: 56px;
  aspect-ratio: 16/9;
  border-radius: 5px;
  overflow: hidden;
  position: relative;
  flex: none;
}
.upnext-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.upnext-body { flex: 1; min-width: 0; }
.upnext-title { font-size: 12.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.history-list { display: flex; flex-direction: column; }
.history-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.history-row:first-child { border-top: none; }
.history-time { color: var(--muted); font-size: 12px; width: 42px; flex: none; }
.history-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-ago { color: var(--faint); font-size: 11.5px; flex: none; }

.queue-status { font-size: 12px; color: var(--muted); }
.queue-status.failed { color: var(--live); }
.queue-status.processing { color: var(--warn); }

/* ── Schedule ───────────────────────────────────────────────────────────── */

.schedule-wrap { padding: 18px 24px 80px; max-width: 860px; }
.schedule-wrap.wide { max-width: none; }

.schedule-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.conflict-note { color: var(--warn); font-size: 12.5px; font-weight: 550; }

.week-grid {
  display: grid;
  grid-template-columns: 52px repeat(7, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: auto;
  max-height: calc(100vh - 300px);
  position: relative;
}
.week-times { border-right: 1px solid var(--border); }
.week-corner { height: 34px; position: sticky; top: 0; background: var(--surface); z-index: 3; border-bottom: 1px solid var(--border); }
.week-hour {
  font-size: 10.5px;
  color: var(--faint);
  text-align: right;
  padding: 2px 6px 0 0;
}
.week-day { min-width: 110px; border-right: 1px solid var(--border); }
.week-day:last-child { border-right: none; }
.week-day-head {
  height: 34px;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 12.5px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 3;
  border-bottom: 1px solid var(--border);
}
.week-day-head.today { color: var(--accent); }
.week-day-col { position: relative; cursor: cell; }
.week-hour-line {
  position: absolute;
  left: 0; right: 0;
  height: 1px;
  background: var(--border);
  opacity: 0.55;
  pointer-events: none;
}
.week-now {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: var(--live);
  z-index: 2;
  pointer-events: none;
}
.week-block {
  position: absolute;
  left: 3px; right: 3px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--block-color) 14%, var(--surface));
  border-left: 3px solid var(--block-color);
  padding: 3px 6px;
  overflow: hidden;
  cursor: pointer;
  z-index: 1;
  transition: box-shadow 0.1s ease;
}
.week-block:hover { box-shadow: var(--shadow); z-index: 2; }
.week-block.off { opacity: 0.4; }
.week-block.continuation { border-left-style: dashed; }
.week-block-name {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.week-block-time { font-size: 10.5px; color: var(--muted); }

.sched-list { display: flex; flex-direction: column; gap: 8px; }
.sched-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
}
.sched-row:hover { box-shadow: var(--shadow); }
.sched-row.off { opacity: 0.55; }
.sched-color { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.sched-name { font-weight: 550; min-width: 120px; }

.color-row { display: flex; gap: 6px; align-items: center; padding-top: 4px; }
.color-dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
}
.color-dot.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface) inset; }

.template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding-top: 4px;
}
.template-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 12px;
  font-weight: 500;
}
.template-card:hover { border-color: var(--accent); }
.template-card.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.template-icon { font-size: 18px; }

.media-item.wont-air { border-color: var(--warn); }
.media-item.wont-air .thumb::after {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(185,139,29,0.14) 10px, rgba(185,139,29,0.14) 20px);
  pointer-events: none;
}
.air-warn { color: var(--warn); font-weight: 600; }

.playlist-pick {
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.playlist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.playlist-item:hover { background: var(--surface-2); }
.playlist-item.picked { background: var(--accent-soft); }
.playlist-order {
  width: 20px; height: 20px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
}
.playlist-item.picked .playlist-order { border-color: var(--accent); background: var(--accent); color: #fff; }
.playlist-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hint {
  color: var(--muted);
  font-size: 12.5px;
  margin: 10px 2px 0;
  line-height: 1.5;
}

/* ── Insights ───────────────────────────────────────────────────────────── */

.insights-wrap { padding: 18px 24px 80px; max-width: 900px; display: flex; flex-direction: column; gap: 16px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.card.stat { padding: 14px 16px; }
.stat-num { font-size: 22px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.insights-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sparkline { width: 100%; height: 64px; }
.sparkline rect { fill: var(--accent); opacity: 0.85; }

/* ── Settings ───────────────────────────────────────────────────────────── */

.settings-wrap { padding: 18px 24px 80px; max-width: 620px; display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card h3 { margin: 0 0 14px; font-size: 14px; font-weight: 600; }

.form-grid { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: flex; gap: 12px; }
.form-row > label { flex: 1; }

label.field-label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 550; color: var(--muted); }

input[type="text"], input[type="url"], input[type="number"], input[type="time"], input[type="file"], select, textarea {
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 60px; }

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.segmented button {
  padding: 6px 14px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.12); }

.inline-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.inline-row .lbl { font-weight: 500; }
.inline-row .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.link-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
}
.link-box code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  color: var(--text);
}

.details-thumb {
  aspect-ratio: 16/9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  display: grid;
  place-items: center;
  color: #fff;
}
.details-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.details-table { display: flex; flex-direction: column; font-size: 12.5px; }
.details-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 5px 0;
  border-top: 1px solid var(--border);
}
.details-row span:first-child { color: var(--muted); flex: none; }
.details-row span:last-child { text-align: right; overflow: hidden; text-overflow: ellipsis; }

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

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  background: rgba(18, 18, 24, 0.4);
  animation: fadeIn 0.12s ease;
}
@keyframes fadeIn { from { opacity: 0; } }

.modal {
  width: min(440px, calc(100vw - 40px));
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  padding: 20px;
  animation: modalIn 0.14s ease;
}
.modal.wide { width: min(640px, calc(100vw - 40px)); }
@keyframes modalIn { from { opacity: 0; transform: translateY(6px) scale(0.99); } }
.modal h3 { margin: 0 0 16px; font-size: 15px; }
.modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.preview-modal { padding-bottom: 16px; }

/* ── Command palette ────────────────────────────────────────────────────── */

.palette-root {
  position: fixed;
  inset: 0;
  z-index: 125;
  display: flex;
  justify-content: center;
  padding-top: 12vh;
  background: rgba(18, 18, 24, 0.35);
  animation: fadeIn 0.1s ease;
}
.palette {
  width: min(520px, calc(100vw - 40px));
  height: fit-content;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: modalIn 0.12s ease;
}
.palette input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 14px 18px;
  font-size: 15px;
  background: var(--surface);
}
.palette input:focus { box-shadow: none; border-color: var(--border); }
.palette-list { max-height: 340px; overflow-y: auto; padding: 6px; }
.palette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 13.5px;
  text-align: left;
}
.palette-item:hover, .palette-item.active { background: var(--accent-soft); }
.palette-hint { color: var(--faint); font-size: 11.5px; }

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

.toast {
  position: fixed;
  bottom: 22px;
  left: 22px;
  z-index: 130;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-weight: 500;
  font-size: 13px;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.18s ease;
  pointer-events: none;
  max-width: 380px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--live); color: #fff; }

/* ── Scrollbars ─────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }
::-webkit-scrollbar-track { background: transparent; }

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 980px) {
  .live-wrap { grid-template-columns: 1fr; }
  .insights-cols { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 64px 1fr; }
  .brand-name, .channel-item-body, .side-tools, .system-meta { display: none; }
  .new-channel-btn span:last-child { display: none; }
  .channel-item { justify-content: center; padding: 8px; }
  .status-dot { position: absolute; right: 5px; top: 5px; }
  .main-head { flex-wrap: wrap; padding: 12px 14px 0; }
  .tabs { padding: 10px 14px 0; overflow-x: auto; }
  .library-toolbar, .grid, .media-list { padding-left: 14px; padding-right: 14px; }
  .schedule-wrap, .settings-wrap, .insights-wrap, .live-wrap { padding-left: 14px; padding-right: 14px; }
  .selection-bar { transform: translateX(-50%); left: 50%; max-width: calc(100vw - 20px); overflow-x: auto; }
}
