:root {
  color-scheme: dark;
  --bg: #070a12;
  --surface: #101624;
  --surface-2: #171f31;
  --surface-3: #202b42;
  --line: rgba(255, 255, 255, 0.11);
  --text: #f7f8fc;
  --muted: #aeb8cc;
  --accent: #9b87f5;
  --accent-strong: #7457e8;
  --success: #55d68b;
  --warning: #ffc56d;
  --danger: #ff7582;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  --focus: 0 0 0 3px rgba(155, 135, 245, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-width: 280px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% -5%, rgba(116, 87, 232, 0.24), transparent 32rem),
    radial-gradient(circle at 95% 8%, rgba(53, 139, 255, 0.13), transparent 28rem),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, select, input { font: inherit; }
button, a, select, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
button, select { min-height: 48px; }
button { touch-action: manipulation; }

.radio-page { min-height: 100vh; padding: max(18px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom)); }
.container {
  width: min(1160px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 740px) minmax(280px, 1fr);
  gap: 22px;
  align-items: start;
}
.player-container,
.station-panel {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(23, 31, 49, 0.94), rgba(12, 17, 29, 0.98));
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
}
.player-container { padding: clamp(18px, 3vw, 30px); display: grid; gap: 18px; }
.player-heading { display: flex; align-items: center; gap: 16px; }
.brand-logo {
  width: clamp(68px, 12vw, 92px);
  height: clamp(68px, 12vw, 92px);
  flex: 0 0 auto;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  object-fit: contain;
}
.brand-copy { min-width: 0; }
.player-heading h1 { margin: 0; font-size: clamp(2rem, 7vw, 3.4rem); line-height: 0.95; letter-spacing: -0.055em; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.13em; }

.player-status {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(6, 10, 18, 0.52);
}
.status-indicator { width: 11px; height: 11px; border-radius: 50%; background: var(--muted); }
.status-indicator.connected { background: var(--success); box-shadow: 0 0 0 5px rgba(85, 214, 139, 0.12); }
.status-indicator.connecting { background: var(--warning); box-shadow: 0 0 0 5px rgba(255, 197, 109, 0.12); }
.status-indicator.error { background: var(--danger); box-shadow: 0 0 0 5px rgba(255, 117, 130, 0.12); }
#status-message { min-width: 0; font-size: 0.9rem; font-weight: 680; overflow-wrap: anywhere; }
.status-actions { display: flex; align-items: center; gap: 8px; }
#buffering-progress { color: var(--muted); font-size: 0.78rem; }
.apk-download, .admin-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 750;
}
.apk-download:hover, .admin-link:hover { background: rgba(155, 135, 245, 0.16); border-color: rgba(155, 135, 245, 0.5); }
.install-note { margin: -6px 2px 0; color: var(--muted); font-size: 0.83rem; }
.install-note strong { color: var(--text); }

.realtime-panel,
.station-selector,
.player-controls,
.now-playing,
.debug-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(7, 11, 20, 0.5);
}
.realtime-panel { padding: 16px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.section-heading h2 { margin: 0; font-size: 1.05rem; letter-spacing: -0.02em; }
.readiness-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid rgba(255, 197, 109, 0.32);
  border-radius: 999px;
  background: rgba(255, 197, 109, 0.09);
  color: var(--warning);
  font-size: 0.74rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.readiness-badge.ready { border-color: rgba(85, 214, 139, 0.38); background: rgba(85, 214, 139, 0.1); color: var(--success); }
.realtime-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.metric {
  min-width: 0;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 7px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: var(--radius-sm);
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.065), rgba(255, 255, 255, 0.022));
}
.metric > span { color: var(--muted); font-size: 0.72rem; font-weight: 720; line-height: 1.25; }
.metric strong { overflow-wrap: anywhere; font-size: clamp(1.05rem, 2.7vw, 1.45rem); line-height: 1.05; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.metric small { color: var(--muted); font-size: 0.68rem; line-height: 1.2; }
.metric-buffer { grid-column: span 1; }
.metric strong.offline { color: var(--danger); }
progress { width: 100%; height: 7px; border: 0; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
progress::-webkit-progress-bar { background: var(--surface-3); }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--accent-strong), #b7a8ff); border-radius: 999px; }
progress::-moz-progress-bar { background: linear-gradient(90deg, var(--accent-strong), #b7a8ff); border-radius: 999px; }

.station-selector { display: grid; gap: 12px; padding: 15px; }
.selector-row { display: grid; grid-template-columns: 88px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.selector-row label, .favorites-title { color: var(--muted); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; }
.selector-row select {
  width: 100%;
  padding: 0 42px 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background-color: var(--surface-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%23d8dcef' d='m5 7 5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  appearance: none;
}
.icon-button, .nav-button, .float-button {
  min-width: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
}
.icon-button svg, .nav-button svg { width: 22px; height: 22px; fill: currentColor; }
.icon-button.active { color: #ff8793; border-color: rgba(255, 135, 147, 0.45); background: rgba(255, 135, 147, 0.09); }
.favorites-container { display: none; padding-top: 12px; border-top: 1px solid var(--line); }
.favorites-container.visible { display: block; }
.favorites-title { margin-bottom: 9px; }
.favorites-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; overflow: visible; }
.favorite-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  min-width: 0;
  min-height: 42px;
  max-width: 100%;
  padding: 6px 8px 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
}
.favorite-item.active { border-color: rgba(155, 135, 245, 0.55); background: rgba(155, 135, 245, 0.12); }
.favorite-item.disabled { opacity: 0.45; cursor: not-allowed; }
.favorite-name { min-width: 0; overflow-wrap: anywhere; white-space: normal; }
.favorite-remove { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; color: var(--muted); background: transparent; cursor: pointer; }
.favorite-remove:hover { color: var(--danger); background: rgba(255, 117, 130, 0.1); }

.player-controls { padding: 15px; display: grid; grid-template-columns: 120px minmax(0, 1fr) minmax(160px, 0.8fr); gap: 12px; align-items: center; }
.navigation-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.nav-button:hover, .icon-button:hover { background: var(--surface-3); border-color: rgba(155, 135, 245, 0.45); }
.control-button {
  min-height: 58px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  color: white;
  background: linear-gradient(135deg, var(--accent-strong), #9a7df2);
  box-shadow: 0 12px 26px rgba(116, 87, 232, 0.26);
  cursor: pointer;
  font-weight: 820;
}
.control-button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.control-button:active { transform: translateY(0); }
.control-button svg, .float-button svg { width: 22px; height: 22px; fill: currentColor; }
.volume-control { min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.volume-icon { display: flex; flex: 0 0 auto; color: var(--muted); }
.volume-icon svg { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; stroke-width: 1.5; }
.volume-slider { width: 100%; min-height: 44px; accent-color: var(--accent); cursor: pointer; }

.now-playing { padding: 16px; display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 14px; row-gap: 3px; align-items: center; }
.now-playing::before { content: ""; width: 42px; height: 42px; grid-row: 1 / span 3; border-radius: 13px; background: radial-gradient(circle at 35% 35%, #b8a9ff, var(--accent-strong) 65%, #382768); box-shadow: 0 8px 20px rgba(116, 87, 232, 0.25); }
.now-playing-title { color: var(--muted); font-size: 0.69rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.now-playing-station { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.2rem; font-weight: 820; letter-spacing: -0.025em; }
.now-playing-song { color: var(--muted); font-size: 0.82rem; }

.debug-panel { padding: 12px; }
.small-button { min-height: 42px; padding: 0 13px; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--muted); background: transparent; cursor: pointer; }
.debug-info { max-height: 230px; overflow: auto; margin-top: 10px; padding: 10px; border-radius: var(--radius-sm); background: #03060c; color: #b8c4db; font-size: 0.72rem; }
.debug-info pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
audio { display: none; }
.footer-nav { grid-column: 1; text-align: center; }

.station-panel { grid-column: 2; grid-row: 1 / span 3; position: sticky; top: 18px; max-height: calc(100vh - 36px); overflow: hidden; display: flex; flex-direction: column; padding: 22px; }
.station-panel h2 { margin: 0; font-size: 1.4rem; letter-spacing: -0.03em; }
.station-panel .lede { margin: 6px 0 16px; color: var(--muted); font-size: 0.86rem; }
.station-panel ul { list-style: none; overflow-y: auto; margin: 0; padding: 0 5px 0 0; scrollbar-width: thin; }
.station-panel li { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 9px; padding: 10px 6px; border-top: 1px solid rgba(255, 255, 255, 0.065); }
.station-panel li:first-child { border-top: 0; }
.station-mark { grid-row: 1 / span 2; color: var(--accent); font-size: 0.7rem; padding-top: 4px; }
.station-panel li > span:nth-child(2) { min-width: 0; overflow-wrap: anywhere; font-weight: 720; font-size: 0.86rem; }
.station-panel small { grid-column: 2; color: var(--muted); font-size: 0.7rem; }

.floating-controls { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 10; transform: translate(-50%, 18px); display: flex; align-items: center; gap: 7px; max-width: calc(100vw - 28px); padding: 8px; border: 1px solid var(--line); border-radius: 999px; background: rgba(15, 21, 35, 0.9); box-shadow: var(--shadow); backdrop-filter: blur(20px); opacity: 0; visibility: hidden; transition: 160ms ease; }
.floating-controls.visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.float-button { border-radius: 50%; }
.float-info { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 8px; font-size: 0.8rem; font-weight: 750; }

@media (hover: none) and (pointer: coarse) { .floating-controls { display: none !important; } }
@media (max-width: 900px) {
  .container { grid-template-columns: minmax(0, 1fr); }
  .station-panel { grid-column: 1; grid-row: auto; position: static; max-height: none; }
  .station-panel ul { max-height: 440px; }
  .footer-nav { grid-column: 1; }
}
@media (max-width: 650px) {
  .radio-page { padding-left: 10px; padding-right: 10px; }
  .player-container { padding: 16px; border-radius: 20px; gap: 14px; }
  .player-heading { align-items: start; }
  .player-status { grid-template-columns: auto minmax(0, 1fr); }
  .status-actions { grid-column: 1 / -1; margin-left: 23px; justify-content: space-between; }
  .realtime-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { min-height: 96px; }
  .selector-row { grid-template-columns: 1fr auto; }
  .selector-row label { grid-column: 1 / -1; }
  .player-controls { grid-template-columns: 1fr; }
  .navigation-controls { order: 2; }
  .control-button { order: 1; min-height: 64px; }
  .volume-control { order: 3; }
  .station-panel { padding: 17px; border-radius: 20px; }
}
@media (max-width: 390px) {
  .section-heading { align-items: flex-start; flex-direction: column; }
  .readiness-badge { align-self: stretch; text-align: center; }
  .realtime-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric { padding: 10px; }
  .apk-download { padding: 0 11px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
