:root {
  --bg: #0b1f33;
  --card: #12293f;
  --card2: #0f2237;
  --fg: #eef4fb;
  --muted: #9db2c9;
  --line: #23405b;
  --accent: #4aa3ff;
  --vfr: #2ecc71;
  --mvfr: #4aa3ff;
  --ifr: #ff6b6b;
  --lifr: #d16bff;
  --warn: #ffbe4d;
  --arrow: #e63946;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef3f8;
    --card: #ffffff;
    --card2: #f4f8fc;
    --fg: #0b1f33;
    --muted: #5a6b7d;
    --line: #d6e0ea;
    --accent: #1769c9;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }

#app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- En-tête ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 17px; font-weight: 650; margin: 0; flex: 1; letter-spacing: .2px; }
.top h1 .club { color: inherit; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 2px; text-decoration-thickness: 2px; }
.top .sub { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.icon-btn {
  border: 1px solid var(--line); background: var(--card);
  width: 40px; height: 40px; border-radius: 12px; font-size: 18px;
  display: grid; place-items: center;
}
.icon-btn:active { transform: scale(.95); }

/* ---------- Contenu ---------- */
main {
  flex: 1;
  padding: 16px 16px calc(84px + var(--safe-b));
  max-width: 640px; width: 100%; margin: 0 auto;
}
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 3px; font-size: 20px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.card h2 .head-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.card .place { color: var(--muted); font-size: 13px; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .aero-top { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.card .aero-top b { color: var(--fg); font-weight: 600; }
.card .place b { font-weight: 600; color: var(--fg); }
.card .place .state { border: 0; padding: 0; font-size: 13px; vertical-align: baseline; }

.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.state.on .dot { background: var(--vfr); }
.state.off .dot { background: var(--ifr); }

/* ---------- Rose des vents ---------- */
.rose-wrap { display: flex; justify-content: center; margin: 6px 0 12px; }
.rose-wrap svg { width: min(78vw, 300px); height: auto; }

/* ---------- Tuiles vent ---------- */
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 6px; }
.metric { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.metric .v { font-size: 22px; font-weight: 700; }
.metric .u { font-size: 12px; color: var(--muted); }
.metric .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.metric.gust .v { color: var(--warn); }

/* ---------- Tuiles METAR ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 6px; }
.tile { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.tile .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.tile .v { font-size: 18px; font-weight: 650; margin-top: 3px; }
.tile .v small { font-weight: 400; color: var(--muted); font-size: 13px; }

.raw { margin-top: 14px; }
.raw .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.raw code { display: block; background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-word; white-space: pre-wrap; color: var(--fg); }

/* ---------- TAF décodé ---------- */
.taf h3 { margin: 4px 0 10px; font-size: 16px; }
.taf .valid { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.trend { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; background: var(--card2); }
.trend .th { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.trend .badge { font-size: 11px; font-weight: 700; letter-spacing: .5px; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #04121f; }
.trend .badge.base { background: var(--muted); }
.trend .badge.TEMPO { background: var(--warn); }
.trend .badge.PROB { background: var(--lifr); }
.trend .when { font-size: 12px; color: var(--muted); }
.trend ul { margin: 4px 0 0; padding-left: 18px; }
.trend li { margin: 2px 0; }

/* ---------- Bandeau dates ---------- */
.stamps { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 13px; color: var(--muted); }
.stamps b { color: var(--fg); font-weight: 600; }
.stamps .row { display: flex; align-items: center; gap: 7px; }
.stamps a { color: var(--accent); text-decoration: none; }

.notice { background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: 12px; padding: 12px 14px; color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.notice.err { border-left-color: var(--ifr); }

/* ---------- Pied de page ---------- */
.foot { margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.5; }
.foot p { margin: 0 0 8px; }
.foot b { color: var(--fg); font-weight: 600; }
.foot a { color: var(--accent); text-decoration: none; }
.foot .foot-h { text-transform: uppercase; letter-spacing: .5px; font-size: 11px; color: var(--muted); margin-top: 12px; margin-bottom: 4px; }
.foot ul { margin: 0 0 8px; padding-left: 18px; }
.foot li { margin: 3px 0; }
.foot .foot-warn { background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: 10px; padding: 10px 12px; }
.foot .foot-attr { font-size: 11px; opacity: .85; margin-bottom: 0; }

/* ---------- Navigation basse ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; padding: 6px 8px calc(6px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--line);
}
.tabs button {
  flex: 1; background: none; border: 0; padding: 8px 4px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); border-radius: 12px; font-size: 11px; font-weight: 600;
}
.tabs button .ti { height: 22px; display: flex; align-items: center; justify-content: center; }
.tabs button .ti svg { display: block; width: 22px; height: 22px; }
.tabs button .ti .icao { font-size: 12px; font-weight: 700; letter-spacing: .5px; }
.tabs button.active { color: var(--accent); }
.tabs button.active .ti { transform: translateY(-1px); }

/* ---------- Feuille réglages ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; display: none; }
.sheet-backdrop.open { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  background: var(--card); border-top-left-radius: 20px; border-top-right-radius: 20px;
  border: 1px solid var(--line); padding: 8px 18px calc(24px + var(--safe-b));
  max-width: 640px; margin: 0 auto; transform: translateY(100%); transition: transform .22s ease;
}
.sheet.open { transform: translateY(0); }
.sheet .grip { width: 40px; height: 4px; border-radius: 999px; background: var(--line); margin: 8px auto 14px; }
.sheet h2 { font-size: 17px; margin: 0 0 14px; }
.field { margin-bottom: 18px; }
.field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.seg { display: flex; gap: 6px; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.seg button { flex: 1; border: 0; background: none; padding: 9px 4px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 14px; }
.seg button.active { background: var(--accent); color: #04121f; }
