/* 风云地球 — 前端样式(简洁大气 · 深色玻璃 · 全端自适应) */

:root {
  --bg: #07090d;
  --panel: rgba(13, 17, 24, 0.78);
  --panel-solid: #10141c;
  --panel-soft: rgba(255, 255, 255, 0.045);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e7edf5;
  --text-dim: #93a0b1;
  --text-faint: #6b7686;
  --accent: #45c4ff;
  --accent2: #35d0ba;
  --danger: #ff5d5d;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --bar-h: 46px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid rgba(69, 196, 255, 0.6); outline-offset: 1px;
}
html, body { height: 100%; overflow: hidden; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased; }

#map { position: absolute; inset: 0; background: #06080c; }
#overlay-root { position: absolute; inset: 0; pointer-events: none; z-index: 450; }
#overlay-root canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#overlay-root canvas#landfill-canvas { z-index: 0; }  /* 深色底图陆地填充:气象层之下 */
#overlay-root canvas#scalar-canvas { z-index: 1; }
#overlay-root canvas#oceanmask-canvas { z-index: 1; }  /* 与 scalar 同层:DOM 顺序在后 → 填色之上、粒子之下 */
#overlay-root canvas#particle-canvas { z-index: 2; }
#overlay-root canvas#isobar-canvas { z-index: 3; }
#overlay-root canvas#vecbase-canvas { z-index: 4; }  /* 矢量线划底图:气象层之上,空白透明 */

.leaflet-container { background: #06080c; font-family: var(--font); }
/* ---------- 顶栏 ---------- */
#topbar {
  position: fixed; top: 14px; left: 14px; z-index: 1000;
  display: flex; align-items: center; gap: 8px;
}
#brand {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0 14px 0 12px; height: var(--bar-h); box-shadow: var(--shadow);
}
#brand b { font-size: 15px; letter-spacing: 0.02em; display: block; }
#brand span { font-size: 9px; color: var(--text-faint); letter-spacing: 2.4px; display: block; margin-top: 1px; }

#searchbox {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0 13px; width: clamp(150px, 18vw, 260px); min-width: 0; height: var(--bar-h); box-shadow: var(--shadow);
  color: var(--text-dim); transition: border-color 0.15s;
}
#searchbox:focus-within { border-color: rgba(69, 196, 255, 0.55); }
#search-input {
  flex: 1; min-width: 0; background: none; border: none; outline: none;
  color: var(--text); font-size: 13.5px; font-family: var(--font); height: 100%;
}
#search-input::placeholder { color: var(--text-faint); }
#search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--panel-solid); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: 320px; overflow-y: auto; z-index: 1200;
}
#search-results .sr-item { padding: 9px 13px; cursor: pointer; }
#search-results .sr-item:hover, #search-results .sr-item.sel { background: rgba(69, 196, 255, 0.1); }
#search-results .sr-name { font-size: 13.5px; }
#search-results .sr-sub { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
#search-results .sr-empty { padding: 10px 13px; color: var(--text-dim); font-size: 12.5px; }
#search-results .sr-cap {
  padding: 6px 13px 4px; font-size: 10px; color: var(--text-faint);
  letter-spacing: 0.08em; border-bottom: 1px solid var(--border);
}
#search-results .sr-item:hover { background: rgba(69, 196, 255, 0.1); }

#loc-btn {
  display: flex; align-items: center; justify-content: center;
  width: var(--bar-h); height: var(--bar-h);
  background: var(--panel); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-dim); cursor: pointer; box-shadow: var(--shadow);
  transition: all 0.15s;
}
#loc-btn:hover { color: var(--accent); border-color: rgba(69, 196, 255, 0.4); }
#share-btn, #fs-btn, #about-btn, #units-btn, #legend-btn {
  background: none; border: none; color: var(--text-dim); font-size: 16px; line-height: 1;
  border-radius: 8px; width: 30px; height: 30px; cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
#share-btn:hover, #fs-btn:hover, #about-btn:hover, #units-btn:hover, #legend-btn:hover { color: var(--text); background: var(--panel-soft); }

/* ---------- 设置(右上) ---------- */
#settings {
  position: fixed; top: 14px; right: 14px; z-index: 1000;
  display: flex; align-items: center; gap: 6px;
  background: var(--panel); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0 8px 0 12px; height: var(--bar-h); box-shadow: var(--shadow);
}
#settings .ctl { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }
#settings select {
  background: var(--panel-soft); color: var(--text); border: 1px solid transparent;
  border-radius: 7px; padding: 4.5px 4px; font-size: 12.5px; font-family: var(--font);
  outline: none; cursor: pointer; max-width: clamp(96px, 10vw, 128px); transition: border-color 0.15s;
}
#settings select:hover { border-color: var(--border-strong); }
#settings select:focus { border-color: rgba(69, 196, 255, 0.5); }
#settings-toggle { display: none; }

/* ---------- 图层栏(左) ---------- */
#layerbar {
  position: fixed; left: 14px; top: 76px; z-index: 1000;
  width: 116px; max-height: calc(100vh - 184px); overflow-y: auto;
  background: var(--panel); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 7px; box-shadow: var(--shadow);
}
#layerbar .sep { height: 1px; background: var(--border); margin: 6px 4px; }
.particle-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: none; color: var(--text); cursor: pointer;
  padding: 7px 9px; border-radius: var(--radius-sm); font-size: 12.5px; font-family: var(--font);
  white-space: nowrap;
}
.particle-toggle .dot {
  margin-left: auto; width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-faint); transition: all 0.2s; flex: none;
}
.particle-toggle.active .dot { background: var(--accent2); box-shadow: 0 0 8px var(--accent2); }
.particle-toggle:hover, .layer-btn:hover { background: var(--panel-soft); }

#layer-buttons { display: block; }
/* 图层分组(手风琴) */
.lgroup { margin: 1px 0; }
.lgroup-head {
  display: flex; align-items: center; gap: 5px; width: 100%;
  background: none; border: none; cursor: pointer; font-family: var(--font);
  color: var(--text-faint); font-size: 10.5px; letter-spacing: 0.06em;
  padding: 6px 6px 5px; border-radius: var(--radius-sm); transition: color 0.15s;
}
.lgroup-head:hover { color: var(--text-dim); background: var(--panel-soft); }
.lgroup-head i {
  font-style: normal; font-size: 9px; color: var(--text-faint);
  background: var(--panel-soft); border-radius: 8px; padding: 1px 5px;
}
.lgroup-head .chev {
  margin-left: auto; font-style: normal; font-size: 12px; line-height: 1;
  transform: rotate(90deg); transition: transform 0.18s; color: var(--text-faint);
}
.lgroup.open .lgroup-head .chev { transform: rotate(270deg); }
.lgroup-head .adot {
  width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: var(--accent); box-shadow: 0 0 6px var(--accent); display: none;
}
.lgroup.has-active .lgroup-head .adot { display: block; }
.lgroup.has-active .lgroup-head { color: var(--text-dim); }
.lgroup-body { display: none; grid-template-columns: 1fr 1fr; gap: 3px; padding: 2px 0 4px; }
.lgroup.open .lgroup-body { display: grid; }
#levelbar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.level-chip {
  background: var(--panel-soft); border: 1px solid transparent; color: var(--text-dim);
  border-radius: 7px; padding: 5px 0; font-size: 11px; cursor: pointer; font-family: var(--font);
  transition: all 0.15s;
}
.level-chip:hover { color: var(--text); }
.level-chip.active {
  background: rgba(69, 196, 255, 0.16); color: var(--accent);
  border-color: rgba(69, 196, 255, 0.45); font-weight: 600;
}
.layer-btn.dim { opacity: 0.32; }
.layer-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: none; border: none; color: var(--text); cursor: pointer;
  padding: 9px 2px 8px; border-radius: var(--radius-sm); font-family: var(--font);
  transition: background 0.15s; white-space: nowrap;
}
.layer-btn span { font-size: 11px; color: var(--text-dim); transition: color 0.15s; }
.layer-btn svg { opacity: 0.75; }
.layer-btn small { display: none; }
.layer-btn.active {
  background: linear-gradient(150deg, rgba(69, 196, 255, 0.2), rgba(53, 208, 186, 0.1));
  box-shadow: inset 0 0 0 1px rgba(69, 196, 255, 0.35);
}
.layer-btn.active span { color: var(--text); }
.layer-btn.active svg { opacity: 1; }

/* ---------- 时间轴(底) ---------- */
#timelinebar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 16px; z-index: 1000;
  width: min(820px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; box-shadow: var(--shadow);
}
#play-btn {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; color: #04222e; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: filter 0.15s;
}
#play-btn:hover { filter: brightness(1.12); }
#time-display { flex: none; width: 122px; line-height: 1.3; }
#time-main { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; display: block; }
#time-sub { font-size: 10.5px; color: var(--text-faint); }
#timeline { flex: 1; height: 46px; position: relative; cursor: pointer; touch-action: none; }
#tl-track { position: absolute; inset: 0; }
#tl-track::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 4px;
  transform: translateY(-50%); border-radius: 2px; background: rgba(255, 255, 255, 0.12);
}
#tl-progress {
  position: absolute; left: 0; top: 50%; height: 4px; transform: translateY(-50%);
  border-radius: 2px; background: linear-gradient(90deg, var(--accent), var(--accent2)); width: 0;
}
#tl-ticks { position: absolute; inset: 0; pointer-events: none; }
#tl-ticks .tick { position: absolute; top: 50%; width: 1px; height: 6px; background: rgba(255, 255, 255, 0.22); transform: translateY(-50%); }
#tl-ticks .tick.major { height: 11px; background: rgba(255, 255, 255, 0.42); }
#tl-ticks .tick-label {
  position: absolute; top: 0; transform: translateX(-50%);
  font-size: 9.5px; color: var(--text-faint); white-space: nowrap; font-variant-numeric: tabular-nums;
}
#tl-now {
  position: absolute; top: 4px; bottom: 4px; width: 2px; margin-left: -1px;
  background: var(--danger); border-radius: 1px; display: none; pointer-events: none;
}
#tl-thumb {
  position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  background: #fff; border-radius: 50%; box-shadow: 0 0 0 3px rgba(69, 196, 255, 0.4), 0 1px 5px rgba(0, 0, 0, 0.5);
}
#tl-step { flex: none; display: flex; gap: 4px; }
#tl-step button {
  background: var(--panel-soft); border: 1px solid transparent; color: var(--text);
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 15px; font-family: var(--font);
  transition: all 0.15s;
}
#tl-step button#step-now { width: auto; padding: 0 10px; font-size: 11.5px; }
#tl-step button:hover { border-color: rgba(69, 196, 255, 0.5); color: var(--accent); }

/* ---------- 图例(钉在图层栏底部,内容超长滚动时也保持可见) ---------- */
#legend {
  cursor: pointer;
  position: sticky; bottom: 0; z-index: 1;
  margin: 2px 2px 0; padding: 9px 5px 3px;
  background: rgba(13, 17, 24, 0.92);
  border-top: 1px solid var(--border);
}
#legend-title { font-size: 10.5px; color: var(--text-dim); margin-bottom: 6px; }
#legend-bar { height: 8px; border-radius: 4px; }
#legend-labels {
  display: flex; justify-content: space-between; margin-top: 4px;
  font-size: 9.5px; color: var(--text-faint); font-variant-numeric: tabular-nums;
}

/* ---------- 不透明度滑块(图层栏底部) ---------- */
#opacity-ctl { display: flex; align-items: center; gap: 7px; padding: 3px 5px 4px; }
#opacity-ctl span { font-size: 10.5px; color: var(--text-faint); flex: none; }
#opacity-ctl b { font-size: 10.5px; color: var(--text-dim); width: 30px; text-align: right; flex: none; font-variant-numeric: tabular-nums; font-weight: 400; }
#opacity-slider {
  flex: 1; min-width: 0; appearance: none; -webkit-appearance: none;
  height: 3px; border-radius: 2px; background: rgba(255, 255, 255, 0.18); outline: none; cursor: pointer;
}
#opacity-slider::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px rgba(69, 196, 255, 0.22);
}
#opacity-slider::-moz-range-thumb { width: 12px; height: 12px; border: none; border-radius: 50%; background: var(--accent); }

/* ---------- 光标取值器(Windy 式悬停读数) ---------- */
#cursor-tip {
  position: fixed; top: 0; left: 0; z-index: 1250;
  background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-strong); border-radius: 9px;
  padding: 6px 10px 7px; pointer-events: none; box-shadow: var(--shadow);
  min-width: 92px; will-change: transform;
}
#ct-val {
  display: flex; align-items: center; gap: 6px;
  font-size: 14.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
}
#ct-sub { display: block; font-size: 10px; color: var(--text-faint); margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ct-arrow { display: inline-block; font-style: normal; color: var(--accent); font-size: 12px; text-shadow: 0 0 6px rgba(69, 196, 255, 0.6); }

/* 填色层切换淡入 */
#scalar-canvas { transition: opacity 0.28s ease; }

/* ---------- 预报面板 ---------- */
#panel {
  position: fixed; top: 74px; right: 14px; bottom: 88px; z-index: 1100;
  width: 348px; display: flex; flex-direction: column;
  background: var(--panel); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  animation: slidein 0.22s ease;
}
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
#panel-head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 13px 15px; border-bottom: 1px solid var(--border);
}
#panel-title { font-size: 15px; font-weight: 600; }
#panel-coords { display: block; font-size: 11px; color: var(--text-faint); margin-top: 2px; font-variant-numeric: tabular-nums; }
#panel-close, #panel-fav {
  background: none; border: none; color: var(--text-faint); font-size: 15px; cursor: pointer;
  padding: 4px 7px; border-radius: 7px; transition: all 0.15s;
}
#panel-close:hover, #panel-fav:hover { color: var(--text); background: var(--panel-soft); }
#panel-fav { font-size: 16px; color: var(--text-dim); }
#panel-body { flex: 1; overflow-y: auto; padding: 14px 15px; }
#panel-body::-webkit-scrollbar, #layerbar::-webkit-scrollbar, #search-results::-webkit-scrollbar { width: 5px; }
#panel-body::-webkit-scrollbar-thumb, #layerbar::-webkit-scrollbar-thumb, #search-results::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 3px; }

.spinner {
  width: 26px; height: 26px; margin: 26px auto; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pcur { display: flex; align-items: center; gap: 13px; margin-bottom: 14px; }
.pcur-icon { font-size: 44px; line-height: 1; }
.pcur-temp { font-size: 38px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1; }
.pcur-temp sup { font-size: 16px; font-weight: 400; }
.pcur-desc { font-size: 13px; color: var(--text-dim); margin-top: 5px; }
.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; }
.pstat { background: var(--panel-soft); border-radius: var(--radius-sm); padding: 8px 10px; }
.pstat b { display: block; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pstat span { font-size: 10.5px; color: var(--text-faint); }
.ptabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.ptabs button {
  background: var(--panel-soft); border: 1px solid transparent;
  color: var(--text-dim); border-radius: 8px; padding: 6px 2px; font-size: 12px; cursor: pointer; font-family: var(--font);
  transition: all 0.15s; white-space: nowrap; text-align: center;
}
.ptabs button.active { color: var(--text); border-color: rgba(69, 196, 255, 0.45); background: rgba(69, 196, 255, 0.1); }
.pchart-wrap { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 6px; }
.pchart-wrap canvas { display: block; width: 100%; height: auto; }
.pchart-legend {
  display: flex; gap: 14px; padding: 7px 11px;
  border-top: 1px solid var(--border);
  font-size: 10px; color: var(--text-dim);
}
.pchart-legend i {
  display: inline-block; width: 12px; height: 3px; border-radius: 2px;
  margin-right: 5px; vertical-align: 2px;
}
.psun { font-size: 11px; color: var(--text-faint); text-align: center; margin-top: 4px; }
.pdays { display: flex; flex-direction: column; gap: 4px; }
.pday {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel-soft); border-radius: var(--radius-sm); padding: 7px 10px;
}
.pday .d-name { width: 42px; font-size: 12.5px; }
.pday .d-icon { width: 26px; text-align: center; font-size: 17px; }
.pday .d-range { flex: 1; height: 5px; border-radius: 3px; position: relative; background: rgba(255,255,255,0.08); }
.pday .d-range i {
  position: absolute; top: 0; bottom: 0; border-radius: 3px;
  background: linear-gradient(90deg, #4aa8ff, #ffd257, #ff7a45);
}
.pday .d-tmin, .pday .d-tmax { font-size: 12px; width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.pday .d-tmin { color: var(--text-faint); }
.pday .d-pp { width: 40px; font-size: 10.5px; color: #6db8ff; text-align: right; }

/* ---------- 弹窗 / 提示 ---------- */
dialog#about {
  background: var(--panel-solid); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  width: min(620px, calc(100vw - 40px)); padding: 0; margin: auto;
}
dialog#about::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(3px); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.dlg-head b { font-size: 14.5px; }
.dlg-head button { background: none; border: none; color: var(--text-faint); font-size: 15px; cursor: pointer; padding: 4px 6px; border-radius: 7px; }
.dlg-head button:hover { color: var(--text); background: var(--panel-soft); }
.dlg-body { padding: 15px 18px; max-height: 65vh; overflow-y: auto; }
.dlg-body table { width: 100%; border-collapse: collapse; }
.dlg-body th {
  text-align: left; vertical-align: top; padding: 7px 10px 7px 0; white-space: nowrap;
  color: var(--accent); font-size: 12.5px; font-weight: 600;
}
.dlg-body td { padding: 7px 0; font-size: 12.5px; line-height: 1.7; color: var(--text); }
.dlg-body a { color: var(--accent); text-decoration: none; }
.dlg-body a:hover { text-decoration: underline; }
.dlg-body p { margin-top: 12px; font-size: 11.5px; color: var(--text-faint); line-height: 1.7; }

#toast {
  position: fixed; top: 72px; left: 50%; transform: translateX(-50%); z-index: 1300;
  background: rgba(43, 20, 22, 0.92); color: #ffb4b4; border: 1px solid rgba(255, 93, 93, 0.35);
  border-radius: 10px; padding: 9px 16px; font-size: 13px; box-shadow: var(--shadow);
  max-width: min(70vw, 560px); text-align: center;
}
#grid-loading {
  position: fixed; top: 72px; left: 50%; transform: translateX(-50%); z-index: 1200;
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 15px;
  font-size: 12.5px; color: var(--text-dim); box-shadow: var(--shadow);
}
#grid-loading .spinner { width: 15px; height: 15px; margin: 0; border-width: 2px; }

#attrib {
  position: fixed; right: 12px; bottom: 4px; z-index: 900;
  font-size: 10px; color: rgba(255, 255, 255, 0.34);
}
#attrib a { color: rgba(255, 255, 255, 0.45); text-decoration: none; }
#attrib a:hover { color: var(--text-dim); }

.marker-pin {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2.5px solid #fff;
  box-shadow: 0 0 0 4px rgba(69, 196, 255, 0.3), 0 2px 8px rgba(0,0,0,.5);
}

/* ---------- 自适应 ---------- */
/* ≤1000:设置收进右下角齿轮抽屉(避免顶栏与设置栏在窄窗口相撞) */
@media (max-width: 1000px) {
  #settings {
    top: auto; right: 10px; bottom: 74px;
    flex-flow: row wrap; align-items: center; gap: 8px;
    height: auto; padding: 12px; width: 218px;
    border-radius: 14px;
    opacity: 0; pointer-events: none; transform: translateY(8px) scale(0.98);
    transition: opacity 0.18s ease, transform 0.18s ease;
  }
  #settings.open { opacity: 1; pointer-events: auto; transform: none; }
  #settings .ctl { flex: 1 1 100%; justify-content: space-between; }
  #settings > button { flex: none; }
  #settings select { flex: 1; max-width: 130px; }
  #settings-toggle {
    display: flex; align-items: center; justify-content: center;
    position: fixed; right: 10px; bottom: 16px; z-index: 1001;
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--panel); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border); color: var(--text); font-size: 18px;
    box-shadow: var(--shadow); cursor: pointer;
  }
  #settings-toggle.active { border-color: rgba(69, 196, 255, 0.5); color: var(--accent); }
  /* 居中时间轴收窄,给右下角齿轮留位 */
  #timelinebar { width: min(720px, calc(100vw - 148px)); }
}

@media (max-width: 820px) {
  #brand { padding: 0 11px; }
  #brand div { display: none; }             /* 只留 logo */
  #searchbox { width: min(300px, calc(100vw - 172px)); }

  /* 图层栏:横向条 */
  #layerbar {
    top: auto; bottom: 74px; left: 10px; right: 64px; width: auto;
    display: flex; align-items: center; gap: 2px; padding: 5px 7px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #layerbar::-webkit-scrollbar { display: none; }
  #layerbar .sep { width: 1px; height: 26px; margin: 0 4px; flex: none; }
  /* 图层分组:横向 chip,点开内联展开该组图层 */
  #layer-buttons { display: flex; gap: 2px; align-items: center; }
  .lgroup { display: flex; align-items: center; flex: none; gap: 2px; }
  .lgroup-head { width: auto; padding: 6px 9px; font-size: 11.5px; letter-spacing: 0; white-space: nowrap; }
  .lgroup-head i { display: none; }
  .lgroup-body { gap: 2px; padding: 0; }
  .lgroup.open .lgroup-body { display: flex; }
  .layer-btn { flex: none; }
  .particle-toggle { width: auto; padding: 7px 8px; flex: none; }
  .particle-toggle span { display: none; }
  .layer-btn { padding: 7px 8px; flex: none; }
  .layer-btn span { display: none; }
  #levelbar { display: none; }  /* 移动端气压层暂收起 */
  #opacity-ctl { display: none; }
  #cursor-tip { display: none; }  /* 触屏无悬停 */

  #timelinebar { width: calc(100vw - 148px); bottom: 14px; left: 10px; transform: none; gap: 8px; padding: 8px 10px; }
  #time-display { width: 96px; }
  #tl-step button#step-now { display: none; }

  #legend { display: none !important; }

  #panel {
    left: 10px; right: 10px; width: auto; top: auto; bottom: 130px; max-height: 44vh;
  }
  #topbar { left: 10px; top: 10px; }
  #attrib { display: none; }
}

@media (max-width: 480px) {
  /* 时间轴给右下角齿轮留位,不再全宽压住齿轮 */
  #timelinebar { width: calc(100vw - 76px); left: 10px; gap: 8px; padding: 8px 10px; }
  #time-display { width: 84px; }
  #time-main { font-size: 13px; }
  #tl-step { display: none; }               /* 移动端用长按/拖动代替步进 */
  #layerbar { bottom: 74px; right: 62px; }
}

/* ---------- 收藏地点(顶栏按钮 + 下拉) ---------- */
#fav-btn {
  display: flex; align-items: center; justify-content: center;
  width: var(--bar-h); height: var(--bar-h);
  background: var(--panel); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-dim); cursor: pointer; box-shadow: var(--shadow);
  transition: all 0.15s;
}
#fav-btn:hover { color: #ffd257; border-color: rgba(255, 210, 87, 0.4); }
#fav-list {
  position: fixed; top: 64px; right: 14px; z-index: 1300;
  width: 240px; max-height: min(420px, 60vh); overflow-y: auto;
  background: var(--panel); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  padding: 6px;
}
#fav-list .fav-empty { padding: 16px 10px; text-align: center; font-size: 12px; color: var(--text-dim); }
#fav-list .fav-empty span { font-size: 10.5px; color: var(--text-faint); }
.fav-item {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 8px; border-radius: 8px; cursor: pointer; transition: background 0.12s;
}
.fav-item:hover { background: var(--panel-soft); }
.fav-item .fav-main { flex: 1; min-width: 0; }
.fav-item .fav-main b { display: block; font-size: 12.5px; color: #ffd257; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav-item .fav-main span { font-size: 10.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.fav-item .fav-del {
  background: none; border: none; color: var(--text-faint); cursor: pointer;
  font-size: 12px; padding: 4px 6px; border-radius: 6px; transition: all 0.12s;
}
.fav-item .fav-del:hover { color: var(--danger, #ff6b5e); background: rgba(255, 107, 94, 0.1); }

/* ---------- 测距/测面积 ---------- */
#measure-btn { background: none; border: none; color: var(--text-dim); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
#measure-btn:hover, #measure-btn.active { color: var(--accent); background: var(--panel-soft); }
#measure-btn.active { border-color: rgba(69, 196, 255, 0.45); background: rgba(69, 196, 255, 0.1); }
#map.measuring { cursor: crosshair !important; }
#map.measuring .leaflet-interactive { cursor: crosshair !important; }
#measure-bar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 84px; z-index: 1150;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(69, 196, 255, 0.4); border-radius: 12px;
  padding: 8px 12px; box-shadow: var(--shadow); max-width: min(92vw, 560px);
}
#measure-info { font-size: 11.5px; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#measure-bar button {
  background: var(--panel-soft); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 7px; padding: 4px 10px; font-size: 11.5px; cursor: pointer; font-family: var(--font);
  white-space: nowrap; transition: all 0.15s;
}
#measure-bar button:hover { color: var(--accent); border-color: rgba(69, 196, 255, 0.5); }
.measure-tip {
  background: rgba(10, 18, 28, 0.92) !important; border: 1px solid var(--border) !important;
  color: var(--text) !important; font-size: 10px !important; border-radius: 6px !important;
  box-shadow: none !important; padding: 2px 6px !important;
}
.measure-tip i { font-style: normal; color: var(--text-dim); }
.measure-total {
  background: rgba(69, 196, 255, 0.16) !important; border: 1px solid rgba(69, 196, 255, 0.5) !important;
  color: #bfe8ff !important; font-size: 11px !important; font-weight: 600; border-radius: 7px !important;
  box-shadow: none !important; padding: 3px 8px !important; white-space: nowrap;
}

/* ---------- 机场 tab ---------- */
.ap-list { display: flex; flex-direction: column; gap: 6px; }
.ap-row { background: var(--panel-soft); border-radius: var(--radius-sm); padding: 9px 10px; }
.ap-head { display: flex; align-items: center; gap: 7px; }
.ap-head b { font-size: 13px; color: var(--accent); font-variant-numeric: tabular-nums; }
.ap-name { flex: 1; min-width: 0; font-size: 11.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-dist { font-size: 10.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.ap-chip {
  font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
  border: 1px solid; border-radius: 5px; padding: 1.5px 5px;
}
.ap-metar { font-size: 11.5px; color: var(--text); margin-top: 5px; line-height: 1.5; }
.ap-raw, .ap-taf {
  margin-top: 6px; background: rgba(0, 0, 0, 0.3); border-radius: 7px; padding: 7px 9px;
  font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; color: var(--text-dim);
  white-space: pre-wrap; word-break: break-all; line-height: 1.55;
}
.ap-taf pre { margin: 0; font: inherit; white-space: pre-wrap; word-break: break-all; }
.ap-links { display: flex; gap: 6px; margin-top: 6px; }
.ap-links .ap-x {
  background: none; border: 1px solid var(--border); color: var(--text-faint);
  border-radius: 6px; padding: 2px 8px; font-size: 10.5px; cursor: pointer; font-family: var(--font);
  transition: all 0.12s;
}
.ap-links .ap-x:hover { color: var(--accent); border-color: rgba(69, 196, 255, 0.5); }

/* ---------- 实时叠加层(观测类开关) ---------- */
#overlay-label {
  font-size: 9.5px; letter-spacing: 0.12em; color: var(--text-faint);
  padding: 0 6px 4px; text-transform: uppercase;
}
#overlay-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
#sat-channel-wrap { padding: 5px 2px 0; }
#sat-channel {
  width: 100%; background: var(--panel-soft); color: var(--text); border: 1px solid transparent;
  border-radius: 7px; padding: 4.5px 4px; font-size: 11px; font-family: var(--font);
  outline: none; cursor: pointer; transition: border-color 0.15s;
}
#sat-channel:hover { border-color: var(--border-strong); }
#sat-channel:focus { border-color: rgba(69, 196, 255, 0.5); }

/* ---------- 台风/站点叠加(canvas 自绘) ---------- */
#overlay-root canvas#tropical-canvas { z-index: 6; }
#overlay-root canvas#stations-canvas { z-index: 7; }
#obs-popup {
  position: absolute; z-index: 10; display: none; pointer-events: none;
  background: rgba(13, 22, 34, 0.96); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 14px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  font-size: 12.5px; line-height: 1.55; max-width: 300px;
}
.tc-popup { min-width: 190px; }
.tc-grid {
  display: grid; grid-template-columns: auto 1fr; gap: 3px 14px;
  font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.tc-grid span { color: var(--text-faint); }
.tc-grid b { font-weight: 600; }

/* ---------- Leaflet 弹窗暗色主题(台风/站点详情) ---------- */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: rgba(13, 22, 34, 0.96); color: var(--text);
}
.leaflet-popup-content-wrapper {
  border: 1px solid var(--border); border-radius: 12px !important;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5) !important;
}
.leaflet-popup-content {
  margin: 11px 14px; font-family: var(--font); font-size: 12.5px; line-height: 1.55;
}
.leaflet-container a.leaflet-popup-close-button { color: var(--text-faint); padding: 5px 6px 0 0; }
.leaflet-container a.leaflet-popup-close-button:hover { color: var(--text); }
.leaflet-popup-tip { box-shadow: none !important; }
@media (max-width: 820px) {
  #overlay-label { display: none; }
  #overlay-buttons { display: flex; gap: 2px; }
  .overlay-btn { padding: 7px 8px; flex: none; }
  #sat-channel-wrap { padding: 0 2px; }
  #sat-channel { max-width: 160px; }
}
#overlay-root canvas#lightning-canvas { z-index: 5; }

/* ---------- 3D 地球视图 ---------- */
#globe-wrap {
  position: fixed; inset: 0; z-index: 2000;
  background: #05090f; display: none;
}
#globe-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#globe-canvas:active { cursor: grabbing; }
#globe-exit {
  position: absolute; top: 16px; right: 16px; z-index: 5;
  background: var(--panel); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 8px 14px; font-size: 12.5px; font-family: var(--font);
  cursor: pointer; transition: all 0.15s;
}
#globe-exit:hover { color: var(--accent); border-color: rgba(69, 196, 255, 0.5); }
#globe-hint {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  font-size: 11.5px; color: var(--text-faint); font-family: var(--font);
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 14px; pointer-events: none;
}
#globe-legend {
  position: absolute; left: 16px; bottom: 18px; z-index: 5;
  flex-direction: column; gap: 4px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px; min-width: 150px;
  font-family: var(--font); backdrop-filter: blur(8px);
}
#globe-legend b { font-size: 11.5px; color: var(--text-dim); font-weight: 600; }
#globe-legend i { display: block; height: 9px; border-radius: 4px; }
#globe-legend span { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-faint); }
#globe-btn { background: none; border: none; color: var(--text-dim); width: 30px; height: 30px; border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
#globe-btn:hover, #globe-btn.active { color: var(--accent); background: var(--panel-soft); }

/* ---------- 批次 A/B:模型胶囊 / 单位弹层 / 轻提示 / 时间轴增强 ---------- */
#model-pill {
  position: fixed; right: 14px; bottom: 78px; z-index: 1000;
  display: flex; align-items: center; gap: 5px;
  background: var(--panel); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 0 8px 0 11px; height: 34px; box-shadow: var(--shadow); color: var(--text-dim);
}
#model-pill svg { flex: none; opacity: 0.8; }
#model-pill select {
  background: none; color: var(--text); border: none; outline: none; cursor: pointer;
  font-size: 12px; font-family: var(--font); max-width: 132px; padding-right: 2px;
}
#model-pill select option, #model-pill select optgroup { background: var(--panel-solid); color: var(--text); }

#units-pop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 1200;
  width: 256px; background: var(--panel-solid); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); padding: 10px 12px;
}
.up-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; }
.up-row > span { font-size: 12px; color: var(--text-dim); flex: none; }
.up-opts { display: flex; gap: 3px; }
.up-opts button {
  background: var(--panel-soft); border: 1px solid transparent; color: var(--text-dim);
  border-radius: 7px; padding: 4px 9px; font-size: 11.5px; cursor: pointer; font-family: var(--font);
  transition: all 0.12s; white-space: nowrap;
}
.up-opts button:hover { color: var(--text); }
.up-opts button.active {
  background: rgba(69, 196, 255, 0.16); color: var(--accent);
  border-color: rgba(69, 196, 255, 0.45); font-weight: 600;
}
body.legend-off #legend { display: none !important; }

#hint {
  position: fixed; right: 14px; bottom: 122px; z-index: 1300;
  background: var(--panel-solid); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 8px 14px; font-size: 12.5px; box-shadow: var(--shadow); pointer-events: none;
}

#now-fab {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 88px; z-index: 990;
  background: var(--panel); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(69, 196, 255, 0.45); color: var(--accent);
  border-radius: 999px; padding: 8px 16px; font-size: 12.5px; font-family: var(--font);
  cursor: pointer; box-shadow: var(--shadow); transition: all 0.15s;
}
#now-fab:hover { background: rgba(69, 196, 255, 0.12); }

/* 时间轴:日期表头 + 周末底色 + 数据窗分段 + 拖动气泡 + 倍速 */
.tl-day-div { position: absolute; top: 14px; bottom: 0; width: 1px; background: rgba(255, 255, 255, 0.14); pointer-events: none; }
.tl-day-div.wk { background: rgba(255, 210, 87, 0.28); }
.tl-day-label {
  position: absolute; top: -1px; transform: translateX(-50%);
  font-size: 9.5px; color: var(--text-faint); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.tl-day-label.wk { color: rgba(255, 210, 87, 0.85); }
.tl-wk-seg { position: absolute; top: 14px; bottom: 0; background: rgba(255, 210, 87, 0.07); pointer-events: none; }
#tl-datapast, #tl-datafcst { position: absolute; top: 14px; bottom: 0; pointer-events: none; }
#tl-datapast { background: rgba(255, 255, 255, 0.08); }
#tl-datafcst { background: rgba(69, 196, 255, 0.16); }
#tl-bubble {
  position: absolute; bottom: calc(100% + 2px); transform: translateX(-50%); z-index: 5;
  background: var(--panel-solid); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 4px 10px; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow);
}
#tl-bubble b { display: block; font-size: 12px; font-variant-numeric: tabular-nums; }
#tl-bubble span { display: block; font-size: 10px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
#tl-speed { flex: none; display: flex; gap: 2px; }
#tl-speed button {
  background: var(--panel-soft); border: 1px solid transparent; color: var(--text-dim);
  border-radius: 7px; padding: 5px 7px; font-size: 10.5px; cursor: pointer; font-family: var(--font);
  transition: all 0.12s;
}
#tl-speed button.active { color: var(--accent); border-color: rgba(69, 196, 255, 0.45); background: rgba(69, 196, 255, 0.1); }

@media (max-width: 1000px) {
  #model-pill { top: 10px; right: 10px; bottom: auto; }
  #units-pop { top: auto; bottom: calc(100% + 8px); }
}
@media (max-width: 900px) {
  #tl-speed { display: none; }
}
@media (max-width: 820px) {
  #model-pill { height: 32px; }
  #model-pill select { max-width: 96px; font-size: 11px; }
  #hint { right: 10px; bottom: 180px; }
  #now-fab { bottom: 128px; }
}
