:root {
  --ink: #eef0f6;
  --ink-dim: rgba(238, 240, 246, 0.62);
  --ink-faint: rgba(238, 240, 246, 0.38);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --glass: rgba(14, 16, 22, 0.62);
  --glass-solid: rgba(12, 14, 19, 0.94);
  --accent: #a78bfa;
  --accent-soft: rgba(167, 139, 250, 0.16);
  --radius: 12px;
  --radius-sm: 8px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #05070b;
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

body { touch-action: none; }

button, input { font: inherit; color: inherit; }

.stage {
  position: fixed;
  inset: 0;
  isolation: isolate;
}

#scene {
  position: absolute;
  inset: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#scene:active { cursor: grabbing; }

.vignette {
  display: none;
}

/* ---------- top ---------- */
.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 22px 0;
  pointer-events: none;
}

.mark {
  display: flex;
  align-items: center;
  gap: 10px;
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.7);
}

.mark .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px 2px rgba(167, 139, 250, 0.55);
  animation: pulse 5.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; box-shadow: 0 0 10px 1px rgba(167, 139, 250, 0.4); }
  50% { opacity: 1; box-shadow: 0 0 16px 3px rgba(167, 139, 250, 0.6); }
}

.mark-text { display: flex; flex-direction: column; gap: 2px; }
.mark-text b { font-size: 14px; font-weight: 550; letter-spacing: 0.06em; }
.mark-text small {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--ink-faint);
  font-weight: 500;
}

.readout {
  pointer-events: auto;
  min-width: 176px;
  padding: 10px 13px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  text-align: right;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

.readout[hidden] { display: none; }

.readout-main {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 8px;
  font-size: 12px;
}
.readout-main span { color: var(--ink-dim); letter-spacing: 0.04em; }
.readout-main strong {
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}
.readout-sub {
  margin-top: 2px;
  font-size: 11px;
  color: var(--ink-dim);
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  font-variant-numeric: tabular-nums;
}
.readout-sub i { opacity: 0.4; font-style: normal; }
.readout-src {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 9.5px;
  line-height: 1.5;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}
.readout-src.warn { color: #e7c07a; }
.readout-src button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 9.5px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- dock ---------- */
.dock {
  position: absolute;
  left: 20px;
  top: 50%;
  bottom: auto;
  width: 88px;
  max-height: calc(100dvh - 140px);
  overflow-y: auto;
  border-radius: 14px;
  transform: translateY(-50%);
  z-index: 5;
  max-width: calc(100vw - 24px);
}

.dock-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.seg { display: flex; flex-direction: column; width: 100%; gap: 2px; }
.dock .seg-btn, .dock .icon-btn { width: 100%; min-height: 44px; }

.seg-btn,
.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  min-width: 40px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-dim);
  cursor: pointer;
  transition: color 0.25s ease, background 0.25s ease, border-color 0.25s ease, transform 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.seg-btn svg, .icon-btn svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.seg-btn span, .icon-label {
  font-size: 12px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.seg-btn:hover, .icon-btn:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }
.seg-btn:active, .icon-btn:active { transform: scale(0.97); }

.seg-btn.is-on {
  color: #fff;
  background: var(--accent-soft);
  border-color: rgba(167, 139, 250, 0.34);
  box-shadow: 0 0 0 1px rgba(167, 139, 250, 0.08) inset;
}
.seg-btn.is-on svg { stroke: var(--accent); filter: drop-shadow(0 0 6px rgba(167, 139, 250, 0.6)); }

.icon-btn[aria-pressed="true"] {
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--line-strong);
}

.split {
  width: 100%;
  height: 1px;
  margin: 4px 0;
  background: var(--line);
  flex: none;
}

/* icon swap */
.i-moon, .i-exit, .i-sound-on { display: none; }
[data-night="true"] .i-sun { display: none; }
[data-night="true"] .i-moon { display: block; }
[aria-pressed="true"] .i-full { display: none; }
[aria-pressed="true"] .i-exit { display: block; }
#sound-btn[aria-pressed="true"] .i-sound-off { display: none; }
#sound-btn[aria-pressed="true"] .i-sound-on { display: block; }

:where(button, input, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- hint ---------- */
.hint {
  position: absolute;
  left: 50%;
  bottom: calc(84px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 4;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: rgba(238, 240, 246, 0.82);
  background: rgba(8, 10, 14, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: 6px 12px;
  border-radius: 100px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.9s ease;
}
.hint.show { opacity: 1; }
.hint b { color: var(--ink-faint); font-weight: 400; margin: 0 2px; }

/* ---------- panel ---------- */
.panel {
  position: absolute;
  right: 22px;
  bottom: calc(96px + var(--safe-b));
  z-index: 6;
  width: 340px;
  max-height: min(66vh, 520px);
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass-solid);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  animation: panelIn 0.28s cubic-bezier(0.22, 0.8, 0.3, 1);
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.panel[hidden] { display: none; }

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.panel-head h2 { margin: 3px 0 0; font-size: 15px; font-weight: 550; letter-spacing: 0.01em; }
.icon-btn.small { min-height: 30px; min-width: 30px; padding: 0; border-radius: 7px; }
.icon-btn.small svg { width: 14px; height: 14px; }

.eyebrow {
  margin: 0;
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--ink-faint);
  font-weight: 500;
}

.panel-note {
  margin: 10px 0 12px;
  font-size: 10.5px;
  line-height: 1.65;
  color: var(--ink-faint);
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.panel-body { overflow-y: auto; flex: 1; min-height: 0; padding-right: 2px; }
.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 4px; }

.city-search label { display: block; font-size: 10.5px; color: var(--ink-dim); margin-bottom: 6px; }

.search-row { display: flex; gap: 6px; }

.search-row input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.search-row input::placeholder { color: var(--ink-faint); }
.search-row input:focus { border-color: rgba(167, 139, 250, 0.5); background: rgba(167, 139, 250, 0.06); }

.btn {
  height: 34px;
  padding: 0 13px;
  border: 1px solid rgba(167, 139, 250, 0.4);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.btn:hover { background: rgba(167, 139, 250, 0.26); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.ghost {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--ink-dim);
}
.btn.ghost:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.3); }
.btn.small { height: 28px; font-size: 11px; padding: 0 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chip {
  height: 25px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink-dim);
  font-size: 11px;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.chip:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.28); }

.feed { margin-top: 14px; }
.feed-empty { margin: 0; font-size: 11px; color: var(--ink-faint); line-height: 1.7; }

.feed-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 10px;
}
.feed-cell {
  padding: 8px 9px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.03);
}
.feed-cell span { display: block; font-size: 9.5px; color: var(--ink-faint); letter-spacing: 0.06em; }
.feed-cell strong {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.feed-cell strong small { font-size: 9.5px; color: var(--ink-faint); margin-left: 2px; }

.feed-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 10.5px;
  color: var(--ink-dim);
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.feed-line b { font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }

.feed-warn {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(231, 192, 122, 0.28);
  border-radius: 7px;
  background: rgba(231, 192, 122, 0.08);
  font-size: 10.5px;
  line-height: 1.65;
  color: #e7c07a;
}

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 9.5px;
  color: var(--ink-faint);
}

/* ---------- footer ---------- */
.foot {
  position: absolute;
  left: 22px;
  bottom: calc(28px + var(--safe-b));
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  color: rgba(240, 242, 248, 0.94);
  background: rgba(8, 10, 14, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 5px 11px;
  border-radius: 100px;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.foot-dot { opacity: 0.5; }

/* ---------- loading / fallback ---------- */
.loading {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  background: radial-gradient(90% 70% at 50% 45%, #0b1018 0%, #05070b 70%);
  transition: opacity 0.9s ease, visibility 0.9s ease;
}
.loading.done { opacity: 0; visibility: hidden; }

.loading-inner { text-align: center; width: min(320px, 78vw); }
.loading-title {
  margin: 10px 0 6px;
  font-size: 26px;
  font-weight: 450;
  letter-spacing: 0.16em;
}
.loading-sub { margin: 0; font-size: 11px; color: var(--ink-faint); letter-spacing: 0.08em; }

.bar {
  margin: 22px auto 12px;
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(167, 139, 250, 0.2), var(--accent));
  transition: width 0.4s ease;
}
.loading-note { margin: 0; font-size: 9.5px; letter-spacing: 0.14em; color: rgba(238, 240, 246, 0.28); }

.fallback {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: #05070b;
  padding: 24px;
  text-align: center;
}
.fallback[hidden] { display: none; }
.fallback h2 { margin: 12px 0 10px; font-size: 18px; font-weight: 500; }
.fallback p { margin: 0 auto 18px; max-width: 380px; font-size: 12px; line-height: 1.8; color: var(--ink-dim); }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .topbar { padding: calc(14px + env(safe-area-inset-top, 0px)) 14px 0; }
  .mark-text small { display: none; }
  .readout { min-width: 0; padding: 8px 10px; }
  .readout-main strong { font-size: 16px; }
  .readout-src { display: none; }

  #scene { left: 0; width: 100%; }
  .dock { left: 8px; width: 58px; bottom: auto; max-height: calc(100dvh - 110px); }
  .dock-row { gap: 0; padding: 4px; border-radius: 13px; }
  .dock .seg-btn, .dock .icon-btn { padding: 5px 2px; gap: 3px; flex-direction: column; min-height: 46px; }
  .seg-btn span, .dock .icon-label { font-size: 10px; display: block; }
  .icon-btn { min-width: 38px; padding: 0 8px; min-height: 38px; }
  .dock .icon-label { display: block; }
  .split { margin: 3px 0; height: 1px; }
  .hint { left: calc(50% + 30px); bottom: calc(22px + var(--safe-b)); white-space: nowrap; font-size: 10px; }
  .foot { display: none; }

  .panel {
    left: 8px;
    right: 8px;
    bottom: calc(68px + var(--safe-b));
    width: auto;
    max-height: min(72vh, 560px);
    padding: 14px;
  }
}

@media (max-width: 380px) {
  .dock .seg-btn span { display: block; }
  .dock .seg-btn { padding: 5px 2px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 录制模式：只留画面 */
body.capture .dock,
body.capture .topbar,
body.capture .foot,
body.capture .hint,
body.capture .vignette,
body.capture .panel,
body.capture .loading,
body.capture .fallback { display: none !important; }
body.capture #scene { cursor: default; }


/* 城市固定为上海，不提供选择器 */
#city-btn, #city-panel { display: none !important; }

body.capture #scene { left: 0; width: 100%; }
