:root {
  --bg: #0f1418; --card: #182026; --card2: #1f2930; --line: #2a363f; --text: #e6edf2; --muted: #8a99a6;
  --teal: #2ec4b6; --amber: #ffb547; --bad: #ff6b6b; --violet: #7f8cff;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .amber { color: var(--amber); }
button { background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 7px 11px; font: inherit; cursor: pointer; }
button:hover { border-color: var(--teal); }
button.primary { background: var(--teal); color: #00201d; border-color: var(--teal); font-weight: 600; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
input, select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; font: inherit; width: 100%; }
input[type=number] { width: 76px; }
input[type=checkbox] { width: auto; }
label { display: block; margin: 6px 0; color: var(--muted); }
label input[type=datetime-local] { margin-top: 3px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
.row { display: flex; align-items: center; } .gap { gap: 6px; } .wrap { flex-wrap: wrap; }
.langs { display: flex; gap: 4px; justify-content: flex-end; }
.langs button { padding: 3px 8px; font-size: 12px; }
.langs button.on { background: var(--teal); color: #00201d; border-color: var(--teal); }
.app-mode .web-only { display: none !important; }
.msg { min-height: 1.2em; color: var(--amber); }

/* gate */
.gate { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.gate-card { width: min(440px, 100%); background: var(--card); border-radius: 18px; padding: 22px; display: grid; gap: 10px; }
.gate h1 { margin: 0; color: var(--teal); font-size: 30px; }
.gate h2 { margin: 12px 0 4px; font-size: 16px; }
.saved { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }

/* map */
#app, #map { position: fixed; inset: 0; }
#map { background: #0b0f12; }
.dark-tiles .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.9) saturate(.6); }
.leaflet-container { font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--card); color: var(--text); }
.leaflet-popup-content { margin: 10px 12px; }
.leaflet-control-attribution { background: rgba(15,20,24,.7) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.float { position: fixed; z-index: 800; background: rgba(24,32,38,.94); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(6px); }
.live { top: max(10px, env(safe-area-inset-top)); left: 54px; padding: 10px 12px; max-width: min(360px, calc(100vw - 70px)); display: grid; gap: 6px; }
.live-top { display: flex; gap: 8px; align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--teal); box-shadow: 0 0 0 4px rgba(46,196,182,.2); }
.chip { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--card2); color: var(--muted); }
.fab { top: max(10px, env(safe-area-inset-top)); right: 10px; padding: 9px 13px; }
.panel { position: fixed; z-index: 900; top: 0; right: 0; bottom: 0; width: 370px; background: var(--card); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform .2s; }
.panel.open { transform: none; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.panel-head .ghost { margin-left: auto; }
.panel-body { overflow: auto; padding: 4px 14px 90px; }
details { border-bottom: 1px solid var(--line); padding: 8px 0; }
summary { cursor: pointer; font-weight: 600; color: var(--teal); padding: 4px 0; }
.sub { margin: 10px 0 4px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.chips button { padding: 5px 9px; border-radius: 99px; font-size: 12px; }
.chips button.on { background: var(--teal); color: #00201d; border-color: var(--teal); }
.loclist { max-height: 180px; overflow: auto; display: grid; gap: 3px; margin: 4px 0; }
.loc { display: flex; justify-content: space-between; gap: 6px; padding: 5px 8px; border-radius: 8px; background: var(--bg); cursor: pointer; font-size: 13px; }
.loc.on { outline: 1px solid var(--teal); background: rgba(46,196,182,.12); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 12px; margin: 6px 0; }
.legend i { display: inline-block; width: 18px; height: 6px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stat { background: var(--bg); border-radius: 10px; padding: 8px; }
.stat b { display: block; font-size: 17px; }
.stat span { color: var(--muted); font-size: 12px; }
.table { display: grid; gap: 2px; font-size: 13px; margin-bottom: 8px; }
.tr { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.tr:hover { background: var(--bg); }
.timeline { left: 50%; transform: translateX(-50%); bottom: max(12px, env(safe-area-inset-bottom)); width: min(640px, calc(100vw - 20px));
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.timeline input { flex: 1; padding: 0; accent-color: var(--teal); }
#scrubInfo { min-width: 120px; text-align: right; }
.busy { position: fixed; z-index: 1000; top: 50%; left: 50%; transform: translate(-50%,-50%); background: var(--card); padding: 12px 18px; border-radius: 12px; border: 1px solid var(--line); }
.me { width: 18px; height: 18px; border-radius: 50%; background: var(--amber); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(255,181,71,.25); }
@media (min-width: 900px) { .panel.open ~ .timeline { left: calc(50% - 185px); } }
@media (max-width: 600px) {
  .panel { width: 100%; top: 30%; border-left: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; transform: translateY(100%); }
  .live { left: 10px; top: auto; bottom: 74px; }
  .fab { top: max(10px, env(safe-area-inset-top)); }
}
