:root {
  color-scheme: dark;
  --bg: #101514;
  --surface: #19211f;
  --text: #eef2e9;
  --muted: #a3b2a8;
  --accent: #c7f69e;
  --border: #303e36;
  --pad-x: clamp(16px, 4vw, 40px);
  --touch: 44px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  scroll-padding-top: 24px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
main {
  max-width: 1100px;
  margin: auto;
  padding: max(28px, env(safe-area-inset-top)) var(--pad-x) calc(24px + env(safe-area-inset-bottom));
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 52px;
}
.brand {
  color: var(--text);
  font-size: clamp(30px, 8vw, 38px);
  font-weight: 800;
  letter-spacing: -2px;
  text-decoration: none;
  line-height: 1;
  min-width: 0;
}
.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  align-items: start;
}
.player {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 30px 36px;
}
.station-heading { min-height: 0; }
.station-identity { display: flex; gap: 16px; align-items: flex-start; }
.station-logo {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  object-fit: cover;
  background: #121a16;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.station-copy { min-width: 0; flex: 1; }
.now-playing {
  margin: 12px 0 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.station-list-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: #121a16;
  border: 1px solid var(--border);
}
.browser-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: #121a16;
  border: 1px solid var(--border);
}
.browser-logo.is-empty {
  background: linear-gradient(145deg, #1c2923, #121a16);
}
h1 {
  font-size: clamp(36px, 5.6vw, 66px);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.05;
  margin: 0;
  overflow-wrap: anywhere;
  hyphens: auto;
}
.play-area {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(20px, 6vw, 32px);
  margin-top: 18px;
}
button, select, input { font: inherit; }
button { cursor: pointer; }
button:disabled, select:disabled { opacity: .6; cursor: default; }
button:focus-visible, select:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
.play {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #142111;
  flex-shrink: 0;
}
.play:hover { background: #dbffba; }
.skip {
  width: var(--touch);
  height: var(--touch);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 20px;
  flex-shrink: 0;
}
#status {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  min-height: 42px;
  margin: 18px 0;
  padding: 0 4px;
}
.quality {
  border-top: 1px solid var(--border);
  padding-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.quality label { font-size: 14px; color: var(--muted); }
select, dialog input {
  border: 1px solid #415045;
  border-radius: 10px;
  padding: 12px;
  background: #121a16;
  color: var(--text);
  width: 100%;
  font-size: 16px;
}
.small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  margin-bottom: 0;
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0 18px;
}
h2 {
  font-size: clamp(20px, 5vw, 23px);
  letter-spacing: -.6px;
  font-weight: 550;
  margin: 0;
}
.section-heading > span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1px;
  white-space: nowrap;
}
.station {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  padding: 16px 14px;
  margin-bottom: 10px;
  min-height: var(--touch);
}
.station.active { border-color: var(--accent); background: #202c21; }
.station:hover { background: #202c21; }
.station-number {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
  min-width: 1.6em;
}
.station-label { min-width: 0; overflow-wrap: anywhere; flex: 1; }
.station strong {
  display: block;
  font-size: 16px;
  font-weight: 550;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.station small {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.35;
}
.station-mark {
  margin-left: auto;
  color: var(--muted);
  font-size: 18px;
  flex-shrink: 0;
}
.station.active .station-mark { color: var(--accent); }
summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  padding: 10px 0;
  min-height: var(--touch);
  display: flex;
  align-items: center;
}
a { color: var(--accent); }
footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.secondary, .primary {
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  min-height: var(--touch);
  color: var(--text);
  background: var(--surface);
}
.secondary:hover { background: #293526; }
.primary {
  background: var(--accent);
  color: #142111;
  border-color: var(--accent);
  font-weight: 600;
}
.wide { width: 100%; }
.manage { margin-top: 14px; }
.custom-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.custom-row > span {
  flex: 1;
  min-width: 100px;
  overflow-wrap: anywhere;
  font-size: 14px;
}
.text-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  min-height: var(--touch);
  padding: 8px;
  font-size: 14px;
}
.danger { color: #ffb6a7; }
.storage-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.notice {
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 18px;
}
.notice p { margin: 0; font-size: 14px; flex: 1; }
.connection {
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 20px;
}
dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px;
  max-width: 500px;
  width: calc(100% - 32px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  margin: auto;
}
dialog::backdrop { background: #000a; }
dialog p { font-size: 16px; line-height: 1.6; }
.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.dialog-heading h2 { font-size: clamp(18px, 5vw, 22px); }
.close {
  color: var(--muted);
  border: 0;
  background: transparent;
  font-size: 28px;
  min-width: var(--touch);
  min-height: var(--touch);
  flex-shrink: 0;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 22px;
  flex-wrap: wrap;
}
dialog label { display: block; font-size: 14px; margin: 14px 0 8px; }
.form-status { color: #ffb6a7; min-height: 20px; font-size: 14px !important; }
.muted { color: var(--muted); }
.browser-dialog { max-width: 640px; }
.browser-filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 8px;
}
.browser-filter { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.browser-filter span { font-size: 12px; }
.browser-filter input {
  border: 1px solid #415045;
  border-radius: 10px;
  padding: 12px;
  background: #121a16;
  color: var(--text);
  width: 100%;
  font-size: 16px;
}
.browser-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 8px;
  max-height: min(52vh, 420px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.browser-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  min-height: 52px;
}
.browser-meta { min-width: 0; flex: 1; }
.browser-meta strong {
  display: block;
  font-size: 14px;
  font-weight: 550;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.browser-meta small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.browser-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.browser-fav {
  border: 0;
  background: transparent;
  color: var(--accent);
  width: 40px;
  min-height: 40px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  display: grid;
  place-items: center;
}
.browser-play {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 13px;
}
.install-short { display: none; }

@media (prefers-reduced-motion: no-preference) {
  button { transition: background-color .15s ease; }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; gap: 28px; }
}

@media (max-width: 760px) {
  main { padding-top: max(18px, env(safe-area-inset-top)); }
  header { margin-bottom: 20px; }
  .player {
    padding: 20px 18px 18px;
    border-radius: 22px;
  }
  .station-heading { margin-bottom: 4px; }
  .station-identity { gap: 12px; }
  .station-logo { width: 52px; height: 52px; border-radius: 12px; }
  .now-playing { font-size: 14px; margin-top: 8px; }
  h1 {
    font-size: clamp(30px, 9vw, 44px);
    letter-spacing: -0.035em;
  }
  .play-area { margin-top: 12px; gap: 22px; }
  .play { width: 74px; height: 74px; }
  #status { min-height: 36px; margin: 12px 0 10px; font-size: 13px; }
  .quality { padding-top: 16px; gap: 8px; }
  .section-heading { margin: 4px 0 14px; align-items: flex-start; flex-wrap: wrap; }
  .station { padding: 14px 12px; gap: 12px; margin-bottom: 8px; }
  .station strong { font-size: 15px; }
  footer { flex-direction: column; gap: 8px; margin-top: 24px; }
  .notice { flex-direction: column; align-items: stretch; gap: 12px; }
  dialog { padding: 20px 16px; width: calc(100% - 20px); border-radius: 18px; }
  .install-full { display: none; }
  .install-short { display: inline; }
  #install { padding: 10px 12px; font-size: 13px; white-space: nowrap; }
}

@media (max-width: 640px) {
  .browser-dialog {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
    padding:
      max(12px, env(safe-area-inset-top))
      max(16px, env(safe-area-inset-right))
      max(16px, env(safe-area-inset-bottom))
      max(16px, env(safe-area-inset-left));
  }
  .browser-dialog[open] {
    display: flex;
    flex-direction: column;
  }
  .browser-dialog .dialog-heading { margin-bottom: 12px; flex-shrink: 0; }
  .browser-dialog > label,
  .browser-dialog > input,
  .browser-filters,
  .browser-dialog > .small {
    flex-shrink: 0;
  }
  .browser-filters { grid-template-columns: 1fr; }
  .browser-list {
    flex: 1;
    max-height: none;
    min-height: 0;
    margin-top: 4px;
  }
  .browser-row {
    gap: 8px;
    padding: 7px 0;
  }
  .browser-play {
    min-height: 34px;
    padding: 6px 10px;
  }
}

@media (max-width: 380px) {
  :root { --pad-x: 12px; }
  .player { padding: 16px 14px; }
  .play { width: 68px; height: 68px; }
  .skip { width: 42px; height: 42px; }
  h1 { font-size: clamp(28px, 8.5vw, 36px); }
}

@media (display-mode: standalone) {
  main { padding-top: max(18px, env(safe-area-inset-top)); }
}
