/* try.html — live demo, single-viewport YouTube-style shell: catalogue/
   interests/channels left, player + tabs center, Up-next queue right.
   Base tokens come from styles-v2.css; the overrides below lock the page
   to the APP's exact palette (app/src/main/res/values/colors.xml). */
:root {
  --indigo: #6366F1;          /* brand_indigo */
  --indigo-soft: rgba(99, 102, 241, 0.16);
  --teal: #14B8A6;            /* brand_teal */
  --teal-soft: rgba(20, 184, 166, 0.13);
  --violet: #8B5CF6;          /* accent_violet */
  --amber: #F59E0B;           /* accent_amber */
  --sky: #38BDF8;             /* accent_sky */
  --emerald: #10B981;         /* accent_emerald */
  --heart: #F43F5E;           /* heart_red */
  --bg-card: #1E1E24;         /* brand_surface_dark */
  --bg-raised: #26262E;
  --text: #E8E8EC;            /* brand_on_dark */
  --text-dim: #B4B4BE;
  --text-faint: #8A8A94;      /* brand_muted */
}

.try-body {
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.try-body [hidden] { display: none !important; }

/* ---------- top bar ---------- */
.try-topbar {
  flex: none; height: 40px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 50;
}
.try-topbar .brand { display: flex; align-items: center; gap: 9px; text-decoration: none; }
.try-live {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--teal); background: var(--teal-soft);
  border-radius: 999px; padding: 3px 9px; margin-left: 4px;
}
.try-topbar-right { display: flex; align-items: center; gap: 14px; }
.try-link {
  color: var(--text-dim); font-size: 0.84rem; text-decoration: none;
}
.try-link:hover { color: var(--text); }
.try-linklike {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--indigo); font: inherit; font-size: 0.8rem; font-weight: 600;
  text-align: left;
}
.try-linklike:hover { text-decoration: underline; }

/* ---------- shell: rail / stage / queue ---------- */
.try-shell {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(240px, 260fr) minmax(0, 820fr) minmax(280px, 320fr);
  gap: 10px;
  padding: 8px 10px;
}

.rail {
  min-height: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.rail-right { overflow: hidden; }
.rail-sec {
  flex: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
/* Catalogue card flexes to fill the left column; the tree scrolls inside it */
#sec-catalogue {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
}
#sec-catalogue .sys-search { flex: none; }
#sec-catalogue .sys-tree { flex: 1; min-height: 90px; }
#sec-catalogue #fb-topic { flex: none; }
#sec-catalogue .try-add { flex: none; margin-top: 8px; }
.rail-left { overflow-y: auto; scrollbar-width: thin; }
.rail-foot { margin-top: auto; }
.rail-head {
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--text-faint);
  margin-bottom: 9px;
}
.rail-hint { font-size: 0.78rem; color: var(--text-faint); }
.rail-foot {
  flex: none;
  display: flex; gap: 16px; justify-content: center;
  padding: 4px 0 10px; font-size: 0.78rem;
}
.rail-foot a { color: var(--text-faint); text-decoration: none; }
.rail-foot a:hover { color: var(--text); }
.rail-foot .try-linklike { color: var(--text-faint); font-size: 0.78rem; font-weight: 500; }
.rail-foot .try-linklike:hover { color: var(--text); text-decoration: none; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chips:empty { margin: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--indigo-soft); color: var(--text);
  border: 1px solid transparent;
  border-radius: 999px; padding: 3px 10px;
  font-size: 0.76rem; font-weight: 500;
  white-space: nowrap;          /* chip text never wraps internally */
}
.chip .chip-x {
  background: none; border: 0; color: var(--text-faint);
  cursor: pointer; font-size: 0.95rem; line-height: 1; padding: 0;
}
.chip .chip-x:hover { color: var(--text); }
.chip--channel { background: var(--teal-soft); color: var(--teal); }
.chip--own { background: rgba(167, 139, 250, 0.14); color: var(--violet); }
.chip--warming { border-style: dashed; border-color: var(--border-strong); opacity: 0.8; }
.chip--warming::after { content: '…'; }
.chip--exhausted { opacity: 0.55; border-style: dashed; border-color: var(--border-strong); }

/* ---------- picks bar (top of the stage, above the player) ---------- */
.picks-bar {
  flex: none; height: 34px;
  display: flex; align-items: center; gap: 4px;
  min-width: 0;
}
.picks-scroll {
  flex: 1; min-width: 0;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
}
.picks-scroll::-webkit-scrollbar { display: none; }
.picks-chips {
  display: flex; flex-wrap: nowrap; gap: 6px;
  margin: 0; width: max-content;
}
.picks-chips .chip { flex: none; }
.picks-arrow {
  flex: none; width: 24px; height: 24px;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: 50%; color: var(--text-dim);
  font-size: 0.9rem; line-height: 1; cursor: pointer;
}
.picks-arrow:hover { color: var(--text); }

/* ---------- catalogue tree (topic_sys) ---------- */
.sys-search {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--text);
  font: inherit; font-size: 0.82rem;
  padding: 7px 11px;
  margin-bottom: 8px;
}
.sys-search:focus { outline: none; border-color: var(--indigo); }
.sys-tree {
  overflow-y: auto;
  scrollbar-width: thin; padding-right: 2px;
}
.sys-list { list-style: none; margin: 0; padding: 0; }
.sys-list .sys-list { padding-left: 19px; }
.sys-list .sys-list[hidden] { display: none; }
.sys-row { display: flex; align-items: center; gap: 3px; padding: 1px 0; }
.sys-caret {
  width: 17px; height: 17px; flex: none;
  background: none; border: 0; padding: 0;
  color: var(--text-faint); font-size: 0.68rem; line-height: 1;
  cursor: pointer; transition: transform 0.15s;
}
.sys-caret:hover { color: var(--text); }
.sys-caret.open { transform: rotate(90deg); }
.sys-caret--leaf { visibility: hidden; }
.sys-label {
  display: flex; align-items: center; gap: 6px; min-width: 0;
  font-size: 0.76rem; color: var(--text-dim); cursor: pointer;
}
.sys-label:hover { color: var(--text); }
.sys-label:has(.sys-check:checked) { color: var(--text); }
.sys-check {
  width: 14px; height: 14px; margin: 0; flex: none;
  accent-color: var(--indigo); cursor: pointer;
}
.sys-count {
  margin-left: auto; padding-right: 4px;
  font-size: 0.68rem; color: var(--text-faint);
}
#fb-topic { display: block; margin-top: 6px; }

/* ---------- forms ---------- */
.try-add { display: flex; gap: 7px; }
.try-add input, .rail-sec textarea, .rail-sec input[type="text"] {
  flex: 1; min-width: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--text);
  font: inherit; font-size: 0.84rem;
  padding: 8px 11px;
}
.rail-sec input:focus, .rail-sec textarea:focus { outline: none; border-color: var(--indigo); }
.btn-sm { padding: 8px 14px; font-size: 0.82rem; border-radius: 10px; }
.btn-xs { padding: 6px 12px; font-size: 0.78rem; border-radius: 9px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }
.try-error { color: var(--heart); font-size: 0.78rem; margin-top: 8px; }

/* ---------- channel candidates ---------- */
.channel-cands { display: flex; flex-direction: column; gap: 7px; margin: 8px 0; }
.channel-cands:empty { margin: 0; }
.cand {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 10px;
}
.cand-name { font-size: 0.82rem; font-weight: 600; }
.cand-handle { font-size: 0.72rem; color: var(--text-faint); display: block; }
.cand-verified {
  font-size: 0.62rem; color: var(--teal); border: 1px solid var(--teal);
  border-radius: 999px; padding: 1px 6px; margin-left: 6px; vertical-align: middle;
}

/* ---------- stage: player ---------- */
.stage {
  min-height: 0; min-width: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.player-frame {
  /* fills all space between picks bar and now-playing — the embed
     letterboxes inside, so there's never a dead gap in the column.
     The width caps at 16:9 of the vertical space available to it —
     292px = topbar 40 + shell padding 16 + picks 34 + now-playing 46
     + strip 132 + three 8px stage gaps — so it only shrinks
     horizontally, centered in the column. */
  flex: 1 1 auto;
  min-height: 200px;
  width: min(100%, calc((100vh - 292px) * 16 / 9));
  margin: 0 auto;
  background: #000;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}
.player-frame iframe, .player-frame #yt-mount { width: 100%; height: 100%; border: 0; display: block; }
.player-idle {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center; padding: 24px;
  color: var(--text-dim); font-size: 0.9rem;
}
.player-idle-glyph {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--indigo-soft); color: var(--violet);
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
}
.player-idle p { max-width: 420px; }

.now-playing {
  flex: none; height: 46px; box-sizing: border-box;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 4px 12px;
}
.np-text { flex: 1; min-width: 0; }
.np-title {
  display: block; font-size: 0.84rem; font-weight: 600; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.np-src { display: block; font-size: 0.7rem; line-height: 1.2; color: var(--violet); }
.np-btns { display: flex; align-items: center; gap: 6px; flex: none; }
.np-like--on { color: var(--heart); border-color: var(--heart); }
.np-plwrap { position: relative; }
.np-plmenu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  display: flex; flex-direction: column; min-width: 190px;
  background: var(--bg-raised); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 6px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}
.plm-row {
  background: none; border: 0; color: var(--text); text-align: left;
  font: inherit; font-size: 0.8rem; padding: 7px 10px; border-radius: 7px;
  cursor: pointer;
}
.plm-row:hover { background: var(--bg-card); }
.plm-new { color: var(--indigo); font-weight: 600; }
.plm-input {
  background: var(--bg-card); border: 1px solid var(--border-strong);
  border-radius: 8px; color: var(--text);
  font: inherit; font-size: 0.8rem; padding: 7px 10px; min-width: 160px;
}
.plm-input:focus { outline: none; border-color: var(--indigo); }

/* ---------- tabs panel (slim strip, pinned to the column bottom) ---------- */
.tabs-panel {
  flex: none; height: 132px; box-sizing: border-box;
  /* margin-top:auto anchors the strip to the shell's bottom padding — any
     leftover height (when the player's width cap wins over its height cap)
     pools between now-playing and the strip instead of under the strip. */
  margin-top: auto;
  display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 12px;
}
/* ONE header row: tabs + playlist chips + import/export/new */
.tabs {
  flex: none; display: flex; align-items: center; gap: 4px;
  margin-bottom: 4px; min-width: 0;
}
.tab {
  flex: none;
  background: none; border: 0; color: var(--text-faint);
  font: inherit; font-size: 0.78rem; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab--on { background: var(--indigo-soft); color: var(--text); }
.tab-tools { margin-left: auto; display: flex; gap: 6px; flex: none; }
.pl-chips {
  display: flex; gap: 6px; flex-wrap: nowrap; min-width: 0;
  overflow-x: auto; scrollbar-width: none;
}
.pl-chips::-webkit-scrollbar { display: none; }
.plchip {
  flex: none;
  background: var(--bg-raised); border: 1px solid var(--border);
  color: var(--text-dim); font: inherit; font-size: 0.72rem; font-weight: 600;
  border-radius: 999px; padding: 3px 9px; cursor: pointer;
}
.plchip:hover { color: var(--text); }
.plchip--on { background: var(--indigo-soft); color: var(--text); border-color: transparent; }
.pl-acts { position: relative; flex: none; }
.pl-acts-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  display: flex; flex-direction: column; min-width: 140px;
  background: var(--bg-raised); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 6px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}
.card-row {
  flex: 1; min-height: 0;
  display: flex; gap: 8px; align-items: flex-start;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
}
.card-row::-webkit-scrollbar { display: none; }
.vcard {
  flex: none; width: 120px; cursor: pointer; position: relative;
  border-radius: 10px; padding: 3px;
}
.vcard:hover { background: var(--bg-raised); }
.vc-thumb {
  display: block; width: 100%; aspect-ratio: 16/9;
  border-radius: 8px; overflow: hidden; background: var(--bg-raised);
  position: relative;
}
.vc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vc-title {
  display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 0.72rem; font-weight: 600; line-height: 1.3; margin-top: 3px;
}
.vc-sub { display: block; font-size: 0.64rem; color: var(--text-faint); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-x {
  position: absolute; top: 7px; right: 7px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.8); border: 0; color: #fff;
  font-size: 0.9rem; line-height: 1; cursor: pointer;
  opacity: 0; transition: opacity 0.15s;
}
.vcard:hover .vc-x { opacity: 1; }
.vc-x:hover { background: var(--heart); }

/* ---------- queue (right rail, YouTube up-next style) ---------- */
.rail-right { display: flex; }
.queue-sec { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px; }
.queue-head {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 8px;
}
.queue-head h4 { font-size: 0.98rem; }
.queue-acts { display: flex; gap: 6px; align-items: center; }
/* slim duration filter row — slider + value, no helper text */
.qfilter {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.qfilter input[type="range"] {
  flex: 1; min-width: 0; height: 14px; margin: 0;
  accent-color: var(--indigo); cursor: pointer;
  background: transparent;
}
.qfilter-lab {
  flex: none; min-width: 48px; text-align: right;
  font-size: 0.7rem; font-weight: 600; color: var(--text-faint);
  white-space: nowrap;
}
.queue-list {
  flex: 1; min-height: 0;
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; scrollbar-width: thin;
}
.qrow {
  display: flex; flex-direction: column; gap: 6px;
  cursor: pointer;
  border-radius: 10px; padding: 5px;
  margin: 0 -5px;
  transition: background 0.15s;
  position: relative;
}
.qrow:hover { background: var(--bg-raised); }
.qrow--playing { background: var(--indigo-soft); }
.q-thumb {
  width: 100%; aspect-ratio: 16/9; flex: none;
  border-radius: 8px; overflow: hidden; background: var(--bg-raised);
  position: relative;
}
.q-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.q-dur {
  position: absolute; right: 4px; bottom: 4px;
  background: rgba(0,0,0,0.85); color: #fff;
  font-size: 0.66rem; font-weight: 600; padding: 2px 5px; border-radius: 4px;
}
.q-body { flex: 1; min-width: 0; padding: 0 2px 2px; }
.q-title {
  font-size: 0.8rem; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.q-meta { display: block; font-size: 0.7rem; color: var(--text-faint); margin-top: 3px; }
.q-src { color: var(--violet); }
.q-src.q-src--channel { color: var(--teal); }
.q-acts {
  display: flex; flex-direction: column; gap: 4px;
  position: absolute; right: 6px; top: 6px;
  opacity: 0; transition: opacity 0.15s;
}
.qrow:hover .q-acts { opacity: 1; }
.q-act {
  width: 24px; height: 24px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.7); border: 1px solid var(--border-strong);
  color: var(--text-dim); font-size: 0.85rem; line-height: 1; cursor: pointer;
}
.q-act:hover { color: var(--text); border-color: var(--text-dim); }

/* ---------- terms gate ---------- */
.terms-modal {
  position: fixed; inset: 0; z-index: 140;
  background: rgba(5, 5, 9, 0.82);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.terms-card {
  width: min(460px, 100%);
  background: var(--bg-card); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 22px;
}
.terms-title { font-size: 1.1rem; margin-bottom: 10px; }
.terms-card p { font-size: 0.86rem; color: var(--text-dim); line-height: 1.55; margin: 0 0 10px; }
.terms-card a { color: var(--indigo); }
.terms-acts {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 16px;
}
.terms-home { color: var(--text-faint); font-size: 0.84rem; text-decoration: none; }
.terms-home:hover { color: var(--text); }

/* ---------- feedback modal ---------- */
.fb-modal {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center;
}
.fb-card {
  width: min(440px, calc(100vw - 32px));
  background: var(--bg-card); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.fb-title { font-size: 1.05rem; }
.fb-card select {
  background: var(--bg-raised); border: 1px solid var(--border-strong);
  border-radius: 9px; color: var(--text);
  font: inherit; font-size: 0.86rem; padding: 8px 11px;
}
.fb-card textarea {
  background: var(--bg-raised); border: 1px solid var(--border-strong);
  border-radius: 9px; color: var(--text); resize: vertical;
  font: inherit; font-size: 0.86rem; padding: 9px 11px;
}
.fb-card select:focus, .fb-card textarea:focus { outline: none; border-color: var(--indigo); }
.fb-acts { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- toasts ---------- */
/* top-center, just below the 40px topbar — never over the now-playing
   bar or the player controls; the whole stack ignores pointer events */
.toast-stack {
  position: fixed; top: 48px; left: 50%; transform: translateX(-50%);
  z-index: 130; display: flex; flex-direction: column; gap: 6px;
  align-items: center; pointer-events: none;
}
.toast {
  background: rgba(38, 38, 46, 0.85);      /* --bg-raised at ~85% */
  border: 1px solid var(--border);
  color: var(--text-dim); font-size: 0.75rem;
  border-radius: 999px; padding: 6px 14px;
  backdrop-filter: blur(6px);
  transition: opacity 0.4s;
}
.toast--out { opacity: 0; }

/* ---------- short viewports (≥1024 wide): keep 3 columns, page scrolls ---------- */
@media (min-width: 1024px) and (max-height: 559px) {
  .try-body { height: auto; overflow-y: auto; }
  .try-shell { min-height: 560px; }
  /* columns stay bounded so inner lists scroll, not the grid row */
  .rail { max-height: 560px; }
}

/* mobile queue/catalogue switcher — inert on desktop: no rules outside
   the ≤1023px media query beyond this hidden base state */
.mob-tabs { display: none; }

/* ---------- narrow viewports: stack to one column, normal scroll ---------- */
@media (max-width: 1023px) {
  .try-body { height: auto; overflow-x: hidden; overflow-y: auto; }
  .try-shell { grid-template-columns: minmax(0, 1fr); }
  /* stage dissolves into the shell grid so its children can interleave with
     the rails: player + now-playing first, then the queue/catalogue switcher,
     then the rails, and the playlists strip below everything */
  .stage { display: contents; }
  .picks-bar { order: 1; }
  .player-frame { order: 2; }
  .now-playing { order: 3; }
  /* tab bar between now-playing and the rails; inactive rail hidden entirely */
  .mob-tabs {
    order: 4; display: flex; gap: 6px; align-items: center;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 10px; padding: 5px;
  }
  .mob-tab {
    flex: 1; background: none; border: 0; color: var(--text-faint);
    font: inherit; font-size: 0.84rem; font-weight: 600;
    padding: 7px 10px; border-radius: 7px; cursor: pointer;
  }
  .mob-tab:hover { color: var(--text); }
  .mob-tab--on { background: var(--indigo-soft); color: var(--text); }
  .rail-right { order: 5; overflow: visible; }
  .rail-left { order: 6; overflow: visible; }
  .tabs-panel { order: 7; }
  .try-shell[data-mtab="queue"] .rail-left { display: none; }
  .try-shell[data-mtab="catalogue"] .rail-right { display: none; }
  .queue-list { max-height: 60vh; }
  #sec-catalogue { flex: none; }
  .sys-tree { max-height: 300px; }
  .player-frame { flex: none; width: 100%; aspect-ratio: 16/9; }
}

@media (max-width: 640px) {
  .try-topbar { padding: 8px 12px; gap: 8px; }
  .try-topbar-right { gap: 8px; }
  /* topbar compacts: Terms + Suggest still reachable from the left-rail footer */
  .try-topbar-right .try-link,
  .try-topbar-right .btn-ghost { display: none; }
  .try-topbar .btn-primary { padding: 7px 14px; font-size: 0.78rem; }
  .try-live { margin-left: 0; }
  .try-shell { padding: 10px 12px 20px; gap: 14px; }
  /* ≥16px inputs keep iOS from auto-zooming on focus */
  .try-add input, .rail-sec textarea, .rail-sec input[type="text"] { font-size: 16px; }
  .np-title { font-size: 0.8rem; }
  /* column layout needs more than the desktop-fixed 46px — unlock height
     or the buttons row spills under the tabs panel */
  .now-playing { flex-direction: column; align-items: stretch; gap: 8px; height: auto; padding: 8px 12px; }
  .np-btns { flex-wrap: wrap; }
  .np-plmenu { left: 0; right: auto; }
  .queue-head { flex-wrap: wrap; }
  .tab-tools { margin-left: 0; }
  .tabs { flex-wrap: wrap; }
}


/* owner kill switch — fixed banner while the API is paused server-side */
.paused-banner {
  position: fixed; top: 48px; left: 50%; transform: translateX(-50%);
  z-index: 90; max-width: min(92vw, 560px); text-align: center;
  background: var(--bg-card); border: 1px solid var(--amber, #f59e0b);
  color: var(--text); border-radius: 10px; padding: 10px 18px;
  font-size: 0.86rem; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

/* ==================================================================
   SHORTS MODE — two-column shell: left = selections/catalogue/channels
   with generous space, right = vertical snap feed. No queue, no
   playlist/tabs panel, no picks bar (selections live in the left rail).
   Everything keyed off .try-shell[data-mode="shorts"] so classic mode
   is byte-for-byte untouched.
   ================================================================== */

/* split wrapper — transparent in classic mode (contents pass through),
   a side-by-side row in shorts mode: catalogue left, selections right */
.rail-split { display: contents; }

/* ---------- mode toggle (topbar, both modes) ---------- */
.mode-switch {
  display: flex; align-items: center; gap: 2px;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px;
}
.mode-tab {
  background: none; border: 0; cursor: pointer;
  color: var(--text-faint); font: inherit;
  font-size: 0.76rem; font-weight: 600;
  padding: 4px 14px; border-radius: 999px;
}
.mode-tab:hover { color: var(--text); }
.mode-tab--on { background: var(--indigo); color: #fff; }

/* ---------- base: shorts pieces hidden in classic mode ---------- */
#sec-selections { display: none; }
.shorts-stage { display: none; }

/* ---------- shell rearrangement ---------- */

.try-shell[data-mode="shorts"] .stage,
.try-shell[data-mode="shorts"] .rail-right,
.try-shell[data-mode="shorts"] .mob-tabs { display: none !important; }
.try-shell[data-mode="shorts"] .shorts-stage { display: flex; }
.try-shell[data-mode="shorts"] #sec-selections { display: flex; }

/* ---------- left rail: selections get the extra space ---------- */
.try-shell[data-mode="shorts"] #sec-selections {
  flex: none;
  flex-direction: column;
}
.try-shell[data-mode="shorts"] #sec-catalogue { flex: 1 1 0; }
.sel-count { color: var(--indigo); margin-left: 3px; text-transform: none; letter-spacing: 0; }
.sel-scroll {
  flex: 0 1 auto; min-height: 0; overflow-y: auto; scrollbar-width: thin;
  max-height: calc(3 * 26px + 2 * 6px);   /* exactly 3 chip rows, rest scrolls */
}
.sel-grid { display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; }
.sel-empty { font-size: 0.8rem; color: var(--text-faint); margin: 4px 0 0; }

.try-shell[data-mode="shorts"] {
  grid-template-columns: minmax(470px, 48fr) minmax(0, 52fr);
}
.try-shell[data-mode="shorts"] .rail-split {
  flex: 1; min-height: 0;
  display: flex; flex-direction: row; gap: 8px;
}
.try-shell[data-mode="shorts"] .rail-split .rail-sec { min-width: 0; }
.try-shell[data-mode="shorts"] .rail-split #sec-catalogue { flex: 1.4 1 0; }
.try-shell[data-mode="shorts"] .rail-split #sec-selections {
  flex: 1 1 0; min-height: 0;
  display: flex; flex-direction: column;
}
.try-shell[data-mode="shorts"] .rail-split #sec-selections .sel-scroll {
  flex: 1; min-height: 0; max-height: none;
}

/* selections as checkbox rows — unticking removes the interest, mirroring
   the catalogue semantics on the left */
.sel-rows { display: flex; flex-direction: column; gap: 2px; }
.sel-row {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 6px; border-radius: 8px;
  font-size: 0.84rem; font-weight: 550; color: var(--text);
  cursor: pointer; min-width: 0;
}
.sel-row:hover { background: rgba(255, 255, 255, 0.05); }
.sel-row input[type="checkbox"] {
  width: 14px; height: 14px; margin: 0; flex: none;
  accent-color: var(--indigo); cursor: pointer;
}
.sel-row .sel-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.sel-row .sel-kind {
  margin-left: auto; flex: none;
  font-size: 0.68rem; font-weight: 500; color: var(--text-faint);
}
.sel-row--own .sel-kind { color: var(--violet); }
.sel-row--warming { opacity: 0.75; }
.sel-row--exhausted { opacity: 0.55; }
.sel-x {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0; margin-left: 2px;
  background: transparent; border: none; border-radius: 6px;
  color: var(--text-faint); cursor: pointer;
  opacity: 0.55;
  transition: color .15s ease, background .15s ease, opacity .15s ease;
}
.sel-x svg { width: 13px; height: 13px; display: block; }
.sel-row:hover .sel-x { opacity: 1; }
.sel-x:hover { color: #f87171; background: rgba(248, 113, 113, 0.13); opacity: 1; }
.sel-x:active { transform: scale(0.88); }

/* compact chips — same visual weight as a catalogue row so the grid
   stays dense; they wrap, never scroll sideways out of view */
.sel-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--indigo-soft); color: var(--text);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 999px; padding: 3px 10px;
  font-size: 0.76rem; font-weight: 500;
  max-width: 100%; box-sizing: border-box;
}
.sel-chip .sel-kind {
  font-size: 0.64rem; font-weight: 500; color: var(--text-faint);
}
.sel-chip--own { background: rgba(139, 92, 246, 0.14); border-color: rgba(139, 92, 246, 0.4); }
.sel-chip--own .sel-kind { color: var(--violet); }
.sel-chip--warming { border-style: dashed; opacity: 0.8; }
.sel-chip--exhausted { opacity: 0.55; border-style: dashed; }
.sel-chip .chip-x { font-size: 0.95rem; }

/* ---------- right: grid queue of upcoming shorts ----------
   2 cards per row, ~3 rows visible (+ a 4th peeking) — card height is
   viewport-driven so the row count holds at any panel width; the narrow
   grid centers in the right half. No snap, no full-screen takeover:
   it's a queue you scroll, not a feed that owns the screen. */
.shorts-stage {
  min-height: 0; min-width: 0; position: relative;
  flex-direction: row;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* center player pane — the single player lives here; the up-next feed
   to its right is thumbnails only, cards never become players */
.sh-player-pane {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; padding: 14px;
}
.sh-center {
  position: relative; overflow: hidden;
  height: min(76vh, 100%);
  aspect-ratio: 9 / 16;
  max-width: 92%;
  background: #000;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
}
.sh-center iframe, .sh-center > div {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
.sh-center-idle {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  color: var(--text-faint); font-size: 0.9rem; text-align: center;
}
.sh-center-meta { flex: none; max-width: 100%; text-align: center; }
.sh-center-title { font-size: 0.94rem; font-weight: 650; line-height: 1.35; }
.sh-center-src { display: block; margin-top: 3px; font-size: 0.78rem; color: var(--violet); }

.shq-side {
  flex: none; width: 348px; min-height: 0;
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border);
}
.shq-head {
  flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
}
.shq-head .rail-head { margin-bottom: 0; }
.shq-count { color: var(--indigo); margin-left: 3px; text-transform: none; letter-spacing: 0; }
#sh-auto[aria-pressed="true"] {
  color: var(--teal); border-color: var(--teal);
}
.sh-feed {
  flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin;
  display: grid;
  grid-template-columns: repeat(2, auto);
  justify-content: center;
  align-content: start;
  gap: 12px;
  padding: 12px;
}
.sh-cell {
  display: flex; align-items: flex-start; justify-content: center;
  position: relative;
}
.sh-card {
  position: relative; overflow: hidden;
  height: 27vh;                  /* ~3 rows + a peeking 4th in the panel */
  aspect-ratio: 9 / 16;
  max-width: 100%;
  background: #000;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.sh-card:hover { border-color: var(--indigo); }
.sh-cell--playing .sh-card {
  border-color: var(--indigo);
  box-shadow: 0 0 0 2px var(--indigo), 0 8px 28px rgba(99, 102, 241, 0.25);
  cursor: default;
}
.sh-cell--watched .sh-card { opacity: 0.45; }
.sh-cell--watched .sh-card:hover { opacity: 0.8; }
.sh-mount, .sh-mount iframe, .sh-mount > div {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0;
}
/* pre-play poster: thumbnail + big play glyph, zero iframes */
.sh-poster {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; cursor: pointer;
}
.sh-playglyph {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.55); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; cursor: pointer; border: 0; z-index: 3;
}
.sh-playglyph:hover { background: rgba(99, 102, 241, 0.75); }
.sh-grad {
  position: absolute; inset: auto 0 0 0; height: 40%;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  pointer-events: none; z-index: 1;
}
.sh-meta {
  position: absolute; left: 8px; right: 8px; bottom: 7px; z-index: 2;
  pointer-events: none;
}
.sh-title {
  font-size: 0.72rem; font-weight: 600; line-height: 1.25; color: #fff;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; text-shadow: 0 1px 5px rgba(0, 0, 0, 0.8);
}
.sh-src {
  display: block; margin-top: 3px;
  font-size: 0.62rem; font-weight: 600; color: #c4b5fd;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sh-dur {
  position: absolute; top: 7px; right: 7px; z-index: 2;
  background: rgba(0, 0, 0, 0.65); border-radius: 6px;
  font-size: 0.64rem; font-weight: 600; padding: 2px 6px; color: #fff;
  pointer-events: none;
}
.sh-acts {
  position: absolute; right: 6px; top: 30px; z-index: 3;
  display: flex; flex-direction: column; gap: 8px;
  opacity: 0; transition: opacity 0.15s;
}
.sh-card:hover .sh-acts, .sh-cell--playing .sh-acts { opacity: 1; }
.sh-acts button {
  width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(20, 20, 28, 0.78); color: #fff; font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center;
}
.sh-like--on { color: var(--heart) !important; }

/* feed-empty state spans both grid columns */
.sh-note {
  grid-column: 1 / -1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  color: var(--text-dim); font-size: 0.9rem; text-align: center;
  padding: 40px 24px; min-height: 40vh;
}
.sh-note .btn { pointer-events: auto; }

/* ---------- narrow viewports ---------- */
@media (max-width: 1023px) {
  .try-shell[data-mode="shorts"] { grid-template-columns: minmax(0, 1fr); }
  .try-shell[data-mode="shorts"] .shorts-stage {
    flex-direction: column;
    order: 1; height: 84vh; flex: none;
  }
  .try-shell[data-mode="shorts"] .shq-side {
    width: 100%; flex: 1; min-height: 0; border-left: 0; border-top: 1px solid var(--border);
  }
  .try-shell[data-mode="shorts"] .sh-player-pane {
    flex: none; height: 52vh;
  }
  .try-shell[data-mode="shorts"] .sh-center { height: calc(100% - 46px); }
  .try-shell[data-mode="shorts"] .rail-left { order: 2; overflow: visible; }
  .try-shell[data-mode="shorts"] #sec-selections { min-height: 0; flex: none; }
  .try-shell[data-mode="shorts"] .sel-scroll { max-height: 30vh; }
  .try-shell[data-mode="shorts"] #sec-catalogue { flex: none; }
}

@media (max-width: 640px) {
  .mode-tab { padding: 4px 10px; font-size: 0.72rem; }
  .try-shell[data-mode="shorts"] .shorts-stage { height: 78vh; }
  .sh-card { height: 24vh; }
}
