/* Loaded before the legacy inline styles; scoped selectors keep both views coherent. */
html { scroll-behavior: smooth; }
html:root { --bg: #f4f7f8; --card: #fff; --text: #173839; --navy: #163b3b; --sub: #607777; --border: #d9e3e2; --accent: #087c6a; --accent-text: #087c6a; --shadow: none; --shadow-hover: none; }
html body { background: #f4f7f8; color: #173839; font-size: 14px; }
html header { max-width: 1280px; padding: 24px 32px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid #d9e3e2; }
html header h1 { font-family: inherit; font-size: 16px; letter-spacing: -.04em; }
html header h1::before { display: none; }
html header .badge { font-size: 12px; letter-spacing: .07em; color: #087c6a; border-color: #087c6a; }
html main { max-width: 1280px; padding: 28px 32px 60px; }
html h2 { font-family: inherit; }
html .card { border-radius: 12px; }
html .field label, html .field .fieldlabel { font-size: 14px; text-transform: none; letter-spacing: 0; color: #536d6b; }
html select { background-color: #fff; min-height: 44px; font-size: 14px; }
html button.primary { background: #087c6a; box-shadow: none; min-height: 44px; }
html button.primary:hover { background: #066656; box-shadow: none; transform: none; }
html .note { font-size: 13px; }
html th { font-size: 13px; background: #edf3f2; border-color: #d9e3e2; }
html th[data-sort]:hover { background: #deeeea; }
html tbody tr:hover td { background: #f0f7f5; }
html footer { font-size: 13px; }
html .range-slider input[type="range"]:focus-visible { outline: 2px solid #087c6a; outline-offset: 5px; }
html .rs-ticks { font-size: 12px; }
html .rs-ticks span { line-height: 1.4; }
html .range-slider { width: 290px; height: 40px; margin: 2px 8px 0; }
html .age-label { color: #087c6a; }
.analysis-link, .comparison-heading a { color: #376a64; font-size: 14px; text-underline-offset: 5px; white-space: nowrap; }
.map-explorer { margin-bottom: 48px; }
.map-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 4px; color: #637c79; font-size: 13px; font-weight: 500; letter-spacing: .08em; }
.map-heading h2 { margin: 0; font-size: 22px; line-height: 1.3; letter-spacing: -.02em; }
.snapshot-date { margin: 0 0 3px; color: #617a77; font-size: 14px; }
.map-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 20px 36px; background: #fff; border: 1px solid #d9e3e2; border-radius: 12px 12px 0 0; padding: 17px 24px; }
.map-toolbar .ward-select-field { margin-left: auto; }
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 350px; background: #fff; border: 1px solid #d9e3e2; border-top: 0; border-radius: 0 0 12px 12px; overflow: hidden; }
.map-canvas { background: #f6faf9; position: relative; min-width: 0; display: flex; flex-direction: column; padding: 20px 18px 16px; }
.map-hint { margin: 0 6px 0; color: #627e79; font-size: 13px; }
.touch-hint { display: none; }
.ward-map { width: 100%; margin: auto 0; }
.ward-map svg { display: block; width: 100%; height: auto; max-height: 660px; overflow: visible; }
.ward-region { cursor: pointer; outline: none; }
.ward-region path { stroke: #fff; stroke-width: 2.4; stroke-linejoin: round; transition: fill .15s, stroke .15s; }
.ward-labels, .ward-labels text { pointer-events: none; }
.ward-labels text { text-anchor: middle; font-family: "Noto Sans JP", sans-serif; paint-order: stroke; }
.ward-label { font-weight: 500; font-size: 12px; }
.ward-label-group.is-highlighted .ward-label { font-weight: 700; }
.ward-value { font-weight: 400; font-size: 10px; }
.ward-highlights { pointer-events: none; }
.ward-highlight { fill: none; stroke: #123f38; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }
.ward-highlight.is-hovered { stroke-width: 2.5; }
.map-water-label { fill: #91aaa8; font-size: 17px; letter-spacing: 5px; }
.map-compass { fill: #7b9490; font-size: 16px; }
.map-legend { margin: 8px auto; width: min(100%, 380px); font-size: 13px; color: #57716d; text-align: center; }
.legend-scale { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.legend-gradient { display: inline-block; height: 9px; flex: 1; border-radius: 10px; background: linear-gradient(90deg,#e1eee7,#07584e); }
.legend-missing { font-size: 12px; margin: 5px 0 0; }
.map-attribution { margin: 6px 0 0; text-align: center; font-size: 12px; color: #718783; }
.map-attribution a { color: inherit; }
.map-tooltip { position: fixed; left: 0; top: 0; z-index: 10; pointer-events: none; width: 282px; max-width: calc(100vw - 16px); color: #173839; font-size: 12px; }
.map-tooltip-card { padding: 14px 16px; border: 1px solid #c9dcd5; border-radius: 10px; background: #fff; box-shadow: 0 12px 35px #17383925; animation: ward-chart-rise 260ms cubic-bezier(.16,1,.3,1) both; }
.map-tooltip[hidden] { display: none; }
.map-tooltip strong { font-size: 14px; display: block; margin-bottom: 6px; }
.map-tooltip p { margin: 3px 0; display: flex; justify-content: space-between; gap: 10px; }
.map-tooltip small { display: block; color: #66837b; margin-top: 10px; }
.tooltip-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.tooltip-heading > span { color: #688279; font-size: 12px; }
.map-tooltip .tooltip-main { align-items: baseline; margin: 0 0 9px; }
.tooltip-main b { color: #075e50; font-size: 21px; font-variant-numeric: tabular-nums; }
.tooltip-main b span { font-size: 12px; font-weight: 400; }
.tooltip-chart { border-top: 1px solid #e4ece8; border-bottom: 1px solid #e4ece8; padding: 9px 0; margin-bottom: 9px; }
.tooltip-chart-heading, .tooltip-chart-dates { display: flex; justify-content: space-between; gap: 10px; color: #668075; font-size: 11px; }
.tooltip-chart-heading { margin-bottom: 5px; }
.trend-change { display: inline-block; font-size: 12px; font-weight: 700; line-height: 1.5; font-variant-numeric: tabular-nums; padding: 2px 6px; border-radius: 4px; background: #edf2ef; color: #536d6b; white-space: nowrap; }
.trend-change[hidden] { display: none; }
.trend-change.is-up { color: #ad3d2b; background: #fcf0ec; }
.trend-change.is-down { color: #2d659b; background: #edf3fa; }
.tooltip-chart svg { width: 100%; height: auto; display: block; animation: ward-chart-rise 420ms cubic-bezier(.16,1,.3,1) 50ms both; }
.tooltip-chart-grid path { stroke: #e5eee8; stroke-width: 1; fill: none; }
.tooltip-chart-axis text { fill: #6c8278; font-size: 10px; text-anchor: end; }
.tooltip-chart-line polyline { fill: none; stroke: #087c6a; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 0; animation: ward-line-draw 620ms cubic-bezier(.22,.61,.36,1) 60ms both; }
.tooltip-chart-line circle { fill: #087c6a; stroke: #fff; stroke-width: 1; animation: ward-point-in 180ms ease-out 460ms both; }
@keyframes ward-chart-rise {
  from { opacity: 0; transform: translate3d(0, 14px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes ward-line-draw {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
@keyframes ward-point-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.tooltip-chart-dates { padding-left: 38px; padding-right: 8px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tooltip-chart-dates.is-single { justify-content: center; }
.tooltip-chart-note, .tooltip-chart-empty { color: #72877d; font-size: 11px; line-height: 1.6; margin-top: 7px; }
.tooltip-chart-empty { padding: 18px 0; text-align: center; }
.ward-detail { padding: 25px 25px 24px; border-left: 1px solid #d9e3e2; min-width: 0; }
.detail-heading { display: flex; align-items: center; justify-content: space-between; }
.detail-heading h3 { font-size: 20px; line-height: 1.3; letter-spacing: -.04em; margin: 2px 0; }
.detail-heading h3:focus { outline: none; }
.detail-code { border: 1px solid #dce9e2; border-radius: 5px; padding: 3px 8px; font-size: 12px; color: #58756b; }
.detail-band { font-size: 13px; color: #657e77; margin: 9px 0 22px; }
.ward-primary p { font-size: 14px; margin: 0; color: #486a61; }
.ward-primary strong { font-size: 28px; line-height: 1.35; letter-spacing: -.045em; font-variant-numeric: tabular-nums; margin-right: 8px; color: #075e50; }
.ward-primary > span { color: #637b74; font-size: 13px; }
.ward-stats { margin: 13px 0 0; }
.ward-stats > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 9px 0; border-bottom: 1px solid #edf2ef; }
.ward-stats dt { color: #637b75; font-size: 14px; }
.ward-stats dd { font-size: 16px; font-weight: 700; margin: 0; font-variant-numeric: tabular-nums; }
.ward-stats dd span { font-size: 12px; font-weight: 400; margin-left: 4px; }
.detail-message { color: #6a7974; font-size: 13px; margin: 9px 0; }
.detail-trend { margin-top: 21px; }
.detail-trend h4 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ward-detail h4 { font-size: 14px; margin: 0 0 9px; }
#wardTrend { height: 110px; }
#trendNote { font-size: 13px; line-height: 1.7; color: #71857d; margin: 3px 0 16px; }
.detail-compare { width: 100%; font-size: 14px !important; display: flex; justify-content: space-between; align-items: center; padding: 10px 13px !important; }
.town-section { margin-top: 26px; }
.town-section h4 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.town-section h4 span { color: #6d837b; font-size: 12px; font-weight: 400; }
.town-row { display: flex; width: 100%; justify-content: space-between; gap: 12px; align-items: center; font: inherit; font-size: 14px; background: transparent; border: 0; border-bottom: 1px solid #e8efeb; color: #264e43; cursor: pointer; text-align: left; padding: 9px 0; }
.town-row:hover { background: #f2f8f4; }
.town-row b { font-variant-numeric: tabular-nums; }
.town-row small { font-size: 12px; color: #6a8277; font-weight: 400; margin-left: 7px; }
.town-section details { font-size: 13px; color: #476d5e; }
.town-section summary { margin-top: 13px; cursor: pointer; }
.town-empty { font-size: 14px; color: #647b72; }
.map-footnote { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; font-size: 12px; color: #647973; margin-top: 12px; }
.map-footnote p { margin: 0; }
.map-footnote details { max-width: 340px; }
.map-footnote summary { cursor: pointer; white-space: nowrap; }
.map-footnote details p { margin-top: 8px; }
.comparison-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin: 0 0 20px; scroll-margin-top: 24px; }
.comparison-heading h2 { margin: 0; font-size: 20px; }
.comparison-heading a { font-size: 13px; }
@media (max-width: 1050px) {
  html header, html main { padding-left: 22px; padding-right: 22px; }
  .map-layout { grid-template-columns: minmax(0, 1fr) 310px; }
  .ward-detail { padding: 22px 18px; }
  .map-toolbar { gap: 16px 22px; padding: 16px 20px; }
  html .range-slider { width: 250px; }
  .ward-label { font-size: 14px; }
  .ward-value { display: none; }
}
@media (max-width: 780px) {
  html header { padding: 18px; }
  html header h1 { font-size: 16px; }
  html header .badge { display: none; }
  .analysis-link { font-size: 12px; }
  html main { padding: 23px 16px 40px; }
  .map-heading h2 { font-size: 20px; }
  .snapshot-date { font-size: 12px; }
  .map-layout { grid-template-columns: 1fr; }
  .map-canvas { padding: 18px 8px 14px; }
  .map-toolbar { gap: 17px; padding: 16px; }
  .map-toolbar .field:first-child { flex: 1; }
  .map-toolbar .age-field { order: 3; flex: 0 0 100%; }
  html .range-slider { width: calc(100% - 16px); margin-bottom: 4px; }
  .ward-detail { border-left: 0; border-top: 1px solid #d9e3e2; padding: 24px; scroll-margin-top: 16px; }
  .map-footnote { flex-direction: column; gap: 6px; }
  .map-hint { text-align: center; font-size: 12px; }
  .ward-label { font-size: 16px; }
  .ward-value { display: none; }
  .map-legend { width: min(85%, 380px); }
  .map-attribution { font-size: 12px; }
  .comparison-heading h2 { font-size: 18px; }
  html .card { padding: 18px 14px; }
  html .controls { align-items: stretch; }
  html .controls .field { flex: 1 1 120px; min-width: 0; }
  html .controls select { width: 100%; }
  html .table-scroll { overflow: auto; }
}
@media (hover: none) {
  .desktop-hint { display: none; }
  .touch-hint { display: inline; }
  .map-tooltip { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ward-region path { transition: none; }
  .map-tooltip-card, .tooltip-chart svg, .tooltip-chart-line polyline, .tooltip-chart-line circle { animation: none; }
}
