:root {
  --ink: #15201d;
  --muted: #69736f;
  --surface: rgba(250, 251, 250, 0.95);
  --line: rgba(21, 32, 29, 0.12);
  --accent: #e64f36;
  --shadow: 0 12px 36px rgba(21, 32, 29, 0.16);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--ink); background: #dce4e0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; letter-spacing: 0; }
button, input { font: inherit; letter-spacing: 0; }
button { color: inherit; }
.hidden { display: none !important; }
.app-shell, #map { position: absolute; inset: 0; }
#map { display: block; width: 100%; height: 100%; background: #dce4e0; cursor: grab; touch-action: none; }
#map.dragging { cursor: grabbing; }

.topbar { position: fixed; z-index: 10; top: max(16px, env(safe-area-inset-top)); left: 18px; right: 18px; display: grid; grid-template-columns: auto minmax(240px, 460px) auto; align-items: center; gap: 14px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand, .search-wrap, .locate-button { background: var(--surface); border: 1px solid rgba(255,255,255,.72); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.brand { height: 54px; display: flex; align-items: center; gap: 10px; padding: 7px 14px 7px 8px; border-radius: 7px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; background: var(--ink); color: white; border-radius: 5px; font-size: 17px; font-weight: 700; }
.brand strong, .brand small { display: block; white-space: nowrap; }
.brand strong { font-size: 16px; line-height: 1.2; }
.brand small { color: var(--muted); font-size: 10px; margin-top: 3px; }

.search-wrap { position: relative; justify-self: center; width: 100%; min-width: 0; height: 48px; border-radius: 7px; }
.search-wrap input { width: 100%; height: 100%; padding: 0 44px; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-wrap input::placeholder { color: #7d8783; }
.search-icon { position: absolute; left: 17px; top: 15px; width: 15px; height: 15px; border: 1.7px solid var(--ink); border-radius: 50%; }
.search-icon::after { content: ""; position: absolute; width: 7px; height: 1.7px; background: var(--ink); right: -5px; bottom: -3px; transform: rotate(45deg); }
.icon-button { border: 0; background: transparent; cursor: pointer; }
.icon-button.compact { position: absolute; right: 6px; top: 5px; width: 38px; height: 38px; font-size: 24px; color: var(--muted); }
.search-results { position: absolute; top: 56px; left: 0; right: 0; padding: 6px; border: 1px solid var(--line); border-radius: 7px; background: rgba(252,253,252,.98); box-shadow: var(--shadow); }
.search-result { width: 100%; display: flex; justify-content: space-between; gap: 20px; padding: 11px 12px; border: 0; border-radius: 5px; background: transparent; text-align: left; cursor: pointer; }
.search-result:hover, .search-result:focus { background: #edf1ef; outline: none; }
.search-result strong { font-size: 14px; }
.search-result span { color: var(--muted); font-size: 12px; white-space: nowrap; }

.locate-button { height: 48px; display: flex; align-items: center; gap: 8px; padding: 0 16px; border-radius: 7px; cursor: pointer; }
.locate-icon { position: relative; width: 15px; height: 15px; border: 1.8px solid currentColor; border-radius: 50%; }
.locate-icon::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: currentColor; }
.locate-icon::after { content: ""; position: absolute; inset: -5px; background: linear-gradient(currentColor,currentColor) center/1px 100% no-repeat, linear-gradient(90deg,currentColor,currentColor) center/100% 1px no-repeat; opacity: .5; }
.locate-button.loading .locate-icon { animation: pulse 1s infinite; }

.map-status { position: fixed; z-index: 5; top: 86px; left: 22px; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 4px; background: rgba(248,250,249,.86); color: var(--muted); font-size: 11px; backdrop-filter: blur(10px); }
.map-status i { width: 3px; height: 3px; border-radius: 50%; background: var(--accent); }
.legend { position: fixed; z-index: 5; right: 20px; top: 86px; width: 230px; padding: 9px 10px 7px; border-radius: 5px; background: rgba(248,250,249,.86); backdrop-filter: blur(10px); }
.legend-scale { height: 7px; border-radius: 2px; background: linear-gradient(90deg,#473b86 0%,#3578b8 28.57%,#45a99a 57.14%,#d4c94f 68.57%,#e98232 80%,#c83e35 100%); }
.legend-labels { position: relative; height: 11px; margin-top: 4px; color: #5e6965; font-size: 9px; }
.legend-labels span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.legend-labels span:nth-child(1) { left: 0; transform: none; }
.legend-labels span:nth-child(2) { left: 28.57%; }
.legend-labels span:nth-child(3) { left: 57.14%; }
.legend-labels span:nth-child(4) { left: 68.57%; }
.legend-labels span:nth-child(5) { left: 80%; }
.legend-labels span:nth-child(6) { right: 0; transform: none; }
.map-controls { position: fixed; z-index: 6; top: 130px; right: 20px; display: grid; overflow: hidden; border: 1px solid rgba(255,255,255,.76); border-radius: 6px; background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.map-controls button { width: 38px; height: 38px; padding: 0; border: 0; background: transparent; color: var(--ink); font-size: 22px; line-height: 1; cursor: pointer; }
.map-controls button + button { border-top: 1px solid var(--line); }
.map-controls button:hover { background: #edf1ef; }

.weather-panel { position: fixed; z-index: 8; left: 18px; right: 18px; bottom: 18px; min-height: 240px; padding: 22px 26px 14px; border: 1px solid rgba(255,255,255,.76); border-radius: 8px; background: var(--surface); box-shadow: 0 18px 52px rgba(21,32,29,.2); backdrop-filter: blur(20px); transition: transform .25s ease; }
.weather-panel.empty { left: auto; width: 310px; min-height: 124px; padding: 20px 24px; }
.detail-close { position: absolute; z-index: 2; top: 10px; right: 12px; width: 34px; height: 34px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; }
.detail-close:hover { background: #edf1ef; color: var(--ink); }
.panel-toggle { display: none; }
.empty-state { display: flex; align-items: center; gap: 16px; }
.empty-temp { font-size: 50px; line-height: 1; font-weight: 600; color: #b2bab7; }
.empty-state p { width: 150px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.current-row { display: grid; grid-template-columns: minmax(220px, .8fr) 1.2fr; gap: 28px; align-items: start; }
.location-line { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 600; }
.weather-badge { padding: 2px 6px; border: 1px solid var(--line); border-radius: 3px; color: var(--muted); font-size: 10px; font-weight: 500; }
.temperature { margin-top: 4px; font-size: clamp(54px, 6vw, 78px); line-height: .94; font-weight: 600; }
.temperature sup { position: relative; top: -20px; font-size: 24px; font-weight: 400; }
.comfort-text { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.metrics div { min-height: 76px; padding: 15px 18px; border-left: 1px solid var(--line); }
.metrics div:first-child { border-left: 0; }
.metrics span, .metrics strong { display: block; }
.metrics span { color: var(--muted); font-size: 11px; }
.metrics strong { margin-top: 8px; font-size: 19px; font-weight: 500; }

.forecast-tabs { display: flex; gap: 22px; margin-top: 13px; border-bottom: 1px solid var(--line); }
.tab { position: relative; padding: 8px 0 10px; border: 0; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; }
.tab.active { color: var(--ink); font-weight: 600; }
.tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }
.forecast-view { height: 112px; overflow: hidden; }
.chart-wrap { position: relative; width: 100%; height: 112px; overflow-x: auto; scrollbar-width: thin; }
#hourlyChart, #weeklyChart { display: block; height: 108px; }
#hourlyChart { width: max(760px,100%); }
#weeklyChart { width: max(2016px,100%); }
.chart-tooltip { position: absolute; z-index: 3; top: 18px; padding: 5px 7px; border-radius: 4px; background: rgba(21,32,29,.92); color: white; font-size: 10px; line-height: 1.45; pointer-events: none; white-space: nowrap; transform: translateX(-50%); }
.time-control { display: grid; grid-template-columns: minmax(180px,1fr) auto; align-items: center; gap: 14px; min-height: 32px; border-top: 1px solid var(--line); }
.time-control input { width: 100%; accent-color: var(--accent); cursor: pointer; }
.time-control output { color: var(--muted); font-size: 10px; white-space: nowrap; }
.daily-list { display: grid; grid-template-columns: repeat(7,1fr); min-width: 650px; height: 100%; }
.daily-item { display: grid; align-content: center; gap: 6px; padding: 8px 12px; border-left: 1px solid var(--line); }
.daily-item:first-child { border-left: 0; }
.daily-item span { color: var(--muted); font-size: 10px; }
.daily-item strong { font-size: 16px; font-weight: 600; }
.daily-item em { color: var(--muted); font-size: 10px; font-style: normal; }
.source-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 7px; color: var(--muted); font-size: 9px; }
.source-line span { min-width: 0; }
.source-line a { color: inherit; }
.source-line button { flex: 0 0 auto; border: 0; background: transparent; color: var(--muted); text-decoration: underline; cursor: pointer; }

.toast { position: fixed; z-index: 30; left: 50%; top: 88px; transform: translateX(-50%); padding: 9px 14px; border-radius: 5px; background: #17211e; color: white; box-shadow: var(--shadow); font-size: 12px; }
.method-dialog { width: min(520px, calc(100vw - 32px)); padding: 28px; border: 0; border-radius: 8px; color: var(--ink); box-shadow: 0 24px 70px rgba(0,0,0,.28); }
.method-dialog::backdrop { background: rgba(15,23,20,.42); backdrop-filter: blur(4px); }
.dialog-close { position: absolute; right: 14px; top: 10px; width: 36px; height: 36px; border: 0; background: transparent; font-size: 25px; cursor: pointer; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.method-dialog h2 { margin: 0 0 14px; font-size: 25px; }
.method-dialog > p { color: var(--muted); font-size: 13px; line-height: 1.7; }
.method-dialog dl { margin: 22px 0; border-top: 1px solid var(--line); }
.method-dialog dl div { display: grid; grid-template-columns: 110px 1fr; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.method-dialog dt { color: var(--muted); }
.method-dialog dd { margin: 0; }
.disclaimer { font-size: 10px !important; }
@keyframes pulse { 50% { transform: scale(.72); opacity: .55; } }

@media (max-width: 700px) {
  .topbar { top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; display: block; }
  .brand { display: none; }
  .search-wrap { justify-self: start; width: calc(100% - 52px); height: 44px; }
  .locate-button { position: absolute; top: 0; right: 0; display: flex; width: 44px; height: 44px; padding: 0; justify-content: center; }
  .locate-button span:last-child { display: none; }
  .map-status { top: 64px; left: 12px; }
  .legend { top: auto; right: 10px; bottom: 194px; width: 170px; }
  .app-shell:has(.weather-panel.empty) .legend { bottom: 112px; }
  .map-controls { top: 116px; right: 10px; }
  .map-controls button { width: 42px; height: 42px; font-size: 24px; }
  .weather-panel, .weather-panel.empty { left: 0; right: 0; bottom: 0; width: auto; min-height: 0; max-height: calc(100dvh - 82px); padding: 18px 14px calc(52px + env(safe-area-inset-bottom)); border-radius: 8px 8px 0 0; overflow-x: hidden; }
  .weather-panel.empty { padding: 17px 14px max(10px, env(safe-area-inset-bottom)); }
  .weather-panel.expanded { padding-top: 32px; padding-bottom: max(10px, env(safe-area-inset-bottom)); overflow-y: auto; }
  .weather-panel:not(.expanded) .forecast-tabs,
  .weather-panel:not(.expanded) .forecast-view,
  .weather-panel:not(.expanded) .time-control,
  .weather-panel:not(.expanded) .source-line { display: none; }
  .panel-toggle { position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; width: 100%; height: 44px; padding: 0 16px; border: 0; border-top: 1px solid var(--line); background: rgba(241,245,243,.96); color: var(--ink); cursor: pointer; }
  .panel-toggle-title { display: flex; align-items: center; gap: 9px; font-size: 12px; font-weight: 600; }
  .panel-toggle-title::before { content: ""; width: 3px; height: 16px; border-radius: 1px; background: var(--accent); }
  .panel-toggle-action { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: 11px; font-weight: 600; }
  .panel-toggle-action i { width: 7px; height: 7px; border-top: 1.5px solid currentColor; border-right: 1.5px solid currentColor; transform: rotate(-45deg) translateY(2px); }
  .weather-panel.expanded .panel-toggle { top: 0; bottom: auto; justify-content: center; height: 28px; border-top: 0; border-bottom: 1px solid var(--line); background: rgba(246,248,247,.94); }
  .weather-panel.expanded .panel-toggle-title { font-size: 10px; font-weight: 500; }
  .weather-panel.expanded .panel-toggle-title::before { display: none; }
  .weather-panel.expanded .panel-toggle-action { margin-left: 8px; font-size: 10px; color: var(--muted); }
  .weather-panel.expanded .panel-toggle-action i { transform: rotate(135deg) translateY(2px); }
  .current-row { grid-template-columns: minmax(100px,.75fr) minmax(0,1.25fr); gap: 8px; align-items: center; }
  .location-line { min-width: 0; padding-right: 20px; }
  .location-line > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .weather-badge { flex: 0 0 auto; }
  .temperature { margin-top: 2px; font-size: 46px; }
  .temperature sup { top: -13px; font-size: 18px; }
  .comfort-text { margin-top: 4px; font-size: 10px; line-height: 1.35; }
  .metrics div { padding: 7px 8px; min-height: 48px; }
  .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .metrics div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .metrics div:nth-child(4) { border-top: 1px solid var(--line); }
  .metrics span { font-size: 9px; }
  .metrics strong { margin-top: 4px; font-size: 14px; }
  .metrics div:last-child strong { font-size: 11px; overflow-wrap: anywhere; }
  .weather-panel.expanded .forecast-tabs { margin-top: 10px; }
  .daily-list { overflow-x: auto; }
  .forecast-view { overflow-x: auto; }
  .detail-close { z-index: 4; top: 2px; right: 3px; width: 40px; height: 40px; }
  .tab { min-height: 40px; }
  .time-control { grid-template-columns: 1fr; gap: 1px; padding: 5px 0; }
  .time-control input { height: 32px; margin: 0; }
  .time-control output { text-align: center; }
  .source-line { align-items: flex-end; padding-bottom: 2px; }
}
