:root {
  color-scheme: light;
  --bg: #eef3f8;
  --bg-deep: #e2ebf5;
  --card: #ffffff;
  --ink: #122033;
  --ink-soft: #52637a;
  --line: #dbe5f0;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #d8f3ef;
  --blue: #2563eb;
  --blue-soft: #e4edff;
  --warn: #b45309;
  --warn-soft: #fff3dc;
  --danger: #b91c1c;
  --danger-soft: #fdeaea;
  --ok: #15803d;
  --ok-soft: #def7e7;
  --radius: 18px;
  --gap: 14px;
  --pad: 16px;
  --shadow: 0 10px 30px rgb(17 40 70 / 8%);
  --max: 880px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(1100px 620px at 85% -10%, #cfe9ff 0%, transparent 55%),
    radial-gradient(900px 540px at -15% 10%, #d9f7ef 0%, transparent 52%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(78px + env(safe-area-inset-bottom));
}

h1, h2, h3, p, dl, dd { margin: 0; }
h1 { font-size: 20px; line-height: 1.25; letter-spacing: -0.01em; }
h2 { font-size: 18px; line-height: 1.3; letter-spacing: -0.01em; }
h3 { font-size: 15px; line-height: 1.4; }
a { color: var(--blue); text-underline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  top: -60px;
  left: 12px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
}
.skip-link:focus { top: 10px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(100%, var(--max));
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) var(--pad) 12px;
  background: rgb(238 243 248 / 82%);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid rgb(255 255 255 / 60%);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-text { min-width: 0; }
.brand-text h1 { font-size: 18px; }
.brand-mark {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background:
    radial-gradient(circle at 70% 30%, #8ef0dc 0 18%, transparent 19%),
    linear-gradient(145deg, #0f766e, #12375f);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 25%), 0 8px 18px rgb(15 118 110 / 22%);
}
.brand-mark-large { width: 52px; height: 52px; border-radius: 16px; }

.muted { color: var(--ink-soft); font-size: 12.5px; }
.meta { color: var(--ink-soft); font-size: 12px; white-space: nowrap; }
.body-text { color: var(--ink); font-size: 14px; overflow-wrap: anywhere; }
.fineprint { margin-top: 10px; color: var(--ink-soft); font-size: 11.5px; line-height: 1.55; }
.error-text { color: var(--danger); font-size: 13px; }

main {
  width: min(100%, var(--max));
  margin: 0 auto;
  padding: 14px var(--pad) 8px;
}

.section { margin: 0 0 28px; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0 2px 10px;
}
.section-head h2 { flex: 1 1 auto; }

.card {
  background: var(--card);
  border: 1px solid rgb(255 255 255 / 80%);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--pad);
  margin: 0 0 var(--gap);
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.card-head h3 { min-width: 0; overflow-wrap: anywhere; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: var(--gap);
}
.stat {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 108px;
  padding: 14px 12px;
  margin: 0;
}
.stat-label { color: var(--ink-soft); font-size: 12px; }
.stat-number {
  display: flex;
  align-items: baseline;
  gap: 3px;
  min-width: 0;
}
.stat-number strong {
  font-size: clamp(22px, 6.6vw, 30px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat-number small { color: var(--ink-soft); font-size: 11px; }

.weather-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 14px;
  align-items: end;
}
.weather-temp {
  font-size: 38px;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.weather-temp small { font-size: 15px; color: var(--ink-soft); letter-spacing: 0; }
.weather-city { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.weather-desc { color: var(--ink-soft); font-size: 13px; }
.weather-side { text-align: right; color: var(--ink-soft); font-size: 12px; line-height: 1.7; }
.weather-side strong { color: var(--ink); font-weight: 600; }

.pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-neutral { background: #e8eef7; color: #4b5f78; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef3f9;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-ok { background: var(--accent-soft); color: var(--accent-strong); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

.banner {
  border-radius: 14px;
  padding: 11px 13px;
  margin: 0 0 var(--gap);
  font-size: 12.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.banner-muted { background: #eef3f9; color: var(--ink-soft); }
.banner-info { background: var(--blue-soft); color: #1d4ed8; }
.banner-warn { background: var(--warn-soft); color: #92400e; }
.banner-ok { background: var(--ok-soft); color: #166534; }
.banner-danger { background: var(--danger-soft); color: var(--danger); }

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  margin-bottom: var(--gap);
  border-radius: 14px;
  background: #e3ebf4;
}
.segment {
  min-height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.segment.is-active { background: #fff; color: var(--ink); box-shadow: 0 3px 10px rgb(17 40 70 / 8%); }

.chart-card { padding-bottom: 12px; }
.chart {
  display: block;
  width: 100%;
  height: 150px;
  touch-action: pan-y;
}

.field-group { margin: 0 0 14px; padding: 0; border: 0; min-width: 0; }
.field-group legend { margin-bottom: 7px; color: var(--ink-soft); font-size: 12px; }
.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.city-row { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { color: var(--ink-soft); font-size: 12px; }
.field input,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
  color: var(--ink);
  outline: none;
}
.field input:focus,
.field select:focus,
.choice:focus-visible,
.btn:focus-visible,
.segment:focus-visible,
.switch input:focus-visible + span {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(15 118 110 / 16%);
}
.field input:disabled,
.field select:disabled { background: #f2f5f9; color: #8a98aa; }
.field input[type="file"] { padding: 7px; font-size: 12.5px; }

.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  flex: 1 1 86px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.choice.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.choice:disabled { opacity: 0.45; cursor: not-allowed; }

.switch-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.switch { display: flex; align-items: center; gap: 10px; min-height: 32px; cursor: pointer; }
.switch-inline { flex: 0 0 auto; margin-bottom: -4px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch > span {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding-left: 48px;
  min-height: 28px;
  font-size: 13px;
  color: var(--ink);
}
.switch > span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 2px;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #cbd6e4;
  transition: background 0.16s ease;
}
.switch > span::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgb(0 0 0 / 20%);
  transition: transform 0.16s ease;
}
.switch input:checked + span::before { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:disabled + span { opacity: 0.5; }

.rule-card {
  padding: 13px;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, background 0.16s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { background: #e8eef7; color: #24405f; }
.btn-secondary:hover { background: #dce6f2; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.city-row .btn { min-height: 44px; }

.result-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdff;
}
.result-text { min-width: 0; }
.result-text strong { display: block; font-size: 13.5px; overflow-wrap: anywhere; }
.result-text span { color: var(--ink-soft); font-size: 11.5px; }
.result-item .btn { flex: 0 0 auto; min-height: 36px; padding: 7px 11px; font-size: 12px; }

.detail-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.detail-list > div { display: flex; justify-content: space-between; gap: 14px; }
.detail-list dt { color: var(--ink-soft); font-size: 12.5px; }
.detail-list dd { font-size: 12.5px; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.footer-note {
  padding: 4px 4px 20px;
  color: var(--ink-soft);
  font-size: 11.5px;
  line-height: 1.6;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 30;
  transform: translateX(-50%);
  width: min(calc(100% - 24px), 520px);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  padding: 6px;
  border: 1px solid rgb(255 255 255 / 70%);
  border-radius: 18px;
  background: rgb(255 255 255 / 88%);
  box-shadow: 0 12px 30px rgb(17 40 70 / 18%);
  backdrop-filter: blur(14px);
}
.tabbar a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 12px;
  color: var(--ink-soft);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
}
.tabbar a:hover { background: #eef3f9; color: var(--ink); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 60;
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 460px);
  padding: 11px 14px;
  border-radius: 13px;
  background: #10243d;
  color: #fff;
  box-shadow: 0 14px 34px rgb(8 20 36 / 28%);
  font-size: 12.5px;
  line-height: 1.5;
}
.toast.is-error { background: #8b1e1e; }
.toast.is-ok { background: #14532d; }

.login-page {
  display: grid;
  place-items: center;
  padding: 24px 16px;
  padding-bottom: 24px;
  background:
    radial-gradient(1000px 600px at 80% 0%, #cfe9ff 0%, transparent 55%),
    linear-gradient(180deg, #eef3f8, #dfe9f4);
}
.login-wrap { width: min(100%, 420px); }
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .brand-mark { margin: 0 auto 14px; }
.login-brand h1 { font-size: 22px; }
.login-brand p { margin-top: 5px; font-size: 13px; }
.login-card { padding: 20px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { margin-top: 4px; }
.login-wrap .footer-note { text-align: center; padding-top: 16px; }

@media (min-width: 720px) {
  body { font-size: 15.5px; }
  main { padding-top: 22px; }
  .stat-grid { gap: 14px; }
  .stat { min-height: 124px; padding: 18px; }
  .stat-number strong { font-size: 34px; }
  .card { padding: 20px; }
  .section { margin-bottom: 34px; }
  .chart { height: 190px; }
  .weather-temp { font-size: 46px; }
  .topbar { padding-top: 16px; }
}

@media (max-width: 360px) {
  :root { --pad: 13px; --gap: 11px; }
  .stat { padding: 11px 9px; min-height: 100px; }
  .stat-number strong { font-size: 22px; }
  .stat-number small { font-size: 10px; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .city-row { grid-template-columns: minmax(0, 1fr); }
  .tabbar a { font-size: 11.5px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
