/* ───────────────────────────── 基础 ───────────────────────────── */
:root {
  --bg: #05070c;
  --fg: #eef3fa;
  --muted: rgba(238, 243, 250, .58);
  --dim: rgba(238, 243, 250, .38);
  --line: rgba(255, 255, 255, .11);
  --glass: rgba(12, 17, 25, .72);
  --glass-2: rgba(12, 17, 25, .9);
  --accent: #4ea1ff;
  --accent-soft: rgba(78, 161, 255, .14);
  --warm: #ffcf8a;
  --r: 12px;
  --shadow: 0 14px 40px rgba(0, 0, 0, .42), 0 2px 8px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; }
ul, dl, dd, dt, h3, p { margin: 0; }

#map { position: fixed; inset: 0; }
.maplibregl-canvas:focus-visible { outline: none; }

/* 画面压角，让四角文字始终读得清 */
.vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(120% 90% at 50% 45%, transparent 42%, rgba(2, 4, 9, .5) 100%);
}
.scrim { position: fixed; left: 0; right: 0; height: 148px; pointer-events: none; z-index: 1; }
.scrim-top { top: 0; background: linear-gradient(rgba(3, 6, 12, .66), transparent); }
.scrim-bottom { bottom: 0; background: linear-gradient(transparent, rgba(3, 6, 12, .72)); }

#ui { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
#ui > * { pointer-events: auto; }

/* ───────────────────────────── 通用玻璃 ───────────────────────────── */
.brand, .search, .rail > .rb, .panel, .hud, .compass, .zoom, .rb2, .chip, .toast, .sug {
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(20px) saturate(1.25);
  backdrop-filter: blur(20px) saturate(1.25);
}

/* ───────────────────────────── 顶栏 ───────────────────────────── */
.topbar {
  position: absolute; top: 16px; left: 16px;
  display: flex; align-items: center; gap: 10px;
  max-width: calc(100vw - 32px);
}

.brand {
  height: 44px; padding: 0 15px 0 12px; border-radius: var(--r);
  display: flex; align-items: center; gap: 8px;
  color: var(--fg); text-decoration: none;
  font-size: 14.5px; font-weight: 600; letter-spacing: .06em;
  transition: border-color .2s, background .2s;
}
.brand svg { width: 19px; height: 19px; color: var(--accent); }
.brand:hover { border-color: rgba(78, 161, 255, .5); }

.search {
  position: relative;
  height: 44px; width: min(380px, 42vw);
  border-radius: var(--r);
  display: flex; align-items: center;
  padding: 0 6px 0 12px;
  transition: border-color .2s, box-shadow .2s, width .25s;
}
.search:focus-within {
  border-color: rgba(78, 161, 255, .55);
  box-shadow: var(--shadow), 0 0 0 3px rgba(78, 161, 255, .13);
}
.search .ic { width: 17px; height: 17px; color: var(--dim); flex: none; }
.search input {
  flex: 1; min-width: 0; height: 100%;
  background: none; border: 0; outline: none;
  color: var(--fg); font-size: 14px; padding: 0 8px;
}
.search input::placeholder { color: var(--dim); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search #go {
  width: 32px; height: 32px; flex: none; border-radius: 9px;
  display: grid; place-items: center; color: var(--muted);
  transition: background .15s, color .15s;
}
.search #go svg { width: 17px; height: 17px; }
.search #go:hover { background: rgba(255, 255, 255, .08); color: var(--fg); }
.search.busy #go { color: var(--accent); }
.search.busy #go svg { animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.sug {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--glass-2); border-radius: 14px; padding: 6px;
  list-style: none; max-height: 46vh; overflow: auto;
  z-index: 20;
}
.sug[hidden] { display: none; }
.sug li {
  padding: 8px 10px; border-radius: 9px; cursor: pointer;
  display: grid; gap: 2px;
  transition: background .12s;
}
.sug li:hover, .sug li.on { background: rgba(255, 255, 255, .07); }
.sug b { font-size: 13.5px; font-weight: 500; }
.sug span { font-size: 11.5px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───────────────────────────── 左侧工具栏 ───────────────────────────── */
.rail {
  position: absolute; left: 16px; top: 76px;
  display: flex; flex-direction: column; gap: 8px;
}
.rail > .rb, .rb2 {
  width: 42px; height: 42px; border-radius: 11px;
  display: grid; place-items: center; color: var(--muted);
  transition: color .16s, border-color .16s, background .16s;
}
.rail > .rb svg, .rb2 svg { width: 20px; height: 20px; }
.rail > .rb:hover, .rb2:hover { color: var(--fg); border-color: rgba(255, 255, 255, .2); }
.rail > .rb.on {
  color: #fff; background: linear-gradient(180deg, rgba(78, 161, 255, .3), rgba(78, 161, 255, .14));
  border-color: rgba(78, 161, 255, .6);
}

/* ───────────────────────────── 面板 ───────────────────────────── */
.panel {
  position: absolute; left: 68px; top: 76px;
  width: 282px; max-height: calc(100vh - 172px);
  border-radius: 15px; padding: 6px 14px 14px;
  overflow: auto; overscroll-behavior: contain;
  transform-origin: left top;
  transition: opacity .18s, transform .2s;
}
.panel[aria-hidden="true"] {
  opacity: 0; transform: translateX(-10px) scale(.985);
  pointer-events: none;
}
.panel::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: 8px; }

.view { display: none; padding-top: 8px; }
.view.on { display: block; animation: viewIn .22s ease both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(4px); } }

.panel h3 {
  font-size: 10.5px; font-weight: 500; letter-spacing: .16em;
  color: var(--dim); text-transform: uppercase;
  margin: 12px 0 8px; display: flex; justify-content: space-between; align-items: center;
}
.panel h3:first-child { margin-top: 4px; }
.panel h3 b { color: var(--muted); font-weight: 500; letter-spacing: 0; font-size: 11px; }

/* 底图选择 */
.bases { display: grid; gap: 4px; margin-bottom: 4px; }
.base {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px; border-radius: 10px; text-align: left;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s;
}
.base:hover { background: rgba(255, 255, 255, .05); }
.base.on { background: var(--accent-soft); border-color: rgba(78, 161, 255, .5); }
.base .sw {
  width: 40px; height: 30px; flex: none; border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, .16);
  background-size: cover;
}
.sw-g { background-image: linear-gradient(150deg, #1f4d3a 0%, #6b8f4e 38%, #2f6f8f 62%, #d9c9a8 100%); }
.sw-e { background-image: linear-gradient(150deg, #3d5942 0%, #8d8a5f 45%, #4a6d7c 75%, #cfc3a5 100%); }
.sw-c { background-image: linear-gradient(150deg, #f3efe4 0%, #e2dccd 45%, #a8c8e0 72%, #f7f4ec 100%); }
.base span { display: grid; gap: 1px; min-width: 0; }
.base b { font-size: 13px; font-weight: 500; }
.base em { font-style: normal; font-size: 11px; color: var(--dim); }

/* 开关 */
.sw-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 2px; font-size: 13px; cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, .055);
}
.sw-row:last-of-type { border-bottom: 0; }
.sw-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tg {
  width: 34px; height: 20px; border-radius: 999px; flex: none;
  background: rgba(255, 255, 255, .15); position: relative;
  transition: background .2s;
}
.tg::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
  transition: transform .2s cubic-bezier(.3, 1.4, .5, 1);
}
.sw-row input:checked + .tg { background: var(--accent); }
.sw-row input:checked + .tg::after { transform: translateX(14px); }
.sw-row input:focus-visible + .tg { outline: 2px solid var(--accent); outline-offset: 3px; }

/* 地形夸张 */
.exa { margin-top: 12px; transition: opacity .2s; }
.exa.off { opacity: .35; pointer-events: none; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px; background: none; margin: 2px 0 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--p, 35%), rgba(255, 255, 255, .16) var(--p, 35%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent); margin-top: -5.5px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
}

/* 景点列表 */
.places { display: grid; gap: 1px; margin: -2px -6px; }
.place {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border-radius: 8px; text-align: left;
  transition: background .14s, color .14s;
}
.place:hover { background: rgba(255, 255, 255, .07); }
.place b { font-size: 13px; font-weight: 400; }
.place i {
  font-style: normal; font-size: 10.5px; color: var(--dim);
  font-variant-numeric: tabular-nums; flex: none;
}

/* 说明 */
.keys { display: grid; grid-template-columns: auto 1fr; gap: 7px 12px; font-size: 12px; }
.keys dt { color: var(--muted); }
.keys dd { color: var(--dim); }
kbd {
  font: inherit; font-size: 11px; padding: 1px 5px; border-radius: 4px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .07);
}
.note { font-size: 11.5px; line-height: 1.8; color: var(--dim); margin-top: 6px; }

/* ───────────────────────────── 左下读数 ───────────────────────────── */
.hud {
  position: absolute; left: 16px; bottom: 16px;
  height: 34px; padding: 0 13px; border-radius: 10px;
  display: flex; align-items: center; gap: 10px;
  font-size: 11.5px; color: rgba(255, 255, 255, .82);
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
  white-space: nowrap;
}
.hud i { width: 1px; height: 11px; background: rgba(255, 255, 255, .16); }
#h-z { color: var(--dim); }

/* ───────────────────────────── 右下控制 ───────────────────────────── */
.ctrl {
  position: absolute; right: 16px; bottom: 34px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.compass {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; position: relative; overflow: hidden;
  transition: border-color .2s;
}
.compass:hover { border-color: rgba(255, 255, 255, .24); }
.compass svg {
  width: 38px; height: 38px;
  transform: rotate(var(--rot, 0deg));
  transition: transform .08s linear;
}
.compass b {
  position: absolute; bottom: 3px; font-size: 7.5px; font-weight: 600;
  letter-spacing: .14em; color: rgba(255, 255, 255, .6);
  background: rgba(5, 8, 14, .6); padding: 0 3px; border-radius: 3px;
}
.zoom {
  width: 42px; border-radius: 11px; overflow: hidden;
  display: grid;
}
.zoom button {
  height: 38px; display: grid; place-items: center; color: var(--muted);
  transition: background .14s, color .14s;
}
.zoom button:first-child { border-bottom: 1px solid rgba(255, 255, 255, .09); }
.zoom button:hover { background: rgba(255, 255, 255, .08); color: var(--fg); }
.zoom svg { width: 16px; height: 16px; }

/* ───────────────────────────── 底部推荐 ───────────────────────────── */
.chips {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%);
  display: flex; gap: 7px; flex-wrap: wrap; justify-content: center;
  max-width: min(720px, 62vw);
  transition: opacity .4s, transform .4s;
}
.chips.gone { opacity: 0; transform: translateX(-50%) translateY(10px); pointer-events: none; }
.chip {
  padding: 7px 13px; border-radius: 999px; font-size: 12px;
  color: rgba(255, 255, 255, .8); white-space: nowrap;
  transition: border-color .16s, color .16s, background .16s;
}
.chip:hover {
  color: #fff; border-color: rgba(78, 161, 255, .6);
  background: rgba(78, 161, 255, .18);
}

.hint {
  position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%);
  font-size: 11.5px; color: rgba(255, 255, 255, .55);
  letter-spacing: .06em; text-shadow: 0 1px 8px rgba(0, 0, 0, .8);
  transition: opacity .8s; white-space: nowrap;
}
.hint.gone { opacity: 0; }

/* ───────────────────────────── 提示条 ───────────────────────────── */
.toast {
  position: absolute; left: 50%; bottom: 92px; transform: translate(-50%, 10px);
  padding: 9px 16px; border-radius: 10px; font-size: 12.5px;
  background: rgba(8, 12, 20, .92); color: var(--fg);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: 78vw; text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ───────────────────────────── 标记点 ───────────────────────────── */
.pin { position: relative; }
.pin i {
  display: block; width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .92), 0 0 24px rgba(78, 161, 255, .9);
  position: relative;
}
.pin i::after {
  content: ""; position: absolute; inset: -13px; border-radius: 50%;
  border: 1px solid rgba(78, 161, 255, .55);
  animation: pulse 2.6s ease-out infinite;
}
@keyframes pulse {
  0% { transform: scale(.45); opacity: .9; }
  100% { transform: scale(1.5); opacity: 0; }
}
.pin span {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%);
  white-space: nowrap; font-size: 12px; padding: 4px 10px; border-radius: 7px;
  background: rgba(8, 12, 20, .84); border: 1px solid rgba(255, 255, 255, .15);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .5);
}

/* 版权信息收进右下，别挡着控制键 */
.maplibregl-ctrl-bottom-right { right: 14px; bottom: 4px; }
.maplibregl-ctrl-attrib {
  background: rgba(8, 12, 20, .6) !important; border-radius: 8px !important;
  font-size: 10.5px !important; padding: 2px 8px !important;
}
.maplibregl-ctrl-attrib, .maplibregl-ctrl-attrib a { color: rgba(255, 255, 255, .5) !important; }
.maplibregl-ctrl-attrib-button { filter: invert(1) opacity(.5); }

/* ───────────────────────────── 开场 ───────────────────────────── */
#boot {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-content: center; justify-items: center; gap: 22px;
  background: radial-gradient(60% 60% at 50% 45%, #0b1220 0%, #05070c 100%);
  transition: opacity .7s ease, visibility .7s;
}
#boot.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-orb { width: 62px; height: 62px; position: relative; }
.boot-orb i {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(78, 161, 255, .22);
  border-top-color: var(--accent);
  animation: spin 1.5s cubic-bezier(.6, .1, .4, .9) infinite;
}
.boot-orb i:nth-child(2) {
  inset: 9px; border-top-color: transparent;
  border-left-color: rgba(255, 255, 255, .55);
  animation-duration: 2.4s; animation-direction: reverse;
}
#boot p { font-size: 11.5px; letter-spacing: .22em; color: var(--dim); }
.dots i { animation: blink 1.4s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; }
.dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 100% { opacity: .15; } 50% { opacity: 1; } }

/* ───────────────────────────── 窄屏 ───────────────────────────── */
@media (max-width: 760px) {
  .topbar { top: 10px; left: 10px; right: 10px; }
  .brand { height: 40px; padding: 0 11px; }
  .brand span { display: none; }
  .search { height: 40px; width: auto; flex: 1; }
  .rail { left: 10px; top: 60px; gap: 6px; }
  .rail > .rb { width: 38px; height: 38px; border-radius: 10px; }
  .rail > .rb svg { width: 18px; height: 18px; }
  .panel {
    left: 10px; right: 10px; top: 60px; width: auto;
    max-height: 66vh; border-radius: 16px;
  }
  .hud { left: 10px; bottom: 10px; height: 30px; font-size: 10.5px; padding: 0 10px; gap: 8px; }
  .hud #h-z, .hud #h-alt { display: none; }
  .hud i { display: none; }
  .ctrl { right: 10px; bottom: 46px; gap: 6px; }
  .compass { width: 40px; height: 40px; }
  .compass svg { width: 32px; height: 32px; }
  .compass b { display: none; }
  .zoom { width: 40px; }
  .zoom button { height: 34px; }
  .rb2 { width: 40px; height: 40px; }
  .rb2 svg { width: 18px; height: 18px; }
  .chips, .hint { display: none; }
  .toast { bottom: 76px; }
  .maplibregl-ctrl-bottom-right {
    right: auto; left: 10px; bottom: 44px; max-width: 66vw;
  }
  .maplibregl-ctrl-attrib { font-size: 9.5px !important; padding: 1px 6px !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::after, *::before { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
