.viz-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin: 24px 0 48px; }
.viz-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 24px; flex-wrap: wrap; }
.viz-head h2 { margin: 0; font-size: 1.15rem; }
.viz-sub { margin: 2px 0 0; font-size: 0.9rem; }
.viz-controls { display: flex; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  font: inherit; font-size: 0.85rem; padding: 6px 12px; border: 0; background: var(--surface); color: var(--muted); cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-checked="true"] { background: var(--tag-bg); color: var(--text); font-weight: 700; }

.chart { position: relative; margin-top: 16px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--border); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 12px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: 0.1; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart .dot.zero { opacity: 0; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 1; min-width: 180px; max-width: 280px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 0.8rem; box-shadow: 0 4px 16px rgb(0 0 0 / 0.12);
}
.tooltip .tt-month { color: var(--muted); }
.tooltip .tt-value { font-size: 1rem; font-weight: 700; margin: 2px 0 4px; font-variant-numeric: tabular-nums; }
.tooltip ul { margin: 0; padding-left: 1.1em; }
.tooltip li { margin: 1px 0; }

.viz-note { font-size: 0.8rem; margin: 8px 0 0; }
.viz-table { margin-top: 12px; font-size: 0.85rem; }
.viz-table summary { cursor: pointer; color: var(--muted); }
.viz-table .table-scroll { overflow-x: auto; }
.viz-table table { width: 100%; min-width: 480px; border-collapse: collapse; margin-top: 8px; }
.viz-table th, .viz-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.viz-table td:first-child { white-space: nowrap; }
.viz-table td.num, .viz-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---- ランキング ---- */
.ranking-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 24px 0 0; }
.ranking-scope { margin: 0; font-size: 0.85rem; }
.ranking-controls ~ .viz-card { margin: 16px 0 0; }
.ranking { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 4px; }
.rank-row {
  display: grid; grid-template-columns: 2em minmax(7em, 14em) 1fr; align-items: center; gap: 8px 12px;
  padding: 6px 4px; border-radius: 6px; color: inherit; text-decoration: none;
}
.rank-row:hover, .rank-row:focus-visible { background: var(--tag-bg); outline: none; }
.rank-no { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; font-size: 0.85rem; }
.rank-label { font-size: 0.9rem; line-height: 1.35; overflow-wrap: anywhere; }
.rank-label small { display: block; color: var(--muted); font-size: 0.75rem; }
.rank-bar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rank-bar .bar { height: 14px; min-width: 2px; background: var(--accent); border-radius: 0 4px 4px 0; flex: none; }
.rank-bar .val { font-size: 0.85rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.more {
  font: inherit; font-size: 0.85rem; margin-top: 8px; padding: 6px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer;
}
.ranking-note { margin: 16px 0 48px; }
main { position: relative; }
@media (max-width: 640px) {
  .rank-row { grid-template-columns: 1.6em 1fr; }
  .rank-bar { grid-column: 2; }
}

/* ---- 地域別マップ（都道府県タイルグリッド） ---- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.map-select select {
  font: inherit; font-size: 0.85rem; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
}
.map { position: relative; margin: 16px auto 0; max-width: 640px; }
.map-grid { display: grid; grid-template-columns: repeat(13, 1fr); grid-template-rows: repeat(13, auto); gap: 3px; }
.tile {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 4px; background: var(--tag-bg); color: var(--muted); text-decoration: none; line-height: 1.1;
  font-size: clamp(0.5rem, 1.6vw, 0.72rem); min-width: 0; overflow: hidden;
}
.tile-name { white-space: nowrap; }
.tile-count { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 1.15em; }
.tile.b1, .swatch.b1 { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); color: var(--text); }
.tile.b2, .swatch.b2 { background: color-mix(in srgb, var(--accent) 45%, var(--surface)); color: var(--text); }
.tile.b3, .swatch.b3 { background: color-mix(in srgb, var(--accent) 72%, var(--surface)); color: var(--surface); }
.tile.b4, .swatch.b4 { background: var(--accent); color: var(--surface); }
a.tile:hover, a.tile:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.map-legend { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; font-size: 0.8rem; color: var(--muted); }
.map-legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 3px; background: var(--tag-bg); border: 1px solid var(--border); }
.delay-note { flex-basis: 100%; }
