:root {
  --bg: #0b0d12;
  --card: #11141b;
  --muted: #98a2b3;
  --text: #e5e7eb;
  --glass: rgba(255, 255, 255, .06);
  --glass-border: rgba(255, 255, 255, .12);
  --accent: #7c3aed;
}

/* Reset and global styles */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg) 0%, #0a0c10 100%);
  font-size: 0.875rem; /* 14px relative */
  line-height: 1.5;
  font-family: system-ui, -apple-system, Segoe UI, Inter, Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

/* Top bar styles */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(90deg, var(--bg) 0%, #0b0f16 100%);
  border-bottom: 1px solid var(--glass-border);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02rem;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 0.875rem;
  transition: color .2s ease;
}

.nav a:hover {
  color: #fff;
}

.api-pill {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--glass-border);
  border-radius: 9999px;
  color: #cbd5e1;
  opacity: .85;
}

/* Layout containers */
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 0.625rem;
  padding: 0.625rem;
  margin-bottom: 0.75rem;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.controls select,
.controls input {
  background: #0e1117;
  color: var(--text);
  border: 1px solid #1f2430;
  border-radius: 0.5rem;
  padding: 0.375rem 0.5rem;
}

.controls .chk {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
}

.sort {
  border: 1px dashed var(--glass-border);
  border-radius: 0.5rem;
  padding: 0.25rem 0.5rem;
}

.sort legend {
  font-size: 0.75rem;
  color: var(--muted);
}

.btn {
  background: linear-gradient(180deg, #1c1f2a, #131720);
  color: #fff;
  border: 1px solid #2a3142;
  border-radius: 0.625rem;
  padding: 0.5rem 0.625rem;
  cursor: pointer;
  transition: border-color .2s ease;
}

.btn:hover {
  border-color: #3d4961;
}

.status {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.75rem;
}

/* Grid and cards */
.grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 0.75rem;
}

.card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 0.75rem;
  padding: 0.75rem;
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.4);
}

.card.full {
  grid-column: 1 / -1;
}

.bleed {
  padding: 0;
}

/* Map container */
#map {
  height: 60vh;
  min-height: 420px;
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 22px 45px rgba(0, 0, 0, 0.55);
}

.metrics {
  display: flex;
  gap: 1.125rem;
}

.metric .k {
  font-size: 1.5rem;
  font-weight: 700;
}

.metric .klabel {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Updated feed styles */
.feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  /* Let the page dictate height instead of a tiny internal scroller */
  max-height: none;
  overflow: visible;
}

/* Latest list in the summary card: allow it to run down the card and scroll with the page */
#summaryCard .feed {
  max-height: none;
  overflow: visible;
}

.feed li {
  border: 1px solid var(--glass-border);
  border-radius: 0.625rem;
  padding: 0.5rem;
  background: rgba(15, 18, 30, 0.9);
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.feed li:hover {
  border-color: rgba(124, 58, 237, 0.9);
  background: rgba(17, 24, 39, 0.98);
  transform: translateY(-1px);
}

.feed a {
  color: #cbd5e1;
  text-decoration: none;
  transition: color .2s ease;
}

.feed a:hover {
  color: #fff;
  text-decoration: underline;
}

/* Skeleton loader */
.skel {
  height: 56px;
  border-radius: 0.625rem;
  background: #0e121a;
  border: 1px solid #1f2430;
  position: relative;
  overflow: hidden;
}

.skel::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .06), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

/* Toast notifications */
.toast {
  position: fixed;
  right: 0.75rem;
  bottom: 0.75rem;
  background: #11141b;
  border: 1px solid var(--glass-border);
  border-radius: 0.625rem;
  padding: 0.625rem;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .25s, transform .25s;
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Leaflet overrides */
.leaflet-container {
  background: #0a0c10;
}

.leaflet-popup-content-wrapper {
  background: #0f1420;
  color: var(--text);
  border: 1px solid var(--glass-border);
}

.leaflet-popup-tip {
  background: #0f1420;
}

/* Custom markers */
.qo-marker {
  position: relative;
  width: 14px;
  height: 14px;
  transform: translate(-7px, -7px);
}

.qo-marker .dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--col, var(--accent));
  border: 2px solid rgba(255, 255, 255, .9);
  box-shadow: 0 0 10px var(--col, var(--accent));
}

.qo-marker .ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid var(--cola, rgba(124, 58, 237, .35));
  animation: pulse 1.8s ease-out infinite;
}

@keyframes pulse {
  0% {
    transform: translate(-50%, -50%) scale(.8);
    opacity: .9;
  }
  70%,
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(2.2);
  }
}

/* Intro orbit overlay */
#introOverlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: radial-gradient(circle at 20% 0%, #111827 0%, #020617 60%, #000 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

#introOverlay.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.intro-orbit {
  position: relative;
  width: 220px;
  height: 220px;
}

.intro-core {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 0.75rem 1.4rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 0 30px rgba(96, 165, 250, 0.5), 0 0 0 1px rgba(15, 23, 42, 0.9);
  text-align: center;
}

.intro-label-main {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
}

.intro-label-sub {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.7rem;
  color: var(--muted);
}

.orbit {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 0 18px rgba(37, 99, 235, 0.4);
  animation: spinOrbit 18s linear infinite;
}

.orbit-1 {
  width: 220px;
  height: 220px;
}

.orbit-2 {
  width: 160px;
  height: 160px;
  animation-duration: 13s;
  animation-direction: reverse;
  opacity: 0.9;
}

.orbit-3 {
  width: 100px;
  height: 100px;
  animation-duration: 9s;
  opacity: 0.8;
}

.orbit span {
  position: absolute;
  top: 50%;
  left: 100%;
  transform: translate(-50%, -50%);
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #e5e7eb, #7dd3fc);
  box-shadow: 0 0 12px #7dd3fc;
}

@keyframes spinOrbit {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* TrendScope bar chart */
.qo-barchart {
  display: block;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.qo-barchart-bg {
  fill: rgba(15, 23, 42, 0.9);
}

.qo-barchart-bar {
  fill: #38bdf8;
  opacity: 0.9;
}

.qo-barchart-bar:hover {
  opacity: 1;
}

.qo-barchart-label,
.qo-barchart-value {
  fill: rgba(226, 232, 240, 0.9);
  font-size: 9px;
}

.qo-chart-empty {
  font-size: 0.75rem;
  color: rgba(148, 163, 184, 0.9);
  padding: 0.25rem 0.5rem;
}

/* QuietOrbit ticker: subtle fade-in + breathing based on speed */
.ticker__viewport {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 450ms ease-out, transform 450ms ease-out;
}

.ticker--ready .ticker__viewport {
  opacity: 1;
  transform: translateY(0);
}

.ticker__segment {
  opacity: 0.9;
  transition: opacity 600ms ease-out;
}

.ticker--slow .ticker__segment {
  opacity: 0.7;
}

.ticker--fast .ticker__segment {
  opacity: 1;
}

/* Map ticker + on-map billboard labels */

#tickerTrack {
  line-height: 1.2;
  overflow: hidden;
  white-space: nowrap;
}

.ticker-item {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding-right: 2.5ch; /* space between items */
}

.ticker-item .pill {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--glass-border);
  color: var(--muted);
}

/* On-map scrolling billboard labels */
.qo-pin-wrap {
  display: inline-flex;
  align-items: center;
}

.qo-scroll-label {
  display: inline-block;
  max-width: 180px;
  margin-left: 0.35rem;
  overflow: hidden;
  white-space: nowrap;
}

.qo-scroll-label-inner {
  display: inline-block;
  padding-right: 3rem;
  will-change: transform;
  animation: qo-label-marquee var(--scroll-duration, 18s) linear infinite;
}

.qo-static-label {
  display: inline-block;
  margin-left: 0.35rem;
  max-width: 210px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes qo-label-marquee {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* Media queries */
@media (max-width: 1000px) {
  .grid {
    grid-template-columns: 1fr;
  }

  #map {
    height: 50vh;
    min-height: 320px;
  }
}

/* Top Trends card + table tweaks */
#trendsCard {
  display: flex;
  flex-direction: column;
}

#trendsTable {
  width: 100%;
  border-collapse: collapse;
}

#trendsTable thead th {
  padding: 0.35rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

#trendsTable tbody tr {
  background: rgba(15, 23, 42, 0.6); /* lighter than the old solid dark block */
}

#trendsTable tbody tr:nth-child(even) {
  background: rgba(15, 23, 42, 0.4);
}

#trendsTable tbody tr:hover {
  background: rgba(148, 163, 184, 0.14);
}

#trendsTable td {
  padding: 0.3rem 0.45rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.9);
}
