:root {
  --primary: #1a73e8;
  --primary-dark: #0d47a1;
  --secondary: #34a853;
  --warning: #fbbc05;
  --danger: #ea4335;

  --bg: #f5f7fa;
  --text: #202124;
  --muted: #5f6368;
  --card: #ffffff;
  --panel: #1f2937;
  --border: #dadce0;
  --accent: #0b5ed7;
}

.theme-dark {
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --secondary: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;

  --bg: #0f172a;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --card: #111827;
  --panel: #111827;
  --border: #334155;
  --accent: #2563eb;
}

/* 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; top:0; left:0; right:0; bottom: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 */
.btn { padding:10px 16px; border:none; border-radius:8px; font-weight:600; cursor:pointer; display:inline-flex; gap:8px; align-items:center; }
.btn-primary { background: var(--primary); color:#fff; }
.btn-secondary { background: var(--card); color: var(--text); border:1px solid var(--border); }
.btn-ghost { background:transparent; border:1px dashed var(--border); }

.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; }
.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 rgba(26,115,232,0.2); }

.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: #f8f9fa; }
.airport-code { font-weight:700; color:var(--primary); }
.airport-name { font-size: .9rem; color:var(--muted); }
.airport-location { font-size: .8rem; 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; }
@media (min-width: 900px){ .weather-display { grid-template-columns: 1fr; } }

.weather-card { background: var(--card); border-radius:12px; padding:18px; box-shadow:0 2px 10px rgba(0,0,0,.08); }
.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 ratio */
  gap:16px;
  align-items: stretch;
}
.gauge-col, .clouds-col {
  background: var(--panel);
  color:#fff;
  border-radius: 12px;
  padding: 12px;
}
.gauge { width:100%; height:320px; }       /* equal height */
.clouds-svg { width:100%; height:320px; }  /* equal height */
.rwy-chips { display:flex; gap:6px; flex-wrap:wrap; margin-top:8px; }

/* Tables, raw */
.weather-data { background: #f1f5f9; color:#111827; border-radius:8px; padding:12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin-top:12px; white-space: pre-wrap; }
.theme-dark .weather-data { background:#0b1220; color:#e5e7eb; }

.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); }
.taf-table th { background: var(--primary); color:#fff; position:sticky; top:0; }
.taf-table tr:nth-child(odd) td { background: rgba(0,0,0,0.02); }
.theme-dark .taf-table tr:nth-child(odd) td { background: rgba(255,255,255,0.03); }

/* Gauges/compass visuals */
.tick { stroke: rgba(255,255,255,.55); stroke-width: 2; }
.tick.major { stroke-width: 3; }
.tick.cardinal { stroke: #fff; stroke-width: 3.5; }
.label { fill: rgba(255,255,255,.9); font-size: 12px; font-weight: 600; text-anchor: middle; dominant-baseline: middle; }
.label.card { font-size: 14px; }
.runway { fill:#0d0d0d; }
.centerline { stroke:#fff; 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; }
