@font-face {
  font-family: "LINE Seed JP";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("https://cdn.jsdelivr.net/fontsource/fonts/line-seed-jp@latest/japanese-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "LINE Seed JP";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("https://cdn.jsdelivr.net/fontsource/fonts/line-seed-jp@latest/japanese-700-normal.woff2") format("woff2");
}

@font-face {
  font-family: "LINE Seed JP";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("https://cdn.jsdelivr.net/fontsource/fonts/line-seed-jp@latest/japanese-800-normal.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --bg: #fff9e8;
  --ink: #222222;
  --muted: #666666;
  --line: #efe7c8;
  --panel: #ffffff;
  --accent: #ffd600;
  --accent-strong: #a27700;
  --accent-contrast: #222222;
  --blue: #56a6f1;
  --pink: #ff7daa;
  --green: #6fcf97;
  --orange: #f2994a;
  --minor: #56a6f1;
  --middle: #ffd600;
  --senior: #ff7daa;
  --shadow: 0 12px 28px rgba(162, 119, 0, 0.12);
  font-family: "LINE Seed JP", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 125, 170, 0.16) 0 10px, transparent 11px),
    radial-gradient(circle at 76% 8%, rgba(86, 166, 241, 0.18) 0 8px, transparent 9px),
    radial-gradient(circle at 92% 32%, rgba(111, 207, 151, 0.15) 0 14px, transparent 15px),
    radial-gradient(circle at 32% 88%, rgba(242, 153, 74, 0.11) 0 12px, transparent 13px);
  pointer-events: none;
}

.material-symbols-rounded {
  font-family: "Material Symbols Rounded";
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 1, "wght" 600, "GRAD" 0, "opsz" 24;
}

.icon-blue {
  color: var(--blue);
}

.icon-pink {
  color: var(--pink);
}

.icon-green {
  color: var(--green);
}

.icon-orange {
  color: var(--orange);
}

.app {
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 24px;
  padding: 28px 28px 116px;
}

.app > :not(.sidebar) {
  grid-column: 2;
}

#overview,
#households,
#population,
#age,
#ageRange,
#rankingPanel,
#about {
  scroll-margin-top: 32px;
}

.sidebar {
  position: sticky;
  top: 28px;
  grid-column: 1;
  grid-row: 1 / span 20;
  height: calc(100vh - 56px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
  border: 1px solid #f2e8c6;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  padding: 28px 18px;
  box-shadow: var(--shadow);
}

.brand {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
  font-size: 15px;
}

.brand-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: var(--accent);
  box-shadow: 0 10px 18px rgba(255, 214, 0, 0.25);
}

.brand-mark .material-symbols-rounded {
  color: #fff;
  font-size: 38px;
  text-shadow: 0 2px 0 rgba(162, 119, 0, 0.12);
}

.nav-toggle {
  display: none;
}

.side-nav {
  display: grid;
  align-content: start;
  gap: 10px;
}

.side-nav a {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
  padding: 0 14px;
  text-decoration: none;
}

.side-nav .material-symbols-rounded {
  flex: 0 0 auto;
  font-size: 23px;
}

.side-nav a:hover,
.side-nav a.active {
  background: var(--accent);
}

.side-nav a.active {
  font-weight: 700;
}

.side-note {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fffefa;
  padding: 14px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.mini-town {
  height: 52px;
  position: relative;
  margin-bottom: 10px;
}

.mini-town span {
  position: absolute;
  bottom: 0;
  width: 28px;
  border-radius: 8px 8px 0 0;
  background: #9ed2ff;
}

.mini-town span:nth-child(1) { left: 4px; height: 34px; }
.mini-town span:nth-child(2) { left: 38px; height: 48px; background: #6fcf97; }
.mini-town span:nth-child(3) { left: 74px; height: 26px; background: #ff7daa; }

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 4.6vw, 56px);
  line-height: 1.2;
  white-space: nowrap;
}

h2 {
  font-size: 22px;
}

.source-link {
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
}

.selection-popup {
  position: fixed;
  right: 8px;
  bottom: 8px;
  z-index: 25;
  width: min(190px, calc(100vw - 16px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 24px rgba(80, 67, 18, 0.14);
  padding: 7px 8px;
  color: var(--ink);
  font-size: 10px;
  backdrop-filter: blur(8px);
}

.selection-popup h2 {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
}

.selection-popup dl {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 7px;
  margin: 0;
}

.selection-popup dt {
  color: var(--muted);
  font-weight: 400;
}

.selection-popup dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 400;
}

a {
  color: var(--accent-strong);
  text-underline-offset: 3px;
}

.controls {
  display: grid;
  grid-template-columns: minmax(260px, auto) minmax(210px, auto) minmax(280px, 1fr);
  align-items: start;
  gap: 16px;
  margin: 28px 0 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 10px 24px rgba(162, 119, 0, 0.08);
  padding: 18px;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  margin-bottom: 10px;
}

.legacy-metric {
  display: none;
}

.metric-buttons {
  display: flex;
  flex-wrap: wrap;
  align-content: start;
  gap: 8px;
}

.metric-buttons legend,
.age-population-field legend {
  width: 100%;
}

.metric-buttons button {
  min-height: 48px;
  border-color: var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(162, 119, 0, 0.08);
}

.metric-buttons button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
}

.age-population-field {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 0;
}

.area-chip-field {
  grid-column: 3;
  grid-row: 1;
  align-self: start;
}

.area-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.area-chips button {
  min-height: 46px;
  border-color: var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 0 24px;
  box-shadow: 0 7px 16px rgba(162, 119, 0, 0.09);
}

.area-chips button.active {
  border-color: var(--accent);
  background: var(--accent);
  font-weight: 700;
}

label {
  display: grid;
  align-content: start;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.controls > label {
  align-self: start;
  grid-column: 1 / -1;
  grid-row: auto;
  order: 1;
}

.controls > label:not(.legacy-metric) {
  opacity: 0.86;
}

select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  padding: 8px 10px;
}

select[multiple] {
  min-height: 112px;
}

input[type="search"],
input[type="number"] {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 8px 10px;
}

input[type="number"] {
  max-width: 90px;
}

.compare-builder {
  display: grid;
  gap: 10px;
  align-content: start;
  position: relative;
  width: min(100%, 860px);
  max-width: 860px;
  margin-top: 18px;
}

.compare-builder > label {
  display: block;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 680px) auto;
  gap: 8px;
  width: 100%;
  max-width: 100%;
}

.search-row input {
  min-width: 0;
}

.search-row button {
  min-height: 48px;
}

.suggestions {
  display: none;
  max-height: 230px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(39, 54, 48, 0.12);
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: 68px;
}

.suggestions.open {
  display: grid;
}

.suggestions button {
  min-height: 36px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-weight: 400;
}

.suggestions button:hover,
.suggestions button:focus {
  background: #eef8f6;
}

.compare-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
}

.compare-chips button {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-color: var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

.empty-chip {
  color: var(--muted);
  font-size: 12px;
  align-self: center;
}

.period-filter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-content: start;
  grid-column: 1 / -1;
  order: 3;
}

.period-filter legend {
  grid-column: 1 / -1;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.kpis article,
.panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.kpis article {
  min-height: 98px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  align-content: center;
  column-gap: 12px;
  row-gap: 2px;
  padding: 14px 16px;
  min-width: 0;
  container-type: inline-size;
}

.kpis i {
  grid-row: 1 / span 2;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  font-style: normal;
}

.kpis i .material-symbols-rounded {
  font-size: 29px;
}

.kpi-pop i {
  background: rgba(86, 166, 241, 0.22);
}

.kpi-home i {
  background: rgba(255, 125, 170, 0.2);
}

.kpi-family i {
  background: rgba(111, 207, 151, 0.22);
}

.kpis span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 0;
  min-width: 0;
}

.kpis strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-wrap: nowrap;
  font-size: clamp(21px, 6.4cqw, 38px);
  line-height: 1;
}

@supports not (font-size: 1cqw) {
  .kpis strong {
    font-size: clamp(21px, 2.2vw, 38px);
  }
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

.panel {
  min-width: 0;
  padding: 24px;
}

.wide {
  min-height: 620px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.trend-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  align-items: center;
  gap: 10px;
}

.age-range-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: end;
  gap: 8px;
}

.age-range-controls label {
  min-width: 88px;
  gap: 5px;
}

.age-range-controls span {
  color: var(--muted);
  line-height: 48px;
}

.scale-toggle {
  display: inline-flex;
  justify-self: start;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.age-population-toggle {
  display: flex;
  flex-wrap: wrap;
  justify-self: start;
  gap: 8px;
}

.scale-toggle button {
  min-height: 36px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
}

.age-population-toggle button {
  min-height: 44px;
  border-color: var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  padding: 0 18px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(162, 119, 0, 0.08);
}

.scale-toggle button.active,
.age-population-toggle button.active {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
}

.base-date-control {
  display: none;
  grid-template-columns: auto 130px;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.base-date-control.visible {
  display: grid;
}

.base-date-control select {
  min-height: 30px;
  font-size: 13px;
  padding: 4px 8px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.legend:empty {
  display: none;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  margin-top: 24px;
  padding: 18px 4px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  text-align: center;
}

.site-footer span,
.site-footer strong {
  white-space: nowrap;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend button {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
  padding: 0 8px;
}

.legend button:disabled {
  cursor: default;
  opacity: 1;
}

.legend button:disabled:hover {
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
}

.legend button:hover {
  border-color: var(--accent);
  background: #fff8cf;
  color: var(--ink);
}

.legend i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.timeline {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.timeline input[type="range"] {
  min-width: 0;
}

.timeline.compact {
  width: min(760px, 100%);
  margin-bottom: 0;
}

button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-contrast);
  font: inherit;
  font-weight: 400;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  background: #ffe45a;
  transform: translateY(-1px);
}

input[type="range"] {
  width: 100%;
  height: 28px;
  border: 0;
  outline: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
}

input[type="range"]::-webkit-slider-thumb {
  width: 24px;
  height: 24px;
  margin-top: -7px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px #fff, 0 5px 12px rgba(162, 119, 0, 0.18);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

input[type="range"]::-moz-range-track {
  height: 10px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px #fff, 0 5px 12px rgba(162, 119, 0, 0.18);
  cursor: pointer;
}

.readout {
  min-height: 31px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}

.readout span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: #fffefa;
}

.readout i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.data-note {
  max-width: 100%;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.chart-wrap {
  width: 100%;
  height: 520px;
}

.chart-wrap.small {
  height: 320px;
}

.chart-wrap.age {
  height: 560px;
}

svg {
  width: 100%;
  height: 100%;
  display: block;
}

.axis {
  stroke: #b8c3bd;
  stroke-width: 1;
}

.grid-line {
  stroke: #e9eee9;
  stroke-width: 1;
}

.line {
  fill: none;
  stroke-width: 3.5;
}

.hit-area {
  fill: transparent;
  cursor: crosshair;
}

.marker-line {
  stroke: #334155;
  stroke-width: 1;
  stroke-dasharray: 4 5;
  opacity: 0.55;
}

.marker-dot {
  stroke-width: 4;
}

.area-fill {
  opacity: 0.08;
}

.tick,
.bar-label {
  fill: var(--muted);
  font-size: 11px;
}

.ranking {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rank-buttons {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: start;
  gap: 8px;
}

#rankingPanel .panel-head {
  align-items: flex-start;
  flex-direction: column;
}

.rank-buttons button {
  min-height: 42px;
  border-color: var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  min-width: 74px;
  padding: 0 12px;
  white-space: nowrap;
}

.rank-buttons button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
}

.ranking li {
  display: grid;
  grid-template-columns: 28px minmax(130px, 0.8fr) minmax(120px, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #f0ead3;
  padding-bottom: 14px;
}

.ranking li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.rank-no {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff7d6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.ranking li:nth-child(-n + 3) .rank-no {
  background: var(--accent);
  color: var(--ink);
}

.rank-name {
  font-weight: 400;
}

.rank-bar {
  height: 12px;
  border-radius: 999px;
  background: #f3f5f2;
  overflow: hidden;
}

.rank-bar i {
  display: block;
  width: var(--rank-bar-width);
  height: 100%;
  border-radius: inherit;
  background: var(--rank-bar-color);
}

.rank-value {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .app {
    width: min(100% - 32px, 720px);
    display: block;
    margin-inline: auto;
    padding: 0 0 116px;
  }

  .sidebar {
    position: sticky;
    top: 8px;
    z-index: 35;
    height: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto;
    align-items: center;
    align-content: center;
    gap: 10px;
    margin: 10px 0 14px;
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 10px 18px;
  }

  .sidebar.nav-open {
    grid-template-rows: auto auto;
  }

  #overview,
  #households,
  #population,
  #age,
  #ageRange,
  #rankingPanel,
  #about {
    scroll-margin-top: 112px;
  }

  .side-note {
    display: none;
  }

  .brand {
    display: flex;
    justify-items: start;
    align-items: center;
    align-self: center;
    gap: 10px;
    text-align: left;
    font-size: 13px;
    line-height: 1.25;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 16px;
  }

  .brand-mark .material-symbols-rounded {
    font-size: 27px;
  }

  .nav-toggle {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    gap: 6px;
    justify-self: end;
    padding-inline: 12px;
    line-height: 1;
  }

  .nav-toggle .material-symbols-rounded {
    font-size: 22px;
  }

  .side-nav {
    grid-column: 1 / -1;
    display: none;
    grid-template-columns: 1fr;
    gap: 8px;
    overflow: visible;
    padding: 8px 0 0;
    border-top: 1px solid var(--line);
  }

  .sidebar.nav-open .side-nav {
    display: grid;
  }

  .controls {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px;
  }

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

  .controls > label {
    grid-column: auto;
    grid-row: auto;
  }

  .area-chip-field {
    grid-column: auto;
    grid-row: auto;
  }

  .metric-buttons,
  .age-population-field,
  .area-chip-field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  .metric-buttons legend,
  .age-population-field legend,
  .area-chip-field legend {
    width: auto;
    min-width: 76px;
    margin: 0 2px 0 0;
  }

  .area-chips {
    gap: 8px;
  }

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

  .wide,
  .age-panel,
  .age-range-panel,
  #rankingPanel {
    grid-column: auto;
  }

  .panel-head,
  .timeline.compact {
    align-items: stretch;
    flex-direction: column;
  }

  .age-range-controls {
    justify-content: start;
  }

  .timeline {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .timeline.compact {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .timeline strong {
    grid-column: 1 / -1;
    justify-self: end;
  }

  .ranking li {
    grid-template-columns: 28px 1fr auto;
  }

  .rank-no,
  .rank-name,
  .rank-value {
    grid-row: 1;
  }

  .rank-value {
    grid-column: 3;
    justify-self: end;
  }

  .rank-bar {
    grid-column: 2 / -1;
    grid-row: 2;
    width: 100%;
  }

  .chart-wrap {
    height: 380px;
  }

  .chart-wrap.age {
    height: 440px;
  }

  h1 {
    font-size: clamp(25px, 6.7vw, 34px);
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: clamp(24px, 7.6vw, 32px);
    white-space: normal;
  }

  .selection-popup {
    right: 6px;
    bottom: 6px;
    width: min(188px, calc(100vw - 12px));
  }

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

  .controls {
    gap: 10px;
    margin-top: 16px;
    padding: 12px;
    border-radius: 22px;
  }

  .controls legend,
  .controls > label,
  .period-filter label {
    font-size: 11px;
  }

  .metric-buttons,
  .age-population-field,
  .area-chip-field {
    gap: 7px;
  }

  .metric-buttons legend,
  .age-population-field legend,
  .area-chip-field legend {
    min-width: 62px;
  }

  .area-chips button,
  .metric-buttons button,
  .age-population-toggle button {
    min-height: 36px;
    padding-inline: 12px;
    font-size: clamp(17px, 5.2vw, 22px);
  }

  .controls > label {
    gap: 5px;
  }

  select,
  input[type="search"],
  input[type="number"] {
    min-height: 42px;
    border-radius: 14px;
    font-size: clamp(17px, 4.8vw, 20px);
    padding: 7px 10px;
  }

  input[type="number"] {
    max-width: 86px;
  }

  .period-filter {
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr);
    align-items: end;
    gap: 6px 8px;
  }

  .period-filter legend {
    grid-column: 1;
    margin: 0 4px 9px 0;
    align-self: end;
  }

  .period-filter label {
    gap: 3px;
  }

  .rank-buttons {
    gap: 6px;
  }

  .rank-buttons button {
    min-width: 68px;
    padding-inline: 10px;
  }
}
