:root {
  --bg: #eef2f5;
  --paper: #ffffff;
  --ink: #17233a;
  --muted: #5b687a;
  --line: #d3dbe3;
  --weather: #d99a14;
  --afford: #2b8a57;
  --jobs: #2f64ad;
  --transit: #a63c69;
  --focus: #2f64ad;
  --display: "Bricolage Grotesque", "Public Sans", system-ui, sans-serif;
  --body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--body); }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* Masthead: the four category colors run as a band under the title */
.masthead { background: var(--ink); color: #fff; padding: 36px 0 30px; position: relative; }
.masthead::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px;
  background: linear-gradient(90deg, var(--weather) 0 25%, var(--afford) 25% 50%, var(--jobs) 50% 75%, var(--transit) 75%); }
.brand { font: 800 1.05rem/1 var(--display); letter-spacing: .01em; margin: 0 0 18px; opacity: .85; }
h1 { font: 800 clamp(2rem, 4.6vw, 3.4rem)/1.04 var(--display); letter-spacing: -.02em; margin: 0; max-width: 18ch; }
.lede { max-width: 58ch; margin: 14px 0 0; color: #c9d3df; font-size: 1.08rem; }

.layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 28px; padding-top: 28px; padding-bottom: 20px; align-items: start; }
.controls { position: sticky; top: 16px; display: grid; gap: 16px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.panel h2 { font: 700 1.05rem/1.2 var(--display); margin: 0 0 14px; }

/* Weight sliders */
.slider { margin-bottom: 14px; }
.slider-top { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; font-size: .95rem; }
.slider-top .share { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; font-size: .88rem; }
.slider input { width: 100%; margin: 8px 0 0; -webkit-appearance: none; appearance: none; height: 6px; border-radius: 3px; cursor: pointer;
  background: linear-gradient(90deg, var(--c) 0 var(--p, 50%), #dfe5eb var(--p, 50%)); }
.slider input::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 4px solid var(--c); box-shadow: 0 1px 2px rgba(23,35,58,.3); }
.slider input::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 4px solid var(--c); }
.slider .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--c); margin-right: 8px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.presets button, .chip { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 4px 11px; font-size: .85rem; cursor: pointer; }
.presets button:hover, .chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.field { display: block; margin-bottom: 14px; border: 0; padding: 0; }
.field > span, .field legend { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 6px; padding: 0; }
.field input[type=search] { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fbfcfd; }
.field input[type=range] { width: 100%; accent-color: var(--ink); }
.field output { font-variant-numeric: tabular-nums; }
#regions { display: flex; flex-wrap: wrap; gap: 6px; }
.linkish { background: none; border: 0; padding: 0; color: var(--jobs); text-decoration: underline; cursor: pointer; font-size: .9rem; }

/* Results */
.results-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.count { margin: 0; color: var(--muted); }
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--paper); }
.view-toggle button { border: 0; background: none; padding: 6px 14px; cursor: pointer; font-size: .9rem; }
.view-toggle button[aria-selected="true"] { background: var(--ink); color: #fff; }
.table-scroll { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 10px; text-align: right; white-space: nowrap; }
th { font-size: .8rem; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--paper); cursor: pointer; user-select: none; vertical-align: bottom; line-height: 1.25; }
th.sorted { color: var(--ink); }
th.sorted::after { content: " ↓"; }
th.sorted.asc::after { content: " ↑"; }
th.l, td.l { text-align: left; }
th .tip { display: block; font-weight: 400; font-size: .72rem; }
tbody tr.row { border-top: 1px solid #edf1f4; cursor: pointer; }
tbody tr.row:hover { background: #f6f9fb; }
tbody tr.row.open { background: #f1f5f9; }
td.rank { font: 700 1.05rem/1 var(--display); color: var(--muted); width: 2.5em; }
td.name { font-weight: 600; }
td.name small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; }
td.total { font: 800 1.15rem/1 var(--display); }
td.bar { width: 34%; min-width: 160px; }
.stack { display: flex; height: 14px; border-radius: 3px; overflow: hidden; background: #edf1f4; }
.stack span { display: block; height: 100%; transition: width .35s ease; }
.s-weather { background: var(--weather); } .s-afford { background: var(--afford); } .s-jobs { background: var(--jobs); } .s-transit { background: var(--transit); }
td.cat { width: 4.2em; }
.pill { display: inline-block; min-width: 2.4em; padding: 2px 6px; border-radius: 4px; font-weight: 600; font-size: .9rem; text-align: center; }
.hint { color: var(--muted); font-size: .85rem; margin: 8px 2px 0; }

/* Detail drawer */
tr.detail td { padding: 0 14px 18px; text-align: left; white-space: normal; background: #f1f5f9; }
.detail-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.detail-grid h4 { font: 700 .98rem/1.2 var(--display); margin: 12px 0 8px; padding-top: 8px; border-top: 4px solid var(--c); }
.detail-grid dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: .88rem; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; text-align: right; font-weight: 600; }
.detail-grid dd .sc { font-weight: 400; color: var(--muted); font-size: .78rem; margin-left: 4px; }
.detail-full { color: var(--muted); font-size: .82rem; margin: 10px 0 0; }

.method { padding-top: 26px; padding-bottom: 10px; }
.method h2 { font: 800 1.6rem/1.1 var(--display); margin: 0 0 14px; }
.method h3 { font: 700 1.05rem/1.2 var(--display); margin: 0 0 6px; padding-top: 8px; border-top: 4px solid var(--c); }
.method p { max-width: 75ch; }
.method-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px; margin-bottom: 8px; }
.method-grid p { font-size: .93rem; color: #34425a; }
.cat-weather { --c: var(--weather); } .cat-afford { --c: var(--afford); } .cat-jobs { --c: var(--jobs); } .cat-transit { --c: var(--transit); }
.sources { color: var(--muted); font-size: .85rem; }
.foot { color: var(--muted); font-size: .85rem; padding-bottom: 40px; }

@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .controls { position: static; grid-template-columns: 1fr 1fr; }
  .detail-grid, .method-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .controls { grid-template-columns: 1fr; }
  .detail-grid, .method-grid { grid-template-columns: 1fr; }
  td.cat, th.cat { display: none; }
  td.bar { min-width: 48px; width: 22%; }
  td.name { white-space: normal; }
  td.total { font-size: 1rem; }
  td.name small { display: none; }
  th.bar { font-size: 0; }
  th, td { padding: 8px 6px; }
}
@media (prefers-reduced-motion: reduce) { .stack span { transition: none; } }
