* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0f172a;
  --panel: #16213a;
  --panel-2: #1c2a47;
  --border: #2a3a5c;
  --text: #e6ebf5;
  --muted: #93a2c2;
  --accent: #e2b93b;
  --vfr: #16a34a;
  --mvfr: #2563eb;
  --ifr: #dc2626;
  --lifr: #d946ef;
  --g: #16a34a;
  --y: #ca9a12;
  --r: #dc2626;
  --true-vh: 100%;
  --nav-clear: calc(78px + env(safe-area-inset-bottom, 0px));
}

html, body { height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px; /* prevents iOS auto-zoom on input focus */
}

#app {
  display: flex;
  flex-direction: column;
  height: var(--true-vh, 100%);
  overflow: hidden;
}

.app-bar {
  flex-shrink: 0;
  padding: max(14px, env(safe-area-inset-top, 0px)) 16px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-bar h1 { font-size: 18px; letter-spacing: 0.5px; color: var(--accent); }
.app-bar .sub { font-size: 12px; color: var(--muted); }

.header-title-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  background: none; border: none; padding: 4px 6px 4px 0; margin: -4px 0 -4px -2px;
  cursor: pointer; text-align: left; min-height: 44px; justify-content: center;
}
.header-title-btn:active { opacity: 0.7; }
.header-nnumber { font-size: 22px; font-weight: 800; letter-spacing: 0.5px; color: var(--accent); line-height: 1.15; }
.header-nnumber::after { content: ' ✎'; font-size: 12px; color: var(--muted); font-weight: 400; }
.icon-btn {
  min-width: 44px; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer;
}

.screen { flex: 1; overflow: hidden; display: none; flex-direction: column; }
.screen.active { display: flex; }
.scroll { flex: 1; overflow-y: auto; padding: 16px 16px var(--nav-clear); }

/* ---- Floating bottom tab bar ---- */
.mob-nav {
  position: fixed;
  bottom: env(safe-area-inset-bottom, 0px);
  left: 50%; transform: translateX(-50%);
  width: calc(100% - 28px); max-width: 460px;
  display: flex; z-index: 105;
  background: rgba(22, 33, 58, 0.97);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: 0 4px 24px rgba(0,0,0,.35);
  padding: 4px 6px;
}
.mob-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 8px 4px; background: none; border: none; cursor: pointer;
  color: var(--muted); border-radius: 22px; transition: color .15s;
}
.mob-nav-item.active { color: var(--accent); }
.mob-nav-item:active { opacity: .65; }
.mob-nav-icon { font-size: 20px; line-height: 1; }
.mob-nav-label { font-size: 10px; font-weight: 700; letter-spacing: .1px; }

/* ---- Cards / form controls ---- */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px; margin-bottom: 14px;
}
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); margin-bottom: 10px; }
.row { display: flex; gap: 10px; margin-bottom: 10px; }
.field { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 12px; color: var(--muted); }
input, select {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 16px; min-height: 44px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); }

.gyr-group { display: flex; gap: 8px; }
.gyr-btn {
  flex: 1; min-height: 44px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--muted); font-weight: 700; cursor: pointer;
}
.gyr-btn[data-val="G"].on { background: var(--g); color: #fff; border-color: var(--g); }
.gyr-btn[data-val="Y"].on { background: var(--y); color: #1a1300; border-color: var(--y); }
.gyr-btn[data-val="R"].on { background: var(--r); color: #fff; border-color: var(--r); }

.station-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.station-table th, .station-table td { padding: 8px 4px; text-align: center; border-bottom: 1px solid var(--border); }
.station-table th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; }
.station-table td:first-child, .station-table th:first-child { text-align: left; }
.cat { font-weight: 800; padding: 2px 8px; border-radius: 6px; font-size: 12px; display: inline-block; min-width: 44px; }
.cat.VFR { color: var(--vfr); }
.cat.MVFR { color: var(--mvfr); }
.cat.IFR { color: var(--ifr); }
.cat.LIFR { color: var(--lifr); }
.cat.none { color: var(--muted); }

.taf-dots { display: inline-flex; gap: 5px; align-items: center; }
.taf-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; background: var(--border); }
.taf-dot.VFR { background: var(--vfr); }
.taf-dot.MVFR { background: var(--mvfr); }
.taf-dot.IFR { background: var(--ifr); }
.taf-dot.LIFR { background: var(--lifr); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--panel-2); border-radius: 10px; padding: 10px; }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.stat .v { font-size: 18px; font-weight: 700; margin-top: 2px; }

.notam-item { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.notam-item:last-child { border-bottom: none; }
.notam-meta { color: var(--muted); font-size: 11px; margin-bottom: 2px; }

/* Hazard flip cards (AIRMET/SIGMET/NOTAM) — tap to flip between raw text and
   a plain-language overview. */
.hazard-card {
  perspective: 1000px; margin-bottom: 10px; cursor: pointer; height: 120px;
}
.hazard-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform 0.5s; transform-style: preserve-3d;
}
.hazard-card.flipped .hazard-inner { transform: rotateY(180deg); }
.hazard-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 10px; font-size: 13px; overflow-y: auto;
}
.hazard-back { transform: rotateY(180deg); }
.muted { color: var(--muted); font-size: 13px; }
.link { color: var(--accent); text-decoration: underline; }

.primary-btn {
  width: 100%; min-height: 48px; border-radius: 12px; border: none;
  background: var(--accent); color: #1a1300; font-weight: 800; font-size: 15px; cursor: pointer;
}
.ghost-btn {
  width: 100%; min-height: 44px; border-radius: 12px; border: 1px solid var(--border);
  background: transparent; color: var(--text); font-weight: 600; cursor: pointer;
}

.stale-badge {
  display: inline-block; font-size: 11px; background: #7a3b0a; color: #ffd9a8;
  padding: 2px 8px; border-radius: 6px; margin-bottom: 8px;
}

#login-screen { align-items: center; justify-content: center; padding: 24px; z-index: 400; }
.login-box { width: 100%; max-width: 360px; }
.login-box h1 { color: var(--accent); font-size: 28px; margin-bottom: 4px; text-align: center; }
.login-box .tagline { color: var(--muted); text-align: center; margin-bottom: 24px; font-size: 13px; }
.error-text { color: var(--ifr); font-size: 13px; margin-top: 8px; min-height: 16px; }

@media (min-width: 701px) { .mob-nav { display: none !important; } }
