:root {
  --panel: rgba(12, 16, 20, 0.93);
  --panel-solid: #0c1014;
  --line: rgba(255, 255, 255, 0.09);
  --text: #e9eef3;
  --muted: #95a3af;
  --accent: #ff7a1a;
  --accent-ink: #1a0d02;
  --ok: #3ddc84;
  --wait: #ffc247;
  --fly: #4db2ff;
  --danger: #ff5a5f;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--panel-solid);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#map { position: fixed; inset: 0; background: #1b2228; }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10px; }

/* ---- Panneau ------------------------------------------------------------ */

#panel {
  position: fixed; z-index: 1000;
  top: 16px; left: 16px; bottom: 16px; width: 380px;
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  padding: 18px 18px 14px;
}
@media (max-width: 720px) {
  #panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto;
    max-height: 52vh; border-radius: var(--radius) var(--radius) 0 0;
    padding: 14px 16px 12px;
  }
}

h1 { font-size: 17px; margin: 0; letter-spacing: 0.01em; }
h2 { font-size: 15px; margin: 0 0 8px; }
h3 { font-size: 13px; margin: 0 0 6px; display: flex; justify-content: space-between; align-items: baseline; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.foot { color: var(--muted); font-size: 11.5px; margin: 14px 0 0; }

.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); white-space: nowrap;
}
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip.ok i { background: var(--ok); }
.chip.wait i { background: var(--wait); animation: blink 1.2s infinite; }
.chip.fly i { background: var(--fly); box-shadow: 0 0 0 0 var(--fly); animation: ping 1.6s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(77, 178, 255, 0.7); } 100% { box-shadow: 0 0 0 8px rgba(77, 178, 255, 0); } }

/* ---- Télémétrie --------------------------------------------------------- */

.telemetry {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  margin: 14px 0; border-radius: 10px; overflow: hidden;
  background: var(--line); border: 1px solid var(--line);
}
.telemetry div { background: var(--panel-solid); padding: 8px 10px; }
.telemetry dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
.telemetry dd { margin: 2px 0 0; font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.telemetry dd.low { color: var(--danger); }

/* ---- Vues --------------------------------------------------------------- */

.view { border-top: 1px solid var(--line); padding-top: 14px; }
.step { margin-bottom: 14px; }
.step output { color: var(--accent); font-weight: 650; font-variant-numeric: tabular-nums; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

button {
  font: inherit; color: var(--text); cursor: pointer;
  border-radius: 9px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06); padding: 8px 12px;
  transition: background 0.15s, opacity 0.15s;
}
button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.12); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.ghost { font-size: 12.5px; padding: 6px 10px; }
button.primary {
  width: 100%; margin-top: 4px; padding: 11px 14px; font-weight: 700;
  background: var(--accent); color: var(--accent-ink); border-color: transparent;
}
button.primary:hover:not(:disabled) { background: #ff8f3d; }
/* L'action principale reste visible quand le panneau défile. */
.view button.primary { position: sticky; bottom: 8px; box-shadow: 0 -10px 18px 4px var(--panel-solid); }
.view button.primary:disabled { opacity: 1; background: #4a3a2e; color: #a8968a; }
button.danger { background: rgba(255, 90, 95, 0.16); border-color: rgba(255, 90, 95, 0.45); font-weight: 650; }
button.danger:hover:not(:disabled) { background: rgba(255, 90, 95, 0.28); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; padding: 7px 14px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.seg.small button { padding: 7px 11px; }
#fly-sub, #fly-target { min-height: 1.45em; }

input[type="range"] { width: 100%; accent-color: var(--accent); margin: 4px 0 0; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--accent); margin-top: 3px; }

.battrow {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin: 0 0 12px; font-size: 13px;
}
.estimate {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px;
  margin: 0 0 12px; padding: 12px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line);
}
.estimate dt { color: var(--muted); font-size: 11.5px; }
.estimate dd { margin: 1px 0 0; font-weight: 650; font-variant-numeric: tabular-nums; }

.warn {
  margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; font-size: 12.5px;
  background: rgba(255, 194, 71, 0.1); border: 1px solid rgba(255, 194, 71, 0.4); color: #ffe2a3;
}
.warn.error { background: rgba(255, 90, 95, 0.12); border-color: rgba(255, 90, 95, 0.45); color: #ffc4c6; }
.result { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; font-size: 13px; border: 1px solid var(--line); }
.result.found { background: rgba(61, 220, 132, 0.12); border-color: rgba(61, 220, 132, 0.45); }
.result.missed { background: rgba(255, 194, 71, 0.1); border-color: rgba(255, 194, 71, 0.4); }

.bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin: 10px 0 4px; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.4s; }

/* ---- Journal ------------------------------------------------------------ */

.journal { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 10px; }
.journal summary { cursor: pointer; font-weight: 650; font-size: 13px; }
.journal ol { list-style: none; margin: 8px 0 0; padding: 0; max-height: 210px; overflow-y: auto; font-size: 12px; }
.journal li { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; padding: 3px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
.journal time { color: var(--muted); font-variant-numeric: tabular-nums; }
.journal .src { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; padding: 1px 6px; border-radius: 4px; align-self: center; }
.journal .src.drone { background: rgba(77, 178, 255, 0.15); color: #9fd3ff; }
.journal .src.station { background: rgba(255, 122, 26, 0.15); color: #ffb98a; }
.journal .txt { overflow-wrap: anywhere; }

/* ---- Marqueurs de carte ------------------------------------------------- */

.home-pin span {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; color: #111; font-weight: 800; font-size: 13px;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.35);
}
.vertex {
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); cursor: grab;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.drone-pin { position: relative; }
.drone-pin svg { width: 44px; height: 44px; transition: transform 0.2s linear; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6)); }
.drone-pin b {
  position: absolute; left: 40px; top: 12px; white-space: nowrap;
  font: 700 11px/1 system-ui, sans-serif; color: #fff;
  background: rgba(0, 0, 0, 0.6); padding: 3px 6px; border-radius: 5px;
}
.target-pin span { display: block; width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff; }
.target-pin.found span { background: var(--ok); animation: found 1.4s infinite; }
.target-pin.missed span { background: #8a96a1; }
@keyframes found { 0% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0.8); } 100% { box-shadow: 0 0 0 18px rgba(61, 220, 132, 0); } }

#toast {
  position: fixed; z-index: 1100; top: 18px; left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--ok); color: #04210f; font-weight: 700;
  padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
@media (min-width: 721px) { #toast { left: calc(50% + 206px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
