* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f8f9fa;
  color: #333;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.topbar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  margin: 6px 8px 0;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  background: rgba(255,255,255,0.96);
  flex-wrap: wrap;
}

.mode-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tool-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-left: auto;
  flex-wrap: wrap;
}

.tab-btn,
.small-btn,
.app-select {
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 10px;
  background: #fff;
  color: #333;
  padding: 6px 10px;
  font-size: 13px;
}

.tab-btn.active { background: #e9ecef; }
.small-btn { cursor: pointer; }
.tab-btn { cursor: pointer; }

.icon-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.12);
  background: #fff;
  color: #333;
  cursor: pointer;
}
.icon-btn.active { background: #e9ecef; }
.icon-btn i { font-size: 14px; }

.mode-root {
  margin: 10px 12px 12px;
  height: calc(100vh - 90px);
  height: calc(100dvh - 90px);
  border: 1px solid #e0e0e0;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.mode-frame {
  width: 100%;
  height: 100%;
  border: 0;
}

.overlay-mode,
.map2d-mode {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
}

.overlay-hint, .map2d-toolbar {
  font-size: 13px;
  color: #555;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.overlay-plane-panel {
  min-width: min(100%, 520px);
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 10px 14px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ov-slider-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ov-slider-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
  color: #333;
}

.ov-slider-head b {
  font-variant-numeric: tabular-nums;
  min-width: 3.5em;
  text-align: right;
  color: #111;
}

.ov-label {
  font-weight: 600;
  color: #444;
}

.ov-slider-row--wide {
  flex: 2;
  min-width: 240px;
}

.ov-slider-row input[type="range"] {
  width: 100%;
  min-height: 28px;
}

.overlay-stage {
  position: relative;
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
}

.overlay-frame {
  position: absolute;
  inset: 0;
}

.overlay-right {
  z-index: 2;
}

.map2d-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.overlay-plane-panel--row {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  min-width: auto;
  max-width: none;
  padding: 6px 10px;
}

.ov-plane-btns {
  display: flex;
  gap: 4px;
}

.map2d-mode {
  background: #fff;
}

.map2d-pane {
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
  min-height: 300px;
  background: #fff;
}

.map2d-pane .leaflet-container,
.leaflet-container.map2d-map {
  background: #fff !important;
}

.map2d-measure-label {
  background: transparent !important;
  border: none !important;
}

.map2d-measure-label span {
  display: inline-block;
  padding: 3px 8px;
  font: 600 12px system-ui, sans-serif;
  color: #4a7a9b;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(126, 182, 218, 0.55);
  border-radius: 6px;
  white-space: nowrap;
  transform: translate(-50%, -50%);
}

.map2d-point-label {
  background: rgba(255, 255, 255, 0.92) !important;
  border: 1px solid rgba(232, 160, 154, 0.6) !important;
  color: #5c4a4a !important;
  font-weight: 600 !important;
  font-size: 11px !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  box-shadow: none !important;
}

@media (max-width: 960px) {
  .topbar { gap: 6px; }
  .mode-root {
    margin: 8px;
    height: calc(100vh - 140px);
    height: calc(100dvh - 140px);
  }
  .map2d-grid {
    grid-template-columns: 1fr;
  }
  .overlay-plane-panel {
    max-width: 100%;
    padding: 8px 10px;
  }
}
