/* BirdWatch — committed dark theme. Palette roles per dataviz reference (dark column). */
:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232322;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;      /* series-1 dark */
  --accent-soft: rgba(57, 135, 229, 0.16);
  --live: #e66767;
  --good: #0ca30c;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; }

/* The [hidden] attribute must always win — several overlays below set an
   explicit display (grid/flex) that would otherwise override it and stay
   painted on top of the content they cover (e.g. the video-offline poster). */
[hidden] { display: none !important; }

body {
  background: var(--page);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.5;
}

main { max-width: 1180px; margin: 0 auto; padding: 0 20px 48px; }

/* ---- top bar ---- */
.topbar {
  max-width: 1180px; margin: 0 auto; padding: 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  font-size: 26px; background: var(--accent-soft); border: 1px solid var(--border);
  border-radius: 12px; width: 52px; height: 52px;
  display: grid; place-items: center;
}
.brand h1 { font-size: 22px; letter-spacing: -0.02em; }
.tag { color: var(--muted); font-size: 13px; }

.live-pill {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.08em;
  color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; padding: 8px 16px;
}
.live-pill .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--live); animation: pulse 1.6s ease-in-out infinite;
}
.live-pill.offline .dot { background: var(--muted); animation: none; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---- hero: video + activity ---- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; }
.video-wrap {
  position: relative; background: #000;
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); aspect-ratio: 16 / 9;
}
.video-wrap video { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-overlay { position: absolute; inset: 0; pointer-events: none; padding: 14px; }
.detect-chip {
  position: absolute; left: 14px; bottom: 14px;
  background: rgba(13, 13, 13, 0.78); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 14px; font-size: 14px; font-weight: 600;
}
.detect-chip::before { content: "●  "; color: var(--good); }
.video-offline {
  position: absolute; inset: 0; display: grid; place-content: center;
  text-align: center; gap: 10px; color: var(--ink-2);
  background: radial-gradient(ellipse at center, #1c1c1b 0%, #0d0d0d 100%);
}
.video-offline span { font-size: 44px; }

.activity {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; min-height: 0;
}
.activity h2 { font-size: 15px; margin-bottom: 12px; color: var(--ink-2); }
.feed { list-style: none; padding: 0; overflow-y: auto; max-height: 420px; }
.feed li {
  padding: 10px 0; border-bottom: 1px solid var(--grid);
  font-size: 13.5px; display: flex; gap: 10px; align-items: baseline;
}
.feed li:last-child { border-bottom: 0; }
.feed .when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.feed .what strong { font-weight: 600; }
.feed li.fresh { animation: slideIn 0.4s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } }
.feed-empty { color: var(--muted); font-size: 13.5px; }

/* ---- stats ---- */
.stats-section, .gallery-section { margin-top: 36px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.section-head h2 { font-size: 19px; letter-spacing: -0.01em; }

.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px; flex-wrap: wrap; }
.tabs button {
  border: 0; background: transparent; color: var(--ink-2);
  font: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 13px; border-radius: 999px; cursor: pointer;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { background: var(--accent-soft); color: var(--ink); }
.tabs .sep { width: 1px; background: var(--grid); margin: 4px 2px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 12px; }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.tile .label { color: var(--muted); font-size: 12.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.tile .value { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; }
.tile .sub { color: var(--ink-2); font-size: 12.5px; }

.chart-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.chart-card h3 { font-size: 15px; color: var(--ink-2); margin-bottom: 14px; }
.chart-card .unit { color: var(--muted); font-weight: 400; }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 190px 1fr 44px; align-items: center; gap: 12px; font-size: 13.5px; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .name.unid { color: var(--muted); font-style: italic; }
.bar-track { background: var(--surface-2); border-radius: 4px; height: 18px; overflow: hidden; }
.bar-fill {
  height: 100%; background: var(--accent);
  border-radius: 0 4px 4px 0; min-width: 3px;
  transition: width 0.45s ease;
}
.bar-row .num { color: var(--ink-2); font-variant-numeric: tabular-nums; text-align: right; }

/* ---- gallery / voting ---- */
.voter-box { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.voter-box input {
  background: var(--surface); border: 1px solid var(--border); color: var(--ink);
  border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 13.5px; width: 160px;
}
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
}
.card .thumb { aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; font-size: 40px; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .body { padding: 12px 14px 14px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.card .species { font-weight: 700; font-size: 15px; }
.card .meta { color: var(--muted); font-size: 12.5px; display: flex; justify-content: space-between; gap: 8px; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
  border-radius: 6px; padding: 2px 7px; vertical-align: 2px; margin-left: 6px;
}
.badge.ai { background: var(--accent-soft); color: var(--accent); }
.badge.community { background: rgba(12, 163, 12, 0.15); color: var(--good); }
.badge.none { background: var(--surface-2); color: var(--muted); }

.vote { display: flex; gap: 6px; }
.vote input {
  flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--ink); border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 13px;
}
.vote button {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  font: inherit; font-size: 13px; font-weight: 600; padding: 7px 12px; cursor: pointer;
}
.vote button:hover { filter: brightness(1.1); }
.vote button.not-bird {
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.vote-done { color: var(--good); font-size: 13px; font-weight: 600; }

footer { max-width: 1180px; margin: 0 auto; padding: 24px 20px 40px; color: var(--muted); font-size: 12.5px; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .feed { max-height: 220px; }
  .bar-row { grid-template-columns: 120px 1fr 40px; }
}
