:root {
  --bg: #0b0e14;
  --panel: #11151d;
  --border: #1d2430;
  --text: #d8dee9;
  --muted: #8a93a5;
  --accent: #5d8cc0;
  --cell: 336px;
  --gap: 10px;
  --maxw: 1340px;
  --row: 8px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 14, 20, 0.9);
  backdrop-filter: blur(6px);
  z-index: 10;
}
.brand { font-size: 13px; letter-spacing: 3px; font-weight: 600; }
.brand .sep { color: var(--muted); margin: 0 4px; }
.brand .wire { color: var(--accent); }
.controls { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }
.speed { display: flex; gap: 2px; }
.speed button {
  background: none; border: 1px solid var(--border); color: var(--muted);
  font-size: 11px; width: 30px; height: 22px; cursor: pointer; border-radius: 4px;
}
.speed button.active { color: var(--text); border-color: var(--accent); background: rgba(93,140,192,0.12); }
#pause-dot { opacity: 0; transition: opacity 0.2s; color: var(--accent); }
#pause-dot.on { opacity: 1; }

/* news radio */
.radio { display: flex; align-items: center; gap: 6px; }
#radio-toggle {
  width: 26px; height: 24px; border: 1px solid var(--border); background: none;
  color: var(--text); border-radius: 5px; cursor: pointer; font-size: 11px;
}
#radio-toggle.playing { color: var(--accent); border-color: var(--accent); background: rgba(93,140,192,0.12); }
#radio-select {
  background: #0d1119; color: var(--text); border: 1px solid var(--border);
  border-radius: 5px; font-size: 11px; padding: 3px 5px; max-width: 160px; cursor: pointer;
}

/* scroll viewport — gutters on the sides so the wall isn't edge-to-edge */
#feed { flex: 1; overflow-y: scroll; scrollbar-width: none; padding-inline: clamp(10px, 5vw, 64px); }
#feed::-webkit-scrollbar { display: none; }

#splash {
  text-align: center; color: var(--muted);
  padding-top: 35vh; font-size: 14px; letter-spacing: 1px;
}

/* the mosaic — content-fit masonry: fixed column width, height set by text.
   The fine --row track + JS-computed row spans pack cards with no wasted space. */
.wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--cell), 1fr));
  grid-auto-rows: var(--row);
  grid-auto-flow: row dense;
  gap: var(--gap);
  padding: var(--gap);
  max-width: var(--maxw);
  margin-inline: auto;
  border-inline: 1px solid var(--border);
}

.tile {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-self: start;          /* hug content height, don't stretch to the row span */
  padding: 16px;
  transition: transform 0.15s, filter 0.15s;
}
.tile:hover { transform: scale(1.012); filter: brightness(1.18); z-index: 2; }

/* importance drives width (column span) + font + colour; height follows the text */
.tile.feature,
.tile.wide { grid-column: span 2; }

/* importance-based colour: cool & dim for one-offs, hot for widely-covered */
.tile.heat-0 { background: #0f1620; border-color: #232d3b; }
.tile.heat-1 { background: #122440; border-color: #34527e; }
.tile.heat-2 { background: #0b3a44; border-color: #2f9aa8; }
.tile.heat-3 { background: #3c2c0e; border-color: #cf9a2f; }
.tile.heat-4 { background: #421710; border-color: #e85a30; }
.tile.heat-4 .badge, .tile.heat-3 .badge { box-shadow: 0 0 0 1px rgba(255,255,255,0.15); }

.meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 8px; }
.badge {
  font-size: 10px; font-weight: 700; letter-spacing: 1px;
  padding: 2px 7px; border-radius: 4px; color: #0b0e14;
}
.srcs {
  font-size: 10px; font-weight: 600; letter-spacing: 0.3px; color: #fff;
  background: rgba(0,0,0,0.5); padding: 2px 6px; border-radius: 4px;
}

.tile h2 {
  font-size: 19px; font-weight: 600; line-height: 1.28;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5; overflow: hidden;
}
.tile p {
  margin-top: 9px; font-size: 15px; line-height: 1.42; color: rgba(216,222,233,0.82);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden;
}
.tile .when { margin-top: auto; padding-top: 9px; font-size: 12.5px; color: rgba(216,222,233,0.7); }

/* small tiles: compact summary so the cell isn't overrun */
.tile.small h2 { font-size: 19px; -webkit-line-clamp: 4; }
.tile.small p  { -webkit-line-clamp: 2; }

/* wide / tall: larger headline */
.tile.wide h2, .tile.tall h2 { font-size: 24px; -webkit-line-clamp: 3; }

/* feature: hero text */
.tile.feature h2 { font-size: 36px; line-height: 1.15; -webkit-line-clamp: 4; }
.tile.feature p  { font-size: 18px; -webkit-line-clamp: 6; }

/* phones: keep headlines bold and readable */
@media (max-width: 620px) {
  :root { --cell: 250px; --gap: 8px; }
  .tile.feature h2 { font-size: 27px; }
  .tile.wide h2, .tile.tall h2 { font-size: 21px; }
  .tile h2 { font-size: 18px; }
}
@media (max-width: 380px) {
  :root { --cell: 200px; }
}
