: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;
}

/* layout stage: the feed flanked by side panels, tight channel to the markets */
#stage { flex: 1; display: flex; min-height: 0; gap: 6px; }

.vticker {
  flex-shrink: 0; overflow-y: auto; scrollbar-width: none;
  padding: 10px; display: flex; flex-direction: column;
}
.vticker::-webkit-scrollbar { display: none; }
#ticker-left  { width: 160px; }   /* reserved empty — for future widgets */
#ticker-right { width: calc(2 * var(--cell) + 30px); }   /* two columns of news-sized cards */
.vtrack { display: flex; flex-direction: column; gap: 10px; flex: 1 1 auto; }
#ticker-right .vtrack {
  display: grid;
  grid-template-columns: repeat(2, var(--cell));   /* each card as wide as a news card */
  grid-auto-rows: 158px;
  gap: 10px;
  flex: 0 0 auto;
}
/* static market cards, styled like the weather corner card; stretch to fill the column */
.vq {
  display: flex; flex-direction: column; justify-content: center;
  background: rgba(11, 14, 20, 0.72); backdrop-filter: blur(4px);
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 20px;
}
.vq .vlabel { font-size: 14px; letter-spacing: 0.5px; text-transform: uppercase; color: var(--muted); }
.vq .vval { font-size: 30px; font-weight: 600; color: var(--text); margin-top: 5px; font-variant-numeric: tabular-nums; }
.vq .chg { font-size: 18px; margin-top: 3px; font-variant-numeric: tabular-nums; }
.vq .up { color: #46c46e; }
.vq .down { color: #e5604d; }

/* mood tint — an edge wash whose colour and strength track the news mood */
#mood {
  position: fixed; inset: 0; pointer-events: none; z-index: 50; opacity: 0;
  background: radial-gradient(125% 95% at 50% 50%, transparent 46%, var(--mood, transparent) 132%);
  transition: opacity 1.4s ease, background 1.4s ease;
}

/* weather + clock corner */
#corner {
  position: fixed; top: 54px; left: 14px; z-index: 8;
  background: rgba(11, 14, 20, 0.72); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; text-align: left; pointer-events: none;
  font-variant-numeric: tabular-nums;
}
#corner .clock { font-size: 22px; font-weight: 600; letter-spacing: 1px; color: var(--text); }
#corner .date { font-size: 11px; color: var(--muted); margin-top: 1px; }
#corner .wx { font-size: 12px; color: var(--muted); margin-top: 5px; }
#corner .wx .glyph { font-size: 14px; }

/* scroll viewport — side panels + the 10px stage gap provide the framing */
#feed { flex: 1; overflow-y: scroll; scrollbar-width: none; padding-inline: 0; }
#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 0;       /* right-align so the wall meets the market cards */
  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); }

/* surging story — breaking highlight */
.tile.surge { border-color: #ff5a36; }
.tile.surge { animation: surgepulse 2.4s ease-in-out infinite; }
@keyframes surgepulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,90,54,0); }
  50%      { box-shadow: 0 0 0 2px rgba(255,90,54,0.5), 0 0 16px rgba(255,90,54,0.3); }
}
.breaking {
  font-size: 10px; font-weight: 800; letter-spacing: 1px;
  padding: 2px 7px; border-radius: 4px; color: #fff; background: #ff5a36;
}

.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; }
  .vticker { display: none; }   /* reclaim full width on phones */
  #corner { top: auto; bottom: 12px; left: 12px; }   /* clear the wrapped topbar */
}
@media (max-width: 380px) {
  :root { --cell: 200px; }
}
