:root{
  --bg:#0b1020; --card:#121a33; --border:rgba(255,255,255,.08);
  --text:#e9ecff; --muted:rgba(233,236,255,.7);
  --good:#37d67a; --bad:#ff4d4f; --warn:#ffcc00;
}
body.theme-light{
  --bg:#f4f7fb;--card:#ffffff;--border:rgba(15,23,42,.16);
  --text:#0b1527;--muted:rgba(15,23,42,.74);
  background:#f4f7fb;color:#0b1527;
}
body.theme-light .card,body.theme-light .topbar{background:rgba(255,255,255,.92);color:#0b1527;border-color:rgba(15,23,42,.16);box-shadow:0 12px 34px rgba(15,23,42,.08)}
body.theme-light .muted,body.theme-light .small,body.theme-light .sub,body.theme-light th,body.theme-light td,body.theme-light .np-progress-label,body.theme-light .np-progress-pct{color:rgba(15,23,42,.74)}
body.theme-light h3,body.theme-light .title,body.theme-light .np,body.theme-light .big{color:#07111f;opacity:1}
body.theme-light .title-selector-btn,body.theme-light .btn{color:#07111f;background:rgba(15,23,42,.06);border-color:rgba(15,23,42,.18);box-shadow:0 8px 20px rgba(15,23,42,.08)}
body.theme-light .title-selector-btn:hover,body.theme-light .btn:hover{background:rgba(15,23,42,.10)}
body.theme-light th,body.theme-light td{border-top-color:rgba(15,23,42,.10)}
body.theme-light .np-progress-bar{background:rgba(15,23,42,.10);border-color:rgba(15,23,42,.12)}
body.theme-light .now-playing-art{background:rgba(15,23,42,.05);border-color:rgba(15,23,42,.16);box-shadow:0 14px 28px rgba(15,23,42,.12);color:rgba(15,23,42,.52)}
body.theme-light .badge{color:#07111f;background:rgba(15,23,42,.06);border-color:rgba(15,23,42,.16)}
body.theme-light .badge.ok{background:rgba(22,163,74,.12);border-color:rgba(22,163,74,.28);color:#14532d}
body.theme-light .badge.warn{background:rgba(202,138,4,.14);border-color:rgba(202,138,4,.30);color:#713f12}
body.theme-light .badge.bad{background:rgba(220,38,38,.12);border-color:rgba(220,38,38,.28);color:#7f1d1d}
body.theme-light .error{background:rgba(220,38,38,.10);border-color:rgba(220,38,38,.28);color:#7f1d1d}
body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto;background:var(--bg);color:var(--text)}
body.bg-solid{background:var(--custom-bg-color)}
body.bg-gradient{background:linear-gradient(135deg,var(--custom-gradient-from),var(--custom-gradient-to))}
body.bg-image{background:linear-gradient(rgba(6,16,29,.72),rgba(6,16,29,.78)),var(--custom-bg-image) center/cover fixed no-repeat}
body.theme-light.bg-image{background:linear-gradient(rgba(244,247,251,.78),rgba(244,247,251,.84)),var(--custom-bg-image) center/cover fixed no-repeat}
body.bg-image .card{background:rgba(18,26,51,var(--image-card-opacity,.50));backdrop-filter:blur(10px)}
body.theme-light.bg-image .card{background:rgba(255,255,255,var(--image-card-opacity,.50))}
.noselect{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent}
.topbar{padding:14px 18px;border-bottom:1px solid var(--border);display:flex;justify-content:space-between;align-items:center}
.brand{display:flex;gap:10px;align-items:center}

/* NOTE: logo image must be set inline in HTML via style="background-image:url(...)" */
.logo{
  width:64px;height:64px;border-radius:10px;background:rgba(255,255,255,.10);
  background-size:cover;background-position:center;background-repeat:no-repeat;
}

.title{font-weight:900;font-size:18px}
.clock{font-size:40px;font-weight:900;opacity:.9}
.sub{color:var(--muted);font-size:20px;font-weight:900;margin-top:2px}
.title-selector-btn{
  display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;text-decoration:none;
  color:var(--text);font-size:12px;font-weight:950;letter-spacing:.2px;
  margin-left:10px;padding:6px 10px;border-radius:10px;border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.08);box-shadow:0 10px 26px rgba(0,0,0,.14);
  white-space:nowrap;transition:background .15s ease, transform .15s ease;
}
.title-selector-btn:hover{background:rgba(255,255,255,.14);transform:translateY(-1px)}
.title-selector-btn:active{transform:translateY(1px)}
.wrap{padding:18px;display:grid;gap:14px;grid-template-columns:repeat(12,1fr)}
.card{background:var(--card);border:1px solid var(--border);border-radius:14px;padding:14px}
.kpi{grid-column:span 3}
.wide{grid-column:span 6}

h3{margin:0 0 10px 0;font-size:20px;letter-spacing:.3px;opacity:.9}
.big{font-size:30px;font-weight:950;line-height:1}
.muted,.small{font-size:15px;font-weight:900;color:var(--muted)}
.row{display:flex;justify-content:space-between;gap:10px;align-items:baseline}
.listener-card{position:relative;overflow:visible;z-index:2}
.listener-card:hover,.listener-card:focus-within{z-index:999}
.listener-card{overflow:visible}
.listener-card.is-open{z-index:1200}
.listener-live-toggle{cursor:pointer;user-select:none}
.listener-live-toggle:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
.listener-popover{position:absolute;left:50%;top:calc(100% - 1px);z-index:1000;display:none;width:min(380px,calc(100vw - 36px));transform:translateX(-50%);background:linear-gradient(180deg,rgba(8,18,34,.98),rgba(5,11,22,.98));border:1px solid rgba(255,255,255,.14);border-radius:16px;padding:14px;box-shadow:0 22px 58px rgba(0,0,0,.42);color:var(--text)}
.listener-popover:before{content:"";position:absolute;left:50%;top:-7px;width:12px;height:12px;transform:translateX(-50%) rotate(45deg);background:rgba(8,18,34,.98);border-left:1px solid rgba(255,255,255,.14);border-top:1px solid rgba(255,255,255,.14)}
.listener-card.is-open .listener-popover{display:block}
.listener-popover>strong{display:flex;align-items:center;justify-content:space-between;gap:10px;font-size:13px;margin:0 0 10px;text-transform:uppercase;letter-spacing:.08em;color:rgba(233,236,255,.86)}
.listener-detail-rows{display:grid;gap:8px;max-height:260px;overflow:auto;padding-right:2px}
.listener-detail-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(112px,.75fr);gap:10px;align-items:start;background:rgba(255,255,255,.065);border:1px solid rgba(255,255,255,.10);border-radius:12px;padding:10px}
.listener-detail-row strong{display:block;font-size:13px;line-height:1.25;color:var(--text);word-break:break-word}
.listener-label{display:block;margin-bottom:4px;font-size:10px;font-weight:950;text-transform:uppercase;letter-spacing:.08em;color:rgba(233,236,255,.52)}
.listener-meta{display:block;margin-top:5px;font-size:11px;font-weight:800;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.listener-detail-empty{font-size:12px;font-weight:850;color:var(--muted);line-height:1.45;background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.10);border-radius:12px;padding:10px}
body.theme-light .listener-popover{background:linear-gradient(180deg,rgba(255,255,255,.99),rgba(246,249,252,.99));border-color:rgba(15,23,42,.16);box-shadow:0 22px 58px rgba(15,23,42,.20);color:#07111f}
body.theme-light .listener-popover:before{background:rgba(255,255,255,.99);border-color:rgba(15,23,42,.16)}
body.theme-light .listener-popover>strong{color:rgba(15,23,42,.72)}
body.theme-light .listener-detail-row,body.theme-light .listener-detail-empty{background:rgba(15,23,42,.045);border-color:rgba(15,23,42,.10)}
body.theme-light .listener-detail-row strong{color:#07111f}
body.theme-light .listener-label{color:rgba(15,23,42,.54)}

.status-online{color:var(--good)}
.status-offline{color:var(--bad)}
.status-degraded{color:var(--warn)}

table{width:100%;border-collapse:collapse;font-size:14px;table-layout:fixed}
th,td{padding:10px;border-top:1px solid rgba(255,255,255,.07);text-align:left;overflow:hidden}
th,td{font-size:15px;color:var(--muted);font-weight:800}

.np{font-size:30px;font-weight:950}

.error{
  grid-column:span 12;background:rgba(255,77,79,.12);
  border:1px solid rgba(255,77,79,.3);color:#ffd6d6;border-radius:12px;
  padding:10px;display:none;white-space:pre-wrap
}

.delta{font-size:16px;font-weight:950;margin-left:10px;vertical-align:middle;opacity:.95}
.delta.up{color:var(--good)}
.delta.down{color:var(--bad)}
.delta.flat{color:var(--muted)}

#card_now_playing{position:relative;transform:translateZ(0);overflow:hidden}
#card_now_playing .now-playing-content{padding-left:148px;min-height:128px}
#card_now_playing.no-album-art .now-playing-content{padding-left:0}
.now-playing-art{
  position:absolute;left:14px;top:54px;
  width:128px;height:128px;border-radius:14px;border:1px solid var(--border);
  background:rgba(255,255,255,.08);box-shadow:0 14px 32px rgba(0,0,0,.25);
  display:grid;place-items:center;overflow:hidden;color:var(--muted);font-size:30px;font-weight:950;
}
.now-playing-art img{width:100%;height:100%;display:block;object-fit:cover}
.now-playing-art.loading{opacity:.72}
.now-playing-art.missing span{display:grid}
.flash{animation:songPulse .95s ease-out 1;transform-origin:center}
@keyframes songPulse{
  0%{transform:scale(1);filter:brightness(1);box-shadow:0 0 0 0 rgba(55,214,122,.35);background:var(--card)}
  35%{transform:scale(1.015);filter:brightness(1.08);box-shadow:0 0 26px 6px rgba(55,214,122,.20);
      background:linear-gradient(180deg, rgba(55,214,122,.10), rgba(18,26,51,1) 55%)}
  100%{transform:scale(1);filter:brightness(1);box-shadow:0 0 0 0 rgba(55,214,122,0);background:var(--card)}
}

@media (max-width: 1100px){
  .kpi{grid-column:span 6}
  .wide{grid-column:span 12}
}

@media (max-width: 760px){
  .topbar{position:static;min-height:0;align-items:flex-start;gap:12px;flex-direction:column}
  .title-selector-btn{margin:8px 0 0}
  .clock{font-size:32px}
  #card_now_playing .now-playing-content{padding-left:142px}
  #card_now_playing.no-album-art .now-playing-content{padding-left:0}
  .now-playing-art{left:12px;top:54px;width:128px;height:128px;border-radius:12px;font-size:24px}
  .listener-popover{position:static;margin-top:12px}
}

.smart-marquee{display:block;width:100%;overflow:hidden;white-space:nowrap;position:relative}
.smart-marquee .inner{display:flex;align-items:baseline;width:max-content;gap:48px;transform:translateX(0);will-change:transform}
.smart-marquee .txt,.smart-marquee .dup{display:inline-block;white-space:nowrap}
.smart-marquee .dup{display:none}
.smart-marquee.is-marquee .dup{display:inline-block}

#backoff_line{opacity:0;transform:translateY(-4px);transition:opacity .35s ease, transform .35s ease;pointer-events:none}
#backoff_line.visible{opacity:1;transform:translateY(0)}

.np-progress{margin-top:10px}
.np-progress-top{display:flex;justify-content:space-between;align-items:center;margin-bottom:6px}
.np-progress-label,.np-progress-pct{font-size:15px;font-weight:900;color:var(--muted)}
.np-progress-bar{height:12px;border-radius:999px;background:rgba(255,255,255,.10);overflow:hidden;border:1px solid rgba(255,255,255,.10)}
.np-progress-fill{height:100%;border-radius:999px;background:linear-gradient(90deg, var(--station-accent, rgba(55,214,122,.95)), rgba(255,204,0,.95));transition:width .35s ease}

.badge{
  display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:950;letter-spacing:.3px;
  padding:4px 10px;border-radius:999px;border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.08);color:var(--text);user-select:none
}
.badge.ok{background:rgba(55,214,122,.14);border-color:rgba(55,214,122,.35);color:#d8ffe8}
.badge.warn{background:rgba(255,204,0,.14);border-color:rgba(255,204,0,.35);color:#fff6cc}
.badge.bad{background:rgba(255,77,79,.14);border-color:rgba(255,77,79,.35);color:#ffd6d6}

.btn{font-size:12px;font-weight:950;color:var(--text);padding:6px 10px;border-radius:10px;border:1px solid rgba(255,255,255,.12);background:rgba(255,255,255,.08);cursor:pointer}
.btn:active{transform:translateY(1px)}
.btn:disabled{opacity:.55;cursor:not-allowed}

.stream-top{display:flex;justify-content:space-between;align-items:center;gap:10px}
.stream-right{display:flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}

body.density-compact .topbar{padding:6px 10px}
body.density-compact .brand{gap:8px}
body.density-compact .logo{width:40px;height:40px;border-radius:7px}
body.density-compact .title{font-size:14px}
body.density-compact .sub{font-size:13px;margin-top:0}
body.density-compact .clock{font-size:24px}
body.density-compact .wrap{padding:8px;gap:6px}
body.density-compact .card{border-radius:8px;padding:7px 8px}
body.density-compact h3{font-size:14px;margin-bottom:4px}
body.density-compact .big{font-size:20px}
body.density-compact .np{font-size:20px}
body.density-compact .muted,body.density-compact .small{font-size:12px}
body.density-compact .row{gap:5px}
body.density-compact table{font-size:12px}
body.density-compact th,body.density-compact td{padding:4px 5px;font-size:11px}
body.density-compact .delta{font-size:12px;margin-left:5px}
body.density-compact .badge{font-size:10px;padding:2px 6px}
body.density-compact .btn,body.density-compact .title-selector-btn{font-size:10px;padding:4px 7px;border-radius:7px}
body.density-compact #card_now_playing .now-playing-content{padding-left:84px;min-height:72px}
body.density-compact #card_now_playing.no-album-art .now-playing-content{padding-left:0;min-height:0}
body.density-compact .now-playing-art{left:8px;top:34px;width:72px;height:72px;border-radius:8px;font-size:18px;box-shadow:0 8px 18px rgba(0,0,0,.20)}
body.density-compact .np-progress{margin-top:4px}
body.density-compact .np-progress-top{margin-bottom:3px}
body.density-compact .np-progress-label,body.density-compact .np-progress-pct{font-size:11px}
body.density-compact .np-progress-bar{height:6px}
body.density-compact .stream-top{gap:5px}
body.density-compact .stream-right{gap:5px}

@media (max-width: 760px){
  body.density-compact .topbar{gap:6px}
  body.density-compact .clock{font-size:22px}
  body.density-compact .wrap{padding:6px;gap:6px}
  body.density-compact #card_now_playing .now-playing-content{padding-left:78px}
  body.density-compact #card_now_playing.no-album-art .now-playing-content{padding-left:0}
  body.density-compact .now-playing-art{left:8px;top:32px;width:68px;height:68px}
}
