:root {
  --background: #fafaf8;
  --foreground: #1a1a1a;
  --muted: #f2f5f4;
  --muted-2: #eef3f7;
  --muted-foreground: #646b70;
  --accent: #9d7427;
  --accent-2: #116466;
  --accent-3: #355c7d;
  --danger: #b7412e;
  --border: #e2e0da;
  --card: #ffffff;
  --ring: #9d7427;
  --shadow: 0 18px 45px rgba(38, 42, 46, 0.08);
  color-scheme: light;
  font-family: "Source Sans 3", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--foreground);
  background:
    radial-gradient(circle at top left, rgba(157, 116, 39, 0.12), transparent 30rem),
    radial-gradient(circle at top right, rgba(17, 100, 102, 0.1), transparent 26rem),
    linear-gradient(180deg, #fffefb 0%, var(--background) 40%, #f5f6f2 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: progress;
  opacity: 0.65;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 0.9rem;
  color: var(--foreground);
  background: #fff;
  outline: none;
}

input::placeholder {
  color: #aeb4b8;
  opacity: 1;
}

input:focus,
select:focus,
button:focus-visible {
  border-color: var(--ring);
  outline: 3px solid rgba(157, 116, 39, 0.18);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.control-panel,
.summary-grid article,
.filters,
.qpf-legend,
.forecast-window,
.city-card,
.details,
.table-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.control-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: end;
  padding: clamp(24px, 4vw, 44px);
}

.title-block {
  max-width: 680px;
}

.title-actions {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 22px;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2 {
  font-family: "Noto Serif TC", serif;
}

h1 {
  margin: 0;
  font-size: 3.4rem;
  letter-spacing: 0;
  line-height: 1.12;
  white-space: nowrap;
}

h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2.6vw, 2rem);
  line-height: 1.25;
}

.title-block p:not(.eyebrow),
.notes p,
.status,
.auth-hint,
.towns,
.time {
  color: var(--muted-foreground);
  line-height: 1.75;
}

.query-form {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 8px;
  color: #313437;
  font-weight: 700;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.save-button {
  min-width: 130px;
}

.primary,
.secondary {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 1rem;
  font-weight: 700;
}

.primary {
  border: 1px solid #1a1a1a;
  color: #fff;
  background: #1a1a1a;
}

.secondary {
  border: 1px solid var(--border);
  color: #303438;
  background: #fff;
}

.refresh-button {
  min-width: 190px;
  min-height: 54px;
  padding: 0 1.4rem;
  font-size: 1.05rem;
  box-shadow: 0 12px 24px rgba(26, 26, 26, 0.12);
}

.refresh-button:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}

.source-note {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.source-note span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  color: var(--muted-foreground);
  background: #fff;
  font-size: 0.92rem;
}

.status {
  grid-column: 1 / -1;
  margin: 0;
  border-left: 4px solid var(--accent-3);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  background: var(--muted-2);
}

.status[hidden] {
  display: none;
}

.status[data-type="success"] {
  border-color: var(--accent-2);
}

.status[data-type="warning"] {
  border-color: var(--accent);
}

.status[data-type="error"] {
  border-color: var(--danger);
}

.auth-hint {
  grid-column: 1 / -1;
  margin: 0;
  border: 1px solid rgba(157, 116, 39, 0.24);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  background: rgba(157, 116, 39, 0.08);
  color: #5f5138;
}

.auth-hint[hidden] {
  display: none;
}

.query-form {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

[data-requires-token][hidden] {
  display: none;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.summary-grid article {
  padding: 20px;
}

.summary-grid span,
.city-card dt {
  color: var(--muted-foreground);
  font-size: 0.88rem;
  font-weight: 700;
}

.city-card dt {
  color: #8b9195;
  font-weight: 600;
}

.summary-grid strong {
  display: block;
  margin-top: 0.35rem;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
}

.summary-grid .summary-list {
  white-space: pre-line;
  font-size: clamp(0.9rem, 1.25vw, 1.05rem);
  line-height: 1.55;
}

.filters {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.85fr;
  gap: 28px;
  margin-top: 18px;
  padding: 20px 22px;
  align-items: start;
}

.filters label {
  grid-template-rows: auto 38px;
  height: 100%;
}

.filters input,
.filters select {
  min-height: 38px;
  padding: 0 0.75rem;
}

.field-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.range-value {
  color: var(--accent-2);
  font-weight: 700;
}

.range-field input[type="range"] {
  width: 100%;
  min-height: 38px;
  height: 38px;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
}

.range-field input[type="range"]:focus {
  border-color: transparent;
  outline: none;
}

.range-field input[type="range"]:focus-visible {
  outline: 3px solid rgba(157, 116, 39, 0.18);
  outline-offset: 4px;
}

.range-field input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 4px;
  border: 1px solid rgba(100, 107, 112, 0.42);
  border-radius: 999px;
  background: #dfe5e2;
}

.range-field input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 999px;
  margin-top: -7px;
  background: #137876;
  box-shadow: 0 0 0 2px #fff;
  -webkit-appearance: none;
  appearance: none;
}

.range-field input[type="range"]::-moz-range-track {
  width: 100%;
  height: 4px;
  border: 1px solid rgba(100, 107, 112, 0.42);
  border-radius: 999px;
  background: #dfe5e2;
}

.range-field input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 999px;
  background: #137876;
  box-shadow: 0 0 0 2px #fff;
}

.qpf-legend {
  display: grid;
  grid-template-columns: minmax(170px, 0.3fr) 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
  padding: 14px 18px;
}

.qpf-legend h2 {
  font-size: clamp(1.25rem, 2.2vw, 1.7rem);
}

.qpf-legend ul {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.qpf-legend li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.qpf-legend strong {
  font-size: 0.88rem;
}

.qpf-legend li span:last-child {
  grid-column: 2;
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.legend-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
}

.forecast-window {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin-top: 18px;
  border-color: rgba(17, 100, 102, 0.28);
  border-left: 5px solid var(--accent-2);
  padding: 15px 18px;
  background: linear-gradient(90deg, rgba(17, 100, 102, 0.1), rgba(255, 255, 255, 0.94));
  box-shadow: 0 14px 34px rgba(17, 100, 102, 0.1);
}

.forecast-window span {
  color: #475056;
  font-size: 0.9rem;
  font-weight: 700;
}

.forecast-window strong {
  color: var(--accent-2);
  font-size: 1.08rem;
  letter-spacing: 0.01em;
}

.level-dry {
  background: #b9c5c7;
}

.level-light {
  background: var(--accent-3);
}

.level-steady {
  background: var(--accent);
}

.level-heavy {
  background: var(--danger);
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.city-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
}

.city-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  content: "";
  background: var(--accent-2);
}

.city-card[data-risk="高"]::before {
  background: var(--danger);
}

.city-card[data-risk="中"]::before {
  background: var(--accent);
}

.city-card[data-risk="低"]::before {
  background: var(--accent-3);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.card-head h2 {
  margin-top: 0;
  font-size: 1.45rem;
}

.card-head strong {
  color: var(--accent-2);
  font-size: 2rem;
  line-height: 1;
}

.city-card[data-risk="高"] .card-head strong {
  color: var(--danger);
}

.bar {
  height: 8px;
  margin: 18px 0;
  overflow: hidden;
  border-radius: 999px;
  background: var(--muted);
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}

dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

dt,
dd {
  margin: 0;
}

dd {
  font-weight: 700;
}

.qpf-level,
.local-heavy {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.qpf-dry,
.qpf-unknown {
  color: #465055;
  background: #e9eeee;
}

.qpf-light {
  color: #17445f;
  background: #e8f2f8;
}

.qpf-steady {
  color: #6c4711;
  background: #f8edda;
}

.qpf-heavy,
.local-heavy {
  color: #7a2116;
  background: #f8e2de;
}

.local-heavy {
  margin-top: 0.35rem;
}

.towns {
  margin: 16px 0 0;
}

.time {
  margin: 8px 0 0;
  font-size: 0.9rem;
}

.empty {
  margin: 18px 0 0;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 24px;
  color: var(--muted-foreground);
  text-align: center;
}

.empty[hidden] {
  display: none;
}

.details {
  display: grid;
  grid-template-columns: 0.75fr 1.25fr;
  gap: 24px;
  margin-top: 32px;
  padding: clamp(22px, 4vw, 36px);
}

.notes {
  display: grid;
  gap: 12px;
}

.notes p {
  margin: 0;
}

.table-wrap {
  margin-top: 18px;
  padding: 20px;
}

.table-wrap h2 {
  margin-bottom: 16px;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted-foreground);
  font-size: 0.86rem;
}

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

@media (max-width: 980px) {
  h1 {
    font-size: 2.8rem;
  }

  .control-panel,
  .details {
    grid-template-columns: 1fr;
  }

  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .qpf-legend {
    grid-template-columns: 1fr;
  }

  .qpf-legend ul {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 2.05rem;
  }

  .title-actions {
    margin-top: 2px;
    padding-top: 20px;
  }

  .shell {
    width: min(100% - 24px, 1180px);
    padding-top: 24px;
  }

  .control-panel {
    padding: 22px;
  }

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

  .qpf-legend ul {
    grid-template-columns: 1fr;
  }

  .actions {
    display: grid;
  }

  .refresh-button {
    width: 100%;
  }
}

@media (max-width: 380px) {
  h1 {
    font-size: 1.72rem;
  }
}
