:root {
  --bg: #0f1216;
  --bg2: #161a20;
  --bg3: #1e232b;
  --line: #2a303a;
  --text: #e9e6df;
  --muted: #8d939c;
  --accent: #f2a93b;
  --accent-ink: #1a1203;
  --danger: #e0614f;
  --radius-s: 6px;
  --radius-m: 10px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --display: "Bahnschrift", "DIN Alternate", "Arial Narrow", var(--font);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.4 var(--font); }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--danger); min-height: 1.2em; margin: 0; }
h2 { font: 600 22px var(--display); letter-spacing: .02em; margin: 8px 0 12px; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; font: 700 20px var(--display); letter-spacing: .04em; text-transform: uppercase; }
.brand.big { font-size: 30px; justify-content: center; margin-bottom: 18px; }
.brand-mark { width: 22px; height: 15px; border: 3px solid var(--accent); border-radius: 3px; position: relative; }
.brand-mark::after { content: ""; position: absolute; left: 4px; right: 4px; bottom: -7px; height: 3px; background: var(--accent); }

/* Buttons & inputs */
.btn { border: 1px solid var(--line); background: var(--bg3); padding: 9px 16px; border-radius: var(--radius-s); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #3a414d; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.round { width: 44px; height: 44px; padding: 0; border-radius: 50%; background: rgba(20,22,26,.7); border-color: rgba(255,255,255,.15); font-size: 17px; }
input[type=search], input[type=text], input[type=url], input[type=password], input:not([type]), select {
  background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; outline: none; min-width: 0;
}
input:focus, select:focus { border-color: var(--accent); }

/* Login */
.login { position: fixed; inset: 0; display: grid; place-items: center; }
.login-card { width: min(360px, 90vw); display: grid; gap: 12px; }

/* Layout */
.app { display: flex; flex-direction: column; height: 100%; }
.top { display: flex; align-items: center; gap: 24px; padding: 12px 20px; border-bottom: 1px solid var(--line); background: var(--bg); }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button { background: none; border: 0; padding: 8px 14px; cursor: pointer; color: var(--muted); font: 600 15px var(--display); letter-spacing: .03em; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.clock { font: 600 18px var(--display); color: var(--muted); font-variant-numeric: tabular-nums; }
.view { display: none; flex: 1; min-height: 0; overflow: auto; }
.view.active { display: block; }
#view-tv.active { display: flex; overflow: hidden; }
.pad { padding: 20px; }
.narrow { max-width: 760px; }

/* TV */
.tv-layout { display: flex; flex: 1; min-height: 0; }
.groups { width: 240px; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.pl-select { margin: 12px 12px 0; }
.group-list { overflow: auto; padding: 8px 0; flex: 1; }
.group-list button { display: flex; justify-content: space-between; width: 100%; text-align: left; background: none; border: 0; padding: 8px 16px; cursor: pointer; color: var(--muted); border-left: 3px solid transparent; }
.group-list button span:last-child { font-size: 12px; opacity: .7; }
.group-list button:hover { color: var(--text); background: var(--bg2); }
.group-list button.active { color: var(--text); border-left-color: var(--accent); background: var(--bg2); }
.channels { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.channels .toolbar { padding: 14px 20px 0; }
.channels .grid { padding: 14px 20px 30px; overflow: auto; flex: 1; align-content: start; }
.toolbar { display: flex; gap: 10px; }
.toolbar input { flex: 1; }
.group-select { display: none; }

/* Grid & tiles */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.tile { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius-m); cursor: pointer; text-align: left; min-height: 68px; }
.tile:hover { border-color: var(--accent); }
.tile.playing { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.tile .logo { width: 64px; height: 44px; flex: none; display: grid; place-items: center; background: #0b0d10; border-radius: var(--radius-s); overflow: hidden; font: 700 14px var(--display); color: var(--muted); }
.tile .logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.tile .t { min-width: 0; flex: 1; }
.tile .t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .t span { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.star { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px; line-height: 1; }
.star.on { color: var(--accent); }
.tile.dragging { opacity: .4; }
.empty { grid-column: 1 / -1; padding: 40px 10px; text-align: center; color: var(--muted); }
.more { grid-column: 1 / -1; justify-self: center; }

/* Settings */
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px; margin-bottom: 24px; }
.form, .card label { display: grid; gap: 12px; }
.card label { gap: 6px; color: var(--muted); font-size: 13px; }
.card label input, .card label select { color: var(--text); font-size: 15px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.row.end { justify-content: flex-end; flex-wrap: wrap; }
.row.end > * { flex: none; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; margin-bottom: 14px; }
.seg button { background: none; border: 0; padding: 8px 14px; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--bg3); color: var(--text); }
.pl-list { display: grid; gap: 8px; margin-bottom: 16px; }
.pl-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius-m); }
.pl-item .t { flex: 1; min-width: 0; }
.pl-item .t span { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Radio bar */
.radio-bar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-top: 1px solid var(--line); background: var(--bg2); }
.radio-bar img { width: 40px; height: 40px; object-fit: contain; border-radius: var(--radius-s); background: #0b0d10; }
.rb-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Player */
.player { position: fixed; inset: 0; background: #000; z-index: 20; }
.player video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.p-top, .p-bottom { position: absolute; left: 0; right: 0; padding: 18px 22px; display: flex; gap: 10px; transition: opacity .3s; }
.p-top { top: 0; background: linear-gradient(rgba(0,0,0,.6), transparent); }
.p-bottom { bottom: 0; align-items: flex-end; background: linear-gradient(transparent, rgba(0,0,0,.85)); padding-top: 60px; }
.player.idle .p-top, .player.idle .p-bottom { opacity: 0; }
.player.idle { cursor: none; }
.p-spacer { flex: 1; }
.p-info { flex: 1; display: flex; gap: 16px; align-items: center; min-width: 0; }
.p-info img { width: 88px; height: 60px; object-fit: contain; background: rgba(255,255,255,.06); border-radius: var(--radius-s); }
.p-text { min-width: 0; flex: 1; max-width: 720px; }
.p-title { display: flex; align-items: center; gap: 6px; font: 600 24px var(--display); }
.p-now { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-prog { height: 3px; background: rgba(255,255,255,.18); margin: 6px 0; border-radius: 2px; overflow: hidden; }
.p-prog i { display: block; height: 100%; width: 0; background: var(--accent); }
.p-ctrl { display: flex; align-items: center; gap: 8px; }
.p-ctrl select { background: rgba(20,22,26,.7); }
#p-vol { width: 90px; accent-color: var(--accent); }
.p-status { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; text-align: center; padding: 20px; font-size: 18px; text-shadow: 0 1px 4px #000; }
.p-status .spin { width: 42px; height: 42px; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.p-list { position: absolute; top: 0; right: 0; bottom: 0; width: 320px; background: rgba(15,18,22,.95); overflow: auto; padding: 80px 0 20px; z-index: 2; border-left: 1px solid var(--line); }
.p-list button { display: flex; gap: 10px; align-items: center; width: 100%; background: none; border: 0; padding: 8px 16px; cursor: pointer; text-align: left; }
.p-list button:hover, .p-list button.active { background: var(--bg3); }
.p-list button.active { box-shadow: inset 3px 0 var(--accent); }
.p-list img { width: 40px; height: 28px; object-fit: contain; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--bg3); border: 1px solid var(--line); padding: 10px 16px; border-radius: var(--radius-s); opacity: 0; pointer-events: none; transition: .25s; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* Mobil */
@media (max-width: 760px) {
  .top { gap: 10px; padding: 10px 12px; flex-wrap: wrap; }
  .brand { font-size: 16px; }
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; }
  .groups { display: none; }
  .channels .toolbar { flex-wrap: wrap; }
  .channels .toolbar input { flex-basis: 100%; }
  .group-select { display: block; flex: 1; }
  .channels .toolbar, .channels .grid, .pad { padding-left: 12px; padding-right: 12px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile { flex-direction: column; text-align: center; gap: 6px; }
  .tile .t { width: 100%; }
  .tile .star { position: absolute; top: 2px; right: 2px; }
  .row { flex-direction: column; }
  .p-info img { display: none; }
  .p-bottom { flex-direction: column; align-items: stretch; }
  #p-vol { display: none; }
  .p-list { width: 85vw; }
}
