:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --text: #1d1f24;
  --muted: #5d6270;
  --line: #dddad3;
  --accent: #4b3fb0;
  --accent-soft: #e9e6fa;
  --case: #d2453b;
  --case-soft: #fbe7e5;
  --notice-bg: #fff4d6;
  --notice-line: #e7c25c;
  --row-alt: #f4f2fb;
  --row-hover: #dfdafa;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(0 0 0 / 0.04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15161a;
    --surface: #1e2026;
    --surface-2: #272a31;
    --text: #e9eaee;
    --muted: #a2a7b4;
    --line: #353842;
    --accent: #a59bff;
    --accent-soft: #2c2850;
    --case: #ff7b70;
    --case-soft: #3a2222;
    --notice-bg: #33290f;
    --notice-line: #8a6d1c;
    --row-alt: #23252c;
    --row-hover: #312c5c;
    --shadow: none;
    color-scheme: dark;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", system-ui, -apple-system, "Hiragino Sans", sans-serif;
  font-size: 1rem;
  line-height: 1.75;
}

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; }

.wrap { width: min(1220px, 100% - 32px); margin-inline: auto; }

/* header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 64px;
  flex-wrap: wrap;
}
.brand {
  /* font-weight: 700; */
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
  line-height: 1.3;
}
.brand small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin: 0; padding: 0; list-style: none; }
.nav a {
  display: block;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

@media (max-width: 720px) {
  .site-header { position: static; }
  .site-header .wrap { padding-block: 12px; }
  .nav { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .nav a { white-space: nowrap; }
}

/* archive notice */
.notice {
  background: var(--notice-bg);
  border-bottom: 1px solid var(--notice-line);
  font-size: 14px;
}
.notice .wrap { padding-block: 10px; }
.notice strong { margin-right: .5em; }

main { padding-block: 40px 64px; }

h1 { font-size: clamp(24px, 4vw, 32px); line-height: 1.4; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 0 0 16px; }
.lead { color: var(--muted); margin: 0 0 32px; }

section + section { margin-top: 48px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card h2 { font-size: 17px; }
.note { font-size: 13px; color: var(--muted); margin: 12px 0 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }

/* stats */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.stat dt { font-size: 13px; color: var(--muted); }
.stat dd { margin: 4px 0 0; font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat dd small { font-size: 14px; font-weight: 400; margin-left: 2px; }
.stat.is-case dd { color: var(--case); }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 7.5em 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.timeline li:first-child { border-top: 0; }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .timeline li { grid-template-columns: 1fr; gap: 0; } }

/* charts */
.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { fill: var(--muted); font-size: 12px; font-family: inherit; }
.chart .axis { stroke: var(--line); }
.chart .bar { fill: var(--case); }
.chart .bar:hover { fill: var(--accent); }
.chart .bar-alt { fill: var(--accent); }
.chart .val { fill: var(--text); font-variant-numeric: tabular-nums; }
.chart-area { max-height: 560px; overflow-y: auto; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; border: 1px solid transparent;
  background: var(--accent); color: #fff; font-weight: 700; text-decoration: none; font-size: 15px;
  cursor: pointer; font-family: inherit;
}
@media (prefers-color-scheme: dark) { .btn { color: #15161a; } }
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn-ghost:disabled { opacity: .4; cursor: default; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

/* list page */
.filters { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }
.filters label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.filters input, .filters select {
  font: inherit; font-size: 15px; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; width: 100%;
}
.filters .wide { grid-column: span 2; }
@media (max-width: 520px) { .filters .wide { grid-column: auto; } }
.result-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 20px 0 12px; font-size: 14px; color: var(--muted); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.cases { width: 100%; border-collapse: collapse; font-size: 14px; }
.cases th, .cases td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.cases th { background: var(--surface-2); font-weight: 700; white-space: nowrap; position: sticky; top: 0; }
.cases th button { all: unset; cursor: pointer; }
.cases th button::after { content: " ↕"; color: var(--muted); font-weight: 400; }
.cases th[aria-sort="ascending"] button::after { content: " ↑"; color: var(--accent); }
.cases th[aria-sort="descending"] button::after { content: " ↓"; color: var(--accent); }
.cases tbody tr:nth-child(even) { background: var(--row-alt); }
.cases tbody tr { transition: background-color .12s; }
.cases tbody tr:hover, .cases tbody tr:focus-within { background: var(--row-hover); box-shadow: inset 4px 0 0 var(--accent); }
.cases td.num, .cases td.date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.cases td.detail { min-width: 16em; }
.tag { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 12px; background: var(--surface-2); white-space: nowrap; }
.tag.is-mild { background: var(--accent-soft); color: var(--accent); }
.tag.is-severe { background: var(--case-soft); color: var(--case); }

@media (max-width: 720px) {
  .table-wrap { border: 0; background: transparent; }
  table.cases, .cases tbody, .cases tr, .cases td { display: block; }
  .cases thead { display: none; }
  .cases tr { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
  .cases td { border: 0; padding: 2px 0; display: flex; gap: 12px; }
  .cases td::before { content: attr(data-label); flex: 0 0 4.5em; color: var(--muted); font-size: 12px; padding-top: 2px; }
  .cases td.detail { min-width: 0; }
}

.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 20px; font-size: 14px; }

/* links page */
.area-block h2 { display: flex; align-items: center; gap: 10px; }
.area-block h2::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--accent); }
.city-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.city-list a { display: block; padding: 10px 14px; background: var(--surface-2); border-radius: 10px; text-decoration: none; color: var(--text); }
.city-list a:hover { background: var(--accent-soft); color: var(--accent); }

/* materials */
.poster figure { margin: 0; }
.poster img { border-radius: 10px; border: 1px solid var(--line); display: block; margin-bottom: 12px; aspect-ratio: 1; object-fit: cover; width: 100%; }
.poster figcaption { font-weight: 700; }

.ad { margin: 48px 0 0; }

.site-footer { border-top: 1px solid var(--line); padding-block: 24px; font-size: 13px; color: var(--muted); }
.site-footer .wrap { display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* 公表日別（年タブ＋月ごとの行） */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  font: inherit; font-size: 14px; padding: 6px 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
}
.tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
@media (prefers-color-scheme: dark) { .tabs button[aria-selected="true"] { color: #15161a; } }
#chart-daily { overflow: visible; }
.yc-summary { margin: -6px 0 16px; }
.yc { display: grid; grid-template-columns: 3.2em 1fr; column-gap: 8px; }
.yc-y { position: relative; }
.yc-ylabel { position: absolute; right: 0; transform: translateY(50%); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.yc-plot { position: relative; height: clamp(240px, 40vw, 380px); }
.yc-grid { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.yc-bars { position: absolute; inset: 0; display: grid; gap: 1px; align-items: end; }
.yc-bar { background: var(--case); border-radius: 2px 2px 0 0; }
.yc-bar:hover { background: var(--accent); }
.yc-x { position: relative; height: 24px; }
.yc-tick { position: absolute; top: 4px; transform: translateX(-50%); font-size: 12px; color: var(--muted); white-space: nowrap; }
@media (max-width: 520px) {
  .yc-tick { font-size: 10px; }
  .yc-bars { gap: 0; }
}

.more { text-align: center; padding: 20px 0; font-size: 14px; color: var(--muted); }

/* サイトID */
.site-id { display: flex; align-items: center; padding-right: 16px; border-right: 1px solid var(--line); }
.site-id img { display: block; width: 200px; height: auto; }
.site-header .brand { margin-left: 0; }
@media (max-width: 520px) {
  .site-id { border-right: 0; padding-right: 0; width: 100%; margin-bottom: -6px; }
  .site-id img { width: 84px; }
  .brand { font-size: 15px; }
}

/* 市町村リンク：エリア地図 */
.area-block { display: grid; grid-template-columns: 180px 1fr; gap: 28px; align-items: start; }
.area-map { width: 100%; height: auto; display: block; }
.area-block.is-kenou { --area: #bf3050; }
.area-block.is-kennan { --area: #6385bc; }
.area-block.is-kenhoku { --area: #2da055; }
.area-block.is-kentou { --area: #a182b0; }
.area-block.is-kensei { --area: #e09a17; }
.area-block h2::before { background: var(--area, var(--accent)); width: 14px; height: 14px; }
.area-block { border-top: 4px solid var(--area, var(--accent)); }
@media (max-width: 640px) {
  .area-block { grid-template-columns: 110px 1fr; gap: 16px; }
  .city-list { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .area-block { grid-template-columns: 1fr; }
  .area-map { width: 150px; margin-inline: auto; }
}
