:root {
  --bg: #0b0b0e;
  --bg-2: #121217;
  --panel: #17171d;
  --panel-2: #1f1f27;
  --border: #26262f;
  --text: #f3f3f5;
  --muted: #9a9aa6;
  --accent: #e82127;
  --accent-2: #ff3b41;
  --ok: #2bd576;
  --warn: #f5c542;
  --radius: 14px;
  --sidebar-w: 88px;
  --topbar-h: 72px;
  --tile: 164px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: stretch;
  padding: 12px 8px; gap: 6px;
  overflow-y: auto;
}
.brand {
  display: grid; place-items: center; height: 56px; margin-bottom: 8px;
}
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px; background: var(--accent);
  display: grid; place-items: center; font-size: 18px; color: #fff;
}
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.nav a, .nav-account {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; min-height: 60px; padding: 8px 4px; border-radius: 12px;
  color: var(--muted); font-size: 11.5px; font-weight: 500; text-align: center;
  transition: background .15s, color .15s;
}
.nav a .ico { font-size: 20px; line-height: 1; }
.nav a:hover, .nav-account:hover { background: var(--panel); color: var(--text); }
.nav a.active { background: var(--panel-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.nav-account { margin-top: auto; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--panel-2);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--text);
  border: 2px solid var(--border);
}
.avatar.signed { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; }
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 16px;
  padding: 0 24px; border-bottom: 1px solid var(--border); background: var(--bg);
}
.logo { font-weight: 800; font-size: 22px; letter-spacing: -.02em; white-space: nowrap; }
.logo span { color: var(--accent); }
.search { flex: 1; max-width: 520px; }
.search input {
  width: 100%; height: 44px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); padding: 0 18px;
}
.search input::placeholder { color: var(--muted); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--panel);
  color: var(--text); font-weight: 600; font-size: 13.5px; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.chip:hover { background: var(--panel-2); border-color: #3a3a45; }
.chip:active { transform: scale(.97); }
.chip.active { background: var(--text); color: #000; border-color: var(--text); }
.chip-plan { border-color: rgba(232, 33, 39, .5); background: rgba(232, 33, 39, .12); }
.chip-danger { border-color: rgba(232, 33, 39, .5); }
.chip-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.clock { text-align: right; line-height: 1.1; min-width: 80px; }
.clock .time { font-weight: 700; font-size: 20px; }
.clock .date { color: var(--muted); font-size: 11.5px; }

.banners { padding: 10px 24px 0; display: flex; flex-direction: column; gap: 8px; }
.banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-radius: 12px; border: 1px solid rgba(232, 33, 39, .45);
  background: linear-gradient(90deg, rgba(232, 33, 39, .18), rgba(232, 33, 39, .05));
  font-size: 14px;
}
.banner .grow { flex: 1; }
.banner .x { background: none; border: 0; font-size: 18px; color: var(--muted); padding: 4px 8px; }
.banner .x:hover { color: var(--text); }

.view { flex: 1; overflow-y: auto; padding: 20px 24px 60px; scroll-behavior: smooth; }

/* ---------- Content ---------- */
.page-title { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; }
.page-title h1 { margin: 0; font-size: 26px; letter-spacing: -.01em; }
.page-title .sub { color: var(--muted); font-size: 14px; }
.page-title .spacer { flex: 1; }

.section { margin-bottom: 28px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.section-head h2 { margin: 0; font-size: 18px; }
.section-head .more { color: var(--muted); font-size: 13px; }
.section-head .more:hover { color: var(--text); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile), 1fr));
}
.row { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.row .tile { flex: 0 0 var(--tile); }

.tile {
  position: relative; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 12px 12px; min-height: 150px;
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  transition: transform .12s, border-color .12s, background .12s; cursor: pointer;
}
.tile:hover { transform: translateY(-3px); border-color: #3d3d4a; background: var(--panel-2); }
.tile:active { transform: scale(.98); }
.tile .logo-wrap {
  width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center;
  overflow: hidden; background: #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}
.tile .logo-wrap img { width: 40px; height: 40px; object-fit: contain; }
.tile .logo-wrap .initials { font-weight: 800; font-size: 22px; color: #fff; width: 100%; height: 100%; display: grid; place-items: center; }
.tile .name { font-weight: 600; font-size: 14px; line-height: 1.2; }
.tile .meta { color: var(--muted); font-size: 11.5px; }
.tile .fav {
  position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .35); color: var(--muted); font-size: 16px; display: grid; place-items: center;
}
.tile .fav:hover { color: var(--text); background: rgba(0, 0, 0, .6); }
.tile .fav.on { color: var(--accent-2); }
.tile .badge {
  position: absolute; top: 10px; left: 10px; font-size: 10px; font-weight: 700; letter-spacing: .04em;
  padding: 3px 7px; border-radius: 999px; background: rgba(43, 213, 118, .15); color: var(--ok);
}
.tile .badge.play { background: rgba(232, 33, 39, .18); color: var(--accent-2); }

.hero {
  border-radius: 20px; padding: 28px 30px; margin-bottom: 24px;
  background: radial-gradient(1200px 300px at 10% -20%, rgba(232, 33, 39, .35), transparent 60%),
              linear-gradient(135deg, #1a1a22, #101015);
  border: 1px solid var(--border); display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.hero h1 { margin: 0 0 6px; font-size: 30px; }
.hero p { margin: 0; color: var(--muted); max-width: 560px; }
.hero .actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

.empty {
  border: 1px dashed var(--border); border-radius: var(--radius); padding: 40px 20px;
  text-align: center; color: var(--muted);
}
.empty strong { color: var(--text); display: block; margin-bottom: 6px; font-size: 16px; }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; max-width: 560px;
}
.card h2 { margin: 0 0 12px; font-size: 18px; }
.card p { color: var(--muted); margin: 6px 0; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { font-size: 13px; font-weight: 600; display: flex; flex-direction: column; gap: 6px; }
.form input[type="text"], .form input[type="url"], .form input[type="email"], .form input[type="password"], .form select {
  height: 46px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-2);
  color: var(--text); padding: 0 14px;
}
.form .row2 { display: flex; gap: 10px; flex-wrap: wrap; }
.form .row2 > * { flex: 1; min-width: 160px; }
.btn {
  height: 46px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2);
  color: var(--text); font-weight: 700; padding: 0 18px;
}
.btn:hover { border-color: #3d3d4a; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.tabs { display: inline-flex; background: var(--bg-2); border-radius: 999px; padding: 4px; margin: 0 auto 14px; }
.tabs button { border: 0; background: none; border-radius: 999px; padding: 8px 16px; color: var(--muted); font-weight: 600; }
.tabs button.active { background: var(--panel-2); color: var(--text); }
.msg { font-size: 13.5px; padding: 10px 12px; border-radius: 10px; }
.msg.err { background: rgba(232, 33, 39, .15); color: #ff8a8e; }
.msg.ok { background: rgba(43, 213, 118, .12); color: var(--ok); }
.note { font-size: 12.5px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.toggle:first-of-type { border-top: 0; }
.toggle .t { font-weight: 600; } .toggle .d { color: var(--muted); font-size: 12.5px; }
.switch { position: relative; width: 48px; height: 28px; border-radius: 999px; background: var(--border); border: 0; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: var(--ok); } .switch.on::after { transform: translateX(20px); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .u { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .x { background: none; border: 0; color: var(--muted); font-size: 18px; }
.list-item .x:hover { color: var(--accent-2); }
code { background: var(--bg-2); padding: 2px 6px; border-radius: 6px; font-size: 13px; }

/* ---------- Player ---------- */
.player {
  position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column;
}
.player-bar {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.player-title { font-weight: 700; flex: 1; }
.player-actions { display: flex; gap: 8px; }
.player-body { flex: 1; position: relative; display: grid; place-items: center; }
.player-body iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.radio-ui { text-align: center; padding: 30px; max-width: 520px; }
.radio-ui .disc {
  width: 160px; height: 160px; border-radius: 50%; margin: 0 auto 20px;
  background: conic-gradient(from 0deg, var(--accent), #5a0a0d, var(--accent));
  display: grid; place-items: center; font-size: 56px; animation: spin 6s linear infinite;
  box-shadow: 0 0 60px rgba(232, 33, 39, .35);
}
.radio-ui .disc.paused { animation-play-state: paused; }
@keyframes spin { to { transform: rotate(360deg); } }
.radio-ui h2 { margin: 0 0 6px; }
.radio-ui .controls { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.radio-ui input[type="range"] { width: 160px; accent-color: var(--accent); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--panel-2); border: 1px solid var(--border); padding: 12px 18px; border-radius: 12px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60;
  font-weight: 600;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive (phone/tablet) ---------- */
@media (max-width: 760px) {
  :root { --sidebar-w: 0px; --tile: 120px; }
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sidebar {
    order: 2; flex-direction: row; border-right: 0; border-top: 1px solid var(--border);
    padding: 6px 8px; overflow-x: auto; overflow-y: hidden;
  }
  .brand { display: none; }
  .nav { flex-direction: row; flex: 1; }
  .nav a, .nav-account { min-width: 64px; min-height: 52px; font-size: 10.5px; }
  .nav-account { margin-top: 0; }
  .main { height: auto; min-height: 0; }
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .clock { display: none; }
  .view { padding: 14px 16px 40px; }
  .banners { padding: 10px 16px 0; }
  .tile { min-height: 130px; }
  .hero { padding: 20px; }
  .hero h1 { font-size: 22px; }
}

/* ---------- In-site viewer additions ---------- */
.tile .badge.out { background: rgba(154, 154, 166, .15); color: var(--muted); }
.tile-out .logo-wrap { opacity: .85; }
.player-hint {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 2;
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px;
  background: rgba(20, 20, 26, .92); border: 1px solid var(--border); font-size: 13px; box-shadow: var(--shadow);
  max-width: min(92vw, 560px);
}
.player-hint .x { background: none; border: 0; color: var(--muted); font-size: 16px; }
.picker { max-width: 520px; width: 100%; padding: 30px; text-align: center; }
.picker h2 { margin: 0 0 14px; }
.picker .form { text-align: left; }
.picker .chips { justify-content: center; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
body.viewing .view { overflow: hidden; }

/* ---------- YouTube page ---------- */
.yt-head { margin-bottom: 18px; }
.yt-search { display: flex; gap: 10px; margin-bottom: 12px; max-width: 760px; }
.yt-search input {
  flex: 1; height: 48px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel);
  color: var(--text); padding: 0 16px; font-size: 15px;
}
.yt-search input::placeholder { color: var(--muted); }
.yt-grid { display: grid; gap: 16px 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin-bottom: 28px; }
.yt-card { cursor: pointer; border-radius: 12px; padding: 6px; transition: background .12s, transform .12s; }
.yt-card:hover { background: var(--panel); transform: translateY(-2px); }
.yt-thumb { position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: var(--panel-2); }
.yt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.yt-dur {
  position: absolute; right: 6px; bottom: 6px; padding: 2px 6px; border-radius: 6px;
  background: rgba(0, 0, 0, .8); font-size: 11.5px; font-weight: 700;
}
.yt-dur.live { background: var(--accent); }
.yt-title {
  margin: 8px 2px 2px; font-weight: 600; font-size: 14px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.yt-meta { margin: 0 2px; color: var(--muted); font-size: 12.5px; }
.yt-setup { max-width: 760px; margin-bottom: 20px; }
.yt-loading { padding: 20px 0; }

/* ---------- Mirror ---------- */
.mirror-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: stretch; margin-bottom: 16px; }
.mirror-card { max-width: none; }
.mirror-pair { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.qr { border-radius: 12px; background: #fff; padding: 6px; width: 160px; height: 160px; }
.code-big { font-size: 44px; font-weight: 800; letter-spacing: .18em; font-family: ui-monospace, Consolas, monospace; text-transform: uppercase; line-height: 1.1; }
.mirror-stage { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.mirror-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.mirror-stage:fullscreen { border-radius: 0; border: 0; }
.stage-badge {
  position: absolute; top: 12px; left: 12px; padding: 6px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, .7); border: 1px solid var(--border); font-size: 12.5px; pointer-events: none;
}
