:root {
  --bg: #f5f1e8;
  --card: #fffdf8;
  --ink: #1c2230;
  --muted: #6a6f7c;
  --line: #e4ddcd;
  --accent: #1f7a5c;
  --accent-soft: #dcefe6;
  --focus: #2f6fdb;

  --comfy: #2e9e74;
  --hot: #e0603f;
  --muggy: #e3a33b;
  --cold: #4f86c6;
  --rain: #7c8597;
  --windy: #a88cc8;
  --missing: #ddd6c6;

  --heat-0: #efe9db;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(40 30 10 / 6%), 0 6px 24px rgb(40 30 10 / 6%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151c;
    --card: #1a1f29;
    --ink: #e9e6de;
    --muted: #9aa0ad;
    --line: #2b3240;
    --accent: #5cc79c;
    --accent-soft: #1d3a30;
    --comfy: #4cc193;
    --hot: #f07b5b;
    --muggy: #f0b955;
    --cold: #6fa3e0;
    --rain: #8e97a9;
    --windy: #bba3da;
    --missing: #2c3240;
    --heat-0: #232a36;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151c; --card: #1a1f29; --ink: #e9e6de; --muted: #9aa0ad; --line: #2b3240;
  --accent: #5cc79c; --accent-soft: #1d3a30; --comfy: #4cc193; --hot: #f07b5b; --muggy: #f0b955;
  --cold: #6fa3e0; --rain: #8e97a9; --windy: #bba3da; --missing: #2c3240; --heat-0: #232a36;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 "Zen Kaku Gothic New", system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* Masthead */
.masthead { padding: 40px 0 20px; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font-weight: 700; letter-spacing: .08em; font-size: 13px; }
h1 {
  font-family: "Zen Old Mincho", Georgia, serif;
  font-size: clamp(28px, 5vw, 46px);
  line-height: 1.15;
  margin: 0 0 12px;
  max-width: 22ch;
  text-wrap: balance;
}
h1 em { font-style: normal; color: var(--accent); }
.lede { max-width: 62ch; margin: 0; color: var(--muted); font-size: 16px; }
h2 { font-size: 17px; margin: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

/* Criteria */
.criteria-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.presets, .regions { display: flex; flex-wrap: wrap; gap: 6px; }
.presets button, .regions button {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 13px;
}
.presets button:hover, .regions button:hover { border-color: var(--accent); }
.presets button.is-on, .regions button.is-on { background: var(--accent); border-color: var(--accent); color: var(--card); }

.sliders { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 22px; }
.slider label { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.slider output { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.slider .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.slider input[type=range] { width: 100%; accent-color: var(--accent); margin: 6px 0 0; }
.slider .tag { display: inline-block; width: 9px; height: 9px; border-radius: 2px; background: var(--c); margin-right: 6px; vertical-align: 1px; }
.rule-summary { margin: 14px 0 0; padding-top: 12px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 13.5px; }

.status { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; margin-bottom: 18px; font-size: 14px; }

/* Explore grid */
.explore { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; }
.explore .card { margin-bottom: 18px; }
#map { height: 560px; border-radius: 10px; background: var(--heat-0); z-index: 0; }
.leaflet-container { font: inherit; }
.leaflet-tooltip { font-size: 13px; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend .ramp { width: 120px; height: 8px; border-radius: 4px; }

.rank-card { display: flex; flex-direction: column; }
.regions { margin-bottom: 10px; }
.ranking { list-style: none; margin: 0; padding: 0; overflow-y: auto; max-height: 520px; flex: 1; }
.ranking li { margin: 0; }
.ranking button {
  width: 100%;
  display: grid;
  grid-template-columns: 2.2em minmax(0, 1fr) minmax(60px, 1.1fr) 3.2em;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
}
.ranking button:hover { background: var(--heat-0); }
.ranking button.is-sel { background: var(--accent-soft); }
.ranking .rk { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; font-size: 13px; }
.ranking .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking .nm small { color: var(--muted); margin-left: 6px; }
.ranking .bar { height: 8px; border-radius: 4px; background: var(--heat-0); overflow: hidden; }
.ranking .bar span { display: block; height: 100%; background: var(--comfy); border-radius: 4px; }
.ranking .val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Detail */
.detail-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; align-items: flex-end; margin-bottom: 18px; }
.detail h2.city { font-family: "Zen Old Mincho", Georgia, serif; font-size: 30px; line-height: 1.1; }
.detail h2.city small { font-size: 18px; color: var(--muted); margin-left: 8px; }
.detail .sub { color: var(--muted); margin: 4px 0 0; }
.bignum { text-align: right; }
.bignum b { font-size: 46px; line-height: 1; color: var(--comfy); font-variant-numeric: tabular-nums; }
.bignum span { display: block; color: var(--muted); font-size: 13px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 20px; }
.fact { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.fact span { display: block; font-size: 12px; color: var(--muted); }
.fact b { font-size: 16px; }
.detail h3 { font-size: 14.5px; margin: 22px 0 8px; }
.detail h3 .muted { font-weight: 400; font-size: 12.5px; }
.cat-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--c); margin-right: 6px; vertical-align: -1px; }
.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; width: 100%; height: auto; min-width: 520px; }
.chart text { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .grid { stroke: var(--line); }
.cal-cell { stroke: var(--card); stroke-width: 1.5; }
.year-controls { display: inline-flex; gap: 4px; margin-left: 8px; flex-wrap: wrap; }
.year-controls button { border: 1px solid var(--line); background: transparent; border-radius: 6px; padding: 1px 8px; font-size: 12px; cursor: pointer; }
.year-controls button.is-on { background: var(--ink); color: var(--card); border-color: var(--ink); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
table.clim { border-collapse: collapse; width: 100%; font-size: 12.5px; font-variant-numeric: tabular-nums; }
table.clim th, table.clim td { padding: 3px 4px; text-align: right; border-bottom: 1px solid var(--line); }
table.clim th:first-child, table.clim td:first-child { text-align: left; color: var(--muted); font-weight: 500; }
.table-wrap { overflow-x: auto; }

.method p { max-width: 75ch; }
.method-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 4px; max-width: 75ch; }
.foot { color: var(--muted); font-size: 13px; padding-bottom: 40px; }

@media (max-width: 900px) {
  .explore, .two-col { grid-template-columns: minmax(0, 1fr); }
  #map { height: 420px; }
  .ranking { max-height: 440px; }
}
@media (max-width: 520px) {
  .masthead { padding-top: 28px; }
  .card { padding: 14px; }
  #map { height: 340px; }
  .bignum { text-align: left; }
  .bignum b { font-size: 38px; }
}

/* Language toggle */
.mast-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.mast-top .eyebrow { margin: 0; }
.lang-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--card); }
.lang-toggle button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 3px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
}
.lang-toggle button:hover { color: var(--ink); }
.lang-toggle button.is-on { background: var(--accent); color: var(--card); }
html:lang(ja) h1 { max-width: 18em; line-break: strict; }
html:lang(ja) h1 em { white-space: nowrap; }
