:root {
  color-scheme: light;
  --bg: #f4f6f6;
  --surface: #ffffff;
  --surface-muted: #f7f8f8;
  --text: #202426;
  --muted: #697176;
  --border: #dfe3e5;
  --border-strong: #c7ced1;
  --ink: #2d3235;
  --blue: #2586d8;
  --cyan: #04a9b5;
  --red: #e6383c;
  --amber: #df7b16;
  --green: #2f9154;
  --purple: #7256c8;
  --shadow: 0 8px 24px rgba(20, 28, 31, 0.1);
  font-family: Inter, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
a {
  font: inherit;
  letter-spacing: 0;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.weather-app {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 58px;
  padding: 7px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

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

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 6px;
  background: var(--ink);
  color: #ffffff;
}

.brand-icon svg {
  width: 21px;
  height: 21px;
  stroke-width: 1.8;
}

.brand h1,
.brand p,
.section-heading h2,
.section-heading p,
.detail-heading h2,
.detail-heading p,
.panel-title h3,
.source-section h2,
.source-section p {
  margin: 0;
}

.brand h1 {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
}

.brand p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  margin-left: auto;
}

.update-status {
  max-width: 300px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.header-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-muted);
}

.header-button.primary {
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
}

.header-button svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.9;
}

.header-button.is-loading svg {
  animation: spin 0.9s linear infinite;
}

main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.official-band,
.summary-section,
.detail-section,
.source-section {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.official-band,
.summary-section,
.detail-section {
  margin-bottom: 14px;
}

.section-heading,
.detail-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 16px 12px;
}

.section-heading h2,
.detail-heading h2,
.source-section h2 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.section-heading h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
}

.section-heading p,
.detail-heading p,
.source-section p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.compact-heading {
  align-items: center;
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #176fb3;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.source-link svg {
  width: 14px;
  height: 14px;
}

.official-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.9fr) minmax(240px, 0.8fr);
  min-height: 116px;
  border-top: 1px solid var(--border);
}

.station-now,
.official-day,
.alarm-list {
  min-width: 0;
  padding: 14px 16px;
}

.official-day,
.alarm-list {
  border-left: 1px solid var(--border);
}

.station-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.station-temperature {
  min-width: 84px;
}

.station-temperature strong {
  display: block;
  font-size: 32px;
  font-weight: 650;
  line-height: 1;
}

.station-temperature span,
.metric-label,
.official-day-label,
.alarm-empty {
  color: var(--muted);
  font-size: 11px;
}

.station-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 11px;
  width: 100%;
}

.metric-value {
  display: block;
  margin-top: 3px;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.25;
}

.official-day-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
}

.official-day-main strong {
  font-size: 21px;
  line-height: 1.15;
}

.official-day-main span {
  color: var(--red);
  font-size: 20px;
  font-weight: 650;
}

.official-day-wind {
  margin-top: 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.alarm-list {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
}

.alarm-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: #a93b32;
  font-size: 11px;
  line-height: 1.45;
}

.alarm-item svg {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  margin-top: 1px;
}

.alarm-empty {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--green);
}

.alarm-empty svg {
  width: 16px;
  height: 16px;
}

.date-rail {
  display: grid;
  grid-template-columns: repeat(7, minmax(110px, 1fr));
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.date-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 110px;
  height: 48px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.date-button:hover {
  border-color: var(--border-strong);
}

.date-button.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
}

.date-button strong {
  font-size: 13px;
}

.date-button span {
  font-size: 11px;
}

.model-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
}

.model-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot.point {
  background: var(--cyan);
}

.legend-dot.cma {
  background: var(--red);
}

.legend-dot.ecmwf {
  background: var(--amber);
}

.table-shell {
  overflow: auto;
  border-top: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.summary-table {
  min-width: 830px;
}

.summary-table tbody tr {
  cursor: pointer;
}

.summary-table tbody tr:hover,
.summary-table tbody tr.is-selected {
  background: #f4f8f8;
}

.summary-table tbody tr.is-selected td:first-child {
  box-shadow: inset 3px 0 var(--cyan);
}

.summit-name-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.summit-name-button strong,
.data-main {
  display: block;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.25;
}

.summit-name-button span,
.data-sub {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.risk-label {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.25;
}

.risk-label.is-watch {
  border-color: #e5b980;
  background: #fff8ed;
  color: #9a5b0e;
}

.risk-label.is-high {
  border-color: #e4aaa7;
  background: #fff2f1;
  color: #a53b34;
}

.detail-heading {
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.summit-control {
  display: inline-grid;
  grid-template-columns: repeat(5, minmax(58px, 1fr));
  min-width: 330px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-muted);
}

.summit-control button {
  height: 31px;
  padding: 0 10px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
}

.summit-control button.is-active {
  background: var(--ink);
  color: #ffffff;
}

.model-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
}

.model-summary {
  min-width: 0;
  padding: 13px 16px;
}

.model-summary + .model-summary {
  border-left: 1px solid var(--border);
}

.model-summary-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.model-summary-heading strong {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.model-summary-heading span {
  color: var(--muted);
  font-size: 9px;
}

.model-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.model-summary-grid strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.35;
}

.model-accent {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.model-accent.point {
  background: var(--cyan);
}

.model-accent.cma {
  background: var(--red);
}

.model-accent.ecmwf {
  background: var(--amber);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
}

.chart-panel {
  min-width: 0;
  padding: 13px 10px 7px;
}

.chart-panel + .chart-panel {
  border-left: 1px solid var(--border);
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 6px;
}

.panel-title h3 {
  font-size: 12px;
  font-weight: 700;
}

.panel-title span {
  color: var(--muted);
  font-size: 9px;
}

.weather-chart {
  width: 100%;
  height: 228px;
}

.hourly-section .section-heading {
  padding-top: 13px;
  padding-bottom: 10px;
}

.hourly-table {
  min-width: 980px;
}

.hourly-table td {
  padding-top: 8px;
  padding-bottom: 8px;
}

.hour-time {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  white-space: nowrap;
}

.weather-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.weather-mark {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-strong);
}

.weather-mark.rain {
  background: var(--blue);
}

.weather-mark.storm {
  background: var(--purple);
}

.hour-model {
  white-space: nowrap;
}

.hour-model strong {
  font-size: 11px;
}

.hour-model span {
  color: var(--muted);
  font-size: 10px;
}

.source-section {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1.8fr);
  gap: 28px;
  padding: 16px;
}

.source-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 20px;
}

.source-item a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
  font-size: 11px;
  font-weight: 650;
  text-decoration: none;
}

.source-item a:hover {
  color: #176fb3;
}

.source-item a svg {
  width: 12px;
  height: 12px;
}

.source-item p {
  margin-top: 2px;
  font-size: 10px;
}

.error-banner {
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid #e5b980;
  border-radius: 5px;
  background: #fff8ed;
  color: #87500c;
  font-size: 11px;
  line-height: 1.5;
}

.empty-inline {
  display: flex;
  align-items: center;
  min-height: 70px;
  color: var(--muted);
  font-size: 11px;
}

.loading-layer {
  position: fixed;
  inset: 58px 0 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(244, 246, 246, 0.82);
  color: var(--muted);
  font-size: 12px;
  backdrop-filter: blur(2px);
}

.spinner {
  width: 19px;
  height: 19px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.toast-region {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: min(360px, calc(100vw - 32px));
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--ink);
  box-shadow: var(--shadow);
  color: #ffffff;
  font-size: 11px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1060px) {
  .official-layout {
    grid-template-columns: 1fr 1fr;
  }

  .alarm-list {
    grid-column: 1 / -1;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .chart-panel + .chart-panel {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .weather-chart {
    height: 240px;
  }
}

@media (max-width: 760px) {
  .app-header {
    padding: 7px 10px;
  }

  .brand p,
  .update-status,
  .header-button span {
    display: none;
  }

  .header-button {
    width: 34px;
    padding: 0;
  }

  main {
    padding: 10px;
  }

  .section-heading,
  .detail-heading {
    align-items: flex-start;
    padding: 13px 12px 10px;
  }

  .official-layout,
  .model-strip,
  .source-section {
    grid-template-columns: 1fr;
  }

  .official-day,
  .alarm-list,
  .model-summary + .model-summary {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .alarm-list {
    grid-column: auto;
  }

  .station-now,
  .official-day,
  .alarm-list,
  .model-summary {
    padding: 12px;
  }

  .date-rail {
    grid-template-columns: repeat(7, 108px);
  }

  .model-legend {
    display: none;
  }

  .detail-heading {
    flex-direction: column;
  }

  .summit-control {
    width: 100%;
    min-width: 0;
  }

  .summit-control button {
    padding: 0 6px;
  }

  .source-section {
    gap: 14px;
    padding: 13px;
  }

  .source-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 440px) {
  .brand h1 {
    max-width: 180px;
    overflow: hidden;
    font-size: 15px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .station-row {
    flex-direction: column;
  }

  .station-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .model-summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .weather-chart {
    height: 220px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
