/* ---------- themes ---------- */
:root, [data-theme="midnight"] {
  --bg: #0a0d12;
  --bg-glow: #101722;
  --panel: rgba(16, 21, 29, .85);
  --card: #141a23;
  --card-hover: #171e29;
  --border: #232b38;
  --border-soft: #1b2230;
  --text: #e8ecf2;
  --text-dim: #8c97a8;
  --text-faint: #5c6675;
  --accent: #38bdf8;
  --accent-ink: #06121d;
  --accent-soft: rgba(56, 189, 248, .14);
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --wave-played: #38bdf8;
  --wave-bg: #31405a;
}

[data-theme="slate"] {
  --bg: #12151a;
  --bg-glow: #1a1f27;
  --panel: rgba(26, 31, 39, .88);
  --card: #1c222b;
  --card-hover: #222834;
  --border: #313a48;
  --border-soft: #262e3a;
  --text: #e6e9ee;
  --text-dim: #98a2b3;
  --text-faint: #6b7688;
  --accent: #a78bfa;
  --accent-ink: #160d2b;
  --accent-soft: rgba(167, 139, 250, .16);
  --green: #4ade80;
  --red: #fb7185;
  --amber: #fbbf24;
  --wave-played: #a78bfa;
  --wave-bg: #3a4152;
}

[data-theme="amber"] {
  --bg: #17120a;
  --bg-glow: #211a0f;
  --panel: rgba(33, 26, 15, .88);
  --card: #221b10;
  --card-hover: #2b2213;
  --border: #3d3018;
  --border-soft: #2f2513;
  --text: #f3e9d6;
  --text-dim: #b59f7d;
  --text-faint: #7f6f52;
  --accent: #f59e0b;
  --accent-ink: #201400;
  --accent-soft: rgba(245, 158, 11, .16);
  --green: #a3b545;
  --red: #ef7d5a;
  --amber: #fbbf24;
  --wave-played: #f59e0b;
  --wave-bg: #4a3c22;
}

[data-theme="phosphor"] {
  --bg: #04120a;
  --bg-glow: #061c10;
  --panel: rgba(6, 26, 15, .9);
  --card: #08200f;
  --card-hover: #0b2914;
  --border: #124023;
  --border-soft: #0d3019;
  --text: #c8f7d4;
  --text-dim: #6fbf88;
  --text-faint: #48815c;
  --accent: #34d399;
  --accent-ink: #012312;
  --accent-soft: rgba(52, 211, 153, .16);
  --green: #34d399;
  --red: #f97066;
  --amber: #eab308;
  --wave-played: #34d399;
  --wave-bg: #1b5233;
}

[data-theme="contrast"] {
  --bg: #000000;
  --bg-glow: #0a0a0a;
  --panel: rgba(0, 0, 0, .92);
  --card: #0c0c0c;
  --card-hover: #161616;
  --border: #3a3a3a;
  --border-soft: #2a2a2a;
  --text: #ffffff;
  --text-dim: #c8c8c8;
  --text-faint: #909090;
  --accent: #ffd000;
  --accent-ink: #1a1400;
  --accent-soft: rgba(255, 208, 0, .18);
  --green: #00e676;
  --red: #ff5252;
  --amber: #ffd000;
  --wave-played: #ffd000;
  --wave-bg: #4a4a4a;
}

[data-theme="light"] {
  --bg: #eef1f5;
  --bg-glow: #ffffff;
  --panel: rgba(255, 255, 255, .9);
  --card: #ffffff;
  --card-hover: #f5f8fc;
  --border: #d3dae4;
  --border-soft: #e2e8f0;
  --text: #1a2432;
  --text-dim: #5a6675;
  --text-faint: #93a0b0;
  --accent: #0284c7;
  --accent-ink: #ffffff;
  --accent-soft: rgba(2, 132, 199, .1);
  --green: #059669;
  --red: #dc2626;
  --amber: #b45309;
  --wave-played: #0284c7;
  --wave-bg: #c2ccd8;
}

:root {
  --radius: 14px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 420px at 50% -180px, var(--bg-glow), transparent),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background .3s, color .3s;
}

/* ---------- header ---------- */

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; }
#logo-slot { display: flex; align-items: center; }
.brand-icon {
  width: 30px; height: 30px;
  color: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent-soft));
}
#logo-slot img {
  max-height: 34px; max-width: 160px;
  display: block;
  object-fit: contain;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 1.2rem; font-weight: 700; letter-spacing: .04em; }
.brand-sub {
  color: var(--text-dim);
  font-size: .74rem;
  font-family: var(--mono);
  letter-spacing: .05em;
}

.controls { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap svg {
  position: absolute; left: 10px;
  width: 14px; height: 14px;
  color: var(--text-faint);
  pointer-events: none;
}
#search {
  background: var(--accent-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 99px;
  padding: 6px 14px 6px 31px;
  width: 220px;
  outline: none;
  transition: border-color .15s, width .2s;
}
#search:focus { border-color: var(--accent); width: 260px; }
#search::placeholder { color: var(--text-faint); }

select {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-family: var(--mono);
  font-size: .82rem;
}
select.loading { border-color: var(--amber); animation: pulse 1.2s infinite; }

.icon-btn, .text-btn {
  background: var(--card);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 11px;
  cursor: pointer;
  font-size: .88rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color .15s, border-color .15s, background .15s;
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover, .text-btn:hover { color: var(--text); border-color: var(--accent); }
.icon-btn.active {
  border-color: var(--amber);
  color: var(--amber);
  background: var(--accent-soft);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 99px;
  padding: 5px 13px;
  font-size: .72rem;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: .09em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.status-pill.ok { color: var(--green); border-color: var(--green); background: var(--accent-soft); }
.status-pill.ok .dot { background: var(--green); box-shadow: 0 0 7px var(--green); }
.status-pill.on-air { color: var(--red); border-color: var(--red); background: var(--accent-soft); }
.status-pill.on-air .dot { background: var(--red); box-shadow: 0 0 8px var(--red); animation: pulse 1s infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.chip {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 99px;
  padding: 3px 11px;
  font-size: .76rem;
  font-family: var(--mono);
}

/* ---------- feed ---------- */

#feed-wrap { flex: 1; overflow-y: auto; scrollbar-gutter: stable; display: flex; flex-direction: column; }
#feed { max-width: 880px; width: 100%; margin: 0 auto; padding: 16px 14px 28px; flex: 1; }

#feed-wrap::-webkit-scrollbar { width: 10px; }
#feed-wrap::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
  border: 2px solid var(--bg);
}

.center { text-align: center; padding: 12px; }
.muted { color: var(--text-dim); font-size: .9rem; }
.hidden { display: none !important; }

.edge-marker {
  display: flex; align-items: center; gap: 12px;
  color: var(--text-faint);
  font-size: .74rem;
  font-family: var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  margin: 10px 0 4px;
}
.edge-marker::before, .edge-marker::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

.empty { text-align: center; padding: 90px 20px; color: var(--text-dim); }
.empty svg { width: 54px; height: 54px; color: var(--text-faint); margin-bottom: 6px; }
.empty p { margin: 4px 0; font-size: 1.05rem; }
.empty .muted { font-size: .88rem; color: var(--text-faint); }

.day-divider {
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  margin: 20px 0 10px;
}
.day-divider span {
  background: var(--card);
  border: 1px solid var(--border-soft);
  color: var(--text-dim);
  border-radius: 99px;
  padding: 3px 15px;
  font-size: .76rem;
  font-family: var(--mono);
}
.day-purge {
  background: var(--card);
  border: 1px solid var(--border-soft);
  color: var(--text-faint);
  border-radius: 99px;
  width: 24px; height: 24px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: color .15s, border-color .15s;
}
.day-purge:hover { color: var(--red); border-color: var(--red); }
.day-purge svg { width: 13px; height: 13px; }

/* ---------- transmission card ---------- */

.card {
  display: flex;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 13px 15px;
  margin: 10px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  transition: background .15s, border-color .15s;
  animation: card-in .25s ease-out;
  position: relative;
}
.card:hover { background: var(--card-hover); border-color: var(--border); }

@keyframes card-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .82rem;
  user-select: none;
  margin-top: 2px;
}
.avatar.unknown { background: transparent; border: 1.5px dashed var(--border); color: var(--text-faint); }
.avatar.clickable { cursor: pointer; transition: filter .15s, border-color .15s; }
.avatar.clickable:hover { filter: brightness(1.3); border-color: var(--text-dim); }

.card-main { flex: 1; min-width: 0; }

.card-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.speaker-name { font-weight: 650; font-size: .92rem; }
.speaker-name.unknown { color: var(--text-dim); font-weight: 400; font-style: italic; }
.speaker-name.clickable { cursor: pointer; }
.speaker-name.clickable:hover { text-decoration: underline; text-underline-offset: 3px; }

.match { color: var(--text-faint); font-size: .72rem; font-family: var(--mono); }

.mdc-badge {
  background: var(--accent-soft);
  border: 1px solid var(--amber);
  color: var(--amber);
  border-radius: 99px;
  padding: 1px 10px 1px 6px;
  font-size: .72rem;
  font-family: var(--mono);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.mdc-badge .moto { width: 13px; height: 13px; flex-shrink: 0; }

.origin-badge {
  border-radius: 99px;
  padding: 1px 10px;
  font-size: .72rem;
  font-family: var(--mono);
  white-space: nowrap;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.origin-badge.origin-local {
  border-color: var(--green);
  color: var(--green);
  background: var(--accent-soft);
}
.origin-badge.origin-remote {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.head-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-faint);
  font-size: .76rem;
  font-family: var(--mono);
  white-space: nowrap;
}
.card-action {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 2px;
  display: inline-flex;
  border-radius: 5px;
  transition: color .15s, background .15s;
}
.card-action svg { width: 15px; height: 15px; }
.card-action:hover { color: var(--text); background: var(--accent-soft); }
.card-action.danger:hover { color: var(--red); }

.transcript {
  margin: 6px 0 2px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-size: .95rem;
}
.transcript.none { color: var(--text-faint); font-style: italic; font-size: .88rem; }

.shimmer {
  height: 11px; width: 55%;
  border-radius: 6px;
  margin: 10px 0 8px;
  background: linear-gradient(90deg, var(--card) 25%, var(--card-hover) 50%, var(--card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

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

.player { display: flex; align-items: center; gap: 11px; margin-top: 8px; }
.play-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .1s;
}
.play-btn:hover { background: var(--accent); color: var(--accent-ink); }
.play-btn:active { transform: scale(.93); }
.play-btn svg { width: 14px; height: 14px; fill: currentColor; }
.play-btn.loading { animation: pulse 1s infinite; }

canvas.wave { flex: 1; height: 38px; min-width: 0; cursor: pointer; display: block; }
.player.expired canvas.wave { opacity: .35; cursor: default; }

.ptime {
  color: var(--text-faint);
  font-size: .74rem;
  font-family: var(--mono);
  min-width: 66px;
  text-align: right;
  white-space: nowrap;
}
.expired-note { color: var(--text-faint); font-size: .74rem; font-family: var(--mono); font-style: italic; }

/* ---------- voter panel ---------- */

.voter-toggle {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: .76rem;
  font-family: var(--mono);
  padding: 4px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.voter-toggle:hover { color: var(--accent); }
.voter-toggle .chev { font-size: .7rem; }

.voter-panel {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}
.voter-node + .voter-node { margin-top: 12px; }
.voter-node-head {
  font-size: .76rem;
  font-family: var(--mono);
  color: var(--text-dim);
  margin-bottom: 7px;
}
.voter-row {
  display: grid;
  grid-template-columns: minmax(90px, 160px) 1fr 36px;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
}
.voter-name {
  font-size: .78rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.voter-bar {
  height: 15px;
  background: var(--accent-soft);
  border-radius: 4px;
  overflow: hidden;
}
.voter-fill {
  height: 100%;
  width: 1%;
  background: var(--accent);
  border-radius: 4px;
  transition: width .25s linear;
}
.voter-fill.voted { background: var(--green); }
.voter-rssi {
  font-size: .74rem;
  font-family: var(--mono);
  color: var(--text-faint);
  text-align: right;
}
.voter-note {
  margin-top: 8px;
  font-size: .7rem;
  color: var(--text-faint);
  font-style: italic;
}

/* ---------- receiving indicator ---------- */

#rx-indicator {
  display: flex; align-items: center; gap: 12px;
  margin: 12px 0;
  padding: 13px 16px;
  background: var(--accent-soft);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  color: var(--red);
  font-weight: 650;
  animation: card-in .25s ease-out;
}
.eq { display: inline-flex; align-items: flex-end; gap: 3px; height: 18px; }
.eq i { width: 4px; border-radius: 2px; background: var(--red); animation: eq-bounce 1s ease-in-out infinite; }
.eq i:nth-child(1) { height: 40%; animation-delay: 0s; }
.eq i:nth-child(2) { height: 90%; animation-delay: .18s; }
.eq i:nth-child(3) { height: 60%; animation-delay: .34s; }
.eq i:nth-child(4) { height: 100%; animation-delay: .5s; }
@keyframes eq-bounce { 0%, 100% { transform: scaleY(.45); } 50% { transform: scaleY(1); } }
.ellipsis::after { content: ""; animation: ellipsis 1.5s steps(4) infinite; }
@keyframes ellipsis { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* ---------- footer ---------- */

#site-footer {
  text-align: center;
  color: var(--text-faint);
  font-size: .8rem;
  padding: 14px;
  border-top: 1px solid var(--border-soft);
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
}
#site-footer:empty { display: none; }

/* ---------- modal ---------- */

#modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(4, 6, 10, .55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
#modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  min-width: 340px;
  max-width: 520px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 18px 50px rgba(0,0,0,.5);
  animation: card-in .18s ease-out;
}
#modal h3 { margin: 0 0 12px; font-size: 1.05rem; }
#modal h4 { margin: 18px 0 8px; font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); }
#modal p { margin: 0 0 10px; line-height: 1.45; }
#modal label { display: block; font-size: .82rem; color: var(--text-dim); margin: 8px 0 3px; }
#modal input[type=password], #modal input[type=text], #modal input[type=date], #modal select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  margin: 2px 0 6px;
  outline: none;
  font-family: inherit;
}
#modal input:focus, #modal select:focus { border-color: var(--accent); }
#modal .err { color: var(--red); font-size: .85rem; min-height: 1.1em; }
#modal .ok-msg { color: var(--green); font-size: .85rem; min-height: 1.1em; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }
.modal-actions .primary { background: var(--accent); color: var(--accent-ink); border: none; font-weight: 650; }
.modal-actions .primary:hover { filter: brightness(1.1); color: var(--accent-ink); }
.modal-actions .danger { border-color: var(--red); color: var(--red); }
.modal-actions .danger:hover { background: var(--red); color: #fff; }

.settings-section { border-top: 1px solid var(--border-soft); padding-top: 4px; }
.user-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: .9rem;
}
.user-row .uname { font-weight: 600; }
.user-row .badge-you { color: var(--text-faint); font-size: .74rem; font-family: var(--mono); margin-left: 6px; }
.link-danger { background: none; border: none; color: var(--red); cursor: pointer; font-size: .82rem; }
.link-danger:hover { text-decoration: underline; }
.theme-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.theme-swatch {
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: .8rem;
  display: flex; align-items: center; gap: 6px;
  background: var(--bg);
  color: var(--text);
}
.theme-swatch.active { border-color: var(--accent); }
.theme-swatch .dots { display: inline-flex; gap: 3px; }
.theme-swatch .dots i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.logo-preview { max-height: 40px; max-width: 150px; margin: 6px 0; display: block; }

@media (max-width: 680px) {
  #search { width: 130px; }
  #search:focus { width: 150px; }
  .brand-sub { display: none; }
  #status-pill #status-text { display: none; }
  .head-right { flex-basis: 100%; margin-left: 0; margin-top: 4px; }
  #modal { min-width: 0; }
}
