:root {
  --bg: #0f1216;
  --surface: #171b21;
  --surface-2: #1f242c;
  --border: #2a313b;
  --text: #e7ecf2;
  --muted: #93a1b1;
  --accent: #4da3ff;
  --accent-2: #ff5c8a;
  --good: #3fd18b;
  --radius: 10px;
  --pad: 16px;
  font-size: 15px;
}

* {
  box-sizing: border-box;
}

/* The HTML `hidden` attribute must beat display rules like .login-screen /
   .topbar / .player (equal specificity would otherwise let display win). */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 96px; /* room for player bar */
}

/* ---- Topbar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px var(--pad);
  background: rgba(15, 18, 22, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tabs button {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
}

.tabs button:hover {
  color: var(--text);
  background: var(--surface);
}

.tabs button.active {
  color: var(--text);
  background: var(--surface-2);
}

/* ---- Views ---- */
.view {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px var(--pad);
}

.view h2 {
  margin: 0 0 4px;
  font-size: 1.3rem;
}

.subhead {
  color: var(--muted);
  margin: 0 0 18px;
  font-size: 0.9rem;
}

/* ---- Cards / list items ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.item.read {
  opacity: 0.5;
}

.item-body {
  flex: 1;
  min-width: 0;
}

.item-kind {
  display: inline-block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bg);
  background: var(--muted);
  padding: 1px 7px;
  border-radius: 20px;
  vertical-align: middle;
}

.item-kind.episode {
  background: var(--accent);
}

.item-kind.article {
  background: var(--good);
}

.item-title {
  font-weight: 600;
  margin: 6px 0 4px;
  line-height: 1.3;
}

.item-title a {
  color: var(--text);
  text-decoration: none;
}

.item-title a:hover {
  color: var(--accent);
}

.item-snippet {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  margin: 4px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-meta {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 6px;
}

.item-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ---- Buttons ---- */
button.btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
}

button.btn:hover {
  border-color: var(--accent);
}

button.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121f;
  font-weight: 600;
}

button.btn.danger:hover {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

button.btn.small {
  padding: 4px 9px;
  font-size: 0.78rem;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.spread {
  justify-content: space-between;
}

input[type="text"],
input[type="url"],
input[type="search"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 11px;
  font-size: 0.9rem;
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

.grow {
  flex: 1;
  min-width: 120px;
}

.pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.pill {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 13px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
}

.pill.active {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--accent);
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 48px 0;
}

.muted {
  color: var(--muted);
}

/* ---- Player bar ---- */
.player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 18px;
  align-items: center;
  padding: 10px 18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.player-meta {
  min-width: 0;
}

.player-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-sub {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 320px;
}

.player-controls #seek {
  width: 200px;
}

.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
}

.icon-btn:hover {
  border-color: var(--accent);
}

.time {
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  min-width: 40px;
}

.player-target {
  display: flex;
  align-items: center;
  gap: 10px;
}

.target-pill {
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.target-pill.casting {
  color: var(--good);
  border-color: var(--good);
}

google-cast-launcher {
  width: 30px;
  height: 30px;
  cursor: pointer;
  --disconnected-color: var(--muted);
  --connected-color: var(--accent);
}

input[type="range"] {
  accent-color: var(--accent);
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 108px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  z-index: 30;
  font-size: 0.88rem;
}

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8vh;
  z-index: 40;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(620px, 92vw);
  max-height: 78vh;
  overflow: auto;
  padding: 20px;
}

/* ---- Account (topbar right) ---- */
.account {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

/* ---- Login gate ---- */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 44px 40px;
  max-width: 380px;
  width: 90vw;
}

.login-logo {
  font-size: 3rem;
  margin-bottom: 8px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.6rem;
}

.login-btn {
  display: inline-block;
  margin-top: 22px;
  text-decoration: none;
  padding: 11px 22px;
  font-size: 0.95rem;
}

@media (max-width: 720px) {
  .player {
    grid-template-columns: 1fr auto;
  }
  .player-target {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
  .player-controls {
    min-width: 0;
  }
  .player-controls #seek {
    width: 120px;
  }
}

/* ---- station genres ---- */
.feed-tag {
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 8px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  box-sizing: border-box;
}

/* Tags wrap within their own block (under the tag list, not the name), and
   are clipped to two rows: 2 * 20px chip + 6px row gap = 46px. */
.feed-tags {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  flex: 1;
  min-width: 0;
  max-height: 46px;
  overflow: hidden;
}

.search-results:not(:empty) {
  margin: 14px 0;
}

/* Actions pinned right; the left column shrinks so tags wrap inside it
   instead of pushing the Play/Delete buttons onto a new line. */
.station-card {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}
.station-main {
  flex: 1;
  min-width: 0;
}
.station-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.station-titlerow {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
}
input.genre-input {
  padding: 3px 9px;
  font-size: 0.82rem;
  width: 140px;
}

.saved-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 24px;
  margin-bottom: 10px;
}
.saved-title {
  font-size: 1.05rem;
  margin: 0 4px 0 0;
}
.genre-chip {
  font-size: 0.8rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
}
.genre-chip:hover {
  border-color: var(--accent);
}
.genre-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0f1216;
  font-weight: 600;
}
