:root {
  --paper: #fdfcfe;
  --ink: #0f0d13;
  --violet: #a238ff;
  --violet-ink: #7a16d6;
  --lilac: #d09aff;
  --line: #d1d1d7;
  --mist: #efedf1;
  --muted: #555257;
  --display: Impact, 'Haettenschweiler', 'Arial Narrow Bold', 'Arial Narrow', sans-serif;
  --ui: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--ui); }
button, input { font: inherit; color: inherit; }
button, a { touch-action: manipulation; }
a { color: inherit; }
button {
  min-height: 48px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper);
  padding: 10px 18px; cursor: pointer; transition: border-color .15s, background .15s;
}
button:hover { border-color: var(--ink); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
button.primary:hover { background: #2a2630; }
button.ghost { background: transparent; color: var(--paper); border-color: #46424c; }
button.ghost:hover { border-color: var(--paper); }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -60px; background: var(--paper); padding: 10px 14px; border-radius: 8px; z-index: 10; }
.skip-link:focus { top: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { font-size: 12px; letter-spacing: .15em; text-transform: uppercase; }

.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 12px max(24px, calc((100vw - 1200px) / 2)); padding-top: max(12px, env(safe-area-inset-top));
  background: var(--ink); color: var(--paper);
}
.brand { display: flex; align-items: center; gap: 10px; font: 24px/1 var(--display); letter-spacing: .04em; text-decoration: none; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--violet); box-shadow: 0 0 0 4px rgba(162, 56, 255, .25); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.live-pill { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: #d9d6de; }
.live-pill.warn { color: var(--lilac); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; }
.live-pill.warn .pulse { background: var(--lilac); }
@media (prefers-reduced-motion: no-preference) {
  .pulse { animation: pulse 2s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: .35; } }
}

.hero { max-width: 1200px; margin: auto; padding: 56px 24px 36px; text-align: center; }
.hero h1 { font: 400 clamp(46px, 8vw, 100px)/.95 var(--display); letter-spacing: .01em; margin: 16px 0 22px; }
.hero p { max-width: 620px; margin: auto; color: var(--muted); }

.shell {
  max-width: 1200px; margin: 0 auto 64px; padding: 0 24px; display: grid;
  grid-template-columns: 280px minmax(320px, 1fr) 280px; gap: 28px; align-items: start;
}
.panel h2 { font-size: 22px; margin: 6px 0 14px; }

/* directory */
.search input { width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.chip { min-height: 36px; padding: 4px 12px; border-radius: 18px; font-size: 13px; text-transform: capitalize; }
.chip[aria-pressed=true] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.station-list { max-height: 720px; overflow-y: auto; padding: 2px 4px 2px 2px; scrollbar-width: thin; }
.station {
  display: grid; grid-template-columns: 48px 1fr; gap: 4px 12px; align-items: center; width: 100%;
  text-align: left; margin: 0 0 8px; padding: 12px; border-radius: 8px;
}
.station .logo { grid-row: span 2; width: 48px; height: 48px; border-radius: 8px; background: var(--mist); display: grid; place-items: center; font-size: 12px; letter-spacing: .08em; color: var(--muted); overflow: hidden; }
.station .logo img { width: 100%; height: 100%; object-fit: cover; }
.station .title { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.station .num { font-weight: 600; font-variant-numeric: tabular-nums; }
.station .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.station .latest { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.station[aria-current=true] { border: 2px solid var(--ink); border-left: 6px solid var(--violet); padding-left: 8px; }
.station .playing-mark { color: var(--violet-ink); font-size: 12px; font-weight: 600; }

/* player */
.player { border: 1px solid var(--line); border-radius: 28px; padding: 24px; text-align: center; width: 100%; max-width: 460px; margin: 0 auto; }
.player-top { display: flex; justify-content: space-between; font-size: 12px; }
.station-name { margin: 14px 0 0; font-weight: 600; min-height: 24px; }
.number { font-size: clamp(76px, 12vw, 104px); line-height: 1.1; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.dial { height: 96px; margin: 6px -8px 0; cursor: grab; touch-action: pan-y; user-select: none; border-radius: 12px; }
.dial:active { cursor: grabbing; }
.dial svg { width: 100%; height: 100%; display: block; }
.dial line { stroke: var(--line); }
.dial line.major { stroke: var(--muted); }
.dial line.on { stroke: var(--ink); stroke-width: 2; }
#ticks { transition: transform 220ms cubic-bezier(.2, .8, .2, 1); }
.dial.dragging #ticks { transition: none; }
.tune-row { display: flex; justify-content: center; gap: 10px; }
.tune-row button { min-width: 72px; }
.tuned-latest { min-height: 24px; font-size: 14px; margin: 12px 0 4px; }

.now { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 20px; }
.media { position: relative; margin: 0 auto 16px; width: 100%; aspect-ratio: 16 / 9; border-radius: 16px; overflow: hidden; background: var(--ink); }
.yt-frame, .yt-frame iframe, #ytPlayer { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.art { position: absolute; inset: 0; display: grid; place-items: center; background: var(--mist); color: var(--muted); font-size: 40px; }
.art img { height: 100%; aspect-ratio: 1; object-fit: cover; }
.badge { background: var(--lilac); color: var(--ink); padding: 4px 10px; border-radius: 12px; display: inline-block; font-size: 12px; }
.track { font-size: 22px; font-weight: 700; margin: 10px 0 0; line-height: 1.25; }
.artist { margin: 4px 0 12px; }
.progress { height: 4px; border-radius: 2px; background: var(--mist); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--ink); }
.times { display: flex; justify-content: space-between; font-size: 12px; font-variant-numeric: tabular-nums; margin-top: 4px; }
.transport { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 16px 0; }
.transport .play { width: 72px; height: 72px; border-radius: 50%; background: var(--ink); color: var(--paper); border-color: var(--ink); padding: 0; }
.links { display: flex; justify-content: center; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 14px; }
.links button[aria-pressed=true] { border-color: var(--violet); color: var(--violet-ink); }
.status { min-height: 24px; font-size: 13px; color: var(--muted); margin: 12px 0 0; }
.status.error { color: #a01f3a; }

/* up next */
.queue { list-style: none; margin: 0; padding: 0; }
.queue li { border-bottom: 1px solid var(--line); }
.queue-item {
  display: grid; grid-template-columns: 44px 1fr 20px; gap: 0 12px; align-items: center; width: 100%;
  min-height: 0; padding: 12px 6px; margin: 0; border: 0; border-radius: 8px; background: transparent; text-align: left;
}
.queue-item:hover { background: var(--mist); }
.queue-item:disabled { opacity: 1; cursor: progress; }
.queue-item b, .queue-item small { min-width: 0; display: block; }
.queue-item .play-now { grid-row: 1 / span 2; grid-column: 3; color: var(--violet-ink); opacity: 0; transition: opacity .15s; }
.queue-item:hover .play-now, .queue-item:focus-visible .play-now { opacity: 1; }
@media (hover: none) { .queue-item .play-now { opacity: .6; } }
.queue .thumb { grid-row: span 2; width: 44px; height: 44px; border-radius: 8px; background: var(--mist); display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.queue .thumb img { width: 100%; height: 100%; object-fit: cover; }
.queue b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.queue small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue .new { color: var(--violet-ink); font-weight: 600; }
@media (prefers-reduced-motion: no-preference) {
  .queue li.fresh { animation: slidein 240ms ease-out; }
  @keyframes slidein { from { opacity: 0; transform: translateY(-6px); } }
}
.empty { padding: 16px; background: var(--mist); border-radius: 8px; margin-top: 12px; }

/* favorites */
.arena { background: var(--ink); color: var(--paper); padding: 48px 24px; }
.arena > div { max-width: 1152px; margin: auto; }
.arena h2 { font: 400 36px/1 var(--display); letter-spacing: .02em; margin: 8px 0 20px; }
.fav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.fav-card { background: var(--paper); color: var(--ink); border-radius: 8px; padding: 18px; text-align: left; border: 0; display: block; width: 100%; }
.fav-card b { display: block; font-size: 30px; font-variant-numeric: tabular-nums; }
.fav-card small { color: var(--muted); display: block; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

dialog { border: 0; border-radius: 20px; padding: 0; max-width: 480px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(15, 13, 19, .55); }
dialog form { padding: 28px; }
dialog h2 { margin-top: 0; }
fieldset { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 16px; padding: 12px 16px; }
fieldset label { display: block; padding: 8px 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

footer { max-width: 1200px; margin: auto; padding: 32px 24px calc(32px + env(safe-area-inset-bottom)); font-size: 13px; color: var(--muted); }

@media (max-width: 1040px) {
  .shell { grid-template-columns: 260px 1fr; }
  .upnext { grid-column: 2; }
}
@media (max-width: 720px) {
  .hero { padding: 28px 20px 20px; }
  .hero h1 { font-size: clamp(36px, 10.5vw, 48px); }
  .hero p { font-size: 15px; }
  .shell { display: flex; flex-direction: column; padding: 0 16px; gap: 24px; }
  .player { order: 1; border-radius: 20px; padding: 20px 16px; max-width: none; }
  .upnext { order: 2; width: 100%; }
  .directory { order: 3; width: 100%; }
  .station-list { max-height: 70vh; }
  .topbar { padding-left: 16px; padding-right: 16px; }
  .live-pill #liveText { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
