:root {
  --bg: #10131a;
  --bg-2: #161b24;
  --panel: #1a2030;
  --line: #2c3548;
  --text: #eef2f8;
  --muted: #9aa6bc;
  --accent: #5eb1ff;
  --good: #3dcea0;
  --warn: #e8b84a;
  --bad: #ef6f78;
  --gold: #d7b45a;
  --font: "DM Sans", "Segoe UI", sans-serif;
  --display: "Instrument Serif", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: var(--font);
  background:
    radial-gradient(900px 420px at 8% -10%, #24314a 0%, transparent 55%),
    radial-gradient(700px 380px at 100% 0%, #1a2838 0%, transparent 50%),
    var(--bg);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.top {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  align-items: end;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.2rem, 4vw, 3.2rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

.lede {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 36rem;
  line-height: 1.45;
}

.top-status {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #1d2433, var(--panel));
  border-radius: 18px;
  padding: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pill-live {
  background: color-mix(in srgb, var(--good) 82%, white);
  color: #062418;
}

.pill-stopped {
  background: color-mix(in srgb, var(--bad) 75%, white);
  color: #2b0b10;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.meta-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.meta-grid strong {
  font-size: 1rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button {
  appearance: none;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #071018;
  font-weight: 700;
  padding: 9px 13px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
}

button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

button:hover { filter: brightness(1.06); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.now-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
}

.now-card {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 18px;
  padding: 18px;
  min-width: 0;
}

.now-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.now-card h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.dot-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.dot-badge.online { color: var(--good); }
.dot-badge.error { color: var(--bad); }
.dot-badge.stopped { color: var(--warn); }

.now-kicker {
  margin: 14px 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

.now-artist {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  line-height: 1.15;
}

.now-title {
  margin: 4px 0 14px;
  color: #c5d0e4;
  font-size: 1.05rem;
}

.now-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.mini-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 700;
}

.mini-badge.found {
  background: color-mix(in srgb, var(--good) 80%, white);
  color: #062418;
  border-color: transparent;
}

.mini-badge.searching {
  background: color-mix(in srgb, var(--warn) 80%, white);
  color: #241800;
  border-color: transparent;
}

.mini-badge.error,
.mini-badge.not_found {
  color: var(--muted);
}

.text-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.text-link:hover { text-decoration: underline; }
.muted { color: var(--muted); }

.isrc {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.cat-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 0.35rem;
  background: rgb(255 255 255 / 0.08);
  border: 1px solid rgb(255 255 255 / 0.12);
}
.hidden { display: none !important; }

.library {
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 20px;
  padding: 18px;
}

.library-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.library-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.blurb {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 40rem;
  line-height: 1.4;
}

.cat-nav {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.cat-btn {
  text-align: left;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 64px;
}

.cat-btn .cat-name {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
}

.cat-btn .cat-count {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.cat-btn.active {
  background: var(--accent);
  color: #071018;
  border-color: transparent;
}

.cat-btn.active .cat-count { color: rgb(7 16 24 / 0.7); }

.table-shell {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: auto;
  max-height: 560px;
  background: var(--panel);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #202839;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  z-index: 1;
}

tbody tr:hover { background: rgb(255 255 255 / 0.02); }

.station-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.station-tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 0.7rem;
  color: var(--muted);
}

.retry-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 4px 8px;
  font-size: 0.75rem;
}

.empty {
  color: var(--muted);
  padding: 28px 12px;
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgb(4 8 14 / 0.72);
}

.modal-card {
  position: relative;
  width: min(720px, 100%);
  max-height: min(80vh, 720px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-subtitle { margin: 6px 0 0; color: var(--muted); }

.candidate-list { display: grid; gap: 8px; }

.candidate {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--bg-2);
}

.candidate-num { color: var(--muted); font-weight: 700; }
.candidate-title { margin: 0 0 2px; font-weight: 650; }
.candidate-meta { margin: 0; color: var(--muted); font-size: 0.82rem; }
.candidate-meta a { color: var(--accent); text-decoration: none; }

@media (max-width: 900px) {
  .top, .now-row { grid-template-columns: 1fr; }
  .cat-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .library-head { flex-direction: column; }
  .candidate { grid-template-columns: 24px 1fr; }
  .candidate button { grid-column: 1 / -1; }
}
