/* PRISM TV - design system. Every component consumes these tokens; themes
   swap token values only, so switching themes genuinely works. */

/* PRISM TV - design system. Every component consumes these tokens; themes
   swap token values only, so switching themes genuinely works. */

:root {
  --primary-color: #6366f1;
  --bg-color: #0b0d12;
  --text-color: #e8eaf0;
  --bg: #0b0d12;
  --surface: #12151d;
  --surface-2: #1a1e29;
  --border: #232937;
  --text: #e8eaf0;
  --muted: #97a0b5;
  --ok: #34d399;
  --dead: #f87171;
  --testing: #fbbf24;
  --accent: #6366f1;            /* overridden by themes.js */
  --on-accent: #ffffff;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .45);
  --topbar-h: 60px;
}

html[data-theme="ocean"] {
  --bg-color: #1a1405;
  --primary-color: #e9c46a;
  --text-color: #1a1a1a;
}

html[data-theme="purple"] {
  --primary-color: #a78bfa;
  --text-color: #1a1a2e;
}

html[data-theme="forest"] {
  --primary-color: #76b5c5;
  --text-color: #e8f4f1;
}

html[data-theme="midnight"] {
  --bg: #000000;
  --surface: #0a0a0c;
  --surface-2: #141417;
  --border: #1f1f26;
}
html[data-theme="slate"] {
  --bg: #171b22;
  --surface: #1f2530;
  --surface-2: #28303f;
  --border: #333c4f;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------- boot ---------- */
.boot {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; background: var(--bg); color: var(--muted); font-size: .95rem;
}
.boot-mark { font-size: 1.6rem; font-weight: 800; letter-spacing: .35em; color: var(--accent); }

/* ---------- topbar ---------- */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .18em; font-size: 1rem; white-space: nowrap; }
.brand-mark { color: var(--accent); font-size: 1.15rem; }
.brand-tv { color: var(--accent); margin-left: -4px; }
.icon-btn {
  background: transparent; color: var(--muted); border: none; border-radius: 10px;
  width: 40px; height: 40px; font-size: 1.15rem; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
#search {
  flex: 1; max-width: 560px; height: 40px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); padding: 0 14px; font-size: .92rem; outline: none;
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.status-chip {
  font-size: .78rem; color: var(--muted); white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 7px 12px; border-radius: 999px;
}
.mv-badge {
  background: var(--accent); color: var(--on-accent);
  font-size: .68rem; font-weight: 700; min-width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; padding: 0 5px;
}
.avatar-btn {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  width: 40px; height: 40px; font-size: 1.25rem;
}

/* ---------- layout ---------- */
#app { display: flex; height: calc(100vh - var(--topbar-h)); }
.sidebar {
  width: 300px; min-width: 300px; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 14px 10px 40px;
}
.main { flex: 1; overflow-y: auto; padding: 20px 26px 80px; scroll-behavior: smooth; }
body.nav-collapsed .sidebar { display: none; }

/* ---------- sidebar tree ---------- */
.tree-section-label {
  font-size: .68rem; font-weight: 700; letter-spacing: .14em; color: var(--muted);
  text-transform: uppercase; margin: 18px 8px 6px;
}
.tree-row {
  display: flex; align-items: center; gap: 4px;
  padding: 7px 8px; border-radius: 9px; font-size: .9rem;
}
.tree-row:hover { background: var(--surface-2); }
.tree-row.active { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.tree-row.active .tree-link { color: var(--accent); font-weight: 600; }
.tree-link { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-row .count { font-size: .72rem; color: var(--muted); }
.tw { background: none; border: none; color: var(--muted); width: 22px; height: 22px; padding: 0; font-size: .8rem; }
.tree-brands { margin-left: 18px; border-left: 1px solid var(--border); padding-left: 4px; }
.tree-row.sub { font-size: .84rem; padding: 5px 8px; }
.tree-channels { margin-left: 30px; }
.tree-channel {
  display: block; padding: 4px 8px; border-radius: 7px; font-size: .8rem; color: var(--muted);
  cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tree-channel:hover { background: var(--surface-2); color: var(--text); }
.tree-channel.more { color: var(--accent); font-style: italic; }

/* ---------- hero ---------- */
.hero {
  position: relative; height: 240px; border-radius: 16px; overflow: hidden;
  background: linear-gradient(120deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border); margin-bottom: 22px;
}
.hero-bg {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: .28; filter: blur(2px) saturate(1.2);
}
.hero-content { position: absolute; inset: 0; padding: 30px 36px; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.hero-kicker { font-size: .7rem; letter-spacing: .25em; color: var(--accent); font-weight: 700; }
.hero h2 { margin: 0; font-size: 2rem; font-weight: 800; text-shadow: 0 2px 12px rgba(0,0,0,.5); }
.hero-meta { color: var(--muted); font-size: .9rem; }
.hero-actions { display: flex; gap: 10px; margin-top: 12px; }
.btn-accent {
  background: var(--accent); color: var(--on-accent); border: none;
  padding: 10px 20px; border-radius: 10px; font-weight: 700; font-size: .9rem;
}
.btn-accent:hover { filter: brightness(1.1); }
.btn-ghost {
  background: rgba(255,255,255,.06); color: var(--text); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: .88rem;
}
.btn-ghost:hover { background: var(--surface-2); }

/* ---------- scope + chips ---------- */
.scope-row { display: flex; align-items: baseline; gap: 14px; }
.scope-row h1 { font-size: 1.3rem; margin: 0 0 4px; }
.result-count { color: var(--muted); font-size: .82rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.chip {
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 999px; font-size: .8rem; font-weight: 600;
}
.chip:hover { color: var(--text); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---------- grid ---------- */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
}
.card { outline: none; }
.card:focus-visible .thumb { box-shadow: 0 0 0 3px var(--accent); }
.thumb {
  position: relative; aspect-ratio: 16 / 11; border-radius: var(--radius); overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.thumb-img { position: absolute; inset: 0; margin: auto; width: 70%; height: 70%; object-fit: contain; transition: transform .18s ease; }
.card:hover .thumb-img { transform: scale(1.06); }
.thumb-fallback { font-size: 2rem; font-weight: 800; color: var(--accent); opacity: .85; }
.play-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 1.9rem; color: #fff; background: rgba(0,0,0,.32);
  opacity: 0; transition: opacity .15s ease;
}
.card:hover .play-hint { opacity: 1; }
.dot {
  position: absolute; left: 8px; top: 8px; width: 10px; height: 10px; border-radius: 50%;
  background: #555e73; box-shadow: 0 0 0 2px rgba(0,0,0,.35);
}
.dot.ok { background: var(--ok); }
.dot.dead { background: var(--dead); }
.dot.testing { background: var(--testing); animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: .5 } to { opacity: 1 } }
.fav-btn, .mv-add {
  position: absolute; border: none; border-radius: 8px;
  background: rgba(0,0,0,.45); color: #fff;
  width: 28px; height: 28px; font-size: .95rem;
  opacity: 0; transition: opacity .15s ease;
}
.fav-btn { right: 8px; top: 8px; }
.mv-add { right: 42px; top: 8px; font-weight: 700; }
.card:hover .fav-btn, .card:hover .mv-add, .fav-btn.on { opacity: 1; }
.fav-btn.on { color: #ffd166; }
.blocked-tag {
  position: absolute; bottom: 6px; right: 6px;
  font-size: .58rem; font-weight: 700; letter-spacing: .08em;
  background: var(--dead); color: #fff; border-radius: 4px; padding: 2px 5px;
}
.is-blocked .thumb-img, .is-blocked .thumb-fallback { opacity: .35; }
.cname { margin-top: 8px; font-size: .86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmeta { font-size: .74rem; color: var(--muted); margin-top: 2px; }
.empty-state { grid-column: 1/-1; text-align: center; padding: 80px 0; color: var(--muted); }
.empty-state h3 { color: var(--text); }

/* ---------- multi-view dock ---------- */
.mv-dock {
  position: fixed; right: 14px; bottom: 14px; z-index: 60;
  display: none; flex-direction: column; gap: 10px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 14px; padding: 10px;
  box-shadow: var(--shadow);
}
.mv-dock.has-tiles { display: flex; }
.mv-head { display: flex; justify-content: space-between; align-items: center; font-size: .7rem; letter-spacing: .12em; color: var(--muted); padding: 0 2px; }
.link-btn { background: none; border: none; color: var(--accent); font-size: .72rem; }
.mv-tile { position: relative; width: 320px; aspect-ratio: 16/9; border-radius: 10px; overflow: hidden; background: #000; }
.mv-tile video { width: 100%; height: 100%; object-fit: contain; }
.mv-label {
  position: absolute; left: 0; bottom: 0; right: 0;
  font-size: .68rem; padding: 4px 8px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.75));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mv-close {
  position: absolute; right: 4px; top: 4px; width: 24px; height: 24px;
  border: none; border-radius: 7px; background: rgba(0,0,0,.55); color: #fff; font-size: .8rem;
}

/* ---------- watch dialog ---------- */
.watch {
  border: 1px solid var(--border); border-radius: 16px; padding: 0;
  background: var(--surface); color: var(--text); width: min(920px, 94vw); max-height: 90vh;
}
.watch::backdrop { background: rgba(0,0,0,.65); backdrop-filter: blur(3px); }
.watch-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px 10px; }
.watch-head h3 { margin: 0; font-size: 1.05rem; }
.watch-meta { color: var(--muted); font-size: .8rem; margin-top: 3px; }
#video { width: 100%; aspect-ratio: 16/9; background: #000; display: block; }
.watch-bar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; flex-wrap: wrap; }
.player-msg { font-size: .82rem; color: var(--testing); }
.player-msg.dim { color: var(--muted); }
.spacer { flex: 1; }
.related { padding: 4px 16px 16px; }
.mini-card {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 8px 12px; margin: 4px 6px 4px 0; font-size: .82rem;
}
.mini-card .dot { position: static; width: 8px; height: 8px; }
.mini-card:hover { border-color: var(--accent); }

/* ---------- profile dialog ---------- */
.profile-pop {
  border: 1px solid var(--border); border-radius: 16px; padding: 22px;
  background: var(--surface); color: var(--text); width: min(420px, 92vw);
}
.profile-pop::backdrop { background: rgba(0,0,0,.6); }
.profile-pop h3 { margin-top: 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .82rem; color: var(--muted); margin: 12px 0; }
.field input, .field select {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  color: var(--text); padding: 9px 12px; font-size: .9rem; outline: none;
}
.field select option { background: var(--surface); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.av-row { display: flex; gap: 8px; flex-wrap: wrap; }
.av { font-size: 1.3rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; width: 42px; height: 42px; }
.av.on { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.hint { font-size: .76rem; color: var(--muted); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 18px; font-size: .85rem; z-index: 200;
  opacity: 0; transition: all .25s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- scrollbars ---------- */
.sidebar::-webkit-scrollbar, .main::-webkit-scrollbar { width: 10px; }
.sidebar::-webkit-scrollbar-thumb, .main::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 6px;
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .status-chip { display: none; }
  .sidebar { position: fixed; z-index: 50; top: var(--topbar-h); bottom: 0; left: 0; box-shadow: var(--shadow); transform: translateX(-105%); transition: transform .2s ease; }
  body:not(.nav-collapsed) .sidebar { transform: translateX(0); }
  body.nav-collapsed .sidebar { display: block; }
  .main { padding: 14px; }
  .hero { height: 190px; }
  .hero h2 { font-size: 1.4rem; }
  .mv-tile { width: 220px; }
}
