:root { --bg:#07090f; --panel:#0f1522; --panel2:#151d30; --line:#26314d; --text:#e8ecf7; --muted:#8c97b3; --accent:#ffb020; --accent2:#3aa0ff; --red:#ff4d4d; }
* { box-sizing: border-box; }
html, body { margin:0; height:100%; background:var(--bg); color:var(--text); font:15px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; }
.hidden { display:none !important; }
.muted { color:var(--muted); } .small { font-size:12.5px; }
h2 { margin:0 0 10px; font-size:13px; letter-spacing:.14em; text-transform:uppercase; color:var(--accent); }
h3 { margin:0 0 8px; font-size:14px; }
.logo { font-weight:800; letter-spacing:.12em; color:var(--text); font-size:18px; }
.logo span { color:var(--accent); } .logo.big { font-size:40px; margin-bottom:6px; }
.btn { background:var(--panel2); color:var(--text); border:1px solid var(--line); border-radius:8px; padding:9px 14px; font:inherit; cursor:pointer; text-decoration:none; display:inline-block; }
.btn:hover { border-color:var(--accent2); } .btn.small { padding:5px 10px; font-size:13px; }
.btn.primary { background:var(--accent); color:#1a1200; border-color:var(--accent); font-weight:700; }
.btn:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, li:focus-visible { outline:2px solid var(--accent2); outline-offset:1px; }

.login { min-height:100%; display:grid; place-items:center; padding:20px; background:radial-gradient(circle at 50% 20%, #15213c, var(--bg) 60%); }
.login-card { background:var(--panel); border:1px solid var(--line); border-radius:16px; padding:36px 40px; text-align:center; display:flex; flex-direction:column; gap:12px; max-width:420px; }
.login-card p { margin:0; }

.app { display:flex; flex-direction:column; height:100vh; height:100dvh; }
.top { display:flex; justify-content:space-between; align-items:center; padding:10px 16px; border-bottom:1px solid var(--line); background:var(--panel); gap:10px; flex-wrap:wrap; }
.top-actions { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.main { flex:1; min-height:0; display:grid; grid-template-columns:270px minmax(0,1fr) 340px; }
.guide-col, .queue-col { background:var(--panel); padding:14px; overflow-y:auto; min-height:0; }
.guide-col { border-right:1px solid var(--line); } .queue-col { border-left:1px solid var(--line); }

.channel-list { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:6px; }
.channel-list li { display:flex; align-items:center; gap:10px; padding:10px; border:1px solid var(--line); border-radius:8px; background:var(--panel2); cursor:pointer; }
.channel-list li:hover { border-color:var(--accent2); }
.channel-list li.active { border-color:var(--accent); background:#2a2110; box-shadow:inset 3px 0 0 var(--accent); }
.num { font:700 15px ui-monospace,Menlo,Consolas,monospace; color:var(--accent); min-width:2.2em; }
.cname { flex:1; font-weight:600; } .ccount { color:var(--muted); font-size:12px; }

.tv-col { padding:14px; display:flex; flex-direction:column; gap:10px; min-width:0; min-height:0; overflow-y:auto; }
.tv { background:#000; border:3px solid #222b44; border-radius:14px; box-shadow:0 0 0 1px #000, 0 12px 40px #000a; overflow:hidden; }
.player-wrap { position:relative; aspect-ratio:16/9; width:100%; background:#000; }
.player-wrap iframe, .player-wrap #player { position:absolute; inset:0; width:100%; height:100%; }
.osd { position:absolute; top:14px; right:18px; font:800 38px ui-monospace,Menlo,Consolas,monospace; color:#7dff9a; text-shadow:0 0 8px #0a5, 2px 2px 0 #000; opacity:0; transition:opacity .6s; pointer-events:none; z-index:2; text-align:right; }
.osd.show { opacity:1; transition:none; } .osd small { display:block; font-size:16px; color:#fff; }
.tv-msg { position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; padding:20px; background:#000c; z-index:3; color:var(--text); }
.remote { display:flex; align-items:center; gap:12px; background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:10px 12px; }
.now { flex:1; min-width:0; }
.now-channel { color:var(--accent); font:700 13px ui-monospace,Menlo,Consolas,monospace; letter-spacing:.08em; }
.now-title { font-weight:700; font-size:17px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.hint { text-align:center; }

.queue { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:8px; }
.queue li { display:flex; gap:10px; cursor:pointer; padding:6px; border:1px solid transparent; border-radius:8px; }
.queue li:hover { background:var(--panel2); }
.queue li.playing { border-color:var(--accent); background:#2a2110; }
.queue img, .queue .ph { width:120px; height:68px; object-fit:cover; border-radius:6px; flex:none; background:#222b44; }
.qtitle { font-size:13.5px; font-weight:600; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.qmeta { color:var(--muted); font-size:12px; }

.modal { position:fixed; inset:0; background:#000c; display:grid; place-items:center; padding:16px; z-index:20; }
.modal-card { background:var(--panel); border:1px solid var(--line); border-radius:14px; padding:18px; width:min(1000px,100%); max-height:92vh; overflow:auto; }
.modal-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; }
.modal-head h2 { margin:0; }
.guide-grid { display:flex; flex-direction:column; gap:2px; }
.grow { display:grid; grid-template-columns:150px 1fr; border:1px solid var(--line); background:var(--panel2); cursor:pointer; }
.grow:hover, .grow.active { border-color:var(--accent); }
.gh { padding:10px; background:#1a2440; display:flex; gap:8px; align-items:center; font-weight:700; }
.gcells { display:flex; gap:6px; padding:8px; overflow-x:auto; align-items:center; }
.gcell { background:#1d2a4d; border-radius:6px; padding:6px 10px; white-space:nowrap; font-size:13px; }

.manage-grid { display:grid; grid-template-columns:1fr 1.4fr; gap:20px; }
.row { display:flex; gap:8px; margin-bottom:10px; }
input, select { background:var(--bg); color:var(--text); border:1px solid var(--line); border-radius:8px; padding:8px 10px; font:inherit; min-width:0; }
.row input, .filter { flex:1; width:100%; } .filter { margin-bottom:8px; }
.cat-manage, .sub-manage { list-style:none; margin:0 0 10px; padding:0; display:flex; flex-direction:column; gap:6px; max-height:56vh; overflow:auto; }
.cat-manage li, .sub-manage li { display:flex; align-items:center; gap:8px; padding:6px 8px; background:var(--panel2); border:1px solid var(--line); border-radius:8px; }
.cat-manage .nm { flex:1; } .sub-manage .nm { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sub-manage img, .sub-manage .av { width:28px; height:28px; border-radius:50%; flex:none; background:#33406a; object-fit:cover; }
.tag { font-size:11px; color:var(--accent); border:1px solid var(--accent); border-radius:99px; padding:0 6px; }
.toast { position:fixed; bottom:70px; left:50%; transform:translateX(-50%); background:#222b44; border:1px solid var(--line); padding:10px 16px; border-radius:10px; z-index:40; }
.toast.err { border-color:var(--red); }
.tabbar { display:none; }

@media (max-width: 1050px) { .main { grid-template-columns:230px minmax(0,1fr) 280px; } }
@media (max-width: 800px) {
  .main { display:block; position:relative; }
  .main > * { display:none; height:100%; width:100%; }
  .main[data-view="guide"] .guide-col, .main[data-view="queue"] .queue-col, .main[data-view="tv"] .tv-col { display:block; }
  .main[data-view="tv"] .tv-col { display:flex; }
  .guide-col, .queue-col { border:0; }
  .tabbar { display:grid; grid-template-columns:repeat(3,1fr); border-top:1px solid var(--line); background:var(--panel); }
  .tabbar button { background:none; color:var(--muted); border:0; padding:14px 0; font:inherit; font-weight:600; }
  .tabbar button.active { color:var(--accent); box-shadow:inset 0 3px 0 var(--accent); }
  .hint, #who { display:none; }
  .manage-grid { grid-template-columns:1fr; }
  .osd { font-size:26px; }
}

/* reorderable channel list */
.cat-manage li[draggable="true"] { cursor:grab; }
.cat-manage li.dragging { opacity:.4; }
.cat-manage li.drop-before { box-shadow:0 -3px 0 var(--accent); }
.cat-manage li.drop-after { box-shadow:0 3px 0 var(--accent); }
.cat-manage .grip { color:var(--muted); letter-spacing:-2px; user-select:none; }
.cat-manage .cnum { font-variant-numeric:tabular-nums; color:var(--accent); font-weight:700; min-width:2ch; }
.btn.icon { padding:2px 8px; min-width:32px; min-height:32px; }
.btn.icon:disabled { opacity:.3; cursor:default; }
.sub-help { margin:0 0 8px; }
.badge { display:inline-block; font-size:10px; font-weight:700; letter-spacing:.5px; padding:0 5px; margin-right:6px; border-radius:4px; background:var(--red); color:#fff; vertical-align:1px; }
.badge.soon { background:#8a6d1a; }

/* sub-channels: indented under their parent */
.channel-list li.sub { margin-left:16px; padding:7px 10px; border-left:3px solid #3a4a78; font-size:14px; }
.channel-list li.sub .cname { font-weight:500; }
.channel-list li.sub .num { font-size:13px; }
.grow.sub { margin-left:18px; }
.cat-manage li.sub { margin-left:22px; }
.modal-card.narrow { width:min(460px,100%); }
.now-why { display:flex; gap:8px; align-items:center; min-width:0; }
.now-why #now-why { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; cursor:help; }
.btn.linkish { padding:1px 8px; font-size:12px; flex:none; }
.queue li { position:relative; }
.queue .mv { position:absolute; right:4px; top:4px; padding:0 6px; font-size:12px; opacity:0; background:#000a; border:1px solid var(--line); color:var(--text); border-radius:6px; cursor:pointer; }
.queue li:hover .mv, .queue li:focus-within .mv, .queue .mv:focus-visible { opacity:1; }
.tag.dim { color:var(--muted); border-color:var(--line); margin-left:4px; }
.subopts { margin-top:14px; border-top:1px solid var(--line); padding-top:12px; }
.chk { display:flex; gap:8px; align-items:center; margin-bottom:8px; }
.sub-toggles { display:flex; flex-direction:column; gap:6px; margin-bottom:8px; max-height:30vh; overflow:auto; }
.sub-toggles .grp { font-weight:700; font-size:13px; margin-top:4px; }
.sub-toggles label { display:flex; gap:8px; align-items:center; font-size:13px; margin-left:12px; }
#move-select { width:100%; }
.chk input, .sub-toggles input { width:auto; flex:none; }
.cat-manage li.sub .nm { font-size:13px; }
.row-top { margin-top:12px; }
.btn.danger { border-color:var(--red); color:#ffb3b3; } .btn.danger:hover { background:#3a1414; }
.modal-card a { color:var(--accent2); }

.tv-msg > div { max-width:36em; }
.tv-msg-actions { display:flex; gap:10px; justify-content:center; flex-wrap:wrap; margin-top:12px; }
.tv-msg a.btn { text-decoration:none; }
#btn-yt { text-decoration:none; }
