:root {
  --tsp-shell-panel: #0f172a;
  --tsp-shell-panel-raised: #172033;
  --tsp-shell-border: rgba(103, 232, 249, 0.56);
  --tsp-shell-text: #e6f7ff;
  --tsp-shell-muted: #a8bac8;
  --tsp-shell-accent: #67e8f9;
}

.tsp-shell-popover {
  position: fixed;
  z-index: 2147483647;
  box-sizing: border-box;
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 96px);
  overflow: auto;
  border: 1px solid var(--tsp-shell-border);
  border-radius: 14px;
  padding: 18px;
  background-color: var(--tsp-shell-panel);
  background-image: none;
  color: var(--tsp-shell-text);
  box-shadow: 0 22px 64px rgba(0, 0, 0, 0.56);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  opacity: 1;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.tsp-shell-popover[data-kind="settings"] {
  width: min(400px, calc(100vw - 24px));
}

.tsp-shell-popover-arrow {
  position: absolute;
  top: -8px;
  left: var(--tsp-shell-arrow-left, 28px);
  z-index: 0;
  width: 16px;
  height: 16px;
  box-sizing: border-box;
  border-top: 1px solid var(--tsp-shell-border);
  border-left: 1px solid var(--tsp-shell-border);
  background-color: var(--tsp-shell-panel);
  transform: rotate(45deg);
}

.tsp-shell-popover-header,
.tsp-shell-popover-title,
.tsp-shell-tabs,
.tsp-theme-options {
  display: flex;
  align-items: center;
}

.tsp-shell-popover-header {
  position: relative;
  z-index: 1;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 13px;
  border-bottom: 1px solid rgba(103, 232, 249, 0.22);
}

.tsp-shell-popover-title {
  gap: 9px;
  min-width: 0;
}

.tsp-shell-popover-title h2 {
  margin: 0;
  color: var(--tsp-shell-accent);
  font-size: 19px;
  line-height: 1.3;
}

.tsp-shell-popover-icon {
  color: var(--tsp-shell-accent);
  font-size: 21px;
}

.tsp-shell-popover-close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: #243047;
  color: #cbd5e1;
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
}

.tsp-shell-popover-close:hover,
.tsp-shell-popover-close:focus-visible {
  background: #334155;
  color: #fff;
  outline: 2px solid rgba(103, 232, 249, 0.48);
}

.tsp-shell-tabs {
  position: relative;
  z-index: 1;
  gap: 8px;
  margin: 14px 0 0;
}

.tsp-shell-tab {
  min-height: 38px;
  border: 1px solid #40506a;
  border-radius: 9px;
  padding: 7px 14px;
  background: #1b263a;
  color: #cbd5e1;
  font: 700 14px/1.2 inherit;
  cursor: pointer;
}

.tsp-shell-tab[aria-selected="true"] {
  border-color: #0891b2;
  background: #087b91;
  color: #fff;
}

.tsp-shell-tab:focus-visible {
  outline: 3px solid rgba(103, 232, 249, 0.35);
  outline-offset: 2px;
}

.tsp-shell-tab-panel {
  position: relative;
  z-index: 1;
  padding-top: 15px;
  color: var(--tsp-shell-text);
  font-size: 14px;
  line-height: 1.72;
}

.tsp-shell-tab-panel[hidden] {
  display: none;
}

.tsp-shell-tab-panel h3 {
  margin: 2px 0 8px;
  color: #cffafe;
  font-size: 16px;
}

.tsp-shell-tab-panel h4 {
  margin: 16px 0 5px;
  color: #bae6fd;
  font-size: 14px;
}

.tsp-shell-tab-panel p {
  margin: 6px 0 10px;
  color: var(--tsp-shell-muted);
}

.tsp-shell-tab-panel ol,
.tsp-shell-tab-panel ul {
  margin: 7px 0 11px;
  padding-left: 22px;
}

.tsp-shell-tab-panel li {
  margin: 5px 0;
}

.tsp-shell-notice {
  margin-top: 13px;
  border-left: 3px solid #22d3ee;
  border-radius: 7px;
  padding: 9px 11px;
  background: #17283a;
  color: #c6edf4;
}

.tsp-settings-section {
  position: relative;
  z-index: 1;
  padding-top: 16px;
}

.tsp-settings-section h3 {
  margin: 0;
  color: #cffafe;
  font-size: 16px;
}

.tsp-settings-section p {
  margin: 5px 0 13px;
  color: var(--tsp-shell-muted);
  font-size: 13px;
  line-height: 1.55;
}

.tsp-theme-options {
  gap: 10px;
}

.tsp-theme-option {
  flex: 1 1 0;
  display: grid;
  min-height: 84px;
  place-items: center;
  gap: 4px;
  border: 1px solid #40506a;
  border-radius: 11px;
  padding: 10px;
  background: #1b263a;
  color: #d8e4ec;
  font: 700 14px/1.25 inherit;
  cursor: pointer;
}

.tsp-theme-option span:first-child {
  font-size: 24px;
}

.tsp-theme-option[aria-pressed="true"] {
  border-color: #22d3ee;
  background: #0e6072;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.18);
}

.tsp-theme-option:focus-visible {
  outline: 3px solid rgba(103, 232, 249, 0.35);
  outline-offset: 2px;
}

/* The map toolbar and every panel it opens use a fully opaque surface. */
.tsp-map-toolbar,
.tsp-map-toolbar-collapsed > button,
.tsp-map-tool-panel,
.tsp-coordinate-convert-panel,
.tsp-map-layer-panel,
.tsp-map-context-menu,
.timespace-feedback-panel,
.timespace-feedback-arrow {
  background-color: #0f172a !important;
  background-image: none !important;
  opacity: 1 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.timespace-feedback-panel {
  right: auto !important;
}

.timespace-feedback-arrow {
  right: auto !important;
}

.tsp-site-header-title h1 {
  font-size: 32px !important;
  line-height: 1.15 !important;
}

.tsp-data-panel,
.tsp-mobile-data-drawer {
  container-name: tsp-data-panel;
  container-type: inline-size;
  min-width: 0;
}

.tsp-data-panel [data-radix-scroll-area-viewport] > div[style*="display: table"],
.tsp-mobile-data-drawer [data-radix-scroll-area-viewport] > div[style*="display: table"] {
  display: block !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

.tsp-evidence-asset-card {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.tsp-evidence-asset-card > .flex {
  min-width: 0;
  flex-wrap: wrap;
}

.tsp-evidence-asset-card > .flex > .flex-1 {
  flex: 1 1 180px;
}

.tsp-evidence-asset-actions {
  flex: 0 1 auto;
  min-width: 0;
}

.tsp-raster-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(124px, 1fr));
  gap: 7px 10px;
  min-width: 0;
}

.tsp-raster-control {
  display: block;
  min-width: 0;
  border-radius: 7px;
  padding: 5px 7px 6px;
  background: #111c30;
}

.tsp-raster-control input[type="range"] {
  display: block;
  width: 100%;
  min-width: 0;
  height: 16px;
  margin: 0;
  accent-color: #22d3ee;
}

@container tsp-data-panel (max-width: 460px) {
  .tsp-evidence-asset-card {
    padding: 8px !important;
  }

  .tsp-evidence-asset-card > .flex {
    gap: 7px !important;
  }

  .tsp-raster-controls {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    margin-top: 7px !important;
  }

  .tsp-raster-control {
    padding: 3px 6px 4px;
  }

  .tsp-raster-control > div {
    margin-bottom: 1px !important;
  }

  .tsp-raster-control input[type="range"] {
    height: 13px;
  }
}

html[data-tsp-theme="light"] {
  --tsp-shell-panel: #f8fbfc;
  --tsp-shell-panel-raised: #fff;
  --tsp-shell-border: #8bbeca;
  --tsp-shell-text: #173747;
  --tsp-shell-muted: #56717e;
  --tsp-shell-accent: #087b91;
  color-scheme: light;
}

html[data-tsp-theme="dark"] {
  color-scheme: dark;
}

html[data-tsp-theme="light"] body {
  background: #eaf2f5;
}

html[data-tsp-theme="light"] .tsp-app-shell {
  background: #eaf2f5 !important;
}

html[data-tsp-theme="light"] .tsp-app-shell > header,
html[data-tsp-theme="light"] .tsp-app-shell > footer,
html[data-tsp-theme="light"] .tsp-mobile-footer {
  border-color: #9ecbd4 !important;
  background: #f8fbfc !important;
  color: #173747 !important;
}

html[data-tsp-theme="light"] .tsp-app-shell > header > div.absolute.inset-0,
html[data-tsp-theme="light"] .tsp-app-shell > footer > div.absolute.inset-0,
html[data-tsp-theme="light"] .tsp-mobile-footer > div.absolute.inset-0 {
  background: none !important;
}

html[data-tsp-theme="light"] .tsp-site-header-actions button {
  color: #087b91 !important;
}

html[data-tsp-theme="light"] .tsp-site-header-actions button:hover,
html[data-tsp-theme="light"] .tsp-site-header-actions button:focus-visible {
  background: #dceef2 !important;
}

html[data-tsp-theme="light"] .tsp-data-rail,
html[data-tsp-theme="light"] .tsp-data-panel,
html[data-tsp-theme="light"] .tsp-mobile-data-drawer {
  border-color: #a7cdd5 !important;
  background: #f8fbfc !important;
  color: #173747 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

html[data-tsp-theme="light"] .tsp-data-rail button,
html[data-tsp-theme="light"] .tsp-data-panel button,
html[data-tsp-theme="light"] .tsp-mobile-data-drawer button {
  color: #356373 !important;
}

html[data-tsp-theme="light"] .tsp-data-panel [class*="text-white"],
html[data-tsp-theme="light"] .tsp-mobile-data-drawer [class*="text-white"] {
  color: #173747 !important;
}

html[data-tsp-theme="light"] .tsp-data-panel [class*="text-slate-"],
html[data-tsp-theme="light"] .tsp-mobile-data-drawer [class*="text-slate-"] {
  color: #56717e !important;
}

html[data-tsp-theme="light"] .tsp-data-panel [class*="border-slate-"],
html[data-tsp-theme="light"] .tsp-mobile-data-drawer [class*="border-slate-"] {
  border-color: #b6cdd4 !important;
}

html[data-tsp-theme="light"] .tsp-data-panel [class*="bg-slate-8"],
html[data-tsp-theme="light"] .tsp-mobile-data-drawer [class*="bg-slate-8"] {
  background-color: #edf4f6 !important;
}

html[data-tsp-theme="light"] .tsp-data-panel button.bg-cyan-600,
html[data-tsp-theme="light"] .tsp-mobile-data-drawer button.bg-cyan-600 {
  background-color: #0891b2 !important;
  color: #fff !important;
}

html[data-tsp-theme="light"] .tsp-map-toolbar,
html[data-tsp-theme="light"] .tsp-map-toolbar-collapsed > button,
html[data-tsp-theme="light"] .tsp-map-tool-panel,
html[data-tsp-theme="light"] .tsp-coordinate-convert-panel,
html[data-tsp-theme="light"] .tsp-map-layer-panel,
html[data-tsp-theme="light"] .tsp-map-context-menu,
html[data-tsp-theme="light"] .timespace-feedback-panel,
html[data-tsp-theme="light"] .timespace-feedback-arrow {
  border-color: #8bbeca !important;
  background-color: #f8fbfc !important;
  color: #173747 !important;
}

html[data-tsp-theme="light"] .tsp-map-toolbar button {
  color: #087b91 !important;
}

html[data-tsp-theme="light"] .tsp-map-tool-panel [class*="text-slate-"],
html[data-tsp-theme="light"] .tsp-map-layer-panel [class*="text-slate-"],
html[data-tsp-theme="light"] .tsp-map-context-menu [class*="text-slate-"],
html[data-tsp-theme="light"] .timespace-feedback-panel p,
html[data-tsp-theme="light"] .timespace-feedback-panel span {
  color: #365967 !important;
  text-shadow: none !important;
}

@media (max-width: 1023px) {
  .tsp-site-header-title h1 {
    font-size: 24px !important;
  }

  .tsp-site-header-actions > button,
  .tsp-user-launcher[data-in-header="true"],
  .tsp-mobile-data-launcher,
  .tsp-map-toolbar button,
  .tsp-map-toolbar-collapsed > button,
  .leaflet-control-zoom a {
    min-width: 44px !important;
    min-height: 44px !important;
  }

  .tsp-site-header-actions > button,
  .tsp-map-toolbar button,
  .tsp-map-toolbar-collapsed > button {
    width: 44px !important;
    height: 44px !important;
  }

  .tsp-user-launcher[data-in-header="true"],
  .tsp-mobile-data-launcher {
    height: 44px !important;
  }

  .tsp-app-shell button[class~="rounded-full"][class~="h-10"][class~="w-10"] {
    width: 44px !important;
    height: 44px !important;
  }

  .tsp-app-shell button[class*="bg-slate-900/95"][class*="border-cyan-500/50"] {
    min-height: 44px !important;
  }

  .leaflet-control-zoom a {
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
  }
}

@media (max-width: 640px) {
  .tsp-site-header-title h1 {
    font-size: 18px !important;
  }
}

/* V114: compact mobile map chrome while preserving the desktop layout. */
.tsp-mobile-header-menu {
  display: none;
  touch-action: manipulation;
}

/* 手机菜单底部图标行只在手机菜单展开时显示(桌面隐藏,防止出现在桌面头部) */
.tsp-mobile-menu-icon-row {
  display: none;
}

/* 修复:Tailwind 未编译 max-h-[78vh],地图图层面板没有高度上限,
   选择天地图等内容变高后顶部会顶出屏幕、关闭按钮不可达。
   补上高度上限与内部滚动,并让标题栏(含关闭按钮)吸顶常驻。 */
.tsp-map-layer-panel {
  max-height: min(78vh, calc(100vh - 240px)) !important;
  overflow-y: auto !important;
}

.tsp-map-layer-panel > div:first-child {
  position: sticky;
  top: -12px;
  z-index: 2;
  background: inherit;
}

/* 手机页脚公安备案链接补上备案图标,与桌面页脚一致;
   inline-flex 垂直居中图标与文字,行高保持与 ICP 链接一致,文字不下沉 */
.tsp-mobile-footer-filing[href*="beian.mps.gov.cn"] {
  display: inline-flex;
  align-items: center;
}

.tsp-mobile-footer-filing[href*="beian.mps.gov.cn"]::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 4px;
  flex-shrink: 0;
  background: url("/beian-icon.png") center / contain no-repeat;
}

/* 数据中心标签两端统一为:…转换 → 报告 → AI。
   桌面侧栏构建顺序是 AI 在前,手机抽屉是报告在前,这里用 flex order 统一。 */
[role="tablist"] [data-testid="report-tab"] {
  order: 5;
}

[role="tablist"] [data-testid="ai-tab"] {
  order: 6;
}

/* V119-r2 手机端修正：Tailwind 未生成 bg-slate-950/98(98% 透明度档位)，
   数据中心移动端入口因此没有任何背景，点按前几乎不可见。
   按需求改为直接使用不透明深蓝底色(与原 hover 色 slate-800 一致)。 */
html:not([data-tsp-theme="light"]) .tsp-mobile-data-launcher {
  background-color: #1e293b !important;
}

html:not([data-tsp-theme="light"]) .tsp-mobile-data-launcher:hover,
html:not([data-tsp-theme="light"]) .tsp-mobile-data-launcher:focus-visible {
  background-color: #334155 !important;
}

@media (max-width: 767px) {
  .tsp-app-shell > header {
    min-height: 48px !important;
    height: 48px !important;
    padding: 0 6px !important;
    /* 高于地图工具栏(z-1000)等图层，保证三点菜单下拉面板不被遮挡 */
    z-index: 1300 !important;
  }

  /* 手机用双指缩放地图，左下角加减号缩放控件直接隐藏 */
  .leaflet-control-zoom {
    display: none !important;
  }

  .tsp-app-shell > header > img {
    width: 28px !important;
    height: 28px !important;
  }

  .tsp-site-header-title {
    position: absolute !important;
    inset: 0 38px !important;
    display: flex !important;
    width: auto !important;
    padding: 0 !important;
    transform: none !important;
    justify-content: center !important;
    pointer-events: none;
  }

  .tsp-site-header-title h1 {
    width: auto !important;
    max-width: 100% !important;
    overflow: visible !important;
    color: #67e8f9;
    font-size: clamp(10px, 3.35vw, 15px) !important;
    line-height: 1.1 !important;
    letter-spacing: 0 !important;
    text-align: center !important;
    text-overflow: clip !important;
    white-space: nowrap !important;
  }

  .tsp-site-header-actions {
    position: absolute !important;
    top: 7px !important;
    right: 6px !important;
    z-index: 1200 !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 32px !important;
    min-width: 32px !important;
    max-width: 172px !important;
    gap: 3px !important;
  }

  .tsp-mobile-header-menu {
    display: inline-flex !important;
    align-self: flex-end;
    align-items: center;
    justify-content: center;
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    border: 1px solid rgba(103, 232, 249, 0.42);
    border-radius: 8px;
    padding: 0 !important;
    background: #0f172a;
    color: #67e8f9;
    font: 800 20px/1 system-ui, sans-serif;
  }

  .tsp-site-header-actions:not([data-mobile-open="true"]) > :not(.tsp-mobile-header-menu) {
    display: none !important;
  }

  .tsp-site-header-actions[data-mobile-open="true"] {
    /* 面板下移到顶栏(48px)下方，不再与标题平行、不遮挡标题 */
    top: 54px !important;
    width: 176px !important;
    padding: 4px !important;
    border: 1px solid rgba(103, 232, 249, 0.42);
    border-radius: 10px;
    background: #0f172a;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.42);
  }

  /* 展开顺序：账户(人名/登录) → [消息 → 使用手册 → 图标行(使用说明/设置/反馈)] */
  .tsp-site-header-actions[data-mobile-open="true"] #tsp-user-launcher-slot {
    order: 1;
  }

  .tsp-site-header-actions[data-mobile-open="true"] #tsp-header-utility-slot {
    order: 2;
  }

  .tsp-site-header-actions[data-mobile-open="true"] #tsp-header-utility-slot [data-testid="site-message-trigger"] {
    order: 1;
  }

  .tsp-site-header-actions[data-mobile-open="true"] #tsp-header-utility-slot [data-testid="site-manual-download"] {
    order: 2;
  }

  .tsp-site-header-actions[data-mobile-open="true"] .tsp-mobile-menu-icon-row {
    order: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 5px;
    padding: 7px 0 2px;
    border-top: 1px solid rgba(103, 232, 249, 0.22);
  }

  .tsp-mobile-menu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 9px;
    border: 1px solid rgba(103, 232, 249, 0.3);
    background: #0b1a33;
    color: #67e8f9;
    padding: 0;
  }

  .tsp-mobile-menu-icon:hover,
  .tsp-mobile-menu-icon:active {
    background: #12315e;
  }

  .tsp-mobile-menu-icon svg {
    width: 20px;
    height: 20px;
  }

  /* 原生意见反馈按钮已由图标行替代，手机菜单中不再显示 */
  .tsp-site-header-actions[data-mobile-open="true"] > button:not(.tsp-mobile-header-menu) {
    display: none !important;
  }

  .tsp-site-header-actions[data-mobile-open="true"] #tsp-header-utility-slot,
  .tsp-site-header-actions[data-mobile-open="true"] #tsp-user-launcher-slot {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    flex-direction: column !important;
    gap: 3px !important;
  }

  .tsp-site-header-actions[data-mobile-open="true"] .tsp-header-utility,
  .tsp-site-header-actions[data-mobile-open="true"] .tsp-user-launcher[data-in-header="true"] {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 38px !important;
    min-height: 38px !important;
    justify-content: center !important;
    align-items: center !important;
    border-radius: 7px !important;
    padding: 0 7px !important;
    font-size: 12px !important;
  }

  .tsp-mobile-data-launcher {
    top: 54px !important;
    left: 6px !important;
    /* V119-r15: 3D 模式顶部坐标读数条与按钮同带排列,原 104px 会重叠;缩到约 3/5(62px)并收紧内距/字号 */
    min-width: 62px !important;
    min-height: 34px !important;
    height: 34px !important;
    border-radius: 8px !important;
    padding: 0 6px !important;
    font-size: 10px !important;
  }

  .tsp-mobile-data-launcher svg {
    width: 12px !important;
    height: 12px !important;
    margin-right: 3px !important;
  }

  .tsp-mobile-data-backdrop {
    background: rgba(0, 0, 0, 0.08) !important;
  }

  .tsp-mobile-data-drawer {
    top: 90px !important;
    right: auto !important;
    bottom: auto !important;
    left: 6px !important;
    /* V119-r17: 3D模式右下角"地图图层管理/全球局部"竖排按钮列(约 left:100vw-149px)不可被抽屉遮住,
       66vw 在窄屏会伸进去;取 min 保证与按钮列至少留 8px 间隙 */
    width: min(66vw, calc(100vw - 165px)) !important;
    max-width: min(66vw, calc(100vw - 165px)) !important;
    height: 66dvh !important;
    max-height: calc(100dvh - 132px) !important;
    border: 1px solid rgba(34, 211, 238, 0.46) !important;
    border-radius: 10px !important;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.5) !important;
  }

  .tsp-mobile-data-drawer > div:first-child {
    min-height: 30px !important;
    padding: 3px 6px !important;
  }

  .tsp-mobile-data-drawer button {
    min-width: 28px !important;
    min-height: 28px !important;
    font-size: 10px !important;
  }

  .tsp-mobile-data-drawer [role="tablist"] {
    margin: 3px 4px 0 !important;
    padding: 1px !important;
  }

  .tsp-mobile-data-drawer [role="tab"] {
    min-height: 32px !important;
    gap: 1px !important;
    padding: 2px 1px !important;
  }

  .tsp-mobile-data-drawer [role="tab"] svg {
    width: 12px !important;
    height: 12px !important;
  }

  .tsp-mobile-data-drawer [role="tab"] span {
    font-size: 9px !important;
  }

  .tsp-mobile-data-drawer [data-radix-scroll-area-viewport] .px-3.py-4 {
    padding: 5px !important;
  }

  .tsp-mobile-data-drawer input,
  .tsp-mobile-data-drawer select,
  .tsp-mobile-data-drawer textarea {
    min-height: 28px !important;
    padding: 3px 5px !important;
    font-size: 10px !important;
  }

  .tsp-mobile-data-drawer p,
  .tsp-mobile-data-drawer label,
  .tsp-mobile-data-drawer [class*="text-sm"],
  .tsp-mobile-data-drawer [class*="text-xs"] {
    font-size: 9px !important;
    line-height: 1.25 !important;
  }

  .tsp-map-toolbar,
  .tsp-map-toolbar-collapsed {
    top: auto !important;
    right: 6px !important;
    bottom: 32px !important;
  }

  .tsp-map-toolbar {
    max-height: min(58dvh, 360px) !important;
    gap: 1px !important;
    padding: 2px !important;
    border-radius: 8px !important;
  }

  .tsp-map-toolbar button,
  .tsp-map-toolbar-collapsed > button {
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    border-radius: 6px !important;
    padding: 0 !important;
  }

  .tsp-map-toolbar button svg,
  .tsp-map-toolbar-collapsed > button svg {
    width: 15px !important;
    height: 15px !important;
  }

  .tsp-geolocation-control {
    top: auto !important;
    right: 6px !important;
    bottom: calc(38px + min(58dvh, 360px)) !important;
  }

  .tsp-geolocation-control button {
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
  }

  .tsp-map-tool-panel:not([data-drag-active="true"]),
  .tsp-map-tool-panel-wide:not([data-drag-active="true"]),
  .tsp-coordinate-convert-panel:not([data-drag-active="true"]) {
    top: 54px !important;
    /* V119-r24: 右缘右移避开右侧地图工具栏(约57px),搜索/坐标转换面板文字不再被遮挡 */
    right: 60px !important;
    left: auto !important;
  }

  .tsp-map-tool-panel,
  .tsp-map-tool-panel-wide,
  .tsp-coordinate-convert-panel {
    width: min(70vw, 260px) !important;
    max-width: calc(100vw - 54px) !important;
    max-height: min(58dvh, 360px) !important;
    border-radius: 9px !important;
    padding: 8px !important;
    font-size: 10px !important;
  }

  .tsp-map-tool-panel h2,
  .tsp-map-tool-panel h3,
  .tsp-map-tool-panel [class*="text-lg"],
  .tsp-map-tool-panel [class*="text-base"] {
    font-size: 12px !important;
    line-height: 1.25 !important;
  }

  .tsp-map-tool-panel p,
  .tsp-map-tool-panel label,
  .tsp-map-tool-panel span,
  .tsp-map-tool-panel [class*="text-sm"],
  .tsp-map-tool-panel [class*="text-xs"] {
    font-size: 10px !important;
    line-height: 1.3 !important;
  }

  .tsp-map-tool-panel button,
  .tsp-coordinate-convert-panel button {
    min-height: 28px !important;
    border-radius: 6px !important;
    padding: 3px 6px !important;
    font-size: 10px !important;
  }

  .tsp-map-tool-panel input,
  .tsp-map-tool-panel select,
  .tsp-map-tool-panel textarea,
  .tsp-coordinate-convert-panel input,
  .tsp-coordinate-convert-panel select,
  .tsp-coordinate-convert-panel textarea {
    min-height: 28px !important;
    padding: 3px 5px !important;
    font-size: 10px !important;
  }

  .tsp-map-tool-panel textarea,
  .tsp-coordinate-convert-panel textarea {
    max-height: 92px !important;
  }

  .tsp-map-tool-panel .mb-4,
  .tsp-map-tool-panel .mb-3,
  .tsp-map-tool-panel .mb-2 {
    margin-bottom: 5px !important;
  }

  .tsp-map-tool-panel .gap-4,
  .tsp-map-tool-panel .gap-3,
  .tsp-map-tool-panel .gap-2 {
    gap: 5px !important;
  }

  .tsp-shell-popover {
    width: min(82vw, 300px) !important;
    max-height: 62dvh !important;
    border-radius: 10px !important;
    padding: 9px !important;
    font-size: 11px !important;
    /* 手机端固定在右上角顶栏下方，不随触发按钮行内定位漂移到左上角 */
    left: auto !important;
    right: 8px !important;
    top: 56px !important;
  }

  .tsp-shell-popover-arrow {
    display: none !important;
  }

  /* 意见反馈面板同样固定右上角(placeFeedback 的行内定位会被此规则覆盖) */
  .timespace-feedback-panel {
    left: auto !important;
    right: 8px !important;
    top: 56px !important;
    z-index: 1400 !important;
  }

  .timespace-feedback-arrow {
    display: none !important;
  }

  .tsp-shell-popover-title h2 {
    font-size: 14px !important;
  }

  .tsp-shell-tab {
    min-height: 30px !important;
    padding: 4px 7px !important;
    font-size: 10px !important;
  }
}

html[data-tsp-theme="light"] .tsp-map-tool-panel input,
html[data-tsp-theme="light"] .tsp-map-tool-panel select,
html[data-tsp-theme="light"] .tsp-map-tool-panel textarea {
  border-color: #aac8d0 !important;
  background: #fff !important;
  color: #173747 !important;
}

html[data-tsp-theme="light"] .tsp-map-tool-panel [class*="bg-slate-8"],
html[data-tsp-theme="light"] .tsp-map-layer-panel [class*="bg-slate-8"] {
  background-color: #e7f1f4 !important;
}

html[data-tsp-theme="light"] .tsp-raster-control {
  background: #e7f1f4;
}

html[data-tsp-theme="light"] .timespace-compliance-footer,
html[data-tsp-theme="light"] .timespace-compliance-footer a {
  color: #426472 !important;
}

html[data-tsp-theme="light"] .tsp-shell-popover-close {
  background: #e4eef2;
  color: #315867;
}

html[data-tsp-theme="light"] .tsp-shell-tab,
html[data-tsp-theme="light"] .tsp-theme-option {
  border-color: #b7cfd7;
  background: #edf5f7;
  color: #315867;
}

html[data-tsp-theme="light"] .tsp-shell-tab[aria-selected="true"],
html[data-tsp-theme="light"] .tsp-theme-option[aria-pressed="true"] {
  border-color: #087b91;
  background: #087b91;
  color: #fff;
}

html[data-tsp-theme="light"] .tsp-shell-tab-panel h3,
html[data-tsp-theme="light"] .tsp-shell-tab-panel h4,
html[data-tsp-theme="light"] .tsp-settings-section h3 {
  color: #0b5365;
}

html[data-tsp-theme="light"] .tsp-shell-notice {
  background: #e6f4f7;
  color: #275664;
}

@media (max-width: 640px) {
  .tsp-shell-popover {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 74px);
    padding: 14px;
  }

  .tsp-shell-popover[data-kind="settings"] {
    width: calc(100vw - 16px);
  }

  .tsp-shell-tabs {
    overflow-x: auto;
  }

  .tsp-shell-tab {
    flex: 1 0 auto;
  }

  .tsp-raster-controls {
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
    gap: 6px;
  }
}

@media (max-width: 767px) and (orientation: portrait) {
  .tsp-map-toolbar {
    max-height: calc(100% - 176px) !important;
    scrollbar-width: thin;
  }

  .tsp-mobile-data-drawer button {
    min-width: 44px !important;
    min-height: 44px !important;
  }

  .tsp-mobile-data-backdrop {
    background: rgba(0, 0, 0, 0.16) !important;
  }

  .tsp-mobile-data-drawer {
    left: 6px !important;
    right: 6px !important;
    top: auto !important;
    bottom: 50px !important;
    width: auto !important;
    max-width: none !important;
    height: min(52vh, 470px) !important;
    max-height: 52vh !important;
    border: 1px solid rgba(34, 211, 238, 0.45) !important;
    border-bottom: 0 !important;
    border-radius: 14px 14px 0 0;
    overflow: hidden;
  }

  .tsp-mobile-data-drawer > div:first-child {
    min-height: 38px;
    padding: 5px 9px !important;
  }

  .tsp-mobile-data-drawer [role="tablist"] {
    margin: 4px 6px 0 !important;
    padding: 2px !important;
  }

  .tsp-mobile-data-drawer [role="tab"] {
    gap: 1px !important;
    padding-top: 4px !important;
    padding-bottom: 4px !important;
  }

  .tsp-mobile-data-drawer [role="tab"] span {
    font-size: 11px !important;
    line-height: 1.05 !important;
  }

  .tsp-mobile-data-drawer [data-radix-scroll-area-viewport] .px-3.py-4 {
    padding: 7px !important;
  }

  .tsp-mobile-data-drawer .tsp-raster-controls {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 4px !important;
    margin-top: 7px !important;
  }

  .tsp-mobile-data-drawer .tsp-raster-control {
    padding: 3px 6px 4px;
  }

  .tsp-mobile-data-drawer .tsp-raster-control > div {
    margin-bottom: 1px !important;
  }

  .tsp-mobile-data-drawer .tsp-raster-control input[type="range"] {
    height: 13px;
  }
}

@media (max-width: 1023px) and (orientation: landscape) {
  .tsp-mobile-data-drawer {
    width: min(46vw, 420px) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tsp-shell-popover *,
  .tsp-shell-popover {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

/* 20260730: keep the embedded multi-source workbench readable at every viewport. */
.tsp-multisource-embed-header {
  display: grid !important;
  grid-template-columns: minmax(180px, 1fr) repeat(4, max-content);
  align-items: center;
}

.tsp-multisource-embed-title {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tsp-multisource-embed-frame {
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
}

/* The status card belongs beside the right toolbar, not underneath it. */
.tsp-geolocation-status {
  right: calc(100% + 12px) !important;
  width: max-content;
  max-width: calc(100vw - 96px) !important;
  white-space: normal !important;
}

.tsp-geolocation-status > div {
  white-space: nowrap;
}

.tsp-geolocation-error {
  min-width: min(180px, calc(100vw - 96px));
}

@media (max-width: 640px) {
  .tsp-multisource-embed-backdrop {
    padding: 0 !important;
  }

  .tsp-multisource-embed-shell {
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }

  .tsp-multisource-embed-header {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px !important;
    padding: 6px !important;
  }

  .tsp-multisource-embed-title {
    grid-column: 1 / -1;
    padding: 0 4px !important;
    font-size: 14px;
    line-height: 20px;
  }

  .tsp-multisource-embed-header > button {
    width: 100%;
    min-width: 0;
    padding-right: 4px !important;
    padding-left: 4px !important;
    font-size: 12px;
  }
}

/* Keep V114 mobile sizing last in the cascade. */
@media (max-width: 767px) {
  .tsp-site-header-actions > .tsp-mobile-header-menu {
    width: 32px !important;
    min-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
  }

  .tsp-shell-popover,
  .tsp-shell-popover[data-kind="settings"] {
    width: min(82vw, 300px) !important;
    max-height: 62dvh !important;
    padding: 9px !important;
  }

  .tsp-map-toolbar {
    max-height: min(58dvh, 360px) !important;
  }

  .tsp-mobile-data-drawer button {
    min-width: 28px !important;
    min-height: 28px !important;
  }

  .tsp-mobile-data-backdrop {
    background: rgba(0, 0, 0, 0.08) !important;
  }

  .tsp-mobile-data-drawer {
    top: 90px !important;
    right: auto !important;
    bottom: auto !important;
    left: 6px !important;
    /* V119-r17: 3D模式右下角"地图图层管理/全球局部"竖排按钮列(约 left:100vw-149px)不可被抽屉遮住,
       66vw 在窄屏会伸进去;取 min 保证与按钮列至少留 8px 间隙 */
    width: min(66vw, calc(100vw - 165px)) !important;
    max-width: min(66vw, calc(100vw - 165px)) !important;
    height: 66dvh !important;
    max-height: calc(100dvh - 132px) !important;
    border: 1px solid rgba(34, 211, 238, 0.46) !important;
    border-radius: 10px !important;
  }

  .tsp-mobile-data-drawer > div:first-child {
    min-height: 30px !important;
    padding: 3px 6px !important;
  }

  .tsp-mobile-data-drawer [role="tablist"] {
    margin: 3px 4px 0 !important;
    padding: 1px !important;
  }

  .tsp-mobile-data-drawer [role="tab"] {
    min-height: 32px !important;
    gap: 1px !important;
    padding: 2px 1px !important;
  }

  .tsp-mobile-data-drawer [role="tab"] span {
    font-size: 9px !important;
  }

  .tsp-mobile-data-drawer [data-radix-scroll-area-viewport] .px-3.py-4 {
    padding: 5px !important;
  }
}

/* V119-r12 手机端聚焦缩放修复：
   iOS Safari / 钉钉等 WebView 在文本输入控件字号 <16px 时，聚焦会强制放大整页，
   且登录提交导致页面 reload 后缩放不还原，表现为“登录后界面被放大、按钮看不到”。
   将手机端所有可输入控件字号统一提升至 16px，从根源阻止聚焦自动缩放；
   复选框/单选/滑杆等非文本控件不受影响，桌面端(≥768px)布局不变。 */
@media (max-width: 767px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]),
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* V119-r21 手机端友链卡片:图标在上、文字在下(桌面保持图标左/文字右) */
@media (max-width: 767px) {
  .tsp-friend-card > div:first-child {
    flex-direction: column !important;
    align-items: center !important;
    gap: 6px !important;
    text-align: center;
  }

  .tsp-friend-card > div:first-child > div:last-child {
    width: 100%;
  }
}
