:root {
  --bg: rgba(255, 255, 255, .94);
  --fg: #14202e;
  --muted: #5a6b7d;
  --line: #d5dde6;
  --accent: #1f6feb;
  --warn-bg: #fff4d6;
  --warn-fg: #6b4a00;
  --bad: #b3261e;
  --shadow: 0 2px 14px rgba(15, 27, 45, .22);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: rgba(20, 29, 43, .94);
    --fg: #e8eef5;
    --muted: #9fb0c3;
    --line: #34455a;
    --accent: #6aa5ff;
    --warn-bg: #4a3a0c;
    --warn-fg: #ffe29a;
    --bad: #ff8a80;
    --shadow: 0 2px 14px rgba(0, 0, 0, .5);
  }
}

html, body { height: 100%; margin: 0; }
body { font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--fg); background: #cfd8e3; }
#map { position: fixed; inset: 0; }

/* ---------- panneau ---------- */
.panel {
  position: fixed; z-index: 1000;
  top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  width: min(300px, calc(100vw - 24px));
  background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 14px; }
.panel-head h1 { font-size: 15px; margin: 0; font-weight: 650; letter-spacing: .01em; cursor: pointer; flex: 1; padding: 10px 0; }
.collapse {
  width: 44px; height: 44px; margin: -6px -2px -6px 0; border: 0; background: none; color: var(--muted);
  font-size: 18px; cursor: pointer; border-radius: 8px;
}
.collapse[aria-expanded="false"] span { display: inline-block; transform: rotate(-90deg); }
.panel-body { padding: 0 14px 12px; }
.panel-body[hidden] { display: none; }

.row { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.row[hidden] { display: none; }
.row input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; }
.grow { flex: 1; font-weight: 550; }
.count { color: var(--muted); font-variant-numeric: tabular-nums; }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.swatch-air { background: linear-gradient(90deg, hsl(18,90%,52%), hsl(150,70%,42%), hsl(285,70%,55%)); }
.swatch-range { background: none; border: 2px solid; border-color: #1f6feb #1b9e6b #1b9e6b #1f6feb; border-radius: 4px; box-sizing: border-box; }
.swatch-ship { background: #1b9e6b; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg) scale(.9); }

.seg { display: grid; grid-template-columns: 1fr 1fr; margin: 0 0 4px 30px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button {
  min-height: 40px; border: 0; background: none; color: var(--fg); font: inherit; font-size: 14px; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; font-weight: 600; }
.seg.disabled { opacity: .45; pointer-events: none; }

.status { margin: 8px 0 0; font-size: 13px; color: var(--muted); min-height: 1.4em; }
.status.bad { color: var(--bad); font-weight: 600; }
.note { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }

.legend { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 4px; font-size: 13px; }
.legend summary { cursor: pointer; min-height: 36px; display: flex; align-items: center; color: var(--muted); }
.legend-block { margin: 4px 0 8px; }
.legend-label { color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.alt-bar { height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, hsl(18,90%,52%), hsl(60,85%,48%), hsl(150,70%,42%), hsl(210,75%,52%), hsl(285,70%,55%)); }
.alt-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 2px; }
.legend-ships { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.legend-ships li { display: flex; align-items: center; gap: 7px; min-height: 24px; }
.legend-range { list-style: none; margin: 6px 0 0; padding: 0; }
.legend-range li { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.line { width: 18px; height: 0; border-top: 3px solid; border-radius: 2px; flex: none; }
.dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }

/* ---------- bannière hors ligne ---------- */
.banner {
  position: fixed; z-index: 1001; left: 50%; transform: translateX(-50%);
  top: max(12px, env(safe-area-inset-top)); max-width: calc(100vw - 340px); min-width: 220px;
  padding: 9px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-fg);
  box-shadow: var(--shadow); font-size: 14px; font-weight: 550; text-align: center;
}
.banner[hidden] { display: none; }

/* ---------- marqueurs ---------- */
.mk { background: none; border: 0; }
.mk svg { display: block; overflow: visible; filter: drop-shadow(0 0 1.5px rgba(0,0,0,.75)); }
.mk .rot { transform-origin: 50% 50%; }
.leaflet-popup-content { margin: 10px 14px; font: 13.5px/1.45 system-ui, sans-serif; min-width: 150px; }
.pop-title { font-weight: 650; font-size: 14.5px; margin-bottom: 2px; }
.pop-sub { color: #5a6b7d; }
.pop-line { margin-top: 2px; }
.leaflet-container a { color: #1f6feb; }

/* ---------- petits écrans ---------- */
@media (max-width: 720px) {
  .banner { top: auto; bottom: max(28px, env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); }
  .panel { width: min(260px, calc(100vw - 24px)); }
}
@media (max-width: 420px) {
  .leaflet-control-zoom { display: none; } /* le pincement suffit */
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
