:root {
  --bg: #f4f6fb;
  --surface: #fff;
  --text: #141a2a;
  --muted: #5d6680;
  --line: #e2e6f0;
  --accent: #0b5cd5;
  --accent-ink: #fff;
  --accent-soft: #e6eefc;
  --ok: #138a4e;
  --warn: #b4441f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 26, 42, .06), 0 4px 14px rgba(20, 26, 42, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f131c;
    --surface: #171c28;
    --text: #e8ecf5;
    --muted: #9aa3ba;
    --line: #262d3d;
    --accent: #5b9bff;
    --accent-ink: #0b1220;
    --accent-soft: #1b2741;
    --ok: #4cc38a;
    --warn: #ff8a65;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.3rem); letter-spacing: -.01em; }
h2 { font-size: 1.3rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 24px; padding-bottom: 48px; min-height: 60vh; }
body.has-player .main { padding-bottom: 120px; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.top-in { display: flex; align-items: center; gap: 20px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 1.15rem; font-weight: 600; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand svg { width: 32px; height: 32px; flex: none; }
.brand b { color: var(--accent); }
.nav { display: flex; gap: 4px; }
.nav a { color: var(--text); padding: 8px 12px; border-radius: 10px; font-weight: 500; }
.nav a:hover { background: var(--accent-soft); text-decoration: none; }
.search { margin-left: auto; display: flex; flex: 0 1 300px; position: relative; }
.search input {
  width: 100%; height: 40px; padding: 0 40px 0 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); color: var(--text); font: inherit; font-size: .95rem;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search button {
  position: absolute; right: 4px; top: 4px; width: 32px; height: 32px;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer;
}
.search svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* ---------- common blocks ---------- */
.hero { text-align: center; padding: 32px 0 16px; }
.hero h1 { max-width: 760px; margin: 0 auto .4em; }
.lead { color: var(--muted); font-size: 1.08rem; max-width: 720px; }
.hero .lead { margin: 0 auto 20px; }
.hero-search { display: flex; gap: 8px; max-width: 560px; margin: 0 auto 8px; }
.hero-search input {
  flex: 1; min-width: 0; height: 48px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 22px; border: 0; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.block { margin-top: 40px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.block-head h2 { margin: 0; }
.more { font-weight: 500; white-space: nowrap; }
.page-head { margin-bottom: 20px; }
.page-head .lead { margin: 0; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: .875rem; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }

/* ---------- station grid ---------- */
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px;
}
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.card-link { display: block; padding: 10px 10px 12px; color: var(--text); }
.card-link:hover { text-decoration: none; }
.card-logo {
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 2 / 1; border-radius: 10px; background: #fff; overflow: hidden; margin-bottom: 10px;
}
.card-logo .logo { width: 100%; height: 100%; object-fit: contain; }
.card-name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-weight: 600; font-size: .95rem; line-height: 1.3; min-height: 2.6em; padding-right: 34px;
}
.logo-ph {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; color: #fff; font-weight: 700; font-size: 1.6rem; letter-spacing: .02em;
  background: linear-gradient(135deg, hsl(var(--h) 62% 48%), hsl(calc(var(--h) + 40) 62% 38%));
}
.play {
  position: absolute; right: 10px; bottom: 12px;
  width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}
.play svg, .btn-play svg, .player-btn svg { width: 18px; height: 18px; fill: currentColor; }
.i-pause, .is-playing .i-play, .lbl-pause, .is-playing .lbl-play { display: none; }
.is-playing .i-pause { display: inline; }
.is-playing .lbl-pause { display: inline; }
.is-loading { animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: .55; } }

/* ---------- chips & directory ---------- */
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips a {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; color: var(--text); font-size: .95rem;
}
.chips a:hover { border-color: var(--accent); text-decoration: none; }
.chips small, .dir small { color: var(--muted); font-size: .8rem; }
.letters { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 20px; }
.letters a { min-width: 34px; padding: 6px 8px; text-align: center; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; }
.dir { columns: 4 220px; column-gap: 24px; }
.dir-group { break-inside: avoid; margin-bottom: 20px; }
.dir-group h2 { color: var(--accent); font-size: 1.1rem; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.dir-group ul { list-style: none; margin: 0; padding: 0; }
.dir-group li { padding: 3px 0; }
.dir-group a { color: var(--text); }

/* ---------- pager ---------- */
.pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 28px; }
.pager a, .pager span { min-width: 40px; height: 40px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; }
.pager a { background: var(--surface); border: 1px solid var(--line); color: var(--text); }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager .cur { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.pager .gap { color: var(--muted); }

/* ---------- station page ---------- */
.station { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 24px; box-shadow: var(--shadow); }
.station-top { display: grid; grid-template-columns: 280px 1fr; gap: 28px; align-items: center; }
.station-logo { aspect-ratio: 2 / 1; border-radius: 14px; overflow: hidden; background: #fff; border: 1px solid var(--line); display: flex; }
.station-logo .logo { width: 100%; height: 100%; object-fit: contain; }
.station-logo .logo-ph { font-size: 2.6rem; }
.station-info h1 { margin-bottom: 12px; }
.tags { list-style: none; margin: 0 0 18px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .875rem; font-weight: 500; }
.tag-country { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.btn-play { min-width: 170px; }
.offline { margin: 0; padding: 12px 16px; border-radius: 12px; background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); font-weight: 500; }
.station-text { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.prose { max-width: 820px; }
.prose p, .prose li { color: var(--text); }
.page { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 28px; }

/* ---------- forms ---------- */
.form { display: grid; gap: 14px; max-width: 560px; }
.form label { display: grid; gap: 6px; font-weight: 500; font-size: .95rem; }
.form input, .form textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--text); font: inherit;
}
.form .hp { position: absolute; left: -9999px; }
.notice { padding: 12px 16px; border-radius: 12px; }
.notice p { margin: 0; }
.notice.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.notice.err { background: color-mix(in srgb, var(--warn) 12%, transparent); color: var(--warn); }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line); background: var(--surface); padding: 28px 0 18px; }
.foot-in { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.foot-in > div { max-width: 420px; }
.brand-sm { font-weight: 700; margin: 0 0 4px; }
.foot-nav { display: flex; flex-wrap: wrap; gap: 8px 20px; align-content: flex-start; }
.foot-nav a { color: var(--text); }
.copy { margin-top: 18px; }

/* ---------- bottom player ---------- */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--surface); border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(20, 26, 42, .1);
}
.player-in { display: flex; align-items: center; gap: 14px; height: 76px; }
.player-station { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; color: var(--text); }
.player-station:hover { text-decoration: none; }
.player-logo { width: 88px; height: 44px; flex: none; border-radius: 8px; overflow: hidden; background: #fff; display: flex; border: 1px solid var(--line); }
.player-logo img, .player-logo .logo-ph { width: 100%; height: 100%; object-fit: contain; font-size: 1rem; }
.player-text { display: grid; min-width: 0; }
.player-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-status { font-size: .85rem; color: var(--muted); }
.player-status.live { color: var(--ok); }
.player-status.live::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: currentColor; animation: pulse 1s infinite alternate; }
.player-btn { width: 48px; height: 48px; flex: none; border: 0; border-radius: 50%; background: var(--accent); color: var(--accent-ink); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.player-btn svg { width: 22px; height: 22px; }
.player-vol { width: 110px; accent-color: var(--accent); }
.player-close { width: 36px; height: 36px; flex: none; border: 0; background: transparent; color: var(--muted); font-size: 1.6rem; cursor: pointer; border-radius: 50%; }
.player-close:hover { background: var(--bg); }
.player-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

/* ---------- popup listen page ---------- */
.listen-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.listen { text-align: center; max-width: 380px; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 24px; }
.listen-logo { display: flex; width: 100%; aspect-ratio: 2 / 1; object-fit: contain; border-radius: 12px; background: #fff; margin-bottom: 14px; }
.listen h1 { font-size: 1.3rem; }
.listen audio { width: 100%; margin: 8px 0; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .top-in { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 6px; row-gap: 6px; }
  .nav { order: 3; width: 100%; margin: 0 -12px; }
  .station-top { grid-template-columns: 1fr; }
  .station-logo { max-width: 320px; }
}
@media (max-width: 560px) {
  .top-in { gap: 12px; }
  .brand span { display: none; }
  .search { flex: 1; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card-name { font-size: .88rem; }
  .hero-search { flex-direction: column; }
  .hero-search input { flex: none; }
  .station, .page { padding: 18px; }
  .player-vol { display: none; }
  .player-logo { width: 64px; height: 32px; }
  .btn-play { width: 100%; }
}
