:root {
  color-scheme: light;
  --bg: #eef3f5;
  --panel: #ffffff;
  --ink: #16212b;
  --muted: #607080;
  --line: #d5dfe5;
  --teal: #0f766e;
  --blue: #2563eb;
  --amber: #b45309;
  --quiet: #475569;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topnav {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
}

.audience-metrics {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.audience-metrics[hidden] {
  display: none;
}

.audience-metrics span + span {
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.audience-metrics strong {
  color: var(--ink);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.topnav a,
button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
  color: #253546;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  padding: 8px 11px;
  cursor: pointer;
}

.topnav a:hover,
button:hover {
  background: #eef3f5;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 25px;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  letter-spacing: 0;
}

#subtitle,
.section-head span,
.metric span,
.hour-detail,
.history-card span,
#latest-frame-meta {
  color: var(--muted);
  font-size: 13px;
}

.status {
  min-width: 170px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 12px;
  font-weight: 700;
  background: #f8fafc;
}

.status.likely_rideable,
.status.rideable_seen,
.status.activity_seen {
  color: #064e3b;
  background: #dff7ee;
  border-color: #99dec7;
}

.status.windy_no_detections {
  color: #1e3a8a;
  background: #dbeafe;
  border-color: #9dbbf7;
}

.status.outside_window,
.status.no_data,
.status.quiet {
  color: var(--quiet);
  background: #f1f5f9;
}

main {
  display: grid;
  gap: 16px;
  padding: 18px;
}

section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.hero {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 13px;
  background: #fbfdfe;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 26px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.frame-strip {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.frame-media {
  display: grid;
  gap: 9px;
}

.frame-media img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 7px;
  border: 1px solid #263544;
  background: #16212b;
}

.webcam-link {
  justify-self: start;
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.webcam-link:hover {
  color: #115e59;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 12px;
}

.chart {
  display: grid;
  gap: 4px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 5px;
  border-radius: 3px;
  vertical-align: -1px;
}

.detect-swatch {
  background: #0f766e;
}

.wind-swatch {
  background: #2563eb;
}

.hour-row {
  border-bottom: 1px solid #edf2f5;
}

.hour-row:last-child {
  border-bottom: 0;
}

.hour-row summary {
  display: grid;
  grid-template-columns: 22px 72px minmax(0, 1fr) 68px minmax(120px, 1fr) minmax(170px, auto);
  gap: 10px;
  align-items: center;
  min-height: 42px;
  cursor: pointer;
  list-style: none;
}

.hour-row summary::-webkit-details-marker {
  display: none;
}

.chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  transition: transform 120ms ease;
}

.hour-row[open] .chevron {
  transform: rotate(90deg);
}

.hour-label {
  font-weight: 700;
  color: #334155;
  font-size: 13px;
}

.bar,
.wind-bar {
  position: relative;
  height: 23px;
  background: #eef3f5;
  border: 1px solid #dce5eb;
  border-radius: 6px;
  overflow: hidden;
}

.bar-fill,
.wind-fill {
  display: block;
  height: 100%;
  min-width: 0;
}

.bar-fill {
  background: linear-gradient(90deg, var(--teal), #14b8a6);
}

.wind-fill {
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 1;
  background: linear-gradient(90deg, var(--blue), #60a5fa);
}

.wind-marker {
  position: absolute;
  top: 2px;
  bottom: 2px;
  z-index: 2;
  width: 2px;
  border-radius: 999px;
  transform: translateX(-1px);
}

.wind-marker.low {
  background: #f59e0b;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.75);
}

.wind-marker.high {
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.85);
}

.hour-count,
.hour-wind {
  color: #253546;
  font-size: 13px;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.hour-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 12px;
  padding: 6px 0 14px 104px;
}

.hour-detail img {
  width: 100%;
  max-height: 56vh;
  object-fit: contain;
  border-radius: 7px;
  background: #16212b;
  border: 1px solid #263544;
}

.frame-facts {
  display: grid;
  gap: 5px;
  align-content: start;
}

.history {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.history-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: #fbfdfe;
}

.history-card[open] {
  grid-column: 1 / -1;
}

.history-summary {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  cursor: pointer;
  list-style: none;
}

.history-summary::-webkit-details-marker {
  display: none;
}

.history-card[open] > .history-summary .chevron {
  transform: rotate(90deg);
}

.history-summary-copy {
  display: grid;
  gap: 3px;
}

.history-card strong {
  display: block;
  margin-bottom: 6px;
}

.history-detail {
  display: grid;
  gap: 3px;
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.history-hour {
  display: grid;
  grid-template-columns: 80px minmax(95px, 0.8fr) minmax(110px, 1fr) minmax(120px, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 34px;
  padding: 5px 7px;
  border-radius: 5px;
  color: #334155;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.history-hour:nth-child(odd) {
  background: #f1f5f9;
}

.history-hour-head {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.error {
  color: #991b1b;
}

.admin-grid,
.admin-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.admin-grid label,
.admin-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.admin-grid input,
.admin-form input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  color: var(--ink);
  font: inherit;
  background: #fff;
}

.checkbox-row {
  align-content: end;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.span-all {
  grid-column: 1 / -1;
}

.admin-result {
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: #f8fafc;
  color: #253546;
  font-size: 12px;
}

@media (max-width: 850px) {
  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-left: 0;
  }

  .topnav {
    margin-left: 0;
  }

  .status {
    min-width: 0;
  }

  .audience-metrics {
    order: 3;
    width: 100%;
  }

  .hero {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .frame-strip,
  .hour-detail,
  .admin-grid,
  .admin-form {
    grid-template-columns: 1fr;
  }

  .hour-detail {
    padding-left: 0;
  }

  .hour-row summary {
    grid-template-columns: 22px 58px minmax(0, 1fr) 58px;
  }

  .wind-bar,
  .hour-wind {
    grid-column: 3 / 5;
  }

  .history-hour {
    grid-template-columns: 70px repeat(3, minmax(90px, 1fr));
    overflow-x: auto;
  }
}

@media (max-width: 520px) {
  main {
    padding: 12px;
  }

  section {
    padding: 13px;
  }

  .hero {
    grid-template-columns: 1fr;
  }
}
