:root {
  --bg: #0d0d12;
  --bg-2: #15151d;
  --panel: #1a1a24;
  --line: #2a2a38;
  --text: #f4f4f6;
  --muted: #9a9aab;
  --accent: #8b7cf6;
  --danger: #f43f5e;
  --ok: #34d399;
  --warn: #f59e0b;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.warn { color: var(--warn); }
.small { font-size: 12px; }
.break { word-break: break-all; }

/* ---------- logo ---------- */

.logo { display: inline-flex; align-items: flex-end; gap: 3px; height: 20px; }
.logo i { display: block; width: 5px; border-radius: 3px; }
.logo i:nth-child(1) { height: 60%; background: #8b7cf6; }
.logo i:nth-child(2) { height: 100%; background: #22d3ee; }
.logo i:nth-child(3) { height: 45%; background: #f59e0b; }
.logo.big { height: 40px; gap: 6px; }
.logo.big i { width: 10px; border-radius: 5px; }

/* ---------- topbar ---------- */

.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 16px; }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 15px; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.nav a, .link { color: var(--muted); text-decoration: none; background: none; border: 0; padding: 0; cursor: pointer; }
.nav a:hover, .link:hover { color: var(--text); }
.nav form { margin: 0; }

/* ---------- player ---------- */

.player-page {
  min-height: 100vh;
  display: flex; flex-direction: column;
  background:
    radial-gradient(900px 600px at 20% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    var(--bg);
  transition: background 1.2s ease;
}

.stage {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: clamp(24px, 4vw, 64px);
  padding: clamp(24px, 5vw, 64px) clamp(16px, 4vw, 40px);
  max-width: 1240px; width: 100%; margin: 0 auto;
}

.now { display: flex; flex-direction: column; justify-content: center; min-width: 0; }

.station-line { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; letter-spacing: .02em; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 var(--accent); }
.is-playing .live-dot { animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 70%, transparent); } 100% { box-shadow: 0 0 0 12px transparent; } }

.eq { display: flex; align-items: flex-end; gap: 6px; height: 56px; margin: 36px 0 20px; }
.eq i { width: 8px; height: 20%; border-radius: 4px; background: var(--accent); opacity: .85; transition: height .4s ease; }
.is-playing .eq i { animation: eq 1.1s ease-in-out infinite alternate; }
.eq i:nth-child(2) { animation-delay: -.3s !important; }
.eq i:nth-child(3) { animation-delay: -.7s !important; animation-duration: .9s !important; }
.eq i:nth-child(4) { animation-delay: -.1s !important; animation-duration: 1.3s !important; }
.eq i:nth-child(5) { animation-delay: -.5s !important; }
.eq i:nth-child(6) { animation-delay: -.9s !important; animation-duration: .8s !important; }
.eq i:nth-child(7) { animation-delay: -.2s !important; animation-duration: 1.2s !important; }
@keyframes eq { 0% { height: 15%; } 50% { height: 95%; } 100% { height: 35%; } }
@media (prefers-reduced-motion: reduce) { .is-playing .eq i, .is-playing .live-dot { animation: none; height: 60%; } }

.track-title {
  margin: 0; font-size: clamp(32px, 5.5vw, 64px); line-height: 1.05; letter-spacing: -.02em; font-weight: 750;
  overflow-wrap: anywhere;
}
.track-artist { margin: 12px 0 0; font-size: clamp(18px, 2.2vw, 24px); color: #d4d4dc; }
.credit { margin: 10px 0 0; font-size: 13px; color: var(--muted); min-height: 1.5em; }
.credit a { color: var(--muted); }
.credit a:hover { color: var(--text); }

.progress { margin-top: 36px; height: 6px; border-radius: 3px; background: var(--line); cursor: pointer; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .25s linear; }
.times { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.controls { display: flex; align-items: center; gap: 18px; margin-top: 22px; }
.icon-btn, .play-btn { border: 0; cursor: pointer; display: grid; place-items: center; border-radius: 50%; }
.icon-btn { width: 48px; height: 48px; background: transparent; color: var(--text); }
.icon-btn:hover { background: var(--panel); }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.play-btn { width: 72px; height: 72px; background: var(--text); color: var(--bg); transition: transform .15s ease; }
.play-btn:hover { transform: scale(1.05); }
.play-btn svg { width: 30px; height: 30px; fill: currentColor; }
.play-btn .i-pause, .is-playing .play-btn .i-play { display: none; }
.is-playing .play-btn .i-pause { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.volume { display: flex; align-items: center; gap: 10px; margin-top: 22px; color: var(--muted); max-width: 260px; }
.volume svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.volume input { width: 100%; accent-color: var(--accent); }

.status { margin: 16px 0 0; color: var(--warn); font-size: 14px; min-height: 1.5em; }

.side h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 0 0 12px; font-weight: 600; }
.side h2:not(:first-child) { margin-top: 32px; }

.stations { display: grid; gap: 8px; }
.station {
  display: grid; gap: 2px; text-align: left; cursor: pointer;
  padding: 11px 14px 11px 18px; border-radius: 12px; position: relative;
  background: color-mix(in srgb, var(--panel) 80%, transparent); border: 1px solid var(--line);
}
.station::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 4px; border-radius: 0 3px 3px 0; background: var(--c); }
.station strong { font-size: 15px; }
.station span { font-size: 12px; color: var(--muted); }
.station:hover { border-color: color-mix(in srgb, var(--c) 50%, var(--line)); }
.station.active { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--panel)); }

.upcoming { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; counter-reset: up; }
.upcoming li { display: grid; padding: 8px 0 8px 30px; position: relative; border-bottom: 1px solid var(--line); counter-increment: up; }
.upcoming li:not(.muted)::before { content: counter(up); position: absolute; left: 0; top: 9px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.upcoming li.muted { padding-left: 0; }
.upcoming strong { font-weight: 550; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upcoming span { font-size: 12px; color: var(--muted); }

.speaker-badge { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

.remote-status { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; margin: 0 0 24px; padding: 6px 12px; border-radius: 999px; font-size: 13px; background: var(--panel); border: 1px solid var(--line); }
.remote-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.remote-status[data-level="ok"] .dot { background: var(--ok); }
.remote-status[data-level="warn"] .dot { background: var(--warn); }
.remote-status[data-level="off"] .dot { background: var(--danger); }
.remote-page .status { color: var(--muted); }

.search-input { margin-bottom: 8px; }
.results { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; border-bottom: 1px solid var(--line); }
.results li.muted { padding: 8px 0; font-size: 13px; }
.results button {
  width: 100%; display: grid; grid-template-columns: 22px minmax(0, 1fr); column-gap: 8px; text-align: left;
  background: none; border: 0; padding: 8px 6px; border-radius: 8px; cursor: pointer;
}
.results button:hover { background: var(--panel); }
.results em { grid-row: span 2; font-style: normal; color: var(--accent); font-size: 12px; align-self: center; }
.results strong { font-weight: 550; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.overlay {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(10px);
}
.overlay-card { text-align: center; }
.overlay-card h2 { font-size: 34px; margin: 18px 0 6px; letter-spacing: -.02em; }
.overlay-card p { color: var(--muted); margin: 0 0 24px; }
.start-btn {
  border: 0; cursor: pointer; border-radius: 999px; padding: 16px 34px; font-size: 18px; font-weight: 650;
  background: var(--text); color: var(--bg);
}
.start-btn:hover { transform: scale(1.03); }

@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; }
  .eq { margin-top: 24px; height: 40px; }
}

/* ---------- generic pages ---------- */

.page { max-width: 1180px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 30px; letter-spacing: -.02em; }
.page-head p { margin: 4px 0 0; }
.page-head form { margin: 0; }

.center-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(16px, 3vw, 28px); margin-bottom: 20px; }
.card h2 { margin: 0 0 6px; font-size: 19px; }
.card > .muted { margin-top: 0; }
.card.narrow { width: 100%; max-width: 380px; }
.card.narrow h1 { margin: 16px 0 4px; font-size: 24px; }
form.card.narrow { display: grid; gap: 16px; padding: 32px; }
form.card.narrow .flash { margin: 0; }
form.card.narrow input[type=password] { padding: 12px 14px; font-size: 16px; }
form.card.narrow .btn { padding: 12px 16px; font-size: 15px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel);
  cursor: pointer; text-decoration: none; font-weight: 550; white-space: nowrap;
}
.btn:hover { border-color: #3b3b4d; background: #20202c; }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { background: #fff; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; cursor: progress; }

.flash { padding: 10px 14px; border-radius: 10px; margin: 0 0 10px; border: 1px solid; }
.flash.ok { border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 10%, transparent); }
.flash.error { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: color-mix(in srgb, var(--danger) 10%, transparent); }

.tabs { display: flex; gap: 4px; margin: 10px 0 20px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--text); border-color: var(--text); }

.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.span-2 { grid-column: 1 / -1; }
@media (max-width: 700px) { .grid-form { grid-template-columns: 1fr; } }

.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span { font-size: 13px; color: #c9c9d3; font-weight: 550; }
input[type=text], input[type=url], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=color] { width: 40px; height: 34px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); cursor: pointer; }
input.num { width: 80px; }
input.time { width: 90px; font-variant-numeric: tabular-nums; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }

.dropzone { padding: 16px; border: 1px dashed #3b3b4d; border-radius: 12px; background: var(--bg); }
.dropzone input[type=file] { color: var(--muted); max-width: 100%; }

.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check i, .dot-tag i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.dot-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; margin: 1px 8px 1px 0; white-space: nowrap; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--panel); color: var(--muted); }

.upload-box summary { display: flex; align-items: baseline; gap: 12px; cursor: pointer; list-style: none; }
.upload-box summary::-webkit-details-marker { display: none; }
.upload-box summary h2 { margin: 0; }
.upload-box summary::before { content: "+"; font-size: 20px; line-height: 1; color: var(--muted); width: 14px; }
.upload-box[open] summary::before { content: "−"; }
.upload-box[open] summary { margin-bottom: 8px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.filters input[type=search] { flex: 1 1 220px; width: auto; }
.filters select { width: auto; flex: 0 1 auto; }

.pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pagination .current { background: var(--text); color: var(--bg); border-color: var(--text); cursor: default; }

.seed-box .section-head { align-items: flex-start; }
.seed-box .section-head p { margin: 4px 0 0; max-width: 70ch; }
.seed-progress { margin-top: 8px; }

/* Remote: controls pinned to the top instead of vertically centred next to the long side list */
.remote-page .stage { align-items: start; }
.remote-page .now { justify-content: flex-start; position: sticky; top: 24px; }
@media (max-width: 860px) { .remote-page .now { position: static; } }

/* Remote: precise volume */
.volume-control { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 22px; color: var(--muted); max-width: 440px; }
.volume-control svg { width: 20px; height: 20px; flex: none; }
.volume-control input[type=range] { flex: 1 1 140px; accent-color: var(--accent); }
.vol-step { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); font-size: 18px; line-height: 1; cursor: pointer; }
.vol-step:hover { border-color: #3b3b4d; }
.vol-number { display: inline-flex; align-items: center; gap: 4px; color: var(--text); }
.vol-number input { width: 74px; text-align: right; font-variant-numeric: tabular-nums; padding: 7px 9px; }

/* Remote: speaker picker */
.speakers { display: grid; gap: 8px; }
.speakers .muted { font-size: 13px; }
.speaker span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rename-btn { margin-top: 8px; background: none; border: 0; padding: 0; color: var(--muted); font-size: 13px; cursor: pointer; text-decoration: underline; }
.rename-btn:hover { color: var(--text); }

/* Remote: command waiting for the speaker */
.is-busy [data-key] { cursor: progress; }
[data-key]:disabled { opacity: .5; }
[data-key].is-loading, [data-key].is-loading:disabled { opacity: 1; position: relative; }
.icon-btn.is-loading svg, .play-btn.is-loading svg, .results button.is-loading em { visibility: hidden; }
[data-key].is-loading::after {
  content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite;
}
.icon-btn.is-loading::after, .play-btn.is-loading::after { inset: 0; margin: auto; }
.station.is-loading::after { width: 16px; height: 16px; right: 14px; top: calc(50% - 8px); color: var(--c); }
.results button.is-loading::after { width: 12px; height: 12px; left: 10px; top: calc(50% - 6px); color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { [data-key].is-loading::after { animation-duration: 2s; } }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.filter { max-width: 320px; }
.bulk { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.bulk select { width: auto; min-width: 220px; }

.table-wrap { overflow-x: auto; margin: 0 -4px 16px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 550; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr.inactive td { opacity: .5; }
.table td a { color: #c9c9d3; }
.table .new-row td { background: color-mix(in srgb, var(--panel) 50%, transparent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; color: #c9c9d3; }

.preview { width: 100%; margin-bottom: 4px; }
.row-between { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
