/* 实时图像与坐标分发 —— 统一深色主题，浅色系统下自动适配 */
:root {
  --bg: #0f1419;
  --bg-soft: #121a22;
  --panel: #171f27;
  --panel-2: #1f2a35;
  --input-bg: #0d1318;
  --line: #2a3744;
  --text: #e6edf3;
  --muted: #93a4b3;
  --accent: #22d3ee;
  --accent-2: #f59e0b;
  --danger: #ef4444;
  --ok: #34d399;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.42);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #eef2f6;
    --bg-soft: #e6ebf1;
    --panel: #ffffff;
    --panel-2: #f1f5f9;
    --input-bg: #ffffff;
    --line: #cbd5e1;
    --text: #0f172a;
    --muted: #5b6b7c;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.14);
    color-scheme: light;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--accent);
}

svg {
  display: block;
}

button {
  font-family: inherit;
}

[hidden] {
  display: none !important;
}

/* ---------- 按钮 / 表单 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn:hover {
  background: color-mix(in srgb, var(--panel-2) 78%, var(--accent) 22%);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06232a;
}

.btn-primary:hover {
  background: #67e8f9;
}

.btn-danger {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.12);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.22);
}

.btn-ghost {
  background: transparent;
}

.btn-sm {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12.5px;
  border-radius: 7px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--panel);
}

.icon-btn.is-active {
  color: var(--accent);
  border-color: rgba(34, 211, 238, 0.6);
}

input[type="text"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.16);
}

input::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  color: var(--text);
  font-size: 13.5px;
  cursor: pointer;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  align-items: end;
}

.form-error {
  margin: 10px 0 0;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
  font-size: 13px;
}

.hint {
  color: var(--muted);
  font-size: 12.5px;
  margin: 0;
}

.hint.is-warn {
  color: #fbbf24;
}

.muted {
  color: var(--muted);
}

/* ---------- 徽标 / 卡片 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge.is-ok {
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.38);
  background: rgba(52, 211, 153, 0.1);
}

.badge.is-warn {
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.38);
  background: rgba(245, 158, 11, 0.1);
}

.badge.is-err {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.38);
  background: rgba(239, 68, 68, 0.1);
}

@media (prefers-color-scheme: light) {
  .badge.is-ok {
    color: #047857;
  }
  .badge.is-warn {
    color: #b45309;
  }
  .badge.is-err {
    color: #b91c1c;
  }
  .form-error {
    color: #b91c1c;
  }
}

.card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.card-head h2 {
  flex: 1;
  margin: 0;
  font-size: 15.5px;
  font-weight: 600;
}

/* ---------- 登录页 ---------- */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px;
  background:
    radial-gradient(1100px 500px at 50% -10%, rgba(34, 211, 238, 0.12), transparent 65%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 390px;
  padding: 26px 24px 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.login-brand svg {
  width: 34px;
  height: 34px;
  color: var(--accent);
  flex: 0 0 auto;
}

.login-brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.login-brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card .btn {
  min-height: 48px;
  font-size: 15px;
}

.login-foot {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 4px 10px 4px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
}

.user-chip svg {
  width: 19px;
  height: 19px;
  color: var(--accent);
  flex: 0 0 auto;
}

.user-chip .user-name {
  overflow: hidden;
  max-width: 130px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.fab-wrap {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 8px);
  left: calc(env(safe-area-inset-left) + 10px);
  z-index: 2600;
  touch-action: none;
}

.fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(15, 20, 25, 0.86);
  color: var(--text);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.fab:hover,
.fab:active {
  border-color: var(--accent);
  background: rgba(34, 211, 238, 0.18);
}

.menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: auto;
  z-index: 2500;
  width: 232px;
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 120px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.menu button,
.menu a {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.menu button:hover,
.menu a:hover {
  background: var(--panel-2);
}

.menu .menu-sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--line);
}

/* 朝向基准边四向选择（加 .menu 前缀提升特异性，压过 .menu button 的通配样式） */
.menu .heading-side-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 2px;
}

.menu .heading-side-label {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.menu .heading-side-group {
  display: flex;
  gap: 4px;
}

.menu .heading-side-btn {
  display: inline-block;
  width: auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 12.5px;
  padding: 5px 8px;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.menu .heading-side-btn:hover {
  background: var(--panel-2);
}

.menu .heading-side-btn.is-active {
  background: rgba(34, 211, 238, 0.16);
  border-color: rgba(34, 211, 238, 0.55);
  color: #eafdff;
}

/* 地图左下角：正北/朝向跟随切换 */
.compass-btn {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 990;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(10, 18, 26, 0.92);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  transition: border-color 0.15s, color 0.15s;
}

.compass-btn:hover {
  border-color: var(--accent);
}

.compass-btn.is-follow {
  border-color: rgba(34, 211, 238, 0.65);
  color: #67e8f9;
}

/* 右上角指南针：指针随地图 bearing 旋转（heading-up 时指示北在屏幕上的方向），
   点击回正北。与左下角 follow 按钮互为补充。 */
.map-compass {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 990;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(10, 18, 26, 0.92);
  cursor: pointer;
  padding: 0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.map-compass:active {
  transform: scale(0.94);
}

.compass-needle {
  display: block;
  width: 24px;
  height: 30px;
  transform: rotate(0deg);
  will-change: transform;
}

/* 朝向基准边高亮：选了非默认持握边（右/底/左）时，地图对应边缘显示 2px
   高亮线，提示“以手机哪条边为前方”。默认顶部不显示。地图旋转发生在
   map-canvas 内部，这条线是 UI 层，固定贴 pane 边缘不随地图转动。 */
.heading-edge {
  position: absolute;
  z-index: 991;
  pointer-events: none;
  background: var(--accent, #22d3ee);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.8);
}

.heading-edge[data-edge='top'] { top: 0; left: 0; right: 0; height: 2px; }

.heading-edge[data-edge='bottom'] { bottom: 0; left: 0; right: 0; height: 2px; }

.heading-edge[data-edge='left'] { top: 0; bottom: 0; left: 0; width: 2px; }

.heading-edge[data-edge='right'] { top: 0; bottom: 0; right: 0; width: 2px; }

/* 跟随模式：本人箭头去掉 CSS 过渡，与地图旋转逐帧同步（箭头钉在正上方）；
   其他用户的箭头仍保留过渡平滑 */
.mk-wrap.follow-pin .dir-arrow {
  transition: none;
}

.menu-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 6px;
  font-size: 13px;
  font-weight: 600;
}

.menu-user svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.menu-user .user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 8px 6px;
}

.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.menu-row:hover {
  background: var(--panel-2);
}

.menu .hint {
  padding: 2px 10px 8px;
  margin: 0;
}

/* ---------- 工具栏（已并入菜单） ---------- */
.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.switch .track {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  transition: background 0.15s, border-color 0.15s;
}

.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s, background 0.15s;
}

.switch input:checked + .track {
  border-color: rgba(34, 211, 238, 0.6);
  background: rgba(34, 211, 238, 0.22);
}

.switch input:checked + .track::after {
  background: var(--accent);
  transform: translateX(18px);
}

.switch input:focus-visible + .track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 主区分屏 ---------- */
.app-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 100dvh;
  /* 刘海/圆角屏留白：viewport-fit=cover 后靠安全区把内容让开 */
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  overflow: hidden;
}

.main-area {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  padding: 10px;
  overflow: hidden;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
  gap: 10px;
  width: 100%;
  height: 100%;
  position: relative; /* 收起态的面板绝对定位在此容器边缘 */
  min-height: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
}

.pane-head {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  user-select: none;
}

.pane-title {
  font-size: 13.5px;
  font-weight: 600;
}

.pane-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.pane-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #070b0f;
}

/* 放大 / 小窗 */
.main-area.layout-max .split {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.pane.pane-max {
  grid-column: 1;
  grid-row: 1;
}

.pane.pane-floating {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 1500;
  width: 320px;
  height: 220px;
  max-width: calc(100% - 32px);
  border-color: rgba(34, 211, 238, 0.55);
  box-shadow: var(--shadow);
}

.pane.pane-floating .pane-head {
  cursor: move;
  touch-action: none;
}

.pane.pane-floating .pane-title {
  font-size: 12.5px;
}

/* 最小化：面板收成屏幕边缘的竖排小标签，点击恢复；另一侧占满。
   rows: 1fr 让塌缩后的单面板占满整屏——竖屏是上下两行布局，
   收起的面板脱离网格流后若不并掉行轨道，剩余面板会缩回半屏 */
.split.min-map,
.split.min-video {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.pane.is-min {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: auto;
  z-index: 1200;
  cursor: pointer;
  border-color: rgba(34, 211, 238, 0.45);
  box-shadow: var(--shadow);
  background: var(--panel);
}

#pane-map.is-min {
  left: 8px;
}

#pane-video.is-min {
  right: 8px;
}

.pane.is-min .pane-head {
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  padding: 8px 4px;
  border-bottom: none;
  background: transparent;
}

.pane.is-min .pane-title {
  writing-mode: vertical-rl;
  letter-spacing: 3px;
  font-size: 12.5px;
}

.pane.is-min .pane-actions {
  flex-direction: column;
  margin-left: 0;
  gap: 4px;
}

.pane.is-min .pane-actions > *:not(.pane-min-btn) {
  display: none;
}

.pane.is-min .pane-min-btn {
  min-width: 0;
  padding-inline: 7px;
  font-size: 12px;
}

.pane.is-min .pane-body {
  display: none;
}

/* 收起后：剩余面板满屏（去掉主区域内边距与间隙） */
.main-area.layout-min {
  padding: 0;
}

.main-area.layout-min .split {
  gap: 0;
}

/* ---------- 地图 ---------- */
.map-canvas {
  position: absolute;
  inset: 0;
  background: #0b1117;
}

.leaflet-container {
  background: #0b1117;
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}

.map-source {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 900;
  max-width: calc(100% - 20px);
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(15, 20, 25, 0.86);
  color: #cbd5e1;
  font-size: 11.5px;
  pointer-events: none;
}

.map-hint {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 900;
  max-width: calc(100% - 20px);
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 20, 25, 0.86);
  color: #cbd5e1;
  font-size: 12px;
  pointer-events: none;
}

/* 标记 */
.mk-wrap {
  border: 0;
  background: transparent;
}

.mk {
  position: relative;
  width: 100%;
  height: 100%;
  color: var(--mk-color, #22d3ee);
}

.mk-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 跟随模式（heading-up）：地图旋转会经 rotateWithView 叠加到整个图标上，
     身体图标用 --mk-counter（= -bearing，由 map.js 随 rotate 事件写入）反向
     抵消，头永远朝上；正北模式变量为 0，行为与原来完全一致 */
  transform: rotate(var(--mk-counter, 0deg));
}

.mk-inner svg {
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.9));
}

.dir-arrow {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: 50% 50%;
}

.dir-arrow {
  /* 朝向平滑：两次更新之间由 CSS 过渡连续旋转（更新约 1Hz，500ms ease-out 近似匀速） */
  transition: transform 500ms ease-out;
  will-change: transform;
}

.dir-arrow svg {
  width: 100%;
  height: 100%;
  /* 朝向箭头放大：相对标记盒 1.6 倍，绕中心缩放不影响旋转角 */
  transform: scale(1.6);
  transform-origin: 50% 50%;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
}

.mk.is-offline {
  /* 离线用户：整体变灰 + 降透明度（20 秒后由 JS 直接移除图标） */
  opacity: 0.6;
  filter: grayscale(1) brightness(0.9);
}

.mk.is-own .mk-inner {
  /* 本人居中图标缩小，给朝向箭头让出视觉空间（需带上反向抵消角，不能丢） */
  transform: rotate(var(--mk-counter, 0deg)) scale(0.66);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75), 0 0 12px rgba(34, 211, 238, 0.55);
}

/* 地图文字标签（Leaflet tooltip） */
.leaflet-tooltip.map-label {
  padding: 2px 7px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 6px;
  background: rgba(15, 20, 25, 0.88);
  color: #e6edf3;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  font: 12px/1.45 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  white-space: nowrap;
}

.leaflet-tooltip.measure-label {
  padding: 1px 6px;
  border: 1px solid rgba(239, 68, 68, 0.85);
  border-radius: 6px;
  background: rgba(15, 20, 25, 0.93);
  color: #fecaca;
  font: 600 12px/1.4 system-ui, sans-serif;
  white-space: nowrap;
}

.leaflet-tooltip.map-label::before,
.leaflet-tooltip.measure-label::before {
  display: none !important;
}

.leaflet-control-zoom a {
  color: var(--text) !important;
  background: rgba(15, 20, 25, 0.9) !important;
  border-color: rgba(148, 163, 184, 0.35) !important;
}

/* 测距面板 */
.measure-panel {
  position: absolute;
  top: 44px;
  right: 10px;
  z-index: 1000;
  width: 232px;
  max-width: calc(100% - 20px);
  max-height: calc(100% - 54px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(23, 31, 39, 0.97);
  box-shadow: var(--shadow);
  overflow: hidden;
}

@media (prefers-color-scheme: light) {
  .measure-panel {
    background: rgba(255, 255, 255, 0.97);
  }
}

.measure-head-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.measure-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 13px;
  font-weight: 600;
}

.measure-head .btn {
  margin-left: auto;
}

.measure-list {
  overflow-y: auto;
  padding: 4px 6px;
}

.measure-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 5px;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.measure-item:hover {
  background: var(--panel-2);
}

.measure-item.is-disabled {
  opacity: 0.5;
  cursor: default;
}

.measure-item input {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

.measure-item .mi-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.measure-item .mi-kind {
  color: var(--muted);
  font-size: 11px;
  margin-left: auto;
  flex: 0 0 auto;
}

.measure-foot {
  padding: 7px 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

/* ---------- 视频 ---------- */
.video-body {
  background: #05080b;
}

.video-body video {
  width: 100%;
  height: 100%;
  background: #05080b;
  object-fit: contain;
}

.video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 18px;
  color: #cbd5e1;
  text-align: center;
  background: rgba(5, 8, 11, 0.35);
  pointer-events: none;
}

.video-overlay .btn {
  pointer-events: auto;
}

.video-overlay .video-msg {
  max-width: 280px;
  font-size: 13px;
  line-height: 1.55;
}

/* ---------- 模态框 / 提示条 ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3, 7, 12, 0.68);
}

.modal {
  width: 100%;
  max-width: 430px;
  max-height: calc(100vh - 40px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.modal h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

.modal form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 4000;
  max-width: calc(100% - 40px);
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 0.2s;
}

.toast.is-show {
  opacity: 1;
}

/* ---------- 管理后台 ---------- */
.admin-body {
  height: auto;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: auto;
}

.admin-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
}

.card .card-head .hint {
  text-align: right;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: 100%;
  min-width: 660px;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--panel-2) 65%, transparent);
}

.cell-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cell-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cell-icon svg {
  width: 17px;
  height: 17px;
  color: var(--muted);
}

.role-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.role-cell svg {
  width: 17px;
  height: 17px;
  color: var(--accent);
}

.role-cell.is-admin svg {
  color: var(--accent-2);
}

.token-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid rgba(245, 158, 11, 0.55);
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.1);
}

.token-box .token-note {
  color: #fbbf24;
  font-size: 12.5px;
}

.token-box code {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-all;
  user-select: all;
}

.token-box .token-actions {
  display: flex;
  gap: 8px;
}

.admin-section-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.form-inline {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.form-inline .field {
  flex: 1 1 180px;
}

.audit-detail {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.denied-card {
  margin: 40px auto;
  max-width: 420px;
  text-align: center;
}

.denied-card p {
  color: var(--muted);
}

/* ---------- 响应式 ---------- */

/* 竖屏：上下两屏；横屏保持左右两屏，把纵向空间全留给画面 */
@media (max-width: 899px) and (orientation: portrait) {
  .split {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .main-area.layout-max .split {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  .pane-floating {
    width: 300px !important;
    height: 200px !important;
  }

  .measure-panel {
    top: 40px;
  }
}

/* iPad Pro 等大屏竖屏（900–1024）：同样上下堆叠，视频给满宽 */
@media (min-width: 900px) and (max-width: 1024px) and (orientation: portrait) {
  .split {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .main-area.layout-max .split {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }
}

/* iPad / 平板：加粗触控操作区，避免 hover 依赖 */
@media (pointer: coarse) and (min-width: 641px) {
  .icon-btn {
    width: 42px;
    height: 42px;
  }

  .pane-head {
    min-height: 46px;
  }
}

@media (max-width: 640px) {
  .pane-head {
    min-height: 38px;
    padding: 4px 8px;
  }

  .main-area {
    padding: 8px;
  }

  .split {
    gap: 8px;
  }

  .pane-floating {
    right: 10px !important;
    bottom: 10px !important;
    width: 280px !important;
    height: 190px !important;
  }

  .admin-main {
    padding: 10px;
  }

  .card {
    padding: 12px;
  }
}

/* 横屏手机：压扁面板标题，减少留白 */
@media (orientation: landscape) and (max-height: 620px) {
  .icon-btn {
    width: 32px;
    height: 32px;
  }

  .main-area {
    padding: 6px;
  }

  .split {
    gap: 6px;
  }

  .pane-head {
    min-height: 32px;
    padding: 3px 8px;
  }

  .pane-title {
    font-size: 12.5px;
  }

  .pane-head .btn {
    min-height: 26px;
    padding: 3px 8px;
    font-size: 11.5px;
  }

  .pane-floating {
    right: 8px !important;
    bottom: 8px !important;
    width: 260px !important;
    height: 168px !important;
  }

  .measure-panel {
    top: 34px;
    max-height: calc(100% - 40px);
  }

  .menu {
    max-height: calc(100dvh - 56px);
  }
}

/* 超矮横屏（手机横屏键盘弹出等）：进一步压缩边框 chrome */
@media (orientation: landscape) and (max-height: 460px) {
  .main-area {
    padding: 4px;
  }

  .split {
    gap: 4px;
  }

  .pane-head {
    min-height: 28px;
    padding: 2px 6px;
  }

  .pane-floating {
    width: 220px !important;
    height: 140px !important;
  }

  .measure-panel {
    top: 30px;
    width: 210px;
    max-height: calc(100% - 34px);
  }
}

/* ---------- 管理后台内容区（新增页面补充） ---------- */
#admin-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (max-width: 640px) {
  #admin-content {
    gap: 12px;
  }
}

/* ---------- 地图涂鸦 ---------- */
/* 入口按钮复用 .compass-btn 基础样式，叠在其上方一层 */
.doodle-btn {
  bottom: 58px;
}

.doodle-btn.is-active {
  border-color: rgba(34, 211, 238, 0.65);
  color: #67e8f9;
}

/* 工具条：竖排悬浮，跟随入口按钮 */
.doodle-toolbar {
  position: absolute;
  left: 10px;
  bottom: 104px;
  z-index: 990;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(10, 18, 26, 0.92);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.doodle-toolbar[hidden] {
  display: none;
}

/* 涂鸦测距：距离标签（线段中点，不随地图旋转） */
.doodle-dist-wrap {
  background: none;
  border: 0;
  pointer-events: none;
}

.doodle-dist-label {
  display: inline-block;
  transform: translate(-50%, -50%);
  padding: 2px 8px;
  border: 1px solid rgba(34, 197, 94, 0.55);
  border-radius: 999px;
  background: rgba(6, 30, 16, 0.85);
  color: #4ade80;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
}

@media (prefers-color-scheme: light) {
  .doodle-dist-label {
    background: rgba(240, 253, 244, 0.92);
    color: #15803d;
  }
}

.doodle-tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.doodle-tool-btn:hover {
  background: var(--panel-2);
}

.doodle-tool-btn.is-active {
  border-color: rgba(34, 211, 238, 0.55);
  background: rgba(34, 211, 238, 0.16);
  color: #67e8f9;
}

/* 清除类按钮：红色警示 */
.doodle-tool-btn.dood-danger {
  color: #f87171;
}

.doodle-tool-btn.dood-danger:hover {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.4);
}

.doodle-sep {
  height: 1px;
  margin: 0 4px;
  background: var(--line);
}

/* 涂鸦实体：divIcon 容器要去掉 Leaflet 默认白底 */
.doodle-marker {
  background: transparent;
  border: 0;
}

.doodle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.6));
}

.doodle-icon svg {
  display: block;
}

/* 管理小浮层（删除/隐藏） */
.doodle-popup {
  min-width: 150px;
}

.doodle-popup-title {
  margin-bottom: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.doodle-popup-actions {
  display: flex;
  gap: 8px;
}
