/* ===== 移动端适配 ===== */
.menu-btn {
  display: none;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
  cursor: pointer;
  width: 30px; height: 30px;
  border-radius: 6px;
  transition: all var(--t-fast) ease;
  position: relative;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
}
.menu-btn:hover { background: rgba(255, 255, 255, .1); }
.menu-btn span {
  display: block;
  width: 15px;
  height: 1.5px;
  background: rgba(255, 255, 255, .8);
  border-radius: 1px;
  transition: all var(--t-normal) var(--ease);
}
/* 面板打开时，汉堡变成 X */
body.sidebar-open .menu-btn span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
body.sidebar-open .menu-btn span:nth-child(2) { opacity: 0; }
body.sidebar-open .menu-btn span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }
#backdrop {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: var(--z-backdrop);
}

@media (max-width: 768px) {
  .topbar { gap: 10px; padding: 0 12px; }
  .topbar .title { font-size: 14px; }
  .topbar .subtitle { display: none; }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .panel-toggle { display: none; }
  .panel-fab { display: none !important; }
  .status-text { max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .sidebar {
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: 300px;
    max-width: 86vw;
    border-radius: 0;
    transform: translateX(-105%);
    transition: transform var(--t-normal) ease;
  }
  .sidebar.open { transform: translateX(0); }
  /* 移动端覆盖桌面端 .collapsed 的高特异性规则，确保抽屉式行为一致 */
  .sidebar.collapsed { transform: translateX(-105%); }
  .sidebar.collapsed.open { transform: translateX(0); }
  .sidebar.collapsed ~ .legend { left: 8px; }
  #backdrop.show { display: block; }

  .attr-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 33.333vh;
    border-radius: 18px 18px 0 0;
    transform: translateY(110%);
    transition: transform var(--t-slow) var(--ease), opacity var(--t-normal) ease;
  }
  .attr-panel.open { transform: translateY(0); opacity: 1; }
  .attr-panel.table-mode { width: 100%; }

  .loading-box { width: 82vw; max-width: 320px; }

  /* ===== 移动端：底部坐标栏（固定最底，贴左） ===== */
  .coord-bar {
    left: 0;
    gap: 10px;
    padding: 4px 10px;
    font-size: 10px;
    max-width: 100vw;
    overflow: hidden;
  }
  .coord-bar span:nth-child(3), .coord-bar span:nth-child(4), .coord-bar span:nth-child(5) { display: none; }
  .sidebar.collapsed ~ .coord-bar { left: 0; }

  /* ===== 移动端：图例（左下角，坐标栏上方） ===== */
  .legend {
    width: 140px;
    bottom: 34px;
    left: 8px;
    padding: 8px 10px;
    transition: bottom var(--t-slow) var(--ease);
  }
  .sidebar.open ~ .legend { display: none; }
  /* 属性面板打开时，图例上移到面板上方 */
  #main:has(.attr-panel.open) .legend { bottom: calc(33.333vh + 8px); }
  .legend .lt { font-size: 11px; }
  .legend .ticks { font-size: 9px; }

  /* ===== 移动端：工具栏容器（始终右上角，不随属性面板左移） ===== */
  .toolbar-wrap { top: 10px; right: 8px; transform: none; }
  .attr-panel.open ~ .toolbar-wrap { top: 10px; right: 8px; bottom: auto; transform: none; }
  .attr-panel.open.table-mode ~ .toolbar-wrap { top: 10px; right: 8px; bottom: auto; transform: none; }
  .tool-toggle .ico { width: 14px; height: 14px; }
  .tool-bar-inner { padding: 5px; gap: 4px; }
  .tool-bar .tool-btn { padding: 6px; }
  .tool-bar .tool-btn .ico { width: 14px; height: 14px; }
  .tool-sep { display: none; }

  /* 移动端：关闭建筑悬浮提示 */
  #tooltip { display: none !important; }

  /* 移动端：引导弹窗 */
  .intro-box { width: 92vw; height: 460px; max-height: 82vh; }
  .intro-main { flex-direction: column; }
  .intro-steps {
    width: 100%;
    flex-direction: row;
    padding: 10px 8px;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    touch-action: none;
  }
  .step-item {
    flex: 1;
    height: 42px;
    padding: 0 4px;
    text-align: center;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
  }
  .step-label { font-size: 11px; }
  .step-line { display: none; }
  .step-glow {
    left: 8px;
    right: auto;
    top: 10px;
    bottom: 10px;
    width: calc((100% - 16px) / 5);
    height: auto;
    border-radius: 9px;
  }
  .intro-track { flex-direction: row; }
  .intro-panel { padding: 14px 16px; }
  .intro-theme { width: 32px; height: 32px; border-radius: 8px; }
  .intro-theme .ico { width: 22px; height: 22px; }
}
