:root {
  color: #e6ebf0;
  background: #0e1217;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body,
.viewer-shell {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
select,
input {
  font: inherit;
}

.viewer-shell {
  position: relative;
  background: #10161c;
}

#scene-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#scene-canvas.dragging {
  cursor: grabbing;
}

.viewer-controls {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 310px;
  padding: 48px 20px 17px;
  background: rgba(23, 28, 34, 0.95);
  border: 1px solid #303842;
  border-radius: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}

.mode-switch {
  position: absolute;
  top: 7px;
  left: 10px;
  height: 21px;
  display: flex;
  overflow: hidden;
  background: #20262e;
  border: 1px solid #39434e;
  border-radius: 999px;
}

.mode-switch a,
.mode-switch span {
  min-width: 39px;
  padding: 0 8px;
  color: #9aa6b1;
  font-size: 10px;
  line-height: 19px;
  text-align: center;
  text-decoration: none;
}

.mode-switch .active {
  color: #ffffff;
  background: #287a75;
}

.mode-switch a:hover {
  color: #ffffff;
  background: #29333c;
}

.language-button {
  position: absolute;
  top: 7px;
  right: 10px;
  height: 21px;
  padding: 0 8px;
  color: #9addd8;
  background: #20262e;
  border: 1px solid #39434e;
  border-radius: 999px;
  cursor: pointer;
  font-size: 10px;
  line-height: 19px;
}

.language-button:hover {
  color: #ffffff;
  border-color: #5b6875;
}

.viewer-control-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  color: #e0e6ec;
  font-size: 13px;
  font-weight: 600;
}

.seed-position-row {
  grid-template-columns: 1fr auto;
  row-gap: 10px;
}

.seed-position-row output {
  color: #b9c2cc;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.seed-position-row input {
  grid-column: 1 / -1;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  margin: 0;
  appearance: none;
  background: #3a424c;
  border-radius: 999px;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  appearance: none;
  background: #171c22;
  border: 2px solid #70c9c2;
  border-radius: 50%;
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  background: #171c22;
  border: 2px solid #70c9c2;
  border-radius: 50%;
}

.viewer-controls select,
.viewer-controls button {
  height: 36px;
  color: #e3e8ed;
  background: #202831;
  border: 1px solid #3b4651;
  border-radius: 7px;
}

.viewer-controls select {
  min-width: 0;
  padding: 0 10px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 2px;
}

.button-row button {
  height: 39px;
}

.viewer-controls button {
  cursor: pointer;
}

.viewer-controls button:hover {
  background: #2b3741;
  border-color: #5a6875;
}

.viewer-controls .primary-button {
  color: #ffffff;
  background: #287a75;
  border-color: #287a75;
  font-weight: 650;
}

.viewer-controls .primary-button:hover {
  background: #31918b;
  border-color: #31918b;
}

#load-status {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 16px;
  margin: 10px 0 0;
  color: #8f9aa5;
  font-size: 11px;
  text-align: center;
}

.viewer-help {
  position: absolute;
  right: 18px;
  bottom: 16px;
  padding: 7px 10px;
  color: #aeb8c1;
  background: rgba(20, 27, 34, 0.78);
  border-radius: 7px;
  font-size: 11px;
  pointer-events: none;
}

.speed-legend {
  position: absolute;
  top: 24px;
  right: 22px;
  display: grid;
  grid-template-columns: 12px 34px 18px;
  grid-template-rows: 1fr 1fr 1fr;
  width: 82px;
  height: 250px;
  padding: 12px 10px;
  color: #f3f6f8;
  background: #171c22;
  border-radius: 8px;
  font-size: 12px;
  pointer-events: none;
}

.speed-gradient {
  grid-row: 1 / 4;
  width: 12px;
  border-radius: 2px;
  background: linear-gradient(to top, #30123b, #4145ab, #2a8bd1, #1bcfd4, #61fc6c, #d1e834, #fca50a, #e12a1f, #7a0403);
}

.speed-maximum,
.speed-midpoint,
.speed-minimum {
  padding-left: 6px;
  font-variant-numeric: tabular-nums;
}

.speed-maximum { align-self: start; }
.speed-midpoint { align-self: center; }
.speed-minimum { align-self: end; }

.speed-title {
  grid-column: 3;
  grid-row: 1 / 4;
  align-self: center;
  white-space: nowrap;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

html[lang="zh-CN"] .speed-title {
  transform: none;
}

[hidden] {
  display: none !important;
}

/* Local drone demo. Original wind viewer remains independent. */
.viewer-controls { width: 278px; max-height: calc(100% - 40px); overflow-y: auto; }
.speed-legend { top: auto; right: auto; left: 16px; bottom: 54px; height: 164px; background: rgba(23,28,34,.88); }
.viewer-help { left: 16px; right: auto; max-width: calc(100% - 32px); }
#scene-canvas.route-editing { cursor: crosshair; }
.drone-panel {
  position: absolute; top: 16px; right: 16px; width: 326px; max-height: calc(100% - 32px);
  padding: 19px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #455462 transparent;
  color: #e5edf3; background: rgba(17,25,33,.96); border: 1px solid #354552; border-radius: 14px;
  box-shadow: 0 12px 40px #0005; font-size: 12px;
}
.drone-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lab-label { color: #6dcfc8; letter-spacing: 2px; font-size: 9px; font-weight: 700; }
.drone-header h1 { font-size: 21px; font-weight: 650; margin: 5px 0 0; letter-spacing: -.4px; }
.drone-state { flex-shrink: 0; padding: 6px 9px; border-radius: 6px; background: #253541; color: #b7c9d5; font-size: 11px; }
.drone-state[data-state="flying"] { background: #123e3a; color: #80e9d6; }
.drone-state[data-state="drifting"] { background: #4c341d; color: #ffc37a; }
.drone-state[data-state="collision"], .drone-state[data-state="boundary"] { background: #542c32; color: #ffafb4; }
.drone-intro { color: #9caebb; line-height: 1.5; margin: 12px 0; }
.drone-panel fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.drone-section-heading { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #2b3a46; padding-top: 13px; margin: 13px 0 10px; color: #91a8b7; font-size: 11px; }
.drone-panel summary { cursor: pointer; list-style: none; }
.drone-panel summary::-webkit-details-marker { display: none; }
.drone-panel summary > span:first-child::before { content: '▸ '; color: #6dcfc8; }
.drone-panel details[open] > summary > span:first-child::before { content: '▾ '; }
.aircraft-tag { color: #5c7d8d; font-size: 9px; letter-spacing: 1px; }
.drone-panel button, .drone-panel select { min-height: 32px; border: 1px solid #364b59; border-radius: 6px; color: #d9e7ef; background: #202f3b; padding: 5px 8px; font-size: 11px; cursor: pointer; }
.drone-panel button:hover:not(:disabled) { background: #304655; border-color: #6b97ab; }
.drone-panel button:focus-visible, .drone-panel input:focus-visible, .drone-panel select:focus-visible { outline: 2px solid #8cebe0; outline-offset: 3px; }
.drone-panel button:disabled, .drone-panel fieldset:disabled { opacity: .45; cursor: default; }
.drone-panel button[aria-pressed="true"] { color: #96f3e7; background: #184b48; border-color: #54b5aa; }
.drone-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.route-actions { grid-template-columns: 1.4fr 1fr 1fr; margin-top: 6px; }
.flight-actions { grid-template-columns: 1fr 1fr; margin-top: 12px; }
.drone-panel .drone-primary { background: #267c76; border-color: #378f88; color: white; font-weight: 600; }
.drone-hint { color: #849dab; font-size: 10px; line-height: 1.55; margin: 8px 0 11px; }
.drone-slider { display: grid; grid-template-columns: 1fr auto; gap: 11px 8px; margin: 12px 0 15px; }
.drone-slider output { font-variant-numeric: tabular-nums; color: #89ded2; }
.drone-slider input { grid-column: 1 / -1; accent-color: #70c9c2; }
.drone-playback { display: flex; gap: 8px; align-items: center; margin-top: 12px; color: #93aab9; }
.drone-playback button { margin-left: auto; }
.drone-notice { color: #a9c2d1; margin: 12px 0 10px; line-height: 1.6; font-size: 11px; }
.drone-notice.warning { color: #ffc37a; }
.drone-key { display: flex; gap: 12px; color: #849dab; font-size: 10px; }
.drone-key > span { display: flex; align-items: center; gap: 4px; }
.drone-key i { display: inline-block; width: 18px; border-top: 3px solid #00e5ff; }
.drone-key i.planned { border-top: 3px dashed #ff48dc; }
.drone-key i.drifting { border-color: #ffe44a; }
.drone-footnote { color: #6e8797; font-size: 9px; line-height: 1.5; margin: 10px 0 0; }
.drone-impact-label { position: absolute; left: 0; top: 0; pointer-events: none; white-space: nowrap; }
.drone-impact-label { padding: 7px 10px; background: #6c2029ec; color: #ffe2e3; border: 1px solid #ff7983; border-radius: 5px; font-size: 12px; box-shadow: 0 0 25px #ff475755; }
@media (max-width: 1000px) {
  .viewer-controls { width: 224px; padding: 42px 12px 12px; max-height: 40vh; }
  .viewer-control-row { grid-template-columns: 68px minmax(0,1fr); gap: 7px; font-size: 11px; }
  .drone-panel { top: auto; bottom: 12px; right: 12px; width: 285px; padding: 14px; max-height: 48vh; }
  .drone-intro { display: none; }
  .drone-panel .drone-section-heading { margin: 9px 0 6px; padding-top: 9px; }
  .drone-header h1 { font-size: 18px; }
  .drone-notice { margin: 8px 0; }
  .drone-footnote { margin: 6px 0 0; }
  .viewer-help { max-width: calc(100% - 320px); font-size: 9px; }
}
@media (max-width: 580px) {
  .viewer-controls { top: 8px; left: 8px; width: 200px; max-height: 28vh; }
  .drone-panel { top: auto; bottom: 8px; right: 8px; width: min(310px, calc(100% - 16px)); max-height: 48vh; }
  .speed-legend { top: 12px; bottom: auto; left: auto; right: 8px; height: 140px; }
  .viewer-help { bottom: auto; top: 29vh; left: 8px; font-size: 9px; max-width: calc(100% - 16px); }
}

/* Persistent flight controls and editable 3D waypoints. */
.drone-header { position: sticky; top: -19px; z-index: 2; padding: 8px 0; background: #111921; }
.drone-status-row { display: flex; align-items: center; gap: 8px; position: sticky; top: 43px; z-index: 2; background: #111921; padding: 5px 0; }
.drone-status-row .drone-primary { margin-left: auto; }
.drone-status-row .drone-stop { color: #ffbcc1; border-color: #99545c; }
.drone-panel.collapsed { overflow: visible; }
.drone-panel.collapsed .drone-header, .drone-panel.collapsed .drone-status-row { position: static; }
.drone-state[data-state="hovering"] { background: #1d443a; color: #a0f2c5; }
.drone-waypoints { max-height: 215px; overflow-y: auto; scrollbar-width: thin; }
.drone-waypoint { display: grid; grid-template-columns: 20px repeat(3, minmax(0, 1fr)); gap: 6px; align-items: center; padding: 7px 0; border-bottom: 1px solid #2b3a46; }
.drone-waypoint > span { color: #70d9c8; }
.drone-waypoint label { min-width: 0; color: #93aab9; font-size: 10px; }
.drone-waypoint input { width: 100%; min-width: 0; margin-top: 4px; padding: 5px 3px; color: #d9e7ef; background: #202f3b; border: 1px solid #364b59; border-radius: 4px; font-size: 11px; }
.drone-waypoint input:disabled { opacity: .5; }
.drone-camera-row { display: flex; align-items: center; gap: 12px; margin-top: 10px; color: #93aab9; }
.drone-camera-row select { flex: 1; min-width: 0; }
@media (max-width: 1000px) { .drone-header { top: -14px; } .drone-status-row { top: 44px; } }

.drone-waypoints { max-height: 320px; }
.drone-waypoint { grid-template-columns: 25px repeat(3, minmax(0, 1fr)); padding: 10px 5px; border: 1px solid transparent; border-bottom-color: #2b3a46; border-radius: 5px; margin-bottom: 4px; }
.drone-waypoint.selected { border-color: #cb9b4d; background: #3b332440; }
.drone-waypoint > button { padding: 3px; min-width: 0; }
.drone-waypoint .waypoint-clearance { grid-column: 2 / 4; }
.drone-waypoint .waypoint-surface { grid-column: 2 / -1; color: #8fa7b8; font-size: 10px; }

/* Leave room for sticky flight controls when revealing a selected waypoint. */
.drone-panel { scroll-padding-top: 115px; scroll-padding-bottom: 12px; }

/* Trackpad-friendly camera movement, independent from waypoint editing. */
.camera-pad { position: absolute; left: 112px; bottom: 54px; z-index: 3; width: 158px; padding: 10px; border: 1px solid #354552; border-radius: 12px; color: #d9e7ef; background: #111921f5; box-shadow: 0 6px 25px #0004; }
.camera-pad summary { cursor: pointer; font-size: 12px; color: #a9d9d1; user-select: none; }
.camera-dpad { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 40px); gap: 4px; margin: 10px 0 6px; }
.camera-pad button { min-width: 0; border: 1px solid #3f5967; border-radius: 7px; background: #20323e; color: #e4f3f4; font-size: 20px; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; }
.camera-pad button:hover, .camera-pad button.held { background: #315d63; border-color: #78d9cc; }
.camera-pad button:focus-visible, .camera-pad summary:focus-visible { outline: 2px solid #8cebe0; outline-offset: 2px; }
.camera-up { grid-area: 1 / 2; }
.camera-left { grid-area: 2 / 1; }
.camera-focus { grid-area: 2 / 2; }
.camera-right { grid-area: 2 / 3; }
.camera-down { grid-area: 3 / 2; }
.camera-zoom { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; height: 36px; }
.camera-pad p { margin: 7px 0 0; color: #91a8b7; font-size: 9px; line-height: 1.4; }
@media (max-width: 580px) {
  .camera-pad { left: 8px; bottom: auto; top: calc(28vh + 32px); width: 158px; max-height: calc(24vh - 48px); min-height: 38px; overflow-y: auto; }
}

.camera-rotate { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: 6px 0; }
.camera-pad .camera-rotate button { min-height: 34px; padding: 3px; font-size: 11px; }

.drone-waypoint .waypoint-contact { grid-column: 1 / -1; font-size: 10px; color: #a8ded4; padding: 6px; }
.route-exposure { white-space: pre-line; padding: 9px 10px; border-left: 2px solid #d89cff; background: #28303d; border-radius: 5px; color: #e0d6ec; line-height: 1.65; }
.waypoint-gizmo { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: hidden; z-index: 2; }
.waypoint-axis { pointer-events: all; cursor: grab; touch-action: none; user-select: none; }
.waypoint-axis text { font: bold 14px system-ui, sans-serif; pointer-events: none; }
.waypoint-axis.active { cursor: grabbing; }
.waypoint-axis:hover circle, .waypoint-axis:focus circle, .waypoint-axis.active circle { fill: #344454; stroke-width: 4; }
.drone-panel, .viewer-controls { z-index: 4; }
.drone-state[data-state="takingoff"], .drone-state[data-state="landing"], .drone-state[data-state="landed"] { color: #a0f2c5; background: #1d443a; }

.route-storage { margin-top: 8px; }

/* Keep the native checkbox for keyboard and label activation; style its track. */
.wind-follow-control { position:relative; display:flex; gap:10px; align-items:center; min-height:32px; font-size:12px; margin:0 0 12px; color:#a1efdf; cursor:pointer; }
.wind-follow-control input { position:absolute; left:0; top:50%; transform:translateY(-50%); width:40px; height:24px; margin:0; opacity:0; cursor:pointer; }
.wind-follow-switch { flex:0 0 38px; height:22px; border:1px solid #52616b; border-radius:999px; background:#26323b; pointer-events:none; transition:background .16s, border-color .16s; }
.wind-follow-switch::after { content:""; display:block; width:14px; height:14px; margin:3px; border-radius:50%; background:#b6c6ce; transition:transform .16s, background .16s; }
.wind-follow-control input:checked + .wind-follow-switch { background:#287a75; border-color:#70c9c2; }
.wind-follow-control input:checked + .wind-follow-switch::after { transform:translateX(16px); background:#d4fff5; }
.wind-follow-control:hover .wind-follow-switch { border-color:#8ddfd4; }
.wind-follow-control input:focus-visible + .wind-follow-switch { outline:2px solid #8cebe0; outline-offset:3px; }
.wind-follow-control input:disabled + .wind-follow-switch { opacity:.45; }
@media (prefers-reduced-motion: reduce) {
  .wind-follow-switch, .wind-follow-switch::after { transition:none; }
}
@media (forced-colors: active) {
  .wind-follow-switch { border-color:ButtonText; }
  .wind-follow-switch::after { background:ButtonText; }
  .wind-follow-control input:checked + .wind-follow-switch { background:Highlight; }
  .wind-follow-control input:checked + .wind-follow-switch::after { background:HighlightText; }
}
.drone-route-name { display:grid; gap:6px; margin-top:12px; color:#a9c2d1; }
.drone-route-name input { min-width:0; padding:8px; color:#e5edf3; background:#17252e; border:1px solid #455a67; border-radius:6px; }
.saved-routes-link { display:block; margin:10px 0; color:#96f3e7; }

.wind-band { margin:0 0 12px; color:#abc2cc; font-size:12px; }
.wind-band[hidden] { display:none; }
.wind-band label { display:flex; justify-content:space-between; gap:8px; }
.wind-band input { width:100%; margin:10px 0 0; accent-color:#70c9c2; }
.wind-band output { color:#91eedc; }
.wind-band p { margin:5px 0 0; font-size:11px; }
