:root {
  --bg: #070b14;
  --bg-2: #0c1322;
  --panel: rgba(12, 19, 34, 0.86);
  --panel-solid: #0e1627;
  --line: rgba(148, 170, 210, 0.14);
  --line-2: rgba(148, 170, 210, 0.26);
  --text: #e8eef9;
  --muted: #8b9ab5;
  --accent: #ffb547;      /* amber: selection, live */
  --accent-ink: #1c1203;
  --teal: #3fd0c9;        /* data on the globe */
  --danger: #ff6b6b;
  --radius: 14px;
  --panel-w: 380px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background:
    radial-gradient(1200px 800px at 35% 45%, #0f1d36 0%, transparent 60%),
    radial-gradient(900px 600px at 90% 10%, #1a1430 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg .fill { fill: currentColor; stroke: none; }
[hidden] { display: none !important; }

#globe { position: fixed; inset: 0; right: var(--panel-w); }
#globe canvas { outline: none; }

.float-tooltip-kap {
  padding: 6px 10px !important; border-radius: 8px !important;
  background: rgba(7, 11, 20, 0.92) !important; border: 1px solid var(--line-2);
  font: 13px/1.3 var(--font) !important; color: var(--text) !important; white-space: nowrap;
}
.float-tooltip-kap b { font-weight: 600; }
.float-tooltip-kap span { color: var(--muted); margin-left: 6px; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; z-index: 20; top: 0; left: 0; right: var(--panel-w);
  display: flex; align-items: center; gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) 20px 14px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; margin-right: auto; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--accent);
  background: radial-gradient(circle, var(--teal) 0 4px, transparent 5px);
  box-shadow: 0 0 24px rgba(255, 181, 71, 0.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 20px; letter-spacing: 0.04em; font-weight: 700; }
.brand-text small { color: var(--muted); font-size: 12px; }

.modes { display: flex; padding: 4px; gap: 2px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px); }
.modes button {
  border: 0; background: transparent; padding: 7px 16px; border-radius: 999px;
  color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px;
}
.modes button.active { background: var(--accent); color: var(--accent-ink); }
.modes button small { font-weight: 500; opacity: 0.7; font-size: 11px; }

.actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 12px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px);
}
.icon-btn:hover { border-color: var(--line-2); background: var(--bg-2); }
.icon-btn.only-icon { width: 36px; padding: 0; justify-content: center; }
.icon-btn.on { color: var(--accent); }
.icon-btn.on svg { fill: currentColor; }
.lang { height: 36px; padding: 0 8px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }

/* ---------- side panel ---------- */
.panel {
  position: fixed; z-index: 15; top: 0; right: 0; bottom: 0; width: var(--panel-w);
  display: flex; flex-direction: column;
  background: var(--panel-solid); border-left: 1px solid var(--line);
  padding-top: max(10px, env(safe-area-inset-top));
}
.panel-grip { display: none; }
.tabs { display: flex; gap: 4px; padding: 10px 14px 0; }
.tabs button {
  flex: 1; border: 0; background: transparent; padding: 10px 0; color: var(--muted);
  border-bottom: 2px solid transparent; font-weight: 600;
}
.tabs button.active { color: var(--text); border-color: var(--accent); }
.panel-head { padding: 12px 16px 0; display: flex; align-items: center; gap: 10px; min-height: 12px; }
.panel-head:empty { display: none; }
.panel-head .back { border: 1px solid var(--line); background: transparent; border-radius: 9px; width: 32px; height: 32px; display: grid; place-items: center; }
.panel-head h2 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.panel-head h2 span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-head .count { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.panel-head .clock { color: var(--muted); font-size: 12px; }

.search { margin: 12px 14px 0; position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search input {
  width: 100%; height: 38px; padding: 0 12px 0 34px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line); outline: none;
}
.search input:focus { border-color: var(--accent); }

.chips { display: flex; gap: 6px; padding: 10px 14px 0; overflow-x: auto; scrollbar-width: none; }
.chips:empty { display: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: transparent; color: var(--muted);
  padding: 4px 10px; border-radius: 999px; font-size: 12px; white-space: nowrap;
}
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.list { list-style: none; margin: 10px 0 0; padding: 0 8px 12px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent;
}
.row:hover, .row:focus-visible { background: var(--bg-2); outline: none; }
.row.active { background: rgba(255, 181, 71, 0.1); border-color: rgba(255, 181, 71, 0.35); }
.row .flag { font-size: 22px; width: 30px; text-align: center; line-height: 1; }
.row .logo, .player .logo {
  width: 40px; height: 40px; border-radius: 9px; object-fit: contain; flex: none;
  background: #fff1 center/60% no-repeat; padding: 4px;
}
.row .logo.fallback, .player .logo.fallback {
  display: grid; place-items: center; font-weight: 700; color: var(--muted); font-size: 15px; padding: 0;
}
.row .body { min-width: 0; flex: 1; }
.row .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 6px; align-items: center; }
.row .n { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.row .badge { color: var(--accent); }
.row .live { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(255, 181, 71, 0.2); animation: pulse 1.6s infinite; flex: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 181, 71, 0); } }
.empty { color: var(--muted); padding: 28px 16px; text-align: center; }
.panel-foot { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.panel-foot a { color: inherit; }

/* ---------- player ---------- */
.player {
  position: fixed; z-index: 25; left: 20px; bottom: 20px; width: min(520px, calc(100vw - var(--panel-w) - 40px));
  background: var(--panel-solid); border: 1px solid var(--line-2); border-radius: var(--radius);
  overflow: hidden; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.player-media { position: relative; aspect-ratio: 16 / 9; background: #000; }
.player-media video, .player-media iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.player.audio-mode .player-media { display: none; }
.player.audio-mode #pFull { display: none; }
.player.failed .player-media { display: block; aspect-ratio: auto; min-height: 150px; background: transparent; }
.player.failed video { display: none; }
.player-overlay {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px;
  background: rgba(0, 0, 0, 0.55); color: var(--text);
}
.player-overlay:empty { display: none; }
.player-overlay .spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff3; border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.player-overlay h3 { margin: 0 0 4px; font-size: 16px; }
.player-overlay p { margin: 0 0 12px; color: var(--muted); }
.player-overlay .btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.btn { border: 1px solid var(--line-2); background: var(--bg-2); border-radius: 9px; padding: 7px 14px; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.player-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.player-bar .icon-btn { background: transparent; backdrop-filter: none; }
.logo-slot { display: contents; }
.player-meta { min-width: 0; flex: 1; }
.player-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player.audio-mode .player-bar { padding: 12px; }
.eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; margin-right: 4px; }
.eq i { width: 3px; background: var(--accent); animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -0.3s; } .eq i:nth-child(3) { animation-delay: -0.6s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 12px; } }
.paused .eq i { animation: none; height: 3px; }

/* ---------- misc ---------- */
.about { max-width: 520px; background: var(--panel-solid); color: var(--text); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 24px; }
.about::backdrop { background: rgba(0, 0, 0, 0.6); }
.about h2 { margin-top: 0; }
.muted { color: var(--muted); font-size: 12px; }
.toast {
  position: fixed; z-index: 40; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-weight: 600;
}

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  :root { --panel-w: 0px; }
  #globe { right: 0; bottom: 48vh; }
  .topbar { right: 0; padding: max(10px, env(safe-area-inset-top)) 12px 10px; gap: 8px; flex-wrap: wrap; }
  .brand-text small, .actions .icon-btn span { display: none; }
  .actions .icon-btn { width: 36px; padding: 0; justify-content: center; }
  .modes { order: 3; width: 100%; justify-content: center; }
  .modes button { flex: 1; justify-content: center; }
  .panel {
    top: auto; left: 0; width: auto; height: 50vh; border-left: 0; border-top: 1px solid var(--line-2);
    border-radius: 18px 18px 0 0; transition: height 0.25s ease; padding-top: 0;
  }
  .panel.expanded { height: 86vh; }
  .panel-grip { display: block; height: 22px; flex: none; position: relative; cursor: grab; }
  .panel-grip::after { content: ""; position: absolute; left: 50%; top: 9px; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--line-2); }
  .tabs { padding-top: 0; }
  .player { left: 0; right: 0; top: 0; bottom: auto; width: auto; border-radius: 0; border-width: 0 0 1px; }
  .player.audio-mode { top: auto; bottom: calc(50vh + 8px); left: 8px; right: 8px; border-radius: var(--radius); border-width: 1px; }
  body.video-open .topbar { display: none; }
}

/* account, complaints */
.user-btn { gap: 6px; max-width: 150px; }
.user-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
dialog .btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }
dialog .btns form { margin: 0; }
dialog a.btn { text-decoration: none; display: inline-block; }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 5px; font-size: 14px; }
.form select, .form textarea {
  width: 100%; box-sizing: border-box; padding: 8px 10px; font: inherit; color: inherit;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.18); border-radius: 8px;
}
.form select option { color: #111; }
