/* SunsetWhisper — dark dashboard */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0b0f16;
  --surface: #121826;
  --surface2: #182131;
  --surface3: #202b3f;
  --border: #2c3649;
  --text: #e7edf7;
  --muted: #8d98aa;
  --accent: #ff7a45;
  --accent2: #ffd4aa;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);

  --score-none: #4a9eff;
  --score-micro: #7bd989;
  --score-small: #f2e75d;
  --score-medium: #ff9d2b;
  --score-large: #ff5a1f;
  --score-super: #d62574;
}

html, body {
  height: 100%;
  background: radial-gradient(circle at top, #111a2d, var(--bg) 55%);
  color: var(--text);
  font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  overflow-x: hidden;
  overflow-y: auto;
}

button, input, textarea, select { font: inherit; }

#app {
  display: grid;
  grid-template-rows: 72px 96px auto;
  min-height: 100vh;
}

#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  background: rgba(18, 24, 38, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255,122,69,0.25), rgba(255,212,170,0.12));
  border: 1px solid rgba(255,122,69,0.25);
  box-shadow: var(--shadow);
  font-size: 22px;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.1;
  font-weight: 700;
  color: var(--text);
}

.brand-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

#data-info {
  flex: 1;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.header-btn {
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.15s ease;
}

.header-btn:hover { background: var(--surface3); }

#hero {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 12px 16px 10px;
}

.hero-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(18,24,38,0.95), rgba(15,20,31,0.95));
  box-shadow: var(--shadow);
  min-width: 0;
}

.hero-card.accent {
  background: linear-gradient(135deg, rgba(255,122,69,0.18), rgba(18,24,38,0.95));
  border-color: rgba(255,122,69,0.28);
}

.hero-title {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.3px;
}

.hero-value {
  margin-top: 8px;
  font-size: 22px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-small { font-size: 16px; }
.hero-meta {
  margin-top: 8px;
  color: var(--accent2);
  font-size: 12px;
  line-height: 1.4;
}

#main {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 0 16px 16px;
  min-height: 0;
  overflow: visible;
}

#map-stack {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.map-card {
  background: rgba(18,24,38,0.96);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 360px;
}

.map-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}

.map-card-title {
  font-size: 16px;
  font-weight: 700;
}

.map-card-subtitle {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

.map-card-meta {
  font-size: 11px;
  color: var(--accent2);
  text-align: right;
  line-height: 1.4;
}

.map-canvas {
  flex: 1;
  min-height: 320px;
}

#map,
#map-sunset,
#map-sunrise {
  min-width: 0;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.map-card #map-sunset,
.map-card #map-sunrise {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.leaflet-container { background: #141b2a; }
.leaflet-control-attribution { background: rgba(11,15,22,0.8) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bar a { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
.leaflet-bar a:hover { background: var(--surface2) !important; }
.leaflet-popup-content-wrapper { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-tooltip { background: var(--surface2); color: var(--text); border: 1px solid var(--border); font-size: 12px; }
.leaflet-tooltip::before { border-top-color: var(--border) !important; }

.city-marker {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #111;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.55), 0 0 0 2px rgba(255,255,255,0.15);
  transition: transform 0.15s ease;
  border: 2px solid rgba(255,255,255,0.25);
}
.city-marker:hover { transform: scale(1.15); }
.marker-label { pointer-events: none; }

#btn-toggle-list {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 1000;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(18,24,38,0.95);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
#btn-toggle-list:hover { background: var(--surface2); }

#city-sidebar {
  position: fixed;
  left: 16px;
  top: 108px;
  width: 250px;
  background: rgba(18,24,38,0.96);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(12px);
  z-index: 800;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 120px);
}
#city-sidebar.open { transform: translateX(0); }

#city-sidebar-header {
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#city-sidebar-header span:first-child { font-weight: 700; }
.sidebar-note { font-size: 12px; color: var(--muted); }

#city-list {
  overflow-y: auto;
  flex: 1;
  padding: 6px;
}

.city-list-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 14px;
  padding: 10px 10px;
  cursor: pointer;
  transition: 0.15s ease;
  text-align: left;
}
.city-list-item:hover {
  background: var(--surface2);
  border-color: rgba(255,255,255,0.06);
}
.city-list-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}
.city-list-name strong { font-size: 13px; }
.city-list-name span { font-size: 11px; color: var(--muted); }

#city-panel {
  position: relative;
  width: 100%;
  height: 100%;
  background: rgba(18,24,38,0.96);
  border: 1px solid var(--border);
  border-radius: 18px;
  backdrop-filter: blur(12px);
  z-index: 900;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
#city-panel.hidden { display: none; }

#panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
}
#panel-city-name { font-size: 18px; font-weight: 700; }
#panel-city-subtitle { font-size: 12px; color: var(--muted); margin-top: 4px; }
.panel-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
}
.panel-close-btn:hover { color: var(--text); }

#panel-score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
#panel-score-value {
  margin-top: 6px;
  font-size: 42px;
  line-height: 1;
  font-weight: 800;
  color: var(--accent);
}

#panel-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 14px 16px;
}
.summary-box,
.meta-item,
.daily-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.summary-box {
  padding: 12px;
}
.meta-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}
.meta-value {
  font-size: 14px;
  font-weight: 700;
}

#panel-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 16px 14px;
}
.meta-item { padding: 12px; }

.score-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  color: #111;
}
.score-badge.small { font-size: 11px; padding: 2px 8px; }
.score-none   { background: var(--score-none); }
.score-micro  { background: var(--score-micro); }
.score-small  { background: var(--score-small); }
.score-medium { background: var(--score-medium); }
.score-large  { background: var(--score-large); color: #fff; }
.score-super  { background: var(--score-super); color: #fff; }

#panel-path-container,
#panel-factor-container,
#panel-chart-container,
#panel-daily-container,
#about-section {
  padding: 0 16px 14px;
}
#panel-path-title,
#panel-factor-title,
#panel-chart-title,
#panel-daily-title {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}
#panel-path-note {
  margin-bottom: 10px;
  color: var(--accent2);
  font-size: 12px;
  line-height: 1.5;
}
.path-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.path-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
}
.path-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.path-card-title {
  font-size: 13px;
  font-weight: 700;
}
.path-card-subtitle {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.4;
}
#panel-sunset-path-diagram,
#panel-sunrise-path-diagram {
  min-height: 250px;
}
#panel-factor-note {
  margin-bottom: 10px;
  color: var(--accent2);
  font-size: 12px;
  line-height: 1.5;
}
#panel-factor-list {
  display: grid;
  gap: 8px;
}
.factor-row {
  display: grid;
  grid-template-columns: 130px 1fr 64px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.factor-name {
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
}
.factor-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}
.factor-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(255,122,69,0.5), rgba(255,255,255,0.95));
}
.factor-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--accent2);
  font-size: 12px;
}
#panel-path-meta {
  margin-bottom: 10px;
  color: var(--accent2);
  font-size: 12px;
  line-height: 1.5;
}
#panel-path-diagram {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  overflow: hidden;
}
.path-empty {
  color: var(--muted);
  font-size: 12px;
  padding: 8px 0;
}
.path-svg {
  width: 100%;
  height: auto;
  display: block;
}
.path-band-label {
  fill: var(--muted);
  font-size: 10px;
}
.path-axis-label {
  fill: var(--muted);
  font-size: 10px;
}
.path-legend-label {
  fill: var(--text);
  font-size: 10px;
}
.path-ray {
  stroke: #ffd08a;
  stroke-width: 2.2;
  stroke-dasharray: 6 5;
  fill: none;
}
.path-origin {
  fill: #ff7a45;
  stroke: #ffffff;
  stroke-width: 1;
}
#forecast-chart {
  height: 220px !important;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
}

#panel-daily-list {
  display: grid;
  gap: 10px;
}
.daily-card { padding: 12px; }
.daily-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.daily-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.daily-grid div {
  background: var(--surface2);
  border-radius: 12px;
  padding: 10px;
}
.daily-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.daily-grid b {
  display: block;
  margin-top: 5px;
  font-size: 14px;
}
.daily-grid small {
  display: block;
  color: var(--accent2);
  margin-top: 2px;
}

#about-section {
  color: var(--muted);
  line-height: 1.7;
  font-size: 12px;
}
#about-section a { color: var(--accent2); text-decoration: none; }
#about-section a:hover { text-decoration: underline; }

#legend {
  position: relative;
  z-index: 900;
  background: rgba(18,24,38,0.96);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  min-width: 150px;
  justify-self: end;
}
#legend h4 {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 8px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  font-size: 12px;
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11,15,22,0.88);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { color: var(--muted); font-size: 14px; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

@media (max-width: 1080px) {
  #hero { grid-template-columns: 1fr; }
  #main { grid-template-columns: 1fr; }
  #city-panel { width: 100%; height: auto; min-height: 520px; }
  .map-card { min-height: 300px; }
  .path-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  #app { grid-template-rows: auto auto auto; }
  #hero { padding-top: 0; }
  #data-info { display: none; }
  #legend { display: none; }
  #city-sidebar {
    width: min(88vw, 320px);
    max-height: calc(100vh - 96px);
    position: fixed;
    top: 96px;
    bottom: auto;
  }
  #main { padding: 0 12px 12px; }
  #map-stack { gap: 10px; }
  .map-card { min-height: 260px; }
  .map-canvas { min-height: 220px; }
  #city-panel { width: 100%; min-height: 0; }
  .path-grid { grid-template-columns: 1fr; }
}
