/* ========== Material 3 设计令牌（动态取色，JS 会覆盖这些默认值） ========== */
:root {
  color-scheme: light;
  --md-sys-color-primary: #0b57d0;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d8e2ff;
  --md-sys-color-on-primary-container: #001a41;
  --md-sys-color-secondary: #565e71;
  --md-sys-color-secondary-container: #e0e2f9;
  --md-sys-color-on-secondary-container: #454659;
  --md-sys-color-surface: #f9f9ff;
  --md-sys-color-surface-container: #eef0f6;
  --md-sys-color-surface-container-high: #e8eaf0;
  --md-sys-color-on-surface: #1a1c20;
  --md-sys-color-on-surface-variant: #44474e;
  --md-sys-color-outline: #74777f;
  --md-sys-color-error: #ba1a1a;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --md-sys-color-primary: #a8c7ff;
    --md-sys-color-on-primary: #002e69;
    --md-sys-color-primary-container: #004494;
    --md-sys-color-on-primary-container: #d8e2ff;
    --md-sys-color-secondary: #bfc7dc;
    --md-sys-color-secondary-container: #454659;
    --md-sys-color-on-secondary-container: #e0e2f9;
    --md-sys-color-surface: #101418;
    --md-sys-color-surface-container: #1b2026;
    --md-sys-color-surface-container-high: #252b32;
    --md-sys-color-on-surface: #e0e3e9;
    --md-sys-color-on-surface-variant: #c1c6ce;
    --md-sys-color-outline: #8b9199;
    --md-sys-color-error: #ffb4ab;
  }
}

/* ========== 基础 ========== */
* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  padding-bottom: 240px;
}

.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

svg { display: block; width: 24px; height: 24px; fill: currentColor; }

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ========== 顶部应用栏 ========== */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-top));
  background: var(--md-sys-color-surface-container);
  box-shadow: 0 1px 0 var(--md-sys-color-outline), 0 1px 3px rgba(0, 0, 0, 0.12);
}

.appbar__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.appbar__brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.appbar__logo {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  flex: none;
}

.appbar__title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

/* ========== 状态徽章 ========== */
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
}

.status-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--md-sys-color-on-surface-variant);
}

.status-chip[data-variant="ok"] {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}
.status-chip[data-variant="ok"]::before { background: currentColor; }

.status-chip[data-variant="busy"] {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}
.status-chip[data-variant="busy"]::before {
  background: currentColor;
  animation: pulse 1.4s ease-in-out infinite;
}

.status-chip[data-variant="error"] {
  background: var(--md-sys-color-error);
  color: #ffffff;
}
.status-chip[data-variant="error"]::before { background: currentColor; }

@keyframes pulse { 50% { opacity: 0.35; } }

/* ========== 地址搜索框（Material 填充式输入） ========== */
.searchbar {
  display: flex;
  align-items: center;
  gap: 2px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 2px 4px 2px 16px;
  border-radius: 999px;
  background: var(--md-sys-color-surface-container-high);
  border: 1px solid var(--md-sys-color-outline);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.searchbar:focus-within {
  border-color: var(--md-sys-color-primary);
  background: var(--md-sys-color-surface-container);
}

.searchbar__icon { flex: none; color: var(--md-sys-color-on-surface-variant); }

.searchbar__input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 15px;
  padding: 8px 0;
}

.searchbar__input::-webkit-search-cancel-button,
.searchbar__input::-webkit-search-decoration { -webkit-appearance: none; }

.searchbar__input::placeholder { color: var(--md-sys-color-on-surface-variant); }

.searchbar__clear { width: 34px; height: 34px; }

/* ========== 模拟位置徽章 ========== */
.simbadge {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 4px 6px 4px 14px;
  border-radius: 999px;
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-size: 13px;
}

.simbadge__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.simbadge__text b { font-weight: 600; }

.simbadge__back {
  flex: none;
  padding: 6px 10px;
  font-size: 13px;
  background: transparent;
  color: inherit;
}

.simbadge__back:hover::before { opacity: 0.12; }

/* ========== 内容 / 卡片 ========== */
.content {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}

.card {
  background: var(--md-sys-color-surface-container-high);
  border-radius: 24px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
}

.card__title { margin: 0 0 12px; font-size: 15px; font-weight: 600; }

/* 解说卡片 */
.poi-card__head { display: flex; align-items: center; gap: 12px; }

.poi-card__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 50%;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.poi-card__name {
  margin: 0;
  flex: 1;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
}

.poi-card__text {
  margin: 12px 0 0;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 14px;
  white-space: pre-wrap;
}

.state-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  flex: none;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

/* 位置卡片 */
.loc { margin: 0; display: grid; gap: 8px; }

.loc__row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  font-size: 14px;
}

.loc__row dt { color: var(--md-sys-color-on-surface-variant); }

.loc__row dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  text-align: right;
  word-break: break-all;
}

/* 权限卡片 */
.perm-card {
  display: grid;
  gap: 14px;
  border: 1px solid var(--md-sys-color-outline);
  background: var(--md-sys-color-surface-container);
}

.perm-card__text { margin: 0; color: var(--md-sys-color-on-surface-variant); font-size: 14px; }

/* ========== 按钮 ========== */
.btn,
.text-btn,
.icon-btn,
.fab {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  font-weight: 500;
  isolation: isolate;
}

.btn,
.text-btn {
  padding: 10px 18px;
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-size: 14px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--md-sys-color-on-surface-variant);
}

/* 状态层 + 简易涟漪（纯 CSS） */
.btn::before,
.text-btn::before,
.icon-btn::before,
.fab::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: currentColor;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.btn::after,
.text-btn::after,
.icon-btn::after,
.fab::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: radial-gradient(circle at center, currentColor 0 16%, transparent 18%);
  background-position: center;
  background-repeat: no-repeat;
  background-size: 1000% 1000%;
  opacity: 0;
  transition: opacity 0.4s ease, background-size 0.4s ease;
  pointer-events: none;
}

.btn:hover::before,
.text-btn:hover::before,
.icon-btn:hover::before,
.fab:hover::before { opacity: 0.08; }

.btn:active::after,
.text-btn:active::after,
.icon-btn:active::after,
.fab:active::after { opacity: 0.28; background-size: 100% 100%; }

/* ========== 底部控制栏 ========== */
.bottombar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  z-index: 30;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 10px;
  border-radius: 28px;
  background: var(--md-sys-color-surface-container);
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.3), 0 2px 3px 0 rgba(0, 0, 0, 0.3);
}

.text-btn { padding: 8px 12px; }

.bottombar__spacer { flex: 1; }

.vol { display: flex; align-items: center; flex: 1 1 120px; max-width: 140px; padding: 0 8px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--md-sys-color-primary) 0%,
    var(--md-sys-color-primary) var(--fill, 50%),
    var(--md-sys-color-on-surface-variant) var(--fill, 50%)
  );
  outline-offset: 4px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--md-sys-color-surface);
  background: var(--md-sys-color-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--md-sys-color-surface);
  background: var(--md-sys-color-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

/* ========== 扩展悬浮按钮（FAB） ========== */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(env(safe-area-inset-bottom) + 88px);
  z-index: 30;
  height: 56px;
  padding: 0 20px;
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-size: 14px;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 8px 3px rgba(0, 0, 0, 0.2), 0 1px 3px rgba(0, 0, 0, 0.3);
}

.fab svg { width: 24px; height: 24px; }

/* ========== Snackbar ========== */
.snackbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(24px);
  bottom: calc(env(safe-area-inset-bottom) + 168px);
  z-index: 40;
  max-width: calc(100vw - 48px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--md-sys-color-on-surface);
  color: var(--md-sys-color-surface);
  font-size: 14px;
  box-shadow: 0 4px 8px 3px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  text-align: center;
}

.snackbar.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.noscript {
  max-width: 640px;
  margin: 16px auto;
  padding: 0 16px;
  color: var(--md-sys-color-error);
}

/* ========== 桌面端 ========== */
@media (min-width: 640px) {
  .bottombar {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    width: 640px;
    margin-left: 0;
    right: auto;
  }

  .fab {
    position: fixed;
    right: calc(50% - 320px + 20px);
    bottom: calc(env(safe-area-inset-bottom) + 88px);
  }

  .snackbar {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom) + 168px);
  }
}

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