/* style.css —— 摩托路书全站唯一样式文件：页面骨架、通用组件、地图覆盖物、Key 引导与响应式 */

/* ===== 设计变量 ===== */
:root {
  /* 主色板 */
  --color-primary: #1e4b7a;
  --color-danger: #dc2626;
  --color-warning: #d97706;
  --color-success: #16a34a;

  /* 中性色 */
  --color-panel: #ffffff;
  --color-white: #ffffff;
  --color-bg: #f1f5f9;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-text-strong: #0f172a;
  --color-surface-subtle: #f8fafc;
  --color-coords: #334155;
  --color-icon-muted: #94a3b8;
  --color-map-bg: #e8ecef;
  --color-dark-surface: #0f172a;
  --color-code-text: #e2e8f0;

  /* 状态与浮层色 */
  --color-danger-soft: #fee2e2;
  --color-danger-bg: #fef2f2;
  --color-danger-border: #fecaca;
  --color-warning-bg: #fef3c7;
  --color-warning-text: #92400e;
  --color-overlay: rgba(15, 23, 42, 0.66);
  --color-hint-bg: rgba(30, 75, 122, 0.92);

  /* 顶栏专用色 */
  --color-on-primary-muted: rgba(255, 255, 255, 0.55);
  --color-view-btn: rgba(255, 255, 255, 0.16);
  --color-view-btn-hover: rgba(255, 255, 255, 0.26);

  /* 字体 */
  --font-sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, monospace;

  /* 尺寸与圆角 */
  --topbar-height: 52px;
  --sidebar-width: 320px;
  --touch-target: 40px;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --radius-pill: 999px;

  /* 动效与阴影 */
  --duration-fast: 0.15s;
  --duration-fade: 0.18s;
  --shadow-marker: 0 2px 6px rgba(0, 0, 0, 0.35);
  --shadow-hint: 0 4px 14px rgba(15, 23, 42, 0.24);
  --shadow-toast: 0 10px 30px rgba(15, 23, 42, 0.3);
  --shadow-setup: 0 20px 50px rgba(0, 0, 0, 0.3);
}

/* ===== 基础重置 ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

/* 全局隐藏工具类；优先级高于组件的 display 声明 */
.hidden {
  display: none !important;
}

/* 键盘可达的可见焦点 */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ===== 布局骨架 ===== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh; /* 旧浏览器回退 */
  height: 100dvh; /* dvh 避免移动端地址栏伸缩时底部被遮挡 */
  overflow: hidden;
  background: var(--color-bg);
}

#topbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
  height: var(--topbar-height);
  padding: 0 16px;
  color: var(--color-white);
  background: var(--color-primary);
}

#banner {
  flex: 0 0 auto;
  padding: 10px 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-warning-text);
  background: var(--color-warning-bg);
  border-left: 4px solid var(--color-warning);
  overflow-wrap: anywhere;
}

#main {
  position: relative; /* 为 #hint 提供定位上下文 */
  display: flex;
  flex: 1;
  flex-direction: row;
  min-height: 0; /* 关键：让子元素在 flex 容器内正确收缩 */
  overflow: hidden;
  background: var(--color-map-bg);
}

#map {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--color-map-bg);
}

#sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  min-height: 0;
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--color-bg);
  border-left: 1px solid var(--color-border);
}

/* ===== 顶栏：品牌、视图切换与操作按钮 ===== */
.brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: baseline;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--color-white);
  white-space: nowrap;
}

.brand-sub {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  color: var(--color-on-primary-muted);
}

.view-switch {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
}

.view-btn {
  min-height: 32px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--color-white);
  white-space: nowrap;
  cursor: pointer;
  background: var(--color-view-btn);
  border: 0;
  border-radius: var(--radius-pill);
  transition:
    background-color var(--duration-fast),
    color var(--duration-fast),
    opacity var(--duration-fast);
}

.view-btn:not(:disabled):hover {
  background: var(--color-view-btn-hover);
}

.view-btn.active,
.view-btn.active:not(:disabled):hover {
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-white);
}

.view-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.btn {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--color-text);
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition:
    background-color var(--duration-fast),
    border-color var(--duration-fast),
    color var(--duration-fast);
}

.btn:hover {
  background: var(--color-bg);
  border-color: var(--color-primary);
}

.btn-danger {
  color: var(--color-danger);
  border-color: var(--color-danger-border);
}

.btn-danger:hover {
  color: var(--color-danger);
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
}

/* label 本身是按钮；input 必须完全隐藏，不能使用 width: 0 的占位方案 */
.btn-file {
  cursor: pointer;
}

.btn-file input[type="file"] {
  display: none;
}

/* 深蓝顶栏上补充白色光晕，让规定的深蓝焦点环仍可辨认 */
#topbar .btn:focus-visible,
#topbar .view-btn:focus-visible {
  box-shadow: 0 0 0 4px var(--color-white);
}

/* ===== 侧栏：面板、概览与路径点 ===== */
.panel {
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.panel:last-child {
  margin-bottom: 0;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-text-strong);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  min-width: 0;
  padding: 8px 4px;
  text-align: center;
  background: var(--color-surface-subtle);
  border-radius: var(--radius-md);
}

.stat-value {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-text-strong);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--color-text-secondary);
  letter-spacing: 0.5px;
}

.points-list {
  max-height: 380px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.pt-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  transition: background-color var(--duration-fast);
}

.pt-item + .pt-item {
  margin-top: 2px;
}

.pt-item:hover {
  background: var(--color-surface-subtle);
}

.pt-role {
  display: inline-flex;
  flex: 0 0 22px;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  color: var(--color-white);
  border-radius: var(--radius-sm);
}

.pt-role-start {
  background: var(--color-success);
}

.pt-role-end {
  background: var(--color-danger);
}

.pt-role-shape {
  background: var(--color-primary);
}

.pt-coords {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-coords);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pt-del {
  display: inline-flex;
  flex: 0 0 24px;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  margin-left: auto;
  font-size: 18px;
  line-height: 1;
  color: var(--color-icon-muted);
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  transition:
    background-color var(--duration-fast),
    color var(--duration-fast);
}

.pt-del:hover,
.pt-del:focus-visible {
  color: var(--color-danger);
  background: var(--color-danger-soft);
}

/* ===== 地图覆盖物：路径点 Marker 与 InfoWindow ===== */
.mk {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  color: var(--color-white);
  text-align: center;
  user-select: none;
  cursor: grab;
  background: var(--color-primary);
  border: 2px solid var(--color-white);
  border-radius: 50%;
  box-shadow: var(--shadow-marker);
  transform-origin: center;
  transition: transform var(--duration-fast);
}

.mk:hover {
  transform: scale(1.08);
}

.mk:active {
  cursor: grabbing;
}

.mk-start {
  background: var(--color-success);
}

.mk-end {
  background: var(--color-danger);
}

.mk-shape {
  font-size: 13px;
  background: var(--color-primary);
}

.iw-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 160px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text);
}

.iw-title {
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text);
}

.iw-del {
  align-self: flex-end;
  padding: 6px 10px;
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-danger);
  cursor: pointer;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  transition:
    background-color var(--duration-fast),
    color var(--duration-fast);
}

.iw-del:hover,
.iw-del:focus-visible {
  color: var(--color-danger);
  background: var(--color-danger-bg);
}

/* ===== 浮动反馈：地图提示与 Toast ===== */
.hint {
  position: absolute;
  top: 12px;
  right: var(--sidebar-width); /* 桌面端以地图区域而非整页为居中基准 */
  left: 0;
  z-index: 5;
  width: max-content;
  max-width: calc(100% - var(--sidebar-width) - 32px);
  padding: 8px 18px;
  margin-right: auto;
  margin-left: auto;
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-white);
  text-align: center;
  pointer-events: none;
  background: var(--color-hint-bg);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-hint);
  opacity: 1;
  transition: opacity var(--duration-fade);
}

/* id 与 class 两种引用方式都命中（HTML 用 id="toast"） */
#toast,
.toast {
  position: fixed;
  bottom: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 1100;
  max-width: calc(100vw - 32px);
  padding: 10px 20px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-white);
  text-align: center;
  overflow-wrap: anywhere;
  pointer-events: none;
  background: var(--color-dark-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-toast);
  opacity: 1;
  transform: translateX(-50%);
  transition: opacity var(--duration-fade);
}

/* ===== 响应式布局（<768px） ===== */
@media (max-width: 767px) {
  #topbar {
    flex-wrap: wrap;
    gap: 8px 10px;
    height: auto;
    padding: 8px 12px;
  }

  .brand-sub {
    display: none;
  }

  .view-switch {
    gap: 2px;
  }

  .view-btn {
    min-height: var(--touch-target);
    padding: 0 12px;
  }

  .topbar-actions {
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
  }

  .btn {
    min-height: var(--touch-target);
    padding: 6px 10px;
    font-size: 12px;
  }

  #main {
    flex-direction: column;
  }

  #map {
    flex: 1;
    min-height: 0;
  }

  #sidebar {
    width: 100%;
    max-height: 42vh;
    padding: 12px;
    overflow-y: auto;
    border-top: 1px solid var(--color-border);
    border-left: 0;
  }

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stat-value {
    font-size: 15px;
  }

  /* 抽屉本身负责滚动，避免路径点列表形成第二层嵌套滚动 */
  .points-list {
    max-height: none;
  }

  .pt-del {
    flex-basis: var(--touch-target);
    width: var(--touch-target);
    height: var(--touch-target);
    font-size: 20px;
  }

  /* 视觉仍为 28px，触达区域扩至 40px */
  .mk::after {
    position: absolute;
    inset: -6px;
    content: "";
    border-radius: 50%;
  }

  .iw-del {
    min-height: var(--touch-target);
    padding: 8px 12px;
  }

  .hint {
    right: 0;
    max-width: 90%;
    font-size: 12px;
  }
}

/* ===== 减少动效 ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }

  .mk:hover {
    transform: none;
  }
}

/* ===== P2：导航模式 ===== */

/* 导航模式：隐藏侧栏，地图占满主区域（顶栏保留，用于退出） */
body.nav-mode #sidebar {
  display: none;
}

/* 顶部转向指令条 */
.nav-instruction {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 8;
  min-width: min(92%, 420px);
  max-width: min(94%, 560px);
  padding: 10px 22px;
  color: #fff;
  text-align: center;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.92);
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  transform: translateX(-50%);
}

.nav-step-text {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
}

.nav-step-dist {
  margin-top: 2px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: #93c5fd;
}

/* 开始导航前的遮罩（必须有用户点按，iOS 语音才能解锁） */
.nav-start-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.35);
}

.btn-nav-start {
  padding: 16px 52px;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: var(--color-success);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(22, 163, 74, 0.45);
  transition: transform var(--duration-fast), box-shadow var(--duration-fast);
}

.btn-nav-start:hover {
  transform: scale(1.04);
  box-shadow: 0 10px 28px rgba(22, 163, 74, 0.55);
}

.btn-nav-start:active {
  transform: scale(0.98);
}

.nav-start-note {
  padding: 6px 14px;
  margin: 0;
  font-size: 12px;
  color: #e2e8f0;
  text-align: center;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 8px;
}

/* 底部状态条：剩余距离 / 剩余时间 / 速度 / 已骑 */
.nav-status {
  position: absolute;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 12px;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 12px;
  color: #fff;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.nav-stat {
  min-width: 0;
  text-align: center;
}

.nav-stat span {
  display: block;
  overflow: hidden;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-stat label {
  font-size: 10px;
  color: #94a3b8;
  letter-spacing: 0.5px;
}

/* 当前位置圆点（比路径点小、带脉冲光晕） */
.nav-pos {
  width: 18px;
  height: 18px;
  background: #2563eb;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.4),
    0 0 0 8px rgba(37, 99, 235, 0.18);
}

@media (max-width: 767px) {
  .nav-step-text {
    font-size: 17px;
  }

  .nav-step-dist {
    font-size: 13px;
  }

  .nav-instruction {
    top: 8px;
    padding: 8px 16px;
  }

  .nav-status {
    padding: 8px;
  }

  .nav-stat span {
    font-size: 14px;
  }

  .btn-nav-start {
    padding: 14px 44px;
    font-size: 18px;
  }
}

/* ===== Key 配置引导层 ===== */
.setup {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--color-overlay);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.setup-card {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 28px 32px;
  overflow-y: auto;
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-setup);
}

.setup-card h1 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--color-text-strong);
}

.setup-steps {
  padding-left: 22px;
  margin: 0;
  font-size: 14px;
  line-height: 1.8;
  color: var(--color-coords);
}

.setup-steps li {
  margin: 4px 0;
}

.setup-steps li::marker {
  font-weight: 600;
  color: var(--color-primary);
}

.setup-steps a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.setup-steps code,
.setup-code {
  font-family: var(--font-mono);
}

.setup-steps code {
  padding: 2px 6px;
  font-size: 13px;
  color: var(--color-text);
  background: var(--color-bg);
  border-radius: var(--radius-xs);
}

.setup-code {
  padding: 14px 16px;
  margin: 16px 0;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.7;
  color: var(--color-code-text);
  white-space: pre;
  background: var(--color-dark-surface);
  border-radius: var(--radius-md);
  -webkit-overflow-scrolling: touch;
}

.setup-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--color-text-secondary);
}

/* 窄屏：卡片留白收紧，整体字号较桌面减 1px */
@media (max-width: 767px) {
  .setup-card {
    padding: 20px;
    font-size: 13px;
  }

  .setup-card h1 {
    font-size: 17px;
  }

  .setup-steps {
    font-size: 13px;
  }

  .setup-steps code {
    font-size: 12px;
  }

  .setup-code {
    font-size: 12px;
  }

  .setup-note {
    font-size: 11px;
  }
}

/* ===== P1：图层、风险面板、录入工具与弹窗 ===== */

/* ---- 顶部示例数据与风险提示条 ---- */
.sample-banner {
  flex: 0 0 auto;
  padding: 8px 16px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-warning-text);
  overflow-wrap: anywhere;
  background: var(--color-warning-bg);
  border-left: 4px solid var(--color-warning);
}

.risk-banner {
  flex: 0 0 auto;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: #991b1b;
  overflow-wrap: anywhere;
  background: var(--color-danger-soft);
  border-left: 4px solid var(--color-danger);
}

/* ---- 图层开关与录入工具 ---- */
.layer-toggles {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  font-size: 13px;
  line-height: 1.4;
  user-select: none;
  cursor: pointer;
}

.toggle input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--color-primary);
  cursor: pointer;
}

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

.tool-actions .btn {
  flex: 1 1 0;
  min-width: 0;
}

.tool-hint {
  padding: 6px 10px;
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-warning);
  overflow-wrap: anywhere;
  background: #fffbeb;
  border-radius: var(--radius-sm);
}

/* ---- 路线风险面板 ---- */
.risk-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.risk-score {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  line-height: 1;
  color: var(--color-text-strong);
}

.risk-level {
  display: inline-block;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-white);
  white-space: nowrap;
  border-radius: var(--radius-pill);
}

.risk-level-low {
  background: var(--color-success);
}

.risk-level-medium {
  background: var(--color-warning);
}

.risk-level-high {
  background: var(--color-danger);
}

.risk-level-none {
  background: var(--color-icon-muted);
}

.risk-intrusion {
  padding: 6px 10px;
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-danger);
  overflow-wrap: anywhere;
  background: var(--color-danger-bg);
  border-radius: var(--radius-sm);
}

.risk-hits {
  max-height: 180px;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.risk-hits li + li {
  border-top: 1px solid var(--color-bg);
}

.risk-hit-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--color-text);
}

.risk-hit-badge {
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  background: var(--cam-color, var(--color-text-secondary));
  border-radius: 50%;
}

.risk-hit-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.risk-hit-score {
  flex: 0 0 auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  color: var(--color-success);
}

.risk-hit-score.score-high {
  color: var(--color-danger);
}

.risk-hit-score.score-mid {
  color: var(--color-warning);
}

.risk-empty {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-icon-muted);
}

/* ---- 摄像头 Marker ---- */
.cam {
  --cam-color: var(--color-text-secondary);

  position: relative;
  width: 26px;
  height: 26px;
  user-select: none;
  cursor: pointer;
}

.cam-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: 14px;
  height: 14px;
  background: var(--cam-color);
  border: 2px solid var(--color-white);
  border-radius: 50%;
  box-shadow: var(--shadow-marker);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

/* 三角箭头指向正北；以圆点圆心为旋转中心按 bearing 旋转 */
.cam-arrow {
  position: absolute;
  top: 0;
  left: calc(50% - 5px);
  z-index: 0;
  width: 10px;
  height: 10px;
  background: rgba(255, 255, 255, 0.92);
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  filter:
    drop-shadow(0 0 1px rgba(15, 23, 42, 0.9))
    drop-shadow(0 1px 1px rgba(15, 23, 42, 0.4));
  pointer-events: none;
  transform: rotate(calc(var(--bearing, 0) * 1deg));
  transform-origin: 50% 13px;
}

.cam-restriction {
  --cam-color: #dc2626;
}

.cam-helmet {
  --cam-color: #d97706;
}

.cam-redlight {
  --cam-color: #ca8a04;
}

.cam-speed {
  --cam-color: #64748b;
}

.cam-no-arrow .cam-arrow,
.cam-arrow.cam-no-arrow {
  display: none;
}

/* ---- 禁区名称标签 ---- */
.zone-label {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--color-danger);
  white-space: nowrap;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--color-danger);
  border-radius: var(--radius-pill);
}

/* ---- 保存禁摩区 / 摄像头弹窗 ---- */
.btn-primary {
  color: var(--color-white);
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-primary:hover {
  color: var(--color-white);
  background: #163e63;
  border-color: #163e63;
}

.dlg {
  width: min(92vw, 400px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  margin: auto;
  overflow-y: auto;
  color: var(--color-text);
  background: var(--color-white);
  border: 0;
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
}

.dlg::backdrop {
  background: rgba(15, 23, 42, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.dlg-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px 22px 18px;
  margin: 0;
}

.dlg-form h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-text-strong);
}

.dlg-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-coords);
}

.dlg-field input,
.dlg-field select {
  width: 100%;
  padding: 9px 10px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--color-text);
  background: var(--color-white);
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
}

.dlg-field input:focus,
.dlg-field select:focus {
  border-color: var(--color-primary);
  outline: none;
}

.dlg-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--color-text-secondary);
}

.dlg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.dlg-actions .btn {
  min-height: 38px;
}

/* ---- 手机端适配（<768px） ---- */
@media (max-width: 767px) {
  .toggle {
    min-height: 40px;
  }

  .risk-score {
    font-size: 24px;
  }

  .risk-hits {
    max-height: 140px;
  }

  .dlg {
    width: 94vw;
  }
}
