:root {
  --bg: #07020f;
  --bg2: #0d0620;
  --pink: #ff2a6d;
  --cyan: #05d9e8;
  --yellow: #f9f002;
  --text: #e6e1ff;
  --muted: #8a80b3;
  --line: rgba(5, 217, 232, 0.25);
  --c: var(--pink);
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(255, 42, 109, 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(5, 217, 232, 0.14), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow-x: hidden;
}

.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(176, 38, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(176, 38, 255, 0.07) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(to bottom, transparent, #000 30%, #000 70%, transparent);
}

.scanlines {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,0.025) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

/* ---------- header ---------- */
.top {
  position: relative; z-index: 1;
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px;
  padding: 24px clamp(14px, 4vw, 40px) 12px;
  border-bottom: 1px solid var(--line);
}

.glitch {
  position: relative; margin: 0;
  font-family: var(--mono);
  font-size: clamp(34px, 8vw, 64px);
  font-weight: 900; letter-spacing: 0.08em; line-height: 1;
  color: #fff;
  text-shadow: 0 0 6px var(--pink), 0 0 22px rgba(255, 42, 109, 0.6);
}
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute; inset: 0;
  overflow: hidden;
}
.glitch::before { color: var(--cyan); text-shadow: none; animation: glitchA 3.2s infinite steps(1); }
.glitch::after { color: var(--yellow); text-shadow: none; animation: glitchB 2.7s infinite steps(1); opacity: .8; }

@keyframes glitchA {
  0%, 88%, 100% { clip-path: inset(100% 0 0 0); transform: none; }
  89% { clip-path: inset(10% 0 60% 0); transform: translate(-4px, 0); }
  92% { clip-path: inset(55% 0 20% 0); transform: translate(4px, 0); }
  95% { clip-path: inset(30% 0 45% 0); transform: translate(-2px, 0); }
}
@keyframes glitchB {
  0%, 90%, 100% { clip-path: inset(100% 0 0 0); transform: none; }
  91% { clip-path: inset(70% 0 5% 0); transform: translate(3px, 0); }
  94% { clip-path: inset(5% 0 75% 0); transform: translate(-3px, 0); }
}

.slogan {
  margin: 8px 0 0; font-family: var(--mono);
  color: var(--cyan); letter-spacing: .12em; text-transform: uppercase; font-size: clamp(12px, 2.6vw, 15px);
}
.caret { animation: blink 1s infinite steps(1); color: var(--pink); }
@keyframes blink { 50% { opacity: 0; } }

.status { display: flex; align-items: center; gap: 14px; font-family: var(--mono); }
.onair {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border: 1px solid var(--muted); color: var(--muted);
  font-size: 13px; letter-spacing: .15em;
}
.onair i { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.onair.live { border-color: var(--pink); color: #fff; box-shadow: 0 0 14px rgba(255,42,109,.45); }
.onair.live i { background: var(--pink); box-shadow: 0 0 10px var(--pink); animation: blink 1.1s infinite; }
.clock { color: var(--yellow); font-size: 15px; letter-spacing: .1em; }

/* ---------- layout ---------- */
.layout {
  position: relative; z-index: 1;
  display: grid; gap: 22px;
  padding: 22px clamp(14px, 4vw, 40px);
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
  .player { position: sticky; top: 16px; }
}

.panel {
  --cut: 18px;
  position: relative;
  background: linear-gradient(160deg, rgba(25, 10, 50, 0.92), rgba(8, 3, 20, 0.95));
  border: 1px solid var(--line);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
  padding: clamp(14px, 3vw, 24px);
}

/* ---------- player ---------- */
.player { --c: var(--pink); }

.display {
  position: relative;
  border: 1px solid color-mix(in srgb, var(--c) 50%, transparent);
  background: rgba(0, 0, 0, 0.45);
  padding: 14px;
  box-shadow: inset 0 0 40px color-mix(in srgb, var(--c) 15%, transparent);
}

.disp-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; font-family: var(--mono); }
.freq {
  font-size: clamp(30px, 7vw, 44px); font-weight: 800; color: var(--c);
  text-shadow: 0 0 12px var(--c); letter-spacing: .04em;
}
.unit { color: var(--muted); font-size: 13px; }
.genre {
  margin-left: auto; font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--bg); background: var(--c); padding: 3px 8px;
}

.st-name {
  margin: 6px 0 10px; font-family: var(--mono); font-size: clamp(20px, 4.5vw, 28px);
  letter-spacing: .14em; color: #fff;
}

.now .label { display: block; font-family: var(--mono); font-size: 11px; color: var(--cyan); letter-spacing: .2em; }
.track { margin-top: 4px; font-size: clamp(15px, 3.4vw, 18px); min-height: 1.4em; overflow-wrap: anywhere; }
.track .artist { color: var(--yellow); font-weight: 700; }
.track .title { color: var(--text); }
.now.flash .track { animation: flash .6s ease; }
@keyframes flash {
  0% { opacity: 0; transform: translateX(-8px); filter: blur(2px); }
  40% { opacity: 1; color: var(--cyan); }
  100% { transform: none; filter: none; }
}

#viz {
  display: block; width: 100%; height: clamp(120px, 24vw, 190px);
  margin: 12px 0 10px;
  border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line);
}

.progress { display: flex; align-items: center; gap: 10px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.progress .bar { flex: 1; height: 4px; background: rgba(255,255,255,.08); position: relative; }
#pBar { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--c); box-shadow: 0 0 10px var(--c); }
.meta { margin-top: 8px; font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .1em; overflow-wrap: anywhere; }

/* tuner */
.tuner {
  position: relative; height: 46px; margin: 16px 0 8px;
  border: 1px solid var(--line); background: rgba(0,0,0,.35); overflow: hidden;
}
.scale { position: absolute; inset: 0; }
.tick { position: absolute; bottom: 0; width: 1px; height: 8px; background: rgba(230,225,255,.25); }
.tick.big { height: 14px; background: rgba(230,225,255,.5); }
.mark {
  position: absolute; top: 4px; transform: translateX(-50%);
  font-family: var(--mono); font-size: 10px; color: var(--muted); white-space: nowrap;
}
.mark.on { color: var(--c); text-shadow: 0 0 8px var(--c); }
.needle {
  position: absolute; top: 0; bottom: 0; width: 2px; left: 50%;
  background: var(--c); box-shadow: 0 0 10px var(--c), 0 0 20px var(--c);
  transition: left .6s cubic-bezier(.6, -0.2, .3, 1.3);
}

/* controls */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }

.btn {
  --bc: var(--cyan);
  font-family: var(--mono); font-size: 14px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--bc); background: transparent;
  border: 1px solid var(--bc); padding: 10px 14px; cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  transition: background .15s, color .15s, box-shadow .15s;
}
.btn:hover, .btn:focus-visible { background: var(--bc); color: var(--bg); outline: none; box-shadow: 0 0 18px var(--bc); }
.btn:active { transform: translateY(1px); }
.btn.icon { width: 48px; height: 48px; padding: 0; display: grid; place-items: center; }
.btn.icon svg { width: 20px; height: 20px; fill: currentColor; }
.btn.play { --bc: var(--c); width: 64px; height: 64px; }
.btn.play svg { width: 28px; height: 28px; }
.btn.wide { margin-left: auto; --bc: var(--yellow); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.small.on { --bc: var(--pink); background: var(--pink); color: var(--bg); }

.volume { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: .1em; }
.volume label { text-transform: uppercase; }
.vol-val { width: 3ch; text-align: right; color: var(--text); }

input[type=range] { flex: 1; min-width: 80px; -webkit-appearance: none; appearance: none; height: 22px; background: transparent; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; background: linear-gradient(90deg, var(--cyan), var(--pink)); }
input[type=range]::-moz-range-track { height: 4px; background: linear-gradient(90deg, var(--cyan), var(--pink)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 18px; margin-top: -7px; background: #fff; box-shadow: 0 0 10px var(--cyan); border: none; }
input[type=range]::-moz-range-thumb { width: 14px; height: 18px; background: #fff; box-shadow: 0 0 10px var(--cyan); border: none; border-radius: 0; }

.hint { margin: 12px 0 0; font-family: var(--mono); font-size: 11px; color: var(--muted); }

/* ---------- stations ---------- */
.sec-title {
  margin: 0 0 14px; font-family: var(--mono); letter-spacing: .2em; color: var(--cyan); font-size: 15px;
  display: flex; justify-content: space-between; align-items: baseline;
}
.sec-title span { color: var(--muted); font-size: 11px; letter-spacing: .1em; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }

.card {
  --cut: 14px;
  position: relative; text-align: left; cursor: pointer;
  color: var(--text); font: inherit;
  padding: 16px 16px 14px;
  background: linear-gradient(150deg, color-mix(in srgb, var(--c) 12%, #0b0418), #07020f 70%);
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
  transition: transform .15s, box-shadow .2s, border-color .2s;
  display: flex; flex-direction: column; gap: 8px;
}
.card:hover, .card:focus-visible { transform: translateY(-2px); border-color: var(--c); box-shadow: 0 0 22px color-mix(in srgb, var(--c) 35%, transparent); outline: none; }
.card .row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.card .cf { font-family: var(--mono); font-size: 24px; font-weight: 800; color: var(--c); text-shadow: 0 0 10px color-mix(in srgb, var(--c) 70%, transparent); }
.card .cbpm { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.card .cn { font-family: var(--mono); font-size: 17px; font-weight: 700; letter-spacing: .12em; }
.card .cg { font-size: 12px; color: var(--c); text-transform: uppercase; letter-spacing: .1em; }
.card .cd { font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.card .cstate { font-family: var(--mono); font-size: 11px; letter-spacing: .15em; color: var(--muted); display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.card .eq { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; }
.card .eq i { width: 3px; height: 3px; background: var(--c); }
.card.active { border-color: var(--c); box-shadow: 0 0 26px color-mix(in srgb, var(--c) 40%, transparent), inset 0 0 30px color-mix(in srgb, var(--c) 12%, transparent); }
.card.active .cstate { color: var(--c); }
.card.active.playing .eq i { animation: eq .8s infinite ease-in-out; }
.card.active.playing .eq i:nth-child(2) { animation-delay: -.3s; }
.card.active.playing .eq i:nth-child(3) { animation-delay: -.55s; }
.card.active.playing .eq i:nth-child(4) { animation-delay: -.15s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 12px; } }

/* ---------- side column / tabs ---------- */
.side { display: grid; gap: 22px; min-width: 0; }

.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.tab {
  font-family: var(--mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); background: rgba(0,0,0,.35); border: 1px solid var(--line);
  padding: 8px 12px; cursor: pointer; transition: color .15s, border-color .15s, box-shadow .15s;
}
.tab b { color: var(--yellow); font-weight: 700; margin-left: 4px; }
.tab:hover, .tab:focus-visible { color: var(--text); border-color: var(--cyan); outline: none; }
.tab.on { color: var(--bg); background: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 14px rgba(5,217,232,.45); }
.tab.on b { color: var(--bg); }

.card-wrap { position: relative; display: flex; }
.card-wrap .card { flex: 1; }
.badge {
  display: inline-block; margin-right: 8px; padding: 1px 6px;
  border: 1px solid var(--c); color: var(--c); font-size: 10px; letter-spacing: .15em;
}
.del {
  position: absolute; right: 8px; bottom: 8px; width: 30px; height: 30px;
  display: grid; place-items: center; cursor: pointer;
  font-size: 14px; color: var(--muted); background: rgba(0,0,0,.6);
  border: 1px solid rgba(255,42,109,.4);
  transition: color .15s, background .15s, box-shadow .15s;
}
.del:hover, .del:focus-visible { color: var(--bg); background: var(--pink); box-shadow: 0 0 12px var(--pink); outline: none; }

.empty {
  margin: 0; padding: 18px; border: 1px dashed var(--line);
  font-family: var(--mono); font-size: 13px; color: var(--muted); text-align: center;
}

/* ---------- ticker ---------- */
.ticker {
  display: flex; align-items: stretch; margin-top: 12px; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
  font-family: var(--mono); font-size: 12px;
}
.tk-label { flex: none; padding: 4px 8px; background: var(--c); color: var(--bg); letter-spacing: .15em; font-weight: 700; }
.tk-wrap { flex: 1; overflow: hidden; white-space: nowrap; position: relative; padding: 4px 0; }
.tk-text { display: inline-block; padding-left: 100%; color: var(--text); animation: marquee 30s linear infinite; }
@keyframes marquee { to { transform: translateX(-100%); } }

/* ---------- tuner clickable ---------- */
.tuner { cursor: crosshair; }
.tuner:hover { border-color: var(--cyan); }
.mark { pointer-events: none; }
@media (max-width: 600px) {
  .mark { font-size: 0; width: 5px; height: 5px; border-radius: 50%; background: var(--c); top: 8px; opacity: .7; }
  .mark.on { font-size: 10px; width: auto; height: auto; background: none; border-radius: 0; top: 4px; opacity: 1; }
}

/* ---------- builder ---------- */
.builder { --cut: 18px; }
.b-intro { margin: -4px 0 14px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.fields { display: grid; gap: 12px 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.f {
  display: flex; flex-direction: column; gap: 6px;
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; color: var(--cyan); text-transform: uppercase;
}
.f output { color: var(--yellow); }
.f.full { grid-column: 1 / -1; }
.f input:not([type=range]):not([type=checkbox]):not([type=color]), .f select {
  width: 100%; min-height: 40px; padding: 8px 10px;
  font: 15px var(--sans); color: var(--text); text-transform: none; letter-spacing: 0;
  background: rgba(0,0,0,.5); border: 1px solid var(--line); border-radius: 0;
  transition: border-color .15s, box-shadow .15s;
}
.f select option { background: var(--bg2); color: var(--text); }
.f input:focus, .f select:focus { outline: none; border-color: var(--pink); box-shadow: 0 0 0 1px var(--pink), 0 0 14px rgba(255,42,109,.35); }
.f input::placeholder { color: rgba(138,128,179,.7); }
.f.color input { width: 100%; height: 40px; padding: 2px; background: rgba(0,0,0,.5); border: 1px solid var(--line); cursor: pointer; }
.f.check { flex-direction: row; align-items: center; gap: 10px; align-self: end; min-height: 40px; color: var(--text); cursor: pointer; }
.f.check input { width: 18px; height: 18px; accent-color: var(--pink); cursor: pointer; }

.msg { min-height: 1.4em; margin: 14px 0 0; font-family: var(--mono); font-size: 13px; color: var(--cyan); }
.msg.err { color: var(--pink); }
.b-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.btn.accent { --bc: var(--pink); }
.btn.file { position: relative; display: inline-flex; align-items: center; --bc: var(--yellow); }
.btn.file input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.btn.file:focus-within { background: var(--bc); color: var(--bg); }
@media (max-width: 480px) { .b-actions .btn { flex: 1 1 100%; text-align: center; justify-content: center; } }

/* ---------- internet radio ---------- */
.net { border-color: rgba(249, 240, 2, 0.25); }
.cat-title { margin: 22px 0 10px; font-family: var(--mono); font-size: 13px; letter-spacing: .18em; color: var(--yellow); font-weight: 700; }
.catalog { display: grid; gap: 8px; }
.cat-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; background: rgba(0,0,0,.4);
  border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
  border-left: 3px solid var(--c);
}
.ci-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ci-text b { font-family: var(--mono); font-size: 14px; letter-spacing: .06em; color: #fff; }
.ci-text span { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.cat-item .btn { flex: none; --bc: var(--c); }
.cat-item .btn.on-air { background: var(--c); color: var(--bg); }
@media (max-width: 420px) { .cat-item { flex-direction: column; align-items: stretch; } }

#pBar.live { background: repeating-linear-gradient(90deg, var(--c) 0 12px, transparent 12px 20px); background-size: 40px 100%; animation: liveflow 1s linear infinite; }
@keyframes liveflow { to { background-position: 40px 0; } }

.card.is-stream .cbpm { max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card.failed .cstate { color: var(--pink); }
.card.failed .eq i { background: var(--pink); }
.mark.live::after { content: '●'; margin-left: 2px; font-size: 8px; vertical-align: top; }

/* ---------- footer ---------- */
.foot {
  position: relative; z-index: 1;
  padding: 18px clamp(14px, 4vw, 40px) 30px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 13px; line-height: 1.5;
}
.foot p { margin: 0 0 6px; max-width: 900px; }
.foot .copy { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--pink); }

@media (max-width: 480px) {
  .btn.wide { margin-left: 0; flex: 1 1 100%; }
  .controls { justify-content: center; }
  .genre { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .glitch::before, .glitch::after, .caret { animation: none; }
}
