:root {
  color-scheme: dark;
  --bg: #0e1116; --panel: #161b22; --panel2: #1c232d; --line: #2a323d;
  --text: #e6edf3; --muted: #8b98a8; --accent: #3b82f6; --accent2: #f59e0b; --bad: #ef4444; --ok: #22c55e;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column; overflow: hidden; }

header { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex: none; }
.brand { font-weight: 700; letter-spacing: .5px; white-space: nowrap; }
.brand span { color: var(--accent); }
#search { flex: 1; min-width: 0; max-width: 520px; }
input, select { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font: inherit; outline: none; }
input:focus, select:focus { border-color: var(--accent); }
#filters { display: flex; gap: 8px; flex: none; }
#filters select { max-width: 170px; }
#tracks { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 12px; color: var(--muted); }
#tracks label { display: flex; align-items: center; gap: 8px; }
#tracks select { padding: 5px 8px; max-width: 220px; }
#tracks select:disabled { opacity: .5; }
video::cue { background: rgba(0, 0, 0, .7); color: #fff; font-size: 1.1em; }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; font-size: 18px;
  width: 36px; height: 36px; cursor: pointer; flex: none; }
.icon-btn:disabled { opacity: .4; cursor: default; }
.icon-btn.on { color: var(--accent2); border-color: var(--accent2); }
#menuBtn { display: none; }

main { flex: 1; min-height: 0; display: grid; grid-template-columns: 220px minmax(280px, 380px) 1fr; }

#cats-pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--panel); }
#cats { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; }
/* Sayfa dugmeleri: imlecli TV kumandalari ic ice kaydirma alanlarini kaydiramaz (teker yok, kenar-kaydirma yalniz belgeye islem yapar) */
.pager { display: none; gap: 6px; flex: none; }
.pager button { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  min-width: 44px; height: 32px; font-size: 14px; cursor: pointer; }
.pager button:hover, .pager button:focus { border-color: var(--accent); outline: none; }
html.tv .pager { display: flex; }
#cats-pane > .pager { padding: 8px 8px 0; }
#cats-pane > .pager button { flex: 1; }
/* Kumanda odagi: 3 metreden secilebilir olmali */
#channels li:focus, #cats button:focus-visible, select:focus-visible, #unmute:focus-visible, .icon-btn:focus-visible {
  outline: 3px solid var(--accent2); outline-offset: -3px; }
#channels li:focus { background: var(--panel2); }
#cats button { display: flex; justify-content: space-between; gap: 8px; width: 100%; text-align: left; background: none;
  border: 0; color: var(--text); padding: 8px 10px; border-radius: 8px; cursor: pointer; font: inherit; }
#cats button:hover { background: var(--panel2); }
#cats button.active { background: var(--accent); color: #fff; }
#cats button .cnt { color: var(--muted); font-variant-numeric: tabular-nums; }
#cats button.active .cnt { color: #dbeafe; }
#cats hr { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }

#list-pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
#list-scroll { flex: 1; min-height: 0; overflow-y: auto; }
#list-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; flex: none;
  background: var(--bg); border-bottom: 1px solid var(--line); font-weight: 600; }
#list-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#list-count { color: var(--muted); font-weight: 400; white-space: nowrap; }
#channels { list-style: none; margin: 0; padding: 4px; outline: none; }
#channels li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; cursor: pointer; }
#channels li:hover { background: var(--panel); }
#channels li.active { background: var(--panel2); box-shadow: inset 3px 0 0 var(--accent); }
#channels .logo { width: 44px; height: 30px; flex: none; border-radius: 4px; background: var(--panel2);
  display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted); font-size: 11px; }
#channels .logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
#channels .nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#channels .tags { display: flex; gap: 4px; flex: none; }
.tag { font-size: 10px; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted);
  text-transform: uppercase; }
.tag.warn { color: var(--accent2); border-color: #5b4210; }
.tag.fav { color: var(--accent2); border: 0; font-size: 13px; padding: 0; }
.empty { padding: 24px 14px; color: var(--muted); }

#player-pane { padding: 16px; overflow-y: auto; min-width: 0; }
#video-wrap { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9;
  max-height: calc(100vh - 230px); margin: 0 auto; }
#video { width: 100%; height: 100%; display: block; background: #000; }
#overlay { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; text-align: center;
  padding: 24px; background: rgba(0, 0, 0, .72); color: var(--text); font-size: 15px; pointer-events: none; }
#overlay.show { display: flex; }
#unmute { position: absolute; top: 12px; right: 12px; z-index: 2; background: var(--accent2); color: #111; border: 0;
  border-radius: 999px; padding: 10px 18px; font: 600 15px/1 inherit; cursor: pointer; box-shadow: 0 4px 16px rgba(0, 0, 0, .5); }
#unmute[hidden] { display: none; }
#overlay.busy #overlay-text::before { content: ""; display: block; width: 28px; height: 28px; margin: 0 auto 12px;
  border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#now { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
#now-logo { width: 64px; height: 44px; object-fit: contain; background: var(--panel2); border-radius: 6px; }
#now-text { flex: 1; min-width: 0; }
#now-name { font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#now-meta { color: var(--muted); }
#status { margin-top: 8px; min-height: 20px; color: var(--muted); }
#status.bad { color: var(--bad); }
#status.ok { color: var(--ok); }
.note { color: var(--muted); font-size: 12px; margin-top: 18px; }
.note a { color: var(--muted); }

/* Orta genislik (960x540 bildiren TV'ler dahil): sutunlar daralir ama yan yana kalir */
@media (max-width: 1100px) {
  main { grid-template-columns: 170px minmax(220px, 300px) 1fr; }
  #player-pane { padding: 10px; }
  #filters select { max-width: 130px; }
}
@media (min-width: 1600px) { html.tv { zoom: 1.4; } }

/* Telefon: tek sutun. Ic ice kaydirma YOK, belgenin kendisi kayar (dokunmatik + kenar-kaydirma ikisi de calisir) */
@media (max-width: 760px) {
  html:not(.tv), html:not(.tv) body { height: auto; }
  html:not(.tv) body { overflow: visible; display: block; }
  html:not(.tv) main { display: block; }
  html:not(.tv) #menuBtn { display: block; }
  html:not(.tv) #player-pane { padding: 0 0 8px; position: sticky; top: 0; z-index: 3; background: var(--bg); overflow: visible; }
  html:not(.tv) #video-wrap { border-radius: 0; max-height: 40vh; width: 100%; }
  html:not(.tv) #now, html:not(.tv) #status, html:not(.tv) #tracks { padding: 0 12px; }
  html:not(.tv) #tracks { margin-top: 6px; gap: 10px; font-size: 12px; }
  html:not(.tv) header { flex-wrap: wrap; }
  html:not(.tv) #filters { order: 5; flex: 1 1 100%; }
  html:not(.tv) #filters select { flex: 1; max-width: none; min-width: 0; }
  html:not(.tv) #now-name { font-size: 15px; }
  html:not(.tv) .note { display: none; }
  html:not(.tv) #cats-pane { display: none; position: fixed; z-index: 5; top: 0; bottom: 0; left: 0; width: 260px;
    box-shadow: 8px 0 24px rgba(0, 0, 0, .5); }
  html:not(.tv) body.menu-open #cats-pane { display: flex; }
  html:not(.tv) #list-pane { border: 0; display: block; }
  html:not(.tv) #list-scroll { overflow: visible; }
  html:not(.tv) .brand span { display: none; }
}
