/* ===== 西塔小助手 · 设计体系 =====
   深色优先 · 黑曜石底 + 单一青绿强调 · 8px 网格 · 12px 圆角
   动效只动 transform/opacity · 200ms cubic-bezier(.16,1,.3,1)
*/

:root {
  --bg: #09090b;
  --bg-elev: #111113;
  --card: #111113;
  --card-2: #161618;
  --hover: rgba(255, 255, 255, .04);
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .14);
  --text: #ededed;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --accent: #2dd4bf;
  --accent-2: #5eead4;
  --accent-dim: rgba(45, 212, 191, .12);
  --accent-border: rgba(45, 212, 191, .35);
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --nav-bg: #0c0c0e;
  --input-bg: #161618;
  --input-border: rgba(255, 255, 255, .1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --sp: 8px;
  --dur: 200ms;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, .55);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Roboto", "Noto Sans CJK SC", "PingFang SC", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Roboto Mono", Menlo, Consolas, monospace;
}

/* 手动浅色主题（设置页切换 / 系统浅色） */
body.light-theme {
  --bg: #fafafa;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --card-2: #f4f4f5;
  --hover: rgba(0, 0, 0, .04);
  --border: rgba(0, 0, 0, .09);
  --border-strong: rgba(0, 0, 0, .16);
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #a1a1aa;
  --nav-bg: #ffffff;
  --input-bg: #f4f4f5;
  --input-border: rgba(0, 0, 0, .12);
  --accent-dim: rgba(13, 148, 136, .1);
  --accent: #0d9488;
  --accent-2: #14b8a6;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06);
}
@media (prefers-color-scheme: light) {
  body:not(.dark-theme):not(.light-theme) {
    --bg: #fafafa;
    --bg-elev: #ffffff;
    --card: #ffffff;
    --card-2: #f4f4f5;
    --border: rgba(0, 0, 0, .09);
    --text: #18181b;
    --text-2: #52525b;
    --text-3: #a1a1aa;
    --nav-bg: #ffffff;
    --input-bg: #f4f4f5;
    --input-border: rgba(0, 0, 0, .12);
    --accent: #0d9488;
    --accent-2: #14b8a6;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overscroll-behavior: none;
}

/* 图标基线对齐 */
.ic { display: inline-block; vertical-align: -0.16em; flex-shrink: 0; }

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}

/* ===== 顶部状态栏 ===== */
#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  padding-top: calc(10px + var(--safe-t));
  padding-left: calc(16px + var(--safe-l));
  padding-right: calc(16px + var(--safe-r));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  min-height: 52px;
  flex-shrink: 0;
  z-index: 20;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.01em;
  min-width: 0;
}
.topbar-left #statusText { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  transition: background-color var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.status-dot.online { background: var(--success); }
.status-dot.sleeping { background: var(--warning); }
.status-dot.offline { background: var(--danger); }
.topbar-right {
  font-size: 13px;
  color: var(--text-2);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* ===== 主内容 ===== */
#mainContent {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  padding-left: calc(12px + var(--safe-l));
  padding-right: calc(12px + var(--safe-r));
  scroll-behavior: smooth;
}

/* ===== 页面切换 ===== */
.page { display: none; }
.page.active { display: block; animation: pageIn var(--dur) var(--ease); }
@keyframes pageIn {
  from { opacity: 0; transform: translate3d(0, 6px, 0); }
  to { opacity: 1; transform: none; }
}

/* ===== 卡片 ===== */
.card-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -.01em;
}
.card-header .spacer { flex: 1; }
.card-header .hint { font-size: 11px; font-weight: 400; opacity: .7; margin-left: auto; color: var(--text-2); }
.card-header .ic { color: var(--text-2); }
.card-body { padding: 10px 14px; }
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 14px;
}
.stat-row + .stat-row { border-top: 1px solid var(--border); }
.stat-label { color: var(--text-2); }
.stat-value { font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; }

/* 今日卡片 */
.today-time { font-size: 18px; font-weight: 700; margin-bottom: 6px; letter-spacing: -.02em; }
.today-desc { font-size: 13.5px; color: var(--text-2); line-height: 1.6; margin-bottom: 8px; }
.today-diary {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.6;
  padding: 10px 12px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
}
.today-updated { font-size: 11px; color: var(--text-3); margin: 4px 0 6px; font-family: var(--mono); }

/* ===== 她的参数面板 ===== */
.bot-params { gap: 10px; }
.param-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; }
.param-name { font-size: 14px; color: var(--text-2); }
.param-select {
  flex: 0 0 auto;
  min-width: 50%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.param-select:focus { border-color: var(--accent); }
.param-actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

/* ===== 设置 ===== */
.setting-row { padding: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.setting-row + .setting-row { border-top: 1px solid var(--border); }
.setting-label { font-size: 13px; color: var(--text-2); }
.setting-input {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  width: 100%;
  outline: none;
  min-height: 48px;
}
.setting-input:focus { border-color: var(--accent); }
.setting-select {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  width: 100%;
  min-height: 48px;
  appearance: none;
  -webkit-appearance: none;
}
.setting-info { font-size: 13px; color: var(--text-2); line-height: 1.6; }
.setting-status { font-size: 12px; color: var(--success); margin-top: 2px; }

/* 分段选择（帧率档位） */
.seg { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.seg::-webkit-scrollbar { display: none; }
.seg-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 48px;
  padding: 0 4px;
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-2);
  font-size: 12px;
  font-family: var(--mono);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.seg-btn:active { transform: scale(.97); }
.seg-btn.active { background: var(--accent-dim); border-color: var(--accent-border); color: var(--accent); }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #04211d; }
.btn-secondary { background: var(--input-bg); color: var(--text); border-color: var(--input-border); }
.btn-mini {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: opacity var(--dur) var(--ease);
}
.btn-mini:active { opacity: .7; }
.btn-accent { background: var(--accent-dim); border-color: var(--accent-border); color: var(--accent); }
.btn-accent:disabled { opacity: .5; }

/* ===== 折叠块 ===== */
details.fold {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
details.fold > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.01em;
  -webkit-tap-highlight-color: transparent;
}
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary .ic { color: var(--text-2); }
details.fold > summary::after {
  content: '';
  width: 7px; height: 7px;
  border-right: 1.5px solid var(--text-3);
  border-bottom: 1.5px solid var(--text-3);
  transform: rotate(45deg);
  margin-left: auto;
  transition: transform var(--dur) var(--ease);
  flex-shrink: 0;
}
details.fold[open] > summary::after { transform: rotate(-135deg); }
details.fold > summary .fold-right { font-size: 12px; font-weight: 400; color: var(--text-2); }
details.fold > summary .fold-sub {
  font-size: 12px; font-weight: 400; color: var(--text-3);
  min-width: 0; max-width: 62%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
details.fold .fold-body { padding: 4px 14px 14px; border-top: 1px solid var(--border); }
details.fold[open] > summary { border-bottom: 0; }
details.fold + details.fold { margin-top: 8px; }
.fold-body .stat-row:first-child { padding-top: 8px; }

/* ===== 迷你统计格 ===== */
.mini-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mini-grid.cols3 { grid-template-columns: repeat(3, 1fr); }
.mini-grid.cols2 { grid-template-columns: repeat(2, 1fr); }
.mini-stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 4px 10px;
  text-align: center;
  min-width: 0;
}
.mini-stat .v {
  font-size: 17px; font-weight: 700; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.mini-stat .v.lg { font-size: 20px; }
.mini-stat .k { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.mini-stat .v.ok { color: var(--success); }
.mini-stat .v.warn { color: var(--warning); }

/* 文本截断 */
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* 胶囊 */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px;
  background: var(--input-bg); border: 1px solid var(--input-border);
  color: var(--text-2);
}
.chip.ok { color: var(--success); border-color: rgba(74, 222, 128, .35); }
.chip.warn { color: var(--warning); border-color: rgba(251, 191, 36, .35); }
.chip.bad { color: var(--danger); border-color: rgba(248, 113, 113, .35); }

.empty-state { text-align: center; color: var(--text-3); font-size: 12.5px; padding: 18px 8px; }
.section-title { font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--text-3); margin: 14px 2px 8px; }
.section-title:first-child { margin-top: 0; }
.summary-line { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.summary-line b { color: var(--text); font-weight: 600; }
.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* 进度条：只用 transform: scaleX() */
.progress {
  position: relative;
  height: 8px;
  background: rgba(128, 128, 128, .22);
  border-radius: 999px;
  overflow: hidden;
}
.progress > .progress-fill {
  position: absolute; inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  background: var(--accent);
  border-radius: 999px;
  will-change: transform;
}
.soul-bar { flex: 1; height: 8px; background: rgba(128, 128, 128, .22); border-radius: 999px; overflow: hidden; margin: 0 8px; }
.soul-fill {
  display: block; height: 100%;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(0);
  background: var(--accent);
  border-radius: 999px;
  transition: transform var(--dur) var(--ease);
  will-change: transform;
}

/* ===== 底部导航 ===== */
#bottomNav {
  display: flex;
  align-items: stretch;
  background: var(--nav-bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  padding-bottom: var(--safe-b);
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
  z-index: 40;
}
.nav-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 56px;
  padding: 8px 2px;
  text-decoration: none;
  color: var(--text-3);
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: color var(--dur) var(--ease), transform var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.nav-item:active { transform: scale(.94); }
.nav-item .ic { width: 20px; height: 20px; }
.nav-item .nav-label { font-size: 10.5px; font-weight: 500; line-height: 1; }
.nav-item.active { color: var(--accent); }

/* 更多：底部弹层 */
.nav-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 1090; /* 高于地图页 leaflet 控件(1000)/地图底栏(550)，否则地图内容会盖住抽屉 */
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  padding: 8px 12px calc(12px + var(--safe-b));
  padding-left: calc(12px + var(--safe-l));
  padding-right: calc(12px + var(--safe-r));
  transform: translate3d(0, 100%, 0);
  opacity: 0;
  visibility: hidden;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease), visibility var(--dur);
  max-width: 560px;
  margin: 0 auto;
}
.nav-sheet.open { transform: none; opacity: 1; visibility: visible; }
.nav-sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 6px; }
.nav-sheet-grid .nav-item {
  flex-direction: row;
  gap: 8px;
  min-height: 52px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-2);
}
.nav-sheet-grid .nav-item.active { color: var(--accent); border-color: var(--accent-border); background: var(--accent-dim); }
.nav-scrim {
  position: fixed; inset: 0; z-index: 1080;
  background: rgba(0, 0, 0, .5);
  opacity: 0; visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur);
}
.nav-scrim.open { opacity: 1; visibility: visible; }

/* ===== 滚动条 ===== */
#mainContent::-webkit-scrollbar { width: 3px; }
#mainContent::-webkit-scrollbar-track { background: transparent; }
#mainContent::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

/* ===== 加载动画 ===== */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { animation: spin .9s linear infinite; }

/* ===== 聊天页 ===== */
.chat-layout {
  display: flex;
  height: calc(100dvh - 52px - 56px - var(--safe-t) - var(--safe-b) - 24px);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--card);
}
.chat-sessions { width: 100%; display: flex; flex-direction: column; background: var(--card); }
.chat-messages { flex: 1; display: flex; flex-direction: column; background: var(--card); }
@media (min-width: 600px) { .chat-sessions { width: 280px; flex-shrink: 0; border-right: 1px solid var(--border); } }
.chat-list-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; font-weight: 600; font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.session-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.session-item {
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 10px 12px;
  border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background-color var(--dur) var(--ease);
}
.session-item:active { background: var(--hover); }
.session-item.active { background: var(--accent-dim); }
.session-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--card-2); color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.session-info { flex: 1; min-width: 0; }
.session-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-preview { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.session-time { font-size: 11px; color: var(--text-3); flex-shrink: 0; font-family: var(--mono); }
.session-loading { padding: 20px; text-align: center; color: var(--text-3); font-size: 13px; }
.chat-msg-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; font-weight: 600; font-size: 14px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.chat-back { display: none; }
@media (max-width: 599px) {
  .chat-back { display: inline-flex; }
  .chat-sessions { border-right: 0; }
  .chat-messages { display: none; }
  .chat-layout.show-messages .chat-sessions { display: none; }
  .chat-layout.show-messages .chat-messages { display: flex; }
}
.message-list {
  flex: 1; overflow-y: auto; padding: 12px;
  -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 10px;
  contain: content;
}
.msg-placeholder { text-align: center; color: var(--text-3); margin: auto; font-size: 14px; }
.msg-row { display: flex; flex-direction: column; max-width: 85%; }
.msg-row.from-bot { align-self: flex-end; align-items: flex-end; }
.msg-row.from-user { align-self: flex-start; align-items: flex-start; }
.msg-sender { font-size: 11px; color: var(--text-3); margin-bottom: 2px; }
.msg-bubble { padding: 8px 12px; border-radius: var(--radius); font-size: 14px; line-height: 1.5; word-break: break-word; white-space: pre-wrap; }
.msg-row.from-bot .msg-bubble { background: var(--accent); color: #04211d; border-bottom-right-radius: 4px; }
.msg-row.from-user .msg-bubble { background: var(--card-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-time { font-size: 10px; color: var(--text-3); margin-top: 2px; font-family: var(--mono); }
.chat-msg-footer { padding: 8px; text-align: center; border-top: 1px solid var(--border); flex-shrink: 0; }
.msg-image { max-width: 200px; border-radius: var(--radius-sm); display: block; margin-top: 4px; }

.chat-filter-row { display: flex; gap: 6px; padding: 8px 12px; }
.filter-chip {
  min-height: 36px; padding: 4px 14px; border-radius: 999px; font-size: 12px;
  background: var(--input-bg); border: 1px solid var(--input-border);
  color: var(--text-2); cursor: pointer; font-family: inherit;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.filter-chip.active { background: var(--accent-dim); border-color: var(--accent-border); color: var(--accent); }

.live-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--accent); }
.live-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ===== 对话页 ===== */
.talk-layout {
  display: flex; flex-direction: column;
  height: calc(100dvh - 52px - 56px - var(--safe-t) - var(--safe-b) - 24px);
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.talk-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; font-weight: 600; font-size: 15px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.talk-header .ic { color: var(--accent); }
.talk-list { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.talk-input-row { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); flex-shrink: 0; }
.talk-input {
  flex: 1; background: var(--input-bg); border: 1px solid var(--input-border);
  border-radius: var(--radius-sm); padding: 12px 14px; color: var(--text);
  font-size: 14px; outline: none; min-height: 48px; font-family: inherit;
}
.talk-input:focus { border-color: var(--accent); }

/* ===== 文件页 ===== */
.file-layout {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  min-height: calc(100dvh - 52px - 56px - var(--safe-t) - var(--safe-b) - 24px);
}
.file-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.file-path {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--text-3); font-size: 12px; font-family: var(--mono);
}
.file-list { padding: 4px 0; }
.file-item {
  display: flex; align-items: center; gap: 10px; min-height: 56px;
  padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background-color var(--dur) var(--ease);
}
.file-item:active { background: var(--hover); }
.file-icon { width: 28px; display: flex; align-items: center; justify-content: center; color: var(--text-2); flex-shrink: 0; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; font-family: var(--mono); }
.file-download { flex-shrink: 0; }

/* ===== DSH 页 ===== */
.dsh-intro { font-size: 13px; color: var(--text-2); line-height: 1.7; margin-bottom: 8px; }
.dsh-intro p { margin-bottom: 6px; }
.dsh-iframe-card { margin-top: 12px; }
.dsh-iframe { width: 100%; height: 100%; min-height: 78dvh; border: none; background: var(--card); }

/* ===== 表情库 ===== */
.stickers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; padding: 10px; }
.sticker-item {
  position: relative; aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  background: var(--card-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px;
}
.sticker-item img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--radius-sm); }
.sticker-del {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px; min-height: 24px; padding: 0;
  border-radius: 50%; font-size: 11px; line-height: 1;
  opacity: .5; display: inline-flex; align-items: center; justify-content: center;
}

/* ===== Agent 流水线 ===== */
.agents-list { display: flex; flex-direction: column; gap: 10px; }
.agent-card {
  background: var(--card-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.agent-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.agent-toggle { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; }
.agent-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.agent-role { font-size: 12px; color: var(--text-2); line-height: 1.5; }
.agent-prompt {
  background: var(--card); border: 1px solid var(--input-border);
  border-radius: var(--radius-sm); padding: 8px 10px; color: var(--text);
  font-size: 12px; width: 100%; resize: vertical; outline: none;
  font-family: var(--mono); line-height: 1.5;
}
.agent-prompt:focus { border-color: var(--accent); }
.plans-fold { margin-top: 6px; }
.diary-content {
  margin-top: 8px; padding: 12px; background: var(--card-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; line-height: 1.8; white-space: pre-wrap;
}

/* ===== 灵魂状态板 ===== */
.soul-hero-wrap { margin-bottom: 12px; }
.soul-hero-wrap .mini-grid { margin-bottom: 8px; }
.soul-hero .card-body { padding: 8px 12px; }
.soul-card .card-body { padding: 10px 14px; }
.soul-ts { font-size: 11px; color: var(--text-3); margin-right: 4px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.soul-md { font-size: 13px; line-height: 1.6; max-height: 220px; overflow-y: auto; }
.soul-radar { width: 100%; max-width: 240px; height: auto; display: block; margin: 4px auto; color: var(--text-3); }
.soul-curve { width: 100%; height: 96px; display: block; margin: 6px 0; }
.soul-more { margin-top: 6px; }
.soul-more summary { font-size: 12px; color: var(--accent); cursor: pointer; list-style: none; }
.soul-more > div { margin-top: 6px; }
details.fold .card { background: transparent; border-color: transparent; }
details.fold .card + .card { border-top: 1px solid var(--border); }
details.fold .card-header { padding: 10px 0 6px; border-bottom: none; color: var(--text); font-size: 13px; }
details.fold .card-body { padding: 0 0 10px; }
details.fold .card-grid { gap: 0; }
.soul-group { margin-bottom: 18px; }

/* ===== 提示 toast ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b));
  transform: translate3d(-50%, 8px, 0);
  background: var(--bg-elev); color: var(--text);
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  font-size: 13px; z-index: 9999; opacity: 0;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  pointer-events: none; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate3d(-50%, 0, 0); }

/* ============================
   地图页（全屏）
   ============================ */
#mainContent.map-active { padding: 0; overflow: hidden; }
#page-map { height: 100%; }
.map-shell { position: relative; height: 100%; overflow: hidden; background: #16181f; }
#mapCanvas { position: absolute; inset: 0; }
.map-follow { display: flex; align-items: center; gap: 4px; color: #cfd3dc; }
.leaflet-container { background: #16181f; }

.map-overlay-top { position: absolute; top: calc(8px + var(--safe-t)); left: 8px; right: 78px; display: flex; align-items: center; gap: 6px; z-index: 500; pointer-events: none; }
.map-overlay-top > * { pointer-events: auto; }
.map-status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: rgba(9, 9, 11, .82); color: #dfe3ec; font-size: 11px; max-width: 58%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid rgba(255, 255, 255, .08); }
.map-status-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #4ade80; flex-shrink: 0; }
.map-status-pill.err::before { background: #f87171; }
.map-chip { display: inline-flex; align-items: center; gap: 4px; min-height: 34px; padding: 5px 12px; border-radius: 999px; background: rgba(9, 9, 11, .82); color: #cfd3dc; font-size: 11px; border: 1px solid rgba(255, 255, 255, .08); cursor: pointer; }
.map-chip input { width: 13px; height: 13px; accent-color: #2dd4bf; }

.map-mode-bar { position: absolute; top: 46px; left: 50%; transform: translate3d(-50%, 0, 0); z-index: 500; display: none; padding: 6px 14px; border-radius: 999px; background: rgba(45, 212, 191, .95); color: #04211d; font-size: 12px; box-shadow: var(--shadow-lg); white-space: nowrap; }
.map-mode-bar.show { display: block; }

.map-compass-mini { position: absolute; right: 10px; top: calc(10px + var(--safe-t)); z-index: 500; width: 64px; padding: 7px 0 4px; border-radius: var(--radius); background: rgba(9, 9, 11, .82); border: 1px solid rgba(255, 255, 255, .08); text-align: center; color: #9aa3b2; }
.compass-dial-small { position: relative; width: 42px; height: 42px; margin: 0 auto; border: 1.5px solid rgba(255, 255, 255, .15); border-radius: 50%; }
.compass-needle { position: absolute; left: 50%; top: 50%; width: 2px; height: 34px; margin: -17px 0 0 -1px; transition: transform .2s var(--ease); }
.compass-needle::before { content: ''; position: absolute; top: 0; left: -2.5px; border-left: 3.5px solid transparent; border-right: 3.5px solid transparent; border-bottom: 17px solid #f87171; }
.compass-needle::after { content: ''; position: absolute; bottom: 0; left: -2.5px; border-left: 3.5px solid transparent; border-right: 3.5px solid transparent; border-top: 17px solid #cfd3dc; }
#compassDeg { font-size: 10px; margin-top: 3px; font-variant-numeric: tabular-nums; font-family: var(--mono); }

.map-fabs { position: absolute; right: 10px; top: calc(120px + var(--safe-t)); z-index: 500; display: flex; flex-direction: column; gap: 10px; }
.map-fab {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(9, 9, 11, .85); border: 1px solid rgba(255, 255, 255, .1);
  color: #dfe3ec; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); cursor: pointer; padding: 0;
  transition: transform var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
.map-fab:active { transform: scale(.94); }
.map-fab.active { background: #2dd4bf; border-color: #2dd4bf; color: #04211d; }

.layer-pop {
  position: absolute; right: 64px; top: calc(120px + var(--safe-t)); z-index: 600; width: 190px;
  padding: 10px 12px; border-radius: var(--radius);
  background: rgba(9, 9, 11, .96); border: 1px solid rgba(255, 255, 255, .1);
  box-shadow: var(--shadow-lg); display: none;
}
.layer-pop.show { display: block; }
.layer-pop .lp-title { font-size: 11px; color: #9aa3b2; margin: 2px 0 4px; }
.layer-pop label { display: flex; align-items: center; gap: 8px; padding: 5px 2px; font-size: 12.5px; color: #dfe3ec; }
.layer-pop input[type="radio"], .layer-pop input[type="checkbox"] { width: 15px; height: 15px; accent-color: #2dd4bf; }
.layer-pop .lp-legend { border-top: 1px solid rgba(255, 255, 255, .08); margin-top: 6px; padding-top: 6px; display: flex; gap: 10px; font-size: 10.5px; color: #9aa3b2; flex-wrap: wrap; }
.map-attr { position: absolute; right: 8px; bottom: calc(3px + var(--safe-b)); z-index: 400; font-size: 9px; color: rgba(255, 255, 255, .35); pointer-events: none; }

.map-sheet {
  position: absolute; left: 8px; right: 8px; bottom: calc(8px + var(--safe-b)); z-index: 550;
  border-radius: var(--radius-lg); background: rgba(9, 9, 11, .94);
  border: 1px solid rgba(255, 255, 255, .1); box-shadow: var(--shadow-lg); overflow: hidden;
}
.sheet-head { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 10px 14px 8px; cursor: pointer; }
.sheet-handle { width: 34px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .22); flex-shrink: 0; }
.sheet-brief { font-size: 12px; color: #dfe3ec; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--mono); }
.sheet-acc { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: rgba(74, 222, 128, .15); color: #4ade80; flex-shrink: 0; }
.sheet-chevron { margin-left: auto; width: 8px; height: 8px; border-right: 1.5px solid #9aa3b2; border-bottom: 1.5px solid #9aa3b2; transform: rotate(-135deg); transition: transform var(--dur) var(--ease); flex-shrink: 0; }
.map-sheet.open .sheet-chevron { transform: rotate(45deg); }
.sheet-tabs { display: flex; gap: 6px; padding: 2px 12px 10px; overflow-x: auto; scrollbar-width: none; }
.sheet-tabs::-webkit-scrollbar { display: none; }
.sheet-tab { flex-shrink: 0; min-height: 34px; padding: 4px 12px; border-radius: 999px; font-size: 12px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .08); color: #9aa3b2; cursor: pointer; }
.sheet-tab.active { background: #2dd4bf; border-color: #2dd4bf; color: #04211d; }
.sheet-tab span { opacity: .85; font-size: 11px; margin-left: 1px; color: inherit; }
.sheet-body { display: none; max-height: 46vh; overflow-y: auto; padding: 0 14px 14px; -webkit-overflow-scrolling: touch; }
.map-sheet.open .sheet-body { display: block; }
.sheet-pane { display: none; }
.sheet-pane.active { display: block; }
.leaflet-bottom.leaflet-left { bottom: calc(118px + var(--safe-b)); }
.map-shell.sheet-open .leaflet-bottom.leaflet-left { display: none; }
.leaflet-control-scale-line { background: rgba(9, 9, 11, .7); color: #cfd3dc; border-color: rgba(255, 255, 255, .3); }

.lg-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.lg-me { background: #4a9eff; }
.lg-mark { background: #ff9f43; }
.lg-line { display: inline-block; width: 13px; height: 3px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.lg-track { background: #ff9f43; }
.lg-measure { background: #ff5470; }
#gnssSummary { font-size: 12px; color: #cfd3dc; margin-bottom: 6px; }
.gnss-main { display: flex; gap: 10px; align-items: flex-start; }
#skyplot { background: rgba(255, 255, 255, 0.04); border-radius: 50%; flex-shrink: 0; }
.gnss-list { flex: 1; max-height: 220px; overflow-y: auto; font-size: 11px; color: #b7bec9; font-family: var(--mono); }
.gnss-list .gnss-item { display: flex; justify-content: space-between; gap: 6px; padding: 2px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
.gnss-list .gnss-item.used { color: #4ade80; }
.marks-tools { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.marks-list { font-size: 12px; max-height: 220px; overflow-y: auto; }
.mark-item { display: flex; align-items: center; gap: 6px; padding: 5px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.mark-item .mark-name { color: #ffb36b; font-weight: 600; }
.mark-item .mark-coord { flex: 1; color: #9aa3b2; font-family: var(--mono); font-size: 11px; }
.measure-label { background: rgba(255, 84, 112, 0.9); color: #fff; border: none; font-size: 11px; padding: 1px 6px; border-radius: 6px; text-align: center; }
.astro-grid, .weather-grid { display: flex; flex-wrap: wrap; gap: 10px 16px; font-size: 13px; color: #cfd3dc; }
.astro-grid .kv, .weather-grid .kv { display: inline-flex; align-items: center; gap: 5px; }
.astro-grid .kv b, .weather-grid .kv b { color: #e7eaf0; font-weight: 600; font-family: var(--mono); }
.cache-row { display: flex; align-items: center; gap: 8px; font-size: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.cache-z { width: 52px; padding: 4px 6px; background: rgba(255, 255, 255, 0.06); color: #e7eaf0; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 6px; font-family: var(--mono); }
.cache-progress { height: 8px; background: rgba(255, 255, 255, 0.08); border-radius: 4px; overflow: hidden; }
.cache-bar { height: 100%; width: 100%; transform: scaleX(0); transform-origin: left center; background: linear-gradient(90deg, #2dd4bf, #4ade80); transition: transform var(--dur) var(--ease); will-change: transform; }
.cache-status { font-size: 12px; color: #9aa3b2; margin-top: 6px; }

/* 自己位置 / 标点 */
.me-wrap { position: relative; width: 44px; height: 44px; }
.me-rot { position: absolute; inset: 0; transform: rotate(0deg); transition: transform .2s var(--ease), opacity .2s; }
.me-rot::before { content: ''; position: absolute; left: 50%; top: 3px; margin-left: -10px; width: 0; height: 0; border-left: 10px solid transparent; border-right: 10px solid transparent; border-bottom: 19px solid rgba(74, 158, 255, .5); }
.me-dot { position: absolute; left: 50%; top: 50%; width: 15px; height: 15px; margin: -7.5px 0 0 -7.5px; background: #4a9eff; border: 2.5px solid #fff; border-radius: 50%; box-shadow: 0 1px 6px rgba(0, 0, 0, .45); }
.xmark { position: relative; width: 24px; height: 24px; }
.xmark-dot { position: absolute; left: 50%; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; background: #ff9f43; border: 2.5px solid #fff; border-radius: 50%; box-shadow: 0 1px 5px rgba(0, 0, 0, .45); }
.xmark-name { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: -3px; font-size: 10px; color: #fff; text-shadow: 0 0 3px rgba(0, 0, 0, .9), 0 0 6px rgba(0, 0, 0, .7); white-space: nowrap; pointer-events: none; }

/* 更新进度条 */
#updateProgressBar { transform: scaleX(0); transform-origin: left center; transition: transform var(--dur) var(--ease); }

/* 页面标题行 / 通用文本 */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 2px 10px;
}
.page-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.page-header h2 .ic { color: var(--accent); }
.muted { color: var(--text-3); font-size: 12px; }
.file-note { padding: 8px 14px; font-size: 12px; color: var(--text-3); border-bottom: 1px solid var(--border); }
.mark-popup { font-size: 12px; line-height: 1.5; }
.mark-popup .mark-coord { display: block; color: #9aa3b2; font-family: var(--mono); font-size: 11px; }

/* ===== 无障碍：减少动效 ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
