:root {
  --panel: rgba(20, 28, 40, 0.86);
  --text: #eef2f7;
  --muted: #9fb0c4;
  --accent: #ffc107;
}
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b2430; font: 13px/1.35 system-ui, sans-serif; color: var(--text); }
#map { position: absolute; inset: 0; background: #1b2430; z-index: 0; }
#glidersLayer { position: absolute; left: 0; top: 0; z-index: 450; pointer-events: none; }
#v3dWrap { position: absolute; inset: 0; background: #a8ccf0; z-index: 10; }
#v3dWrap[hidden] { display: none; }
#v3d, #cockpit { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#v3d { touch-action: none; cursor: grab; }
#cockpit { pointer-events: none; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tag {
  position: absolute; left: 0; top: 0; white-space: pre; text-align: center; pointer-events: auto; cursor: pointer;
  font: 600 11px/1.2 system-ui, sans-serif; color: #fff; background: rgba(16, 20, 24, 0.45); padding: 2px 6px; border-radius: 6px;
}
.tag.own { color: var(--accent); }
.tag:hover { background: rgba(16, 20, 24, 0.75); }

#panel {
  position: absolute; top: 10px; left: 10px; width: 260px; max-width: calc(100vw - 32px); z-index: 1000;
  background: var(--panel); border-radius: 8px; padding: 8px 10px; box-shadow: 0 2px 10px rgba(0,0,0,.4);
}
#panel .head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; gap: 6px; }
#panel button { background: #2c3a4f; color: var(--text); border: 0; border-radius: 4px; padding: 4px 8px; cursor: pointer; font: inherit; }
#panel button:hover { background: #3b4d68; }
#problem { background: #7a1f1f; color: #fff; border-radius: 4px; padding: 6px; margin: 6px 0; user-select: text; }
#wx, #h3wx { color: var(--muted); font-size: 12px; margin-bottom: 6px; white-space: pre-line; }
#wx:empty, #h3wx:empty, #h3state:empty { display: none; }
.wxModel { display: flex; align-items: center; gap: 8px; margin: 4px 0 6px; font-size: 12px; color: var(--muted); }
.wxModel select { margin-left: 4px; }
/* both models side by side: a box beside the panel (too wide for it), click "Compare" again to close */
#wxCmp { position: fixed; top: 10px; left: 290px; max-width: calc(100vw - 300px); z-index: 1001; overflow-x: auto;
  background: var(--panel); border-radius: 8px; padding: 8px 10px; box-shadow: 0 2px 10px rgba(0,0,0,.4);
  font: 12px/1.4 ui-monospace, Consolas, monospace; white-space: pre; color: var(--text); }
#wxCmp[hidden] { display: none; }
#counts { color: var(--muted); margin: 6px 0; }
#search { display: flex; gap: 4px; margin-bottom: 6px; }
#search input { flex: 1; min-width: 0; background: #0f1621; color: var(--text); border: 1px solid #34445a; border-radius: 4px; padding: 4px 6px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 6px; margin: 6px 0; }
.filters label { white-space: nowrap; }
.volRow { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.volRow label { white-space: nowrap; }
#volFps { color: #9aa7b6; font-size: 12px; }
#sel { margin: 6px 0; padding: 6px; background: rgba(255,193,7,.12); border-radius: 4px; }
#sel[hidden] { display: none; }
#selName, #h3name { color: var(--accent); font-weight: 600; }
#selInfo { color: var(--muted); font-size: 12px; }
#fly { margin-top: 6px; width: 100%; background: #b8860b !important; color: #fff; font-weight: 600; }
#fly:hover { background: #d19b0f !important; }
#h3name { margin-top: 6px; font-size: 14px; }
#h3vals { margin: 2px 0 6px; }
#h3state { color: #ffcc80; font-size: 12px; margin-bottom: 6px; }
#camMode { width: 100%; }
.hint { color: var(--muted); font-size: 11px; margin: 4px 0; }
.sub { color: var(--muted); margin-top: 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
#regions { list-style: none; padding: 0; margin: 4px 0 0; max-height: 36vh; overflow: auto; }
#regions li { display: flex; justify-content: space-between; padding: 3px 4px; border-radius: 4px; cursor: pointer; }
#regions li:hover { background: rgba(255,255,255,.08); }
#regions li span:last-child { color: var(--muted); }
#panel.folded #body { display: none; }
body:not(.in3d) .only3d { display: none !important; }
body.in3d .only2d { display: none !important; }

#note { position: absolute; left: 10px; bottom: 2px; right: 120px; z-index: 900; color: #cfd8e3; font-size: 10px; text-shadow: 0 1px 2px #000; pointer-events: none; }
#note a { color: #cfd8e3; pointer-events: auto; }
body.in3d #note { bottom: 4px; }
.leaflet-control-attribution { font-size: 10px; }

#replayBar {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 20px; z-index: 950; width: min(760px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; box-sizing: border-box;
  background: var(--panel); border-radius: 8px; padding: 6px 10px; box-shadow: 0 2px 10px rgba(0,0,0,.4);
}
#replayBar button, #replayBar select { background: #2c3a4f; color: var(--text); border: 0; border-radius: 4px; padding: 4px 8px; cursor: pointer; font: inherit; }
#replayBar button:hover { background: #3b4d68; }
#rpPlay { width: 34px; }
#rpSlider { flex: 1; min-width: 120px; accent-color: var(--accent); }
#rpTime { min-width: 150px; color: var(--muted); font-variant-numeric: tabular-nums; }
#rpLive { color: #8f8 !important; font-weight: 600; }
body.replaying #rpLive { color: var(--text) !important; background: #b8860b; }
body.replaying #rpTime { color: var(--accent); }
#rpNote { width: 100%; color: var(--muted); font-size: 11px; }
#rpNote:empty { display: none; }
body.replaying #v3dWrap { box-shadow: inset 0 0 0 3px rgba(255, 193, 7, 0.6); }

/* flight data box (3D): instrument-style numbers, can be dragged anywhere */
#flightBox {
  position: absolute; z-index: 30; right: 16px; top: 16px; min-width: 230px; max-width: calc(100% - 32px); box-sizing: border-box;
  background: rgba(12, 18, 28, 0.78); color: var(--text); border-radius: 10px; padding: 0 10px 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.45); backdrop-filter: blur(4px); user-select: none; font-variant-numeric: tabular-nums;
}
#fbHead { cursor: move; touch-action: none; padding: 7px 0 5px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
#fbName { color: var(--text); text-transform: none; letter-spacing: 0; margin-left: 4px; }
.fbGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.fbGrid > div { display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 4px; }
.fbVal { font-size: 26px; font-weight: 600; line-height: 1.05; text-align: right; min-width: 62px; }
.fbUnit { font-size: 11px; color: var(--muted); }
.fbLab { grid-column: 1 / -1; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.fbVal.up { color: #6fe08a; } .fbVal.down { color: #ff8a7a; }
#fbNear { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: 12px; }
#fbNear th { font-weight: 400; color: var(--muted); font-size: 10px; text-transform: uppercase; text-align: right; padding: 2px 0 2px 6px; }
#fbNear th:first-child, #fbNear td:first-child { text-align: left; padding-left: 0; }
#fbNear td { text-align: right; padding: 2px 0 2px 6px; border-top: 1px solid rgba(255,255,255,.08); white-space: nowrap; }
#fbNear td.up { color: #6fe08a; } #fbNear td.down { color: #ff8a7a; }

@media (max-width: 600px) {
  #panel { width: calc(100vw - 32px); }
  #note { display: none; }
  #wxCmp { top: auto; bottom: 70px; left: 8px; max-width: calc(100vw - 16px); font-size: 11px; }
}

/* webcam view (cloud calibration): our picture in the camera's 16:9 shape, the camera's picture over its left part */
#camImg { display: none; }
.camOnly { display: none; }
body.camMode .camOnly { display: block; }
body.camMode #camMode, body.camMode #flightBox { display: none; }
body.camMode #v3dWrap { inset: auto; left: 0; top: 0; width: min(100vw, 177.78vh); aspect-ratio: 16 / 9; height: auto; }
body.camMode #camImg { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.camOnly input[type=range] { width: 120px; vertical-align: middle; }
#camDebug { position: fixed; left: 0; bottom: 0; z-index: 50; display: flex; flex-wrap: wrap; gap: 2px; background: #000; }
#camDebug canvas { width: 320px; height: 180px; }
