:root {
  --primary: #1a73e8;
  --primary-dark: #0d47a1;
  --secondary: #34a853;
  --warning: #fbbc05;
  --danger: #ea4335;

  --bg: #f5f7fa;
  --text: #202124;
  --muted: #5f6368;
  --card: #ffffff;
  --panel: #ffffff;          /* light panel for Default mode */
  --panel-fg: #111827;       /* dark text on light panels */
  --border: #dadce0;
  --accent: #0b5ed7;
  --rwy-threshold: #ffffff;/* runway threshold color */


  /* Gauges & SVG theme tokens */
  --gauge-ring-fill: rgba(0,0,0,.08);
  --gauge-ring-stroke: rgba(0,0,0,.22);
  --svg-tick: rgba(0,0,0,.6);
  --svg-tick-major: rgba(0,0,0,.8);
  --svg-tick-cardinal: #111;
  --svg-label: rgba(0,0,0,.85);

  --rwy-fill: #0d0d0d;
  --rwy-centerline: #ffffff;
  --rwy-num: #ffffff;

  --wind-needle: #2132cf; /* was magenta; themeable */

  --zone-good: #10b981;
  --zone-warn: #f59e0b;
  --zone-bad:  #ef4444;

  --needle-blade: #ffffff;
  --needle-handle:#101214;
  --needle-hub:   #0c0d0e;
  --needle-hub-hi:rgba(255,255,255,.35);

  --cloud-grad-top: #ffffff;
  --cloud-grad-bottom: #d5dbe3;
  --cloud-stroke: #ffffff;
  --cloud-grid: rgba(0,0,0,.12);
  --cloud-grid-text: rgba(0,0,0,.6);
  --cloud-label: #e5e7eb;
  --cloud-label-strong: #c7d2fe;
  --cloud-label-text: #111827;
  --shadow-color: #000000;

  /* Raw/TAF table backgrounds */
  --raw-bg: #f1f5f9;

  /* Gauge height (kept equal across compass/speed/clouds) */
  --g-h: 320px;
}
.theme-dark {
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --secondary: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;

  --bg: #0f172a;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --card: #111827;
  --panel: #0b1220;          /* dark panel for Dark mode */
  --panel-fg: #e5e7eb;       /* light text on dark panels */
  --rwy-threshold: #ffffff;
  --border: #334155;
  --accent: #2563eb;

  --gauge-ring-fill: rgba(255,255,255,.05);
  --gauge-ring-stroke: rgba(255,255,255,.22);
  --svg-tick: rgba(255,255,255,.55);
  --svg-tick-major: rgba(255,255,255,.75);
  --svg-tick-cardinal: #ffffff;
  --svg-label: rgba(255,255,255,.9);

  --rwy-fill: #0f0f12;
  --rwy-centerline: #f9fafb;
  --rwy-num: #ffffff;

  --wind-needle: #69b7d6;

  --zone-good: #22c55e;
  --zone-warn: #f59e0b;
  --zone-bad:  #ef4444;

  --needle-blade: #ffffff;
  --needle-handle:#0b0c0f;
  --needle-hub:   #0a0b0c;
  --needle-hub-hi:rgba(255,255,255,.4);

  --cloud-grad-top: #e5e7eb;
  --cloud-grad-bottom: #b6c0cc;
  --cloud-stroke: #ffffff;
  --cloud-grid: rgba(255,255,255,.15);
  --cloud-grid-text: rgba(255,255,255,.75);
  --cloud-label: #273244;
  --cloud-label-strong: #1f2a3a;
  --cloud-label-text: #e5e7eb;
  --shadow-color: #000000;

  --raw-bg: #0b1220;

  --g-h: 300px;
}

/* Mobile-friendly gauge heights */
@media (max-width: 900px){ :root { --g-h: 260px; } }
@media (max-width: 560px){ :root { --g-h: 220px; } }

/* Base */
* { box-sizing:border-box; }
body { margin:0; background:var(--bg); color:var(--text); font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial; }
.container { max-width:1200px; margin:0 auto; padding:20px; }
header { text-align:center; margin-bottom:20px; padding:12px 0; border-bottom:1px solid var(--border); }
header h1 { color: var(--primary); margin:6px 0; }

/* Toolbar + theme switch */
.toolbar { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:10px 0 6px; }
.switch { position:relative; display:inline-block; width:42px; height:22px; }
.switch input { opacity:0; width:0; height:0; }
.slider { position:absolute; cursor:pointer; inset:0; background:#d1d5db; transition:.2s; border-radius:999px; }
.slider:before { position:absolute; content:""; height:18px; width:18px; left:2px; bottom:2px; background:white; transition:.2s; border-radius:50%; }
.switch input:checked + .slider { background:#10b981; }
.switch input:checked + .slider:before { transform:translateX(20px); }

.theme-switch { position: relative; display:inline-flex; align-items:center; width:48px; height:26px; padding:2px; border-radius:999px; border:1px solid var(--border); background:var(--card); cursor:pointer; }
.theme-switch input { display:none; }
.theme-switch .theme-thumb { position:relative; width:22px; height:22px; border-radius:999px; background:var(--primary); display:grid; place-items:center; transition: transform .2s ease; color:#fff; }
.theme-switch .fa-sun {font-size:12px;} .theme-switch .fa-moon {font-size:12px; display:none;}
.theme-switch input:checked + .theme-thumb { transform: translateX(20px); }
.theme-switch input:checked + .theme-thumb .fa-sun { display:none; }
.theme-switch input:checked + .theme-thumb .fa-moon { display:inline; }

.last-update-small { font-size:.85rem; color:var(--muted); margin-left:8px; }

/* Buttons, chips */
/* Buttons unified */
.btn {
  padding: 10px 16px; border-radius: 10px;
  font-weight: 700; border: 1px solid var(--border);
  background: var(--card); color: var(--text);
  transition: transform .06s ease, background .2s ease, border-color .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color:#fff; border-color: var(--primary); }
.btn-ghost   { background: transparent; border-style: dashed; }
.chip { border:1px solid var(--border); background:var(--card); color:var(--text); padding:6px 10px; border-radius:999px; font-size:.85rem; cursor:pointer; }
.chip.active { background: var(--primary); color:#fff; border-color: var(--primary); }
.chip.fav { background:#fff7ed; border-color:#fdba74; color:#c2410c; }
.theme-dark .chip.fav { background:#2b1d12; border-color:#9a5a24; color:#fbbf24; }

.favorites { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin:8px 0 12px; }
.fav-bar { display:flex; gap:6px; flex-wrap:wrap; }

/* Search */
.search-section { background: var(--card); border-radius:12px; padding:16px; box-shadow:0 2px 10px rgba(0,0,0,.08); margin-bottom:20px; border:1px solid var(--border); }
.search-form { display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.search-input-container { position:relative; flex:1; min-width:260px; }
.search-input { width:100%; padding:12px 14px; border:1px solid var(--border); border-radius:8px; background:var(--card); color:var(--text); }
.search-input:focus { outline:none; border-color:var(--primary); box-shadow:0 0 0 2px color-mix(in srgb, var(--primary) 30%, transparent); }
.search-results { position:absolute; top:100%; left:0; right:0; background:var(--card); border:1px solid var(--border); border-radius:8px; box-shadow:0 4px 12px rgba(0,0,0,.15); max-height:300px; overflow-y:auto; z-index:10; display:none; }
.search-result-item { padding:10px 12px; border-bottom:1px solid var(--border); cursor:pointer; }
.search-result-item:hover { background: color-mix(in srgb, var(--primary) 8%, var(--card)); }
.airport-code { font-weight:700; color:var(--primary); }
.airport-name, .airport-location { font-size:.9rem; color:var(--muted); }

.nearby-section { margin-top:12px; padding-top:12px; border-top:1px solid var(--border); }
.nearby-airfields { display:grid; grid-template-columns: repeat(auto-fill,minmax(200px,1fr)); gap:12px; margin-top:8px; }
.nearby-item { background: var(--card); border:1px solid var(--border); border-radius:8px; padding:10px; }

/* Cards */
.weather-display { display:grid; grid-template-columns: 1fr; gap:20px; }
.weather-card { background: var(--card); border-radius:12px; padding:18px; box-shadow:0 2px 10px rgba(0,0,0,.08); border:1px solid var(--border); }
.card-header { display:flex; justify-content:space-between; align-items:center; gap:12px; padding-bottom:12px; border-bottom:1px solid var(--border); }
.card-title { font-size:1.2rem; color:var(--primary); display:flex; gap:10px; align-items:center; }
.view-controls { display:flex; gap:8px; }

/* METAR layout */
.metar-summary { margin:10px 0 12px; }
.airfield-info { display:flex; flex-wrap:wrap; gap:16px; }
.info-item { display:flex; flex-direction:column; }
.info-label { font-size:.85rem; color:var(--muted); }
.info-value { font-weight:700; }

.metar-gauges-grid {
  display:grid;
  grid-template-columns: 1fr 1fr 2fr; /* 3/3/6 */
  gap:16px; align-items: stretch;
}
@media (max-width: 900px){
  .metar-gauges-grid { grid-template-columns: 1fr; }
}

/* Gauge & clouds containers now match */
.gauge-col, .clouds-col {
  background: var(--panel);
  color: var(--panel-fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
}

.gauge { width:100%; height: var(--g-h); }
.clouds-svg { width:100%; height: var(--g-h); }
.rwy-chips { display:flex; gap:6px; flex-wrap:wrap; margin-top:8px; }

/* Raw & tables */
.weather-data { background: var(--raw-bg); color: var(--text); border-radius:8px; padding:12px; font-family: ui-monospace,SFMono-Regular,Menlo,monospace; margin-top:12px; white-space: pre-wrap; }
.data-table { width:100%; border-collapse:collapse; margin-top:12px; background:var(--card); border:1px solid var(--border); border-radius:8px; overflow:hidden; }
.data-table th { background:var(--primary); color:#fff; padding:10px 12px; text-align:left; }
.data-table td { padding:10px 12px; border-bottom:1px solid var(--border); }
.data-table tr:last-child td { border-bottom:none; }

/* TAF grid */
.taf-table { width:100%; border-collapse:collapse; border:1px solid var(--border); border-radius:8px; overflow:hidden; }
.taf-table th, .taf-table td { padding:8px 10px; border-bottom:1px solid var(--border); color: var(--text); background: var(--card); }
.taf-table th { background:var(--primary); color:#fff; position:sticky; top:0; }
.taf-table tr:nth-child(odd) td { background: color-mix(in srgb, var(--text) 2%, var(--card)); }
.theme-dark .taf-table tr:nth-child(odd) td { background: color-mix(in srgb, #fff 4%, var(--card)); }

/* Flight category badges */
.weather-condition { display:inline-block; padding:4px 8px; border-radius:4px; font-size:.8rem; font-weight:600; margin-right:8px; margin-bottom:8px; color:#fff; }
.condition-vfr  { background:#28a745; }
.condition-mvfr { background:#0080f0; }
.condition-ifr  { background:#c5221f; }
.condition-lifr { background:#9722ce; }

/* SVG styling via classes (use theme vars) */
.tick { stroke: var(--svg-tick); stroke-width: 2; }
.tick.major { stroke: var(--svg-tick-major); stroke-width: 3; }
.tick.cardinal { stroke: var(--svg-tick-cardinal); stroke-width: 4.5; } /* thicker */
.label { fill: var(--svg-label); font-size:12px; font-weight:600; text-anchor:middle; dominant-baseline:middle; }
.label.card { font-size: 15px; font-weight: 800; } /* bolder cardinals */
.spd-tick { stroke: var(--svg-tick); stroke-width:2; }
.spd-tick.major { stroke: var(--svg-tick-major); stroke-width:3; }
.spd-label { fill: var(--svg-label); font-size: 12px; text-anchor: middle; dominant-baseline: middle; }


.centerline { stroke: var(--rwy-centerline); stroke-width:3; stroke-dasharray:12 10; stroke-linecap:round; }

/* Misc */
.loading { text-align:center; padding:20px; color:var(--muted); }
.error { background:#ffebee; color:#c5221f; padding:12px; border-radius:8px; display:flex; gap:10px; align-items:center; }
.hidden { display:none !important; }

/* Prevent grid children from forcing the page wider */
.weather-display, .weather-card, .taf-scroller { min-width: 0; }

/* Horizontal scroll container for wide hour tables */
.taf-scroller {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

/* Compact, predictable columns; table can be wider than the card */
.taf-table {
  width: max-content;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

/* Keep header visible when vertically scrolling inside the card */
.taf-table th { position: sticky; top: 0; z-index: 1; }

/* Optional niceties */
.taf-table th.hour, .taf-table td.hour { width: 56px; }  /* tweak to taste */
.taf-table th.sticky, .taf-table td.sticky {
  position: sticky; left: 0; z-index: 2; background: var(--card);
}

/* ── Responsive stat row: 6 / 3 / 2 / 1 cols ───────────────────────── */
.stat-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(6, 1fr);
  margin: 10px 0 6px;
}
@media (max-width: 1400px) { .stat-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px)  { .stat-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px)  { .stat-row { grid-template-columns: 1fr; } }

/* Stat cards: center content vertically (and horizontally by default) */
.stat-card { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--card); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.stat-card .value,
.stat-card .caption {
  display: flex;
  align-items: center;          /* vertical centering */
  gap: 10px;
}
.stat-card .value { padding: 12px 14px; font-weight: 800; font-size: 1.3rem; color: #fff; }
.stat-card .value .big { font-size: 1.6rem; }
.stat-card .caption { padding: 8px 14px; font-size: .9rem; color: #fff; opacity: .9; }

/* accents */
.accent-blue .value   { background: linear-gradient(0deg, color-mix(in srgb, var(--primary) 60%, #0000) 0%, var(--primary) 100%); }
.accent-blue .caption { background: color-mix(in srgb, var(--primary) 70%, #0000); }
.accent-green .value   { background: linear-gradient(0deg, color-mix(in srgb, #22c55e 60%, #0000) 0%, #22c55e 100%); }
.accent-green .caption { background: color-mix(in srgb, #22c55e 70%, #0000); }

/* Keep wide tables/graphs inside cards */
.weather-display, .weather-card, .taf-scroller { min-width: 0; }

/* Cloud SVG always sits on panel background */
.clouds-svg { width:100%; height: var(--g-h); display:block; }

/* Header layout */
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Raw chips in header */
:root {
  --chip-bg: #f3f4f6;         /* light */
  --chip-fg: #111827;
}
.theme-dark {
  --chip-bg: #111827;         /* dark */
  --chip-fg: #e5e7eb;
}

.raw-chip {
  max-width: clamp(220px, 35vw, 720px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .85rem;
  background: var(--chip-bg);
  color: var(--chip-fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
}

/* tiny button variant to sit in header */
.btn.btn-xs {
  padding: 6px 8px;
  border-radius: 8px;
  font-size: .85rem;
  line-height: 1;
}
.btn.btn-xs i { font-size: .9rem; }

/* Optional: quick visual feedback on copy */
.btn.copied { outline: 2px solid var(--primary); }

.raw-modal-backdrop {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: color-mix(in srgb, var(--bg) 40%, transparent);
  z-index: 9999;
}
.raw-modal-backdrop.hidden { display: none; }

.raw-modal {
  width: min(900px, 92vw);
  max-height: 86vh;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  display: grid; grid-template-rows: auto 1fr auto; gap: 10px;
  padding: 12px;
}

.raw-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.raw-modal-pre {
  margin: 0; padding: 12px; border-radius: 8px;
  background: var(--panel); color: var(--panel-fg);
  overflow: auto; white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  max-height: 60vh;
}
.raw-modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
