/* Dartcom-Inspired Observatory Weather Dashboard */
:root {
  --bg: #0a111f;
  --bg-elev: #111b2e;
  --bg-soft: #16233a;
  --border: #233452;
  --text: #eef4fc;
  --muted: #8ea3c2;
  --accent: #38bdf8;
  --temp: #fb923c;
  --dew: #38bdf8;
  --wind: #34d399;
  --gust: #f43f5e;
  --press: #a78bfa;
  --solar: #facc15;
  --rain: #60a5fa;
  --cum: #22d3ee;
  --ok: #22c55e;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
}

[data-theme="light"] {
  --bg: #eef3f8;
  --bg-elev: #ffffff;
  --bg-soft: #f4f7fb;
  --border: #d5e0ec;
  --text: #0f172a;
  --muted: #52647c;
  --accent: #0284c7;
  --temp: #ea580c;
  --dew: #0284c7;
  --wind: #059669;
  --gust: #e11d48;
  --press: #7c3aed;
  --solar: #ca8a04;
  --rain: #2563eb;
  --cum: #0891b2;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.4;
}

/* Header & Forecast Ticker */
.topbar {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-inner, .forecast-inner, .container, .footer {
  max-width: 1420px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  padding-bottom: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.status-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok);
  flex-shrink: 0;
}

.status-dot.offline {
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.updated-time {
  font-size: 0.8rem;
  color: var(--muted);
  font-family: Consolas, Monaco, monospace;
}

.icon-btn, .mini-btn, .primary-btn {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}

.icon-btn:hover, .mini-btn:hover { border-color: var(--accent); }
.primary-btn {
  background: var(--accent);
  color: #06101f;
  border-color: var(--accent);
}

.forecast-bar {
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
  padding: 8px 0;
}

.forecast-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

.forecast-label {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  margin-right: 6px;
}

.forecast-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  font-size: 0.76rem;
  padding: 3px 9px;
  border-radius: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--muted);
}

/* Main Layout */
.container {
  padding-top: 18px;
  padding-bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.card-header h2, .card-header h3 {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.muted { color: var(--muted); font-size: 0.8rem; }

.badge-soft {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--accent);
}

/* Hero Grid */
.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 1.35fr;
  gap: 16px;
  align-items: stretch;
}

.webcam-card {
  display: flex;
  flex-direction: column;
}

.webcam-frame {
  flex: 1;
  background: #050912;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
}

.webcam-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-actions { display: flex; gap: 6px; }

.instruments-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.metric-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.big-reading {
  font-size: 2.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 4px 0 10px;
}

.big-reading.sm { font-size: 1.85rem; margin: 2px 0 6px; }
.big-reading.center { text-align: center; }

.unit {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
  margin-left: 4px;
}

.sub-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.sub-grid.three { grid-template-columns: repeat(3, 1fr); }
.sub-grid.four { grid-template-columns: repeat(4, 1fr); }

.sub-grid > div {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
}

.lbl {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-footer-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--muted);
  flex-wrap: wrap;
}

/* Wind Compass SVG */
.wind-layout {
  display: flex;
  align-items: center;
  gap: 12px;
}

.compass-svg {
  width: 118px;
  height: 118px;
  flex-shrink: 0;
}

.dial-ring { fill: var(--bg-soft); stroke: var(--border); stroke-width: 2.5; }
.dial-inner { fill: none; stroke: var(--border); stroke-dasharray: 3 4; stroke-width: 1; }
.dial-cardinal { fill: var(--muted); font-size: 11px; font-weight: 700; }
.needle-head { fill: var(--wind); }
.needle-shaft { stroke: var(--wind); stroke-width: 2.5; stroke-linecap: round; }
.needle-hub { fill: var(--text); }

.wind-dir-txt {
  font-weight: 700;
  color: var(--wind);
  font-size: 0.9rem;
  margin-bottom: 6px;
}

.sub-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.8rem;
  color: var(--muted);
}

.sub-list strong { color: var(--text); }

/* Barometer SVG */
.baro-svg {
  width: 100%;
  max-width: 175px;
  height: 88px;
  margin: 0 auto;
  display: block;
}

.gauge-track { fill: none; stroke: var(--border); stroke-width: 9; stroke-linecap: round; }
.gauge-low { fill: none; stroke: rgba(244, 63, 94, 0.55); stroke-width: 9; stroke-linecap: round; }
.gauge-high { fill: none; stroke: rgba(52, 211, 153, 0.55); stroke-width: 9; stroke-linecap: round; }
.baro-needle { stroke: var(--press); stroke-width: 3; stroke-linecap: round; }
.gauge-tick { fill: var(--muted); font-size: 9.5px; font-family: monospace; }

/* Solar / Sunshine */
.sunshine-strip { margin-bottom: 10px; }
.sunshine-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 6px;
  color: var(--muted);
}
.sunshine-row strong { color: var(--text); }
.progress-track {
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #eab308, #fde047);
  transition: width 0.5s ease;
}

/* 7-Day Outlook Strip */
.outlook-week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}

.outlook-day {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.outlook-day.tomorrow-hl {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.08);
}

.outlook-icon { font-size: 1.65rem; line-height: 1.1; }
.outlook-temps { font-weight: 700; font-size: 0.92rem; }
.outlook-temps .hi { color: var(--temp); }
.outlook-temps .lo { color: var(--accent); }
.outlook-meta { font-size: 0.72rem; color: var(--muted); }

/* Rainfall Banner */
.rain-stats-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}

.rain-stat {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  text-align: center;
}

.rain-stat.highlight {
  border-color: rgba(96, 165, 250, 0.55);
  background: rgba(96, 165, 250, 0.1);
}

.rain-stat strong {
  font-size: 1.08rem;
  color: var(--rain);
}

/* Charts Section */
.charts-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.section-toolbar h2 { margin: 0; font-size: 1.05rem; }

.segmented {
  display: inline-flex;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
  gap: 3px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--accent);
  color: #06101f;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  height: 225px;
}

.canvas-wrap.tall {
  height: 280px;
}

/* Historical Data Explorer & Year Comparison */
.explorer-section, .compare-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-btn {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.chip-btn:hover { border-color: var(--accent); color: var(--text); }
.chip-btn.active {
  background: var(--accent);
  color: #06101f;
  border-color: var(--accent);
}

.explorer-controls, .compare-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.compare-controls { align-items: center; }

.control-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.control-group label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ctrl-input {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.ctrl-input.sm { padding: 5px 8px; }

.metric-toggles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
}

.lbl-inline {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  margin-right: 4px;
}

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  padding: 4px 9px;
  border-radius: 7px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.toggle-pill input { accent-color: var(--accent); cursor: pointer; }
.toggle-pill.compact { padding: 5px 9px; }

.query-summary-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.compare-deltas-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.delta-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.delta-card strong { font-size: 1.02rem; }

.delta-pill {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--accent);
}

.delta-pill.up { color: #34d399; }
.delta-pill.down { color: #fb923c; }

a.mini-btn { text-decoration: none; display: inline-flex; align-items: center; }

.canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.76rem;
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 4px;
}

.c-temp { background: var(--temp); }
.c-dew { background: var(--dew); }
.c-wind { background: var(--wind); }
.c-gust { background: var(--gust); }
.c-press { background: var(--press); }
.c-solar { background: var(--solar); }
.c-rain { background: var(--rain); }
.c-cum { background: var(--cum); }

/* Almanac Section */
.almanac-grid, .bottom-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.sun-arc-svg {
  width: 100%;
  max-width: 360px;
  height: 120px;
  display: block;
  margin: 0 auto 8px;
}

.horizon-line { stroke: var(--border); stroke-width: 1.5; stroke-dasharray: 4 4; }
.sun-path-track { fill: none; stroke: rgba(250, 204, 21, 0.45); stroke-width: 2.5; }
.sun-dot { fill: #facc15; filter: drop-shadow(0 0 6px rgba(250, 204, 21, 0.8)); }
.arc-lbl { fill: var(--muted); font-size: 10.5px; font-weight: 600; }

.moon-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.moon-svg { width: 56px; height: 56px; flex-shrink: 0; }

.seasons-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.season-item {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.season-item.next-up {
  border-color: rgba(56, 189, 248, 0.55);
}

.season-days {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

/* Records Table */
.table-wrap { overflow-x: auto; }
.records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.records-table th, .records-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.records-table th {
  color: var(--muted);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rec-time {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
}

.extra-sensors-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.extra-chip {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

/* Footer */
.footer {
  padding-top: 14px;
  padding-bottom: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--muted);
}

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal[hidden] { display: none; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, 0.78);
}

.modal-box {
  position: relative;
  z-index: 1;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.cam-modal-box { max-width: 1040px; }
.cam-modal-box img { width: 100%; border-radius: 8px; display: block; }

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.modal-head h3 { margin: 0; }

.field-lbl {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin: 12px 0 6px;
}

.text-input {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 0.9rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

/* Responsive Breakpoints (Tablet + Android Phone APK) */
@media (max-width: 1120px) {
  .hero-grid { grid-template-columns: 1fr; }
  .rain-stats-grid, .outlook-week-grid { grid-template-columns: repeat(4, 1fr); }
  .query-summary-grid { grid-template-columns: repeat(3, 1fr); }
  .compare-deltas-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 780px) {
  .instruments-grid, .charts-grid, .almanac-grid, .bottom-grid {
    grid-template-columns: 1fr;
  }
  .rain-stats-grid, .query-summary-grid, .outlook-week-grid { grid-template-columns: repeat(2, 1fr); }
  .compare-deltas-grid { grid-template-columns: 1fr; }
  .sub-grid.four { grid-template-columns: repeat(2, 1fr); }
  .seasons-list { grid-template-columns: 1fr; }
  .big-reading { font-size: 2.15rem; }
}
