/* ==========================================================================
   Apple-Weather-inspired frosted glass UI
   --------------------------------------------------------------------------
   The map is a full-bleed layer; every panel floats above it with
   backdrop-filter. That only works because the map is genuinely painted
   *behind* the panels - previously the map sat in its own grid cell next to
   the panels, so there was nothing to blur and everything looked flat.
   ========================================================================== */

:root {
  /* one translucent surface recipe, reused everywhere */
  --glass:        rgba(18, 24, 34, 0.55);
  --glass-strong: rgba(14, 19, 27, 0.74);
  --glass-soft:   rgba(255, 255, 255, 0.06);
  --blur:         30px;
  --blur-heavy:   44px;

  --stroke:       rgba(255, 255, 255, 0.10);
  --stroke-soft:  rgba(255, 255, 255, 0.06);
  --hairline:     rgba(255, 255, 255, 0.08);

  --text:   #f2f6fb;
  --muted:  rgba(233, 240, 250, 0.66);
  --faint:  rgba(233, 240, 250, 0.42);

  --accent:  #5ac8fa;      /* iOS blue */
  --accent-2:#0a84ff;
  --danger:  #ff453a;      /* iOS red */
  --warn:    #ff9f0a;      /* iOS orange */
  --ok:      #30d158;      /* iOS green */

  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;

  --shadow: 0 12px 40px rgba(0, 0, 0, 0.42);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.28);

  --rail-w: 264px;
  --right-w: 340px;
  --gap: 14px;
  --topbar-h: 58px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #070b11;
  color: var(--text);
  font: 13px/1.55 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
        "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- layers ---------- */
#map { position: fixed; inset: 0; z-index: 0; }
.ui { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
.ui > * { pointer-events: auto; }

/* ---------- the glass recipe ---------- */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  backdrop-filter: blur(var(--blur)) saturate(180%);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
}

/* iOS-style specular highlight along the top edge */
.glass::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent, rgba(255, 255, 255, 0.30), transparent);
  pointer-events: none;
}

/* ---------- top bar ---------- */
.topbar {
  position: absolute;
  top: var(--gap);
  left: var(--gap);
  right: var(--gap);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 18px;
  border-radius: var(--r-lg);
  overflow: hidden;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.brand .logo-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: linear-gradient(160deg, #7dd3fc, var(--accent-2));
  box-shadow: 0 0 14px rgba(90, 200, 250, 0.85);
}
.brand .sub {
  color: var(--faint); font-size: 12px;
  padding-left: 10px; border-left: 1px solid var(--hairline);
}

.tabs {
  display: flex; gap: 3px; margin-left: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--stroke-soft);
  border-radius: 12px; padding: 3px;
}
.tab {
  background: transparent; border: 0; color: var(--muted);
  padding: 6px 14px; border-radius: 9px; cursor: pointer;
  font-size: 12.5px; text-decoration: none;
  transition: background .18s, color .18s;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.07); }
.tab.active {
  color: #06131f; font-weight: 600;
  background: linear-gradient(170deg, #8fdcff, var(--accent));
  box-shadow: 0 2px 10px rgba(90, 200, 250, 0.35);
}

.status { margin-left: auto; display: flex; gap: 9px; align-items: center; }

.badge {
  padding: 5px 11px; border-radius: 20px; font-size: 11.5px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--stroke-soft);
  color: var(--muted); white-space: nowrap;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.badge-live { color: #9ff2b6; border-color: rgba(48, 209, 88, 0.35); background: rgba(48, 209, 88, 0.12); }
.badge-mock { color: #ffd48a; border-color: rgba(255, 159, 10, 0.35); background: rgba(255, 159, 10, 0.12); }

.account {
  display: flex; align-items: center; gap: 9px;
  padding-left: 11px; margin-left: 3px;
  border-left: 1px solid var(--hairline);
}
.account .who {
  font-size: 12px; color: var(--muted); max-width: 180px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.avatar {
  width: 27px; height: 27px; border-radius: 50%;
  background: linear-gradient(160deg, #7dd3fc, var(--accent-2));
  color: #06131f; font-weight: 700; font-size: 12px;
  display: grid; place-items: center; text-transform: uppercase;
  box-shadow: 0 2px 10px rgba(90, 200, 250, 0.35);
}

/* ---------- floating rails ---------- */
.rail {
  position: absolute;
  top: calc(var(--topbar-h) + var(--gap) * 2);
  bottom: var(--gap);
  width: var(--rail-w);
  display: flex; flex-direction: column;
  gap: var(--gap);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.18) transparent;
}
.rail-left { left: var(--gap); }
.rail-right { right: var(--gap); width: var(--right-w); }
.rail::-webkit-scrollbar { width: 7px; }
.rail::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.16); border-radius: 4px;
}
.rail::-webkit-scrollbar-track { background: transparent; }

/* ---------- cards ---------- */
.card {
  position: relative;
  border-radius: var(--r-lg);
  padding: 14px 15px;
  flex: 0 0 auto;
  overflow: hidden;
}
.card h3 {
  margin: 0 0 11px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--faint);
  display: flex; align-items: center; justify-content: space-between;
}

.empty { color: var(--faint); font-size: 12.5px; padding: 8px 0; }
.hint { color: var(--faint); font-size: 11.5px; margin: 10px 0 0; line-height: 1.6; }

/* ---------- buttons ---------- */
.btn {
  background: var(--glass-soft);
  color: var(--text);
  border: 1px solid var(--stroke);
  border-radius: var(--r-sm);
  padding: 6px 12px; cursor: pointer; font-size: 12px;
  transition: background .16s, border-color .16s, transform .1s;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255,255,255,.2); }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(170deg, #8fdcff, var(--accent));
  border-color: transparent; color: #06131f; font-weight: 600;
  box-shadow: 0 3px 14px rgba(90, 200, 250, 0.32);
}
.btn-primary:hover { background: linear-gradient(170deg, #a7e5ff, var(--accent)); }
.btn-sm { padding: 4px 10px; font-size: 11.5px; }
.btn-xs {
  padding: 2px 7px; font-size: 13px; line-height: 1.25;
  border-radius: 8px; color: var(--muted);
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- poi list ---------- */
.poi-list { display: flex; flex-direction: column; gap: 7px; }
.poi-item {
  position: relative;
  border: 1px solid var(--stroke-soft);
  border-radius: var(--r-md);
  padding: 9px 11px; cursor: pointer;
  background: rgba(255, 255, 255, 0.045);
  display: flex; flex-direction: column; gap: 3px;
  transition: background .16s, border-color .16s, transform .1s;
}
.poi-item:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255,255,255,.18);
}
.poi-item:active { transform: scale(0.985); }
.poi-item.selected {
  border-color: rgba(90, 200, 250, 0.55);
  background: rgba(90, 200, 250, 0.14);
  box-shadow: inset 0 0 0 1px rgba(90, 200, 250, 0.2);
}
.poi-item .row1 { display: flex; align-items: center; gap: 7px; }
.poi-item .name { font-weight: 600; font-size: 13px; }
.poi-item .meta { color: var(--faint); font-size: 11px; }
.kind-chip {
  font-size: 10px; padding: 2px 7px; border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--stroke-soft);
  color: var(--muted); white-space: nowrap;
}

/* ---------- switch rows ---------- */
.switch-row {
  display: flex; align-items: center; gap: 11px;
  padding: 7px 4px; cursor: pointer; font-size: 12.5px;
  border-radius: 9px;
  transition: background .16s;
}
.switch-row:hover { background: rgba(255,255,255,.05); }

/* The native checkbox stays in the DOM (focusable, accessible) but invisible;
   the track/knob below is what the user sees. Scoped with > span so it never
   touches the label text span - a bare `.switch-row span` rule previously
   squashed the text to 38x22px. */
.switch-row input {
  position: absolute;
  opacity: 0; width: 0; height: 0;
  margin: 0; pointer-events: none;
}
.switch-row .switch-track {
  position: relative; flex: 0 0 auto;
  width: 40px; height: 23px; border-radius: 20px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid var(--stroke-soft);
  transition: background .2s, border-color .2s;
}
.switch-row .switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 17px; height: 17px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.45);
  transition: transform .2s;
}
.switch-row input:checked + .switch-track {
  background: var(--ok);
  border-color: transparent;
  box-shadow: 0 2px 10px rgba(48, 209, 88, 0.35);
}
.switch-row input:checked + .switch-track::after { transform: translateX(17px); }
.switch-row input:focus-visible + .switch-track {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.switch-row > span:last-child { color: var(--text); }

/* ---------- budget ---------- */
.budget-detail { font-size: 12.5px; display: flex; flex-direction: column; gap: 7px; }
.budget-detail > div:first-child { font-size: 13px; }
.budget-bar {
  height: 6px; border-radius: 4px; overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
}
.budget-bar > i {
  display: block; height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #8fdcff, var(--accent-2));
  transition: width .4s ease;
}
.budget-bar > i.warn { background: linear-gradient(90deg, #ffd48a, var(--warn)); }
.budget-bar > i.danger { background: linear-gradient(90deg, #ff8a80, var(--danger)); }

/* ---------- overlays: draw toolbar + inspector ---------- */
.draw-toolbar {
  position: absolute;
  top: calc(var(--topbar-h) + var(--gap) * 2 + 4px);
  left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  padding: 9px 13px; border-radius: 999px;
  z-index: 6; overflow: hidden;
}
.draw-hint { font-size: 12px; color: var(--muted); }
.hidden { display: none !important; }

.inspect {
  position: absolute;
  left: calc(var(--rail-w) + var(--gap) * 2);
  bottom: var(--gap);
  width: 350px; max-height: 62%;
  border-radius: var(--r-lg);
  z-index: 6; overflow: hidden;
  display: flex; flex-direction: column;
}
.inspect-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 14px 9px;
  border-bottom: 1px solid var(--hairline);
}
.inspect-head strong { font-size: 14px; font-weight: 600; }
.inspect-body {
  padding: 12px 14px 14px; overflow-y: auto;
  font-size: 12.5px;
  scrollbar-width: thin;
}
.inspect-body::-webkit-scrollbar { width: 6px; }
.inspect-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 4px; }

/* ---------- weather readout ---------- */
.wx-current { display: flex; align-items: baseline; gap: 11px; margin-bottom: 10px; }
.wx-temp {
  font-size: 38px; font-weight: 300; letter-spacing: -.02em;
  line-height: 1;
}
.wx-meta { color: var(--muted); font-size: 11.5px; }
.wx-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 11px 0;
}
.wx-grid div {
  display: flex; justify-content: space-between; gap: 8px;
  padding-bottom: 5px; border-bottom: 1px solid var(--hairline);
}
.wx-grid span:first-child { color: var(--faint); }

.hourly-strip {
  display: flex; gap: 7px; overflow-x: auto; padding: 3px 0 6px;
  scrollbar-width: thin;
}
.hourly-strip::-webkit-scrollbar { height: 5px; }
.hourly-strip::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 3px; }
.hourly-cell {
  min-width: 57px; text-align: center; padding: 8px 4px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke-soft);
  font-size: 11.5px; flex: 0 0 auto;
}
.hourly-cell .h { color: var(--faint); font-size: 10.5px; }
.hourly-cell .t { font-weight: 600; margin: 4px 0 2px; font-size: 14px; }
.hourly-cell .w { color: var(--accent); font-size: 10.5px; }

/* ---------- alerts ---------- */
.alert-item {
  border: 1px solid var(--stroke-soft);
  border-left-width: 3px;
  border-radius: var(--r-md);
  padding: 10px 12px; margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.05);
}
.alert-item .a-head {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
}
.alert-item .a-sum { color: var(--muted); font-size: 11.5px; margin-top: 5px; line-height: 1.55; }
.alert-item .a-meta { color: var(--faint); font-size: 10.5px; margin-top: 5px; }
.sev-chip {
  font-size: 10px; padding: 2px 8px; border-radius: 20px;
  color: #06131f; font-weight: 700; white-space: nowrap;
}

/* ---------- dialog ---------- */
.dialog {
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(var(--blur-heavy)) saturate(180%);
  backdrop-filter: blur(var(--blur-heavy)) saturate(180%);
  color: var(--text);
  padding: 0; width: 440px; max-width: 93vw;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.dialog::backdrop {
  background: rgba(3, 7, 12, 0.55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.dialog form { padding: 20px; display: flex; flex-direction: column; gap: 13px; }
.dialog h3 { margin: 0 0 2px; font-size: 16px; font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.field > span { color: var(--faint); font-size: 11.5px; }
.field input[type=text], .field select {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--stroke);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 9px 11px; font-size: 12.5px; width: 100%;
  transition: border-color .16s, background .16s;
}
.field input[type=text]:focus, .field select:focus {
  outline: none;
  border-color: rgba(90, 200, 250, 0.6);
  background: rgba(255, 255, 255, 0.1);
}
.field select option { background: #131a24; color: var(--text); }

.geom-box { display: flex; align-items: center; gap: 11px; }
.geom-status { color: var(--faint); font-size: 11.5px; flex: 1; }
.geom-status.ok { color: var(--ok); }
.channel-row { display: flex; gap: 15px; flex-wrap: wrap; }
.channel-row label { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.dialog-actions {
  display: flex; justify-content: flex-end; gap: 9px; margin-top: 6px;
  padding-top: 14px; border-top: 1px solid var(--hairline);
}
.preset-desc { color: var(--muted); font-size: 11.5px; line-height: 1.65; }
.preset-desc ul { margin: 7px 0 0; padding-left: 17px; }
.preset-desc li { margin-bottom: 3px; }

/* ---------- map-missing notice ---------- */
.map-missing {
  position: absolute;
  left: calc(var(--rail-w) + var(--gap) * 2);
  right: calc(var(--right-w) + var(--gap) * 2);
  top: 50%; transform: translateY(-50%);
  border-radius: var(--r-lg);
  padding: 26px 30px; text-align: center;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.map-missing h4 { margin: 0 0 4px; font-size: 16px; color: var(--warn); }
.map-missing p { margin: 0; color: var(--muted); font-size: 12.5px; max-width: 520px; line-height: 1.7; }
.map-missing code {
  background: rgba(255,255,255,.09); border: 1px solid var(--stroke-soft);
  border-radius: 6px; padding: 2px 7px; font-size: 11.5px; color: var(--accent);
}
.map-missing-note { color: var(--faint) !important; margin-top: 8px !important; }

/* ==========================================================================
   高德 (Amap) control skinning - the stock white chrome clashes badly with
   the dark glass, so the built-ins are restyled to match.
   ========================================================================== */
.amap-logo, .amap-copyright {
  opacity: .42; filter: grayscale(1) brightness(2.2);
}
.amap-copyright { background: transparent !important; color: var(--faint) !important; }

.amap-scale-text, .amap-scale-line, .amap-scale-line-text {
  color: var(--muted) !important;
  border-color: rgba(255,255,255,.4) !important;
}

.amap-info-content {
  background: var(--glass-strong) !important;
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  backdrop-filter: blur(var(--blur)) saturate(180%);
  border: 1px solid var(--stroke) !important;
  border-radius: var(--r-md) !important;
  box-shadow: var(--shadow) !important;
  color: var(--text) !important;
  padding: 10px 13px !important;
  font-size: 12.5px !important;
}
.amap-info-sharp {
  border-top-color: var(--glass-strong) !important;
  border-bottom-color: var(--glass-strong) !important;
}
.amap-info-close { color: var(--muted) !important; }

/* keep MapLibre-era popup rule harmless in case an old bundle lingers */
.maplibregl-popup-content { border-radius: var(--r-md); }
