/* Momo Index Kathmandu: warm street-food palette, mobile first, no framework. */
:root {
  --crimson: #B0132B;
  --crimson-700: #8C0F22;
  --crimson-900: #5E0A17;
  --crimson-50: #FBEAEA;
  --cream: #FFF5E1;
  --paper: #FFFBF2;
  --mustard: #E3A21A;
  --mustard-300: #F6D27A;
  --mustard-50: #FDF1D3;
  --bar-up: #B0132B;     /* pricier than the city (validated pair, see README) */
  --bar-down: #B97C0A;   /* cheaper than the city */
  --ink: #2A1A12;
  --ink-2: #5A4636;
  --muted: #6F5A49;
  --line: #EAD7B5;
  --grid: #EFE2C8;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 0 rgba(94, 10, 23, .06), 0 6px 16px -8px rgba(94, 10, 23, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif;
  --display: "Baloo 2", var(--font);
  --tabbar-h: 64px;
  --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px);
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; }
p { margin: 0; }
a { color: var(--crimson-700); }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
:focus-visible { outline: 3px solid var(--mustard); outline-offset: 2px; border-radius: 6px; }
main:focus { outline: none; }

.skip { position: absolute; left: 8px; top: -60px; background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { top: 8px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px var(--gutter) 8px;
  max-width: 760px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.brand-momo { width: 38px; height: 34px; flex: none; }
.brand-np { font-family: var(--display); font-weight: 800; font-size: 30px; color: var(--crimson); line-height: 1; padding-top: 4px; }
.brand-words { display: flex; flex-direction: column; line-height: 1; }
.brand-index { font-family: var(--display); font-weight: 800; font-size: 20px; }
.brand-city { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.topbar-link { font-weight: 600; text-decoration: none; padding: 8px 14px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); color: var(--ink); }
.topbar-link[aria-current="page"] { background: var(--crimson); border-color: var(--crimson); color: var(--paper); }

/* ---------- Status + filters ---------- */
.status {
  max-width: 760px; margin: 0 auto 8px; padding: 8px var(--gutter);
  font-size: 14px; color: var(--ink-2);
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.status.is-error { background: var(--crimson-50); border-radius: var(--radius-sm); margin: 0 var(--gutter) 8px; color: var(--crimson-900); }
@media (min-width: 792px) { .status.is-error { margin: 0 auto 8px; } }

.filters {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  max-width: 760px; margin: 0 auto; padding: 4px var(--gutter) 12px;
}
.pill-select { position: relative; display: inline-flex; }
.pill-select select {
  appearance: none; -webkit-appearance: none;
  background: var(--paper); border: 1.5px solid var(--line); border-radius: 999px;
  padding: 8px 30px 8px 13px; font-weight: 600; font-size: 15px; min-height: 40px; cursor: pointer;
}
.pill-select::after {
  content: ""; position: absolute; right: 13px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg); pointer-events: none;
}
.pill-select select.is-active { background: var(--crimson); border-color: var(--crimson); color: var(--paper); }
.pill-select:has(select.is-active)::after { border-color: var(--paper); }
.pill-check {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px;
  padding: 6px 11px; border-radius: 999px; border: 1.5px dashed var(--mustard); background: var(--mustard-50);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.pill-check input { width: 18px; height: 18px; accent-color: var(--crimson); margin: 0; }

/* ---------- Layout ---------- */
main { max-width: 760px; margin: 0 auto; padding: 0 var(--gutter); }
.view { display: flex; flex-direction: column; gap: 14px; }
.view-head { padding: 6px 2px 2px; }
.view-head h1 { font-size: 30px; font-weight: 800; color: var(--crimson-900); }
.view-head p { color: var(--ink-2); margin-top: 6px; }
.h-np { display: block; font-size: 17px; font-weight: 600; color: var(--crimson); margin-top: 2px; }
.card {
  background: var(--paper); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); border: 1px solid #F3E4C6;
}
.card-title { font-size: 20px; font-weight: 800; }
.card-sub { font-size: 14px; color: var(--muted); margin-top: 2px; }
.note { font-size: 13px; color: var(--muted); padding: 0 4px; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; background: var(--mustard-50); color: #7A5204; border: 1px dashed var(--mustard);
  vertical-align: 2px; white-space: nowrap;
}
.sample-note {
  display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--ink-2);
  background: var(--mustard-50); border: 1px dashed var(--mustard); border-radius: var(--radius-sm); padding: 8px 12px;
}

/* ---------- Home ---------- */
.hero {
  position: relative; overflow: hidden;
  background: var(--crimson); color: var(--paper);
  border-radius: 26px; padding: 20px 18px 18px;
  display: grid; grid-template-columns: 1fr; gap: 6px;
  box-shadow: 0 10px 24px -12px rgba(94, 10, 23, .6);
}
.hero::before { /* dhaka-ish dotted texture, very subtle */
  content: ""; position: absolute; inset: 0; opacity: .12; pointer-events: none;
  background-image: radial-gradient(var(--mustard-300) 1.2px, transparent 1.3px);
  background-size: 14px 14px;
}
.hero-text { position: relative; }
.hero-eyebrow { font-size: 14px; font-weight: 600; color: #FFE7B8; }
.hero-figure { font-size: 64px; font-weight: 800; line-height: 1; margin-top: 8px; letter-spacing: -.01em; }
.hero-rs { font-size: 32px; font-weight: 600; color: #FFE7B8; vertical-align: 18px; margin-right: -4px; }
.hero-sub { font-size: 14px; color: #FFE7B8; margin-top: 8px; max-width: 30ch; }
.hero-art { position: relative; width: 150px; height: 109px; justify-self: end; margin: -10px -6px -10px 0; }
@media (min-width: 520px) {
  .hero { grid-template-columns: 1fr auto; align-items: end; padding: 24px; }
  .hero-art { width: 200px; height: 145px; margin: 0 -6px -10px 0; }
  .hero-figure { font-size: 80px; }
}

.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { padding: 14px; }
.stat-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.stat-np { display: block; font-family: var(--display); font-weight: 800; font-size: 18px; color: var(--crimson); line-height: 1.1; }
.stat-value { font-family: var(--display); font-weight: 800; font-size: 24px; line-height: 1.15; margin-top: 6px; overflow-wrap: anywhere; }
.stat-meta { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.stat-meta span { display: block; }

.type-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; margin-top: 12px; }
.type-tile {
  text-align: left; border: 1.5px solid var(--line); background: var(--cream); border-radius: 14px;
  padding: 10px 12px; cursor: pointer; min-height: 64px;
}
.type-tile:hover { border-color: var(--mustard); }
.type-tile .tt-name { display: block; font-weight: 700; font-size: 14px; }
.type-tile .tt-plate { display: block; font-family: var(--display); font-weight: 800; font-size: 22px; line-height: 1.2; }
.type-tile .tt-n { display: block; font-size: 12px; color: var(--muted); }
.type-tile[disabled] { cursor: default; opacity: .6; }

.updated { font-size: 13px; color: var(--muted); text-align: center; }
.cta {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink);
  background: var(--mustard-300); border-radius: var(--radius); padding: 14px 16px; border: 2px solid var(--mustard);
}
.cta-momo { width: 44px; height: 38px; flex: none; }
.cta strong { font-family: var(--display); font-size: 19px; }
.cta-arrow { margin-left: auto; font-size: 26px; font-weight: 800; color: var(--crimson); }

/* ---------- Index (diverging bars) ---------- */
.chart-card { padding: 14px 14px 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch-up { background: var(--bar-up); }
.swatch-down { background: var(--bar-down); }
.index-axis { display: flex; justify-content: center; font-size: 12px; color: var(--muted); padding: 2px 0 4px; }
.index-list { list-style: none; margin: 0; padding: 0; }
.idx-row { padding: 8px 6px 6px; border-radius: 10px; cursor: default; outline-offset: 0; }
.idx-row:hover, .idx-row:focus-visible, .idx-row.is-hot { background: var(--cream); }
.idx-row.is-thin { opacity: .55; }
.idx-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.idx-name { font-weight: 700; }
.idx-rank { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; margin-right: 4px; }
.idx-meta { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.idx-track { position: relative; height: 22px; margin-top: 2px; }
.idx-track::before { /* city median baseline */
  content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--ink-2); opacity: .45;
}
.idx-bar { position: absolute; top: 5px; height: 12px; }
.idx-bar.up { left: 50%; background: var(--bar-up); border-radius: 0 4px 4px 0; }
.idx-bar.down { right: 50%; background: var(--bar-down); border-radius: 4px 0 0 4px; }
.idx-val { position: absolute; top: 1px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Trend ---------- */
.trend-chart { position: relative; min-height: 240px; touch-action: pan-y; }
.trend-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.trend-chart svg:focus { outline: none; }
.trend-chart svg:focus-visible { outline: 3px solid var(--mustard); outline-offset: 4px; }
.trend-chart .tick { font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.trend-chart .end-label { font-size: 13px; font-weight: 700; fill: var(--ink); }
.trend-chart .gridline { stroke: var(--grid); stroke-width: 1; }
.trend-chart .axis { stroke: var(--line); stroke-width: 1; }
.trend-chart .line { fill: none; stroke: var(--crimson); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend-chart .area { fill: var(--crimson); opacity: .1; }
.trend-chart .dot { fill: var(--crimson); stroke: var(--paper); stroke-width: 2; }
.trend-chart .dot { fill: var(--ink-2); stroke: var(--paper); stroke-width: 2; }
.trend-chart .dot.thin { fill: var(--paper); stroke: var(--ink-2); stroke-width: 2; }
.trend-chart .head { fill: var(--crimson); stroke: var(--paper); stroke-width: 2; }
.trend-chart .dot.is-hot { r: 6; }
.chart-note { font-size: 12px; color: var(--muted); margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.key { display: inline-flex; align-items: center; gap: 6px; }
.key-line { width: 18px; height: 2px; background: var(--crimson); border-radius: 2px; }
.key-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-2); }
.key-dot.thin { background: var(--paper); border: 2px solid var(--ink-2); }
.chip-est {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 1px 7px; border-radius: 999px; border: 1px solid #FFE7B8; color: #FFE7B8; vertical-align: 1px;
}
.model-note { font-size: 13px; color: var(--ink-2); background: var(--paper); border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.model-note a { font-weight: 700; white-space: nowrap; }
.formula { font-family: var(--display); font-weight: 800; font-size: 17px; color: var(--crimson-900); background: var(--cream); border-radius: 12px; padding: 10px 12px; margin-top: 8px; }
.idx-row.is-model .idx-bar { opacity: .4; }
.idx-row.is-model .idx-meta { font-style: italic; }
.optional { font-weight: 400; color: var(--muted); font-size: 13px; }
.rules { margin: 6px 0 8px; padding-left: 20px; }
.rules li + li { margin-top: 4px; }
.data-table td.src { min-width: 150px; }
.data-table td.src a { font-weight: 600; white-space: nowrap; }
.trend-chart .crosshair { stroke: var(--ink-2); stroke-width: 1; opacity: .5; }
.details summary { cursor: pointer; font-weight: 700; }
.details[open] summary { margin-bottom: 10px; }

/* ---------- Tables ---------- */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--grid); vertical-align: top; }
.data-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; background: var(--paper); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.entries { min-width: 900px; }
.entries th button {
  all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; padding: 4px 0;
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit;
}
.entries th button:focus-visible { outline: 3px solid var(--mustard); }
.entries th button::after { content: "↕"; opacity: .35; font-size: 12px; }
.entries th[aria-sort="ascending"] button::after { content: "↑"; opacity: 1; color: var(--crimson); }
.entries th[aria-sort="descending"] button::after { content: "↓"; opacity: 1; color: var(--crimson); }
.entries th[aria-sort] { color: var(--crimson-900); }
.sticky-col { position: sticky; left: 0; background: var(--paper); z-index: 1; box-shadow: 1px 0 0 var(--grid); }
.entries td.sticky-col { max-width: 170px; }
.r-name { font-weight: 700; display: block; overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.data-table td.pp { font-weight: 700; }
.view h1[tabindex="-1"]:focus { outline: none; }
.index-list .empty { list-style: none; }
.r-sub { display: block; font-size: 12px; color: var(--muted); }
.table-count { font-size: 13px; color: var(--muted); text-align: center; }
.empty { padding: 28px 16px; text-align: center; color: var(--ink-2); }
.empty a { font-weight: 700; }

.search { position: relative; display: block; }
.search svg { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; margin-top: -9px; color: var(--muted); }
.search input {
  width: 100%; padding: 12px 14px 12px 42px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--paper);
  font-size: 16px; min-height: 46px;
}

/* ---------- Buttons ---------- */
.btn { border: 0; border-radius: 999px; padding: 12px 20px; font-weight: 700; font-size: 16px; cursor: pointer; min-height: 48px; }
.btn-primary { background: var(--crimson); color: var(--paper); width: 100%; font-size: 17px; }
.btn-primary:hover { background: var(--crimson-700); }
.btn-primary[disabled] { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; border: 1.5px solid var(--line); color: var(--ink); align-self: center; }
.linklike { all: unset; color: var(--crimson-700); text-decoration: underline; cursor: pointer; }

/* ---------- Form ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > legend { font-weight: 700; font-size: 15px; padding: 0; }
.field input[type="text"], .field input[type="number"], .field input[type="date"], .field input[type="url"], .field select {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--cream); font-size: 16px;
}
.field select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.field input:focus, .field select:focus { border-color: var(--mustard); outline: none; box-shadow: 0 0 0 3px rgba(227, 162, 26, .35); }
.field.has-error input, .field.has-error select { border-color: var(--crimson); background: var(--crimson-50); }
.hint { font-size: 13px; color: var(--muted); }
.err { font-size: 13px; color: var(--crimson); font-weight: 600; min-height: 0; }
.err:empty { display: none; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stepper { display: grid; grid-template-columns: 44px 1fr 44px; gap: 6px; }
.stepper input { text-align: center; padding: 10px 4px !important; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step { border: 1.5px solid var(--line); background: var(--paper); border-radius: 14px; font-size: 22px; font-weight: 700; cursor: pointer; color: var(--crimson); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; min-height: 42px; padding: 8px 16px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--cream); font-weight: 600; font-size: 15px;
}
.chip input:checked + span { background: var(--crimson); border-color: var(--crimson); color: var(--paper); }
.chip input:focus-visible + span { outline: 3px solid var(--mustard); outline-offset: 2px; }
.field.has-error .chip span { border-color: var(--crimson); }
.calc { background: var(--mustard-50); border-radius: 14px; padding: 12px 14px; font-size: 15px; color: var(--ink-2); }
.calc strong { color: var(--ink); font-size: 17px; }
.form-error { color: var(--crimson); font-weight: 600; }
.form-error:empty { display: none; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.success { display: flex; gap: 14px; align-items: flex-start; border: 2px solid var(--mustard); background: var(--mustard-50); }
.success:focus { outline: none; }
.success-momo { width: 56px; height: 49px; flex: none; }
.success-title { font-family: var(--display); font-weight: 800; font-size: 20px; color: var(--crimson-900); }
.success-links { margin-top: 8px; font-weight: 600; }

/* ---------- About ---------- */
.prose .card h2 { font-size: 21px; font-weight: 800; color: var(--crimson-900); margin-bottom: 6px; }
.prose .card p + p { margin-top: 8px; }
.example { background: var(--cream); border-radius: 14px; padding: 12px 14px; margin-top: 10px; font-size: 15px; }
.example p + p { margin-top: 4px; }
.ex-label { display: inline-block; min-width: 64px; font-weight: 800; color: var(--crimson); }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  background: var(--paper); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -6px 18px -12px rgba(94, 10, 23, .35);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none;
  color: var(--muted); font-size: 12px; font-weight: 600; padding: 4px 0; min-height: 48px; justify-content: flex-end;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--crimson); }
.tab-add-bubble {
  display: grid; place-items: center; width: 50px; height: 50px; margin-top: -24px; border-radius: 50%;
  background: var(--crimson); color: var(--paper); border: 4px solid var(--paper); box-shadow: 0 6px 14px -6px rgba(94, 10, 23, .7);
}
.tabbar a.tab-add { color: var(--crimson-700); }
.tabbar a.tab-add[aria-current="page"] .tab-add-bubble { background: var(--crimson-900); }
@media (min-width: 792px) {
  .tabbar { left: 50%; right: auto; width: 520px; transform: translateX(-50%); bottom: 12px; border-radius: 22px; border: 1px solid var(--line); padding-bottom: 6px; }
}

/* ---------- Tooltip + toast ---------- */
.tooltip {
  position: fixed; z-index: 40; pointer-events: none; max-width: 240px;
  background: var(--ink); color: var(--paper); border-radius: 12px; padding: 8px 12px; font-size: 13px;
  box-shadow: 0 8px 20px -8px rgba(0, 0, 0, .5);
}
.tooltip .tt-title { font-size: 12px; color: #E8D9C4; }
.tooltip .tt-value { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tooltip .tt-line { color: #E8D9C4; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 45;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px);
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px;
  max-width: calc(100vw - 32px); text-align: center;
}

/* ---------- Loading frame ---------- */
body.is-loading .view { opacity: .6; transition: opacity .2s; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media (forced-colors: active) {
  .idx-bar, .swatch { forced-color-adjust: none; }
}
