/* NYC Restaurant Grades: full-screen map with a results sheet, in a subway-sign style.
   Grade "bullets" borrow MTA line colours (A = A/C/E blue, B = 4/5/6 green, C = B/D/F/M orange,
   N = N/Q/R/W yellow, P = 7 purple, Z = J/Z brown), darkened where needed so white letters stay readable. */
:root {
  color-scheme: light dark;
  --bg: #f6f5f1; --paper: #ffffff; --ink: #111111; --ink2: #3a3a3a; --muted: #5f5f5f; --rule: #111111; --hair: #dcdad3;
  --band: #111111; --band-ink: #ffffff; --band-muted: #b9b9b9;
  --A: #0039a6; --B: #00782f; --C: #c2410c; --N: #fccc0a; --P: #9b2a91; --Z: #8a5a2b; --U: #6d6e70;
  --line-A: #0039a6; --line-B: #00933c; --line-C: #ff6319; --line-N: #fccc0a; --line-P: #b933ad; --line-Z: #996633;
  --crit: #c8102e; --focus: #2b63d4;
  --shadow: 0 6px 24px rgb(0 0 0 / 0.18);
  --font: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --top: 168px; /* measured in app.js */
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0b; --paper: #161616; --ink: #f4f4f2; --ink2: #d0d0cc; --muted: #a3a39f; --rule: #f4f4f2; --hair: #2e2e2e;
    --band: #000000; --A: #2459c8; --crit: #ff5a6e; --focus: #7aa7ff;
    --shadow: 0 6px 24px rgb(0 0 0 / 0.6);
  }
  .leaflet-container img.leaflet-tile { filter: invert(1) hue-rotate(180deg) brightness(0.82) contrast(0.95) grayscale(0.35); }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font: 17px/1.35 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a { color: inherit; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }

/* ---------- grade bullets ---------- */
.bullet { flex: none; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: #fff; font: 800 20px/1 var(--font); }
.b-A { background: var(--A); } .b-B { background: var(--B); } .b-C { background: var(--C); }
.b-N { background: var(--N); color: #111; } .b-P { background: var(--P); } .b-Z { background: var(--Z); } .b-UNGRADED { background: var(--U); }

/* ---------- map ---------- */
.map { position: fixed; inset: 0; background: var(--bg); }
.leaflet-container { background: var(--bg); font-family: var(--font); }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-control-attribution, .leaflet-control-attribution a { color: #333 !important; }
.pin { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: #fff; font: 800 13px/1 var(--font); border: 2px solid #fff; box-shadow: 0 1px 4px rgb(0 0 0 / 0.45); }
.pin.b-N { color: #111; }
.pin.on { width: 34px; height: 34px; font-size: 17px; border-color: #111; box-shadow: 0 0 0 3px #fff, 0 3px 10px rgb(0 0 0 / 0.5); }
.cluster { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #111; color: #fff; font: 800 12px/1 var(--font); border: 2px solid #fff; box-shadow: 0 1px 5px rgb(0 0 0 / 0.4); }
.you { width: 18px; height: 18px; border-radius: 50%; background: #2f7cf6; border: 3px solid #fff; box-shadow: 0 0 0 6px rgb(47 124 246 / 0.25); }

/* ---------- top: black band, stripe, filter chips ---------- */
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; pointer-events: none; }
.band { pointer-events: auto; background: var(--band); color: var(--band-ink); padding: max(6px, env(safe-area-inset-top)) 12px 4px; }
.band-row { display: flex; align-items: center; gap: 8px; }
.brand { flex: 1; min-width: 0; }
.brand h1 { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.1; }
.brand p { margin: 1px 0 0; color: var(--band-muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Small to look at, still a 44px target. */
.band-btn { flex: none; position: relative; display: grid; place-items: center; width: 44px; height: 44px; margin: -6px -8px -6px 0; border: 0; background: none; color: #fff; font-weight: 800; font-size: 15px; }
.band-btn::before { content: ""; position: absolute; width: 28px; height: 28px; border: 2px solid #fff; border-radius: 50%; }
.search { display: flex; align-items: center; gap: 8px; height: 40px; margin-top: 2px; border-bottom: 2px solid #fff; }
.search svg { flex: none; width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: #fff; font-size: 17px; font-weight: 700; }
.search input::placeholder { color: #a8a8a8; font-weight: 500; }
.search input::-webkit-search-cancel-button { display: none; }
.clear { flex: none; width: 44px; height: 44px; margin-right: -10px; border: 0; background: none; color: #fff; font-size: 24px; line-height: 1; }
.stripe { height: 3px; background: linear-gradient(90deg, var(--line-A) 0 16.6%, var(--line-C) 16.6% 33.3%, var(--line-B) 33.3% 50%, var(--line-N) 50% 66.6%, var(--line-P) 66.6% 83.3%, var(--line-Z) 83.3%); }
.chips { pointer-events: auto; display: flex; gap: 6px; overflow-x: auto; padding: 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; position: relative; isolation: isolate; display: inline-flex; align-items: center; gap: 5px; height: 44px; padding: 0 11px 0 4px; border: 0; background: none; color: var(--ink); font-weight: 800; font-size: 13px; white-space: nowrap; }
.chip::before { content: ""; position: absolute; inset: 7px 0; z-index: -1; border-radius: 15px; background: var(--paper); box-shadow: 0 1px 6px rgb(0 0 0 / 0.22); }
.chip .bullet { width: 22px; height: 22px; font-size: 13px; }
.chip[aria-pressed="true"], .chip[data-on="true"] { color: var(--paper); }
.chip[aria-pressed="true"]::before, .chip[data-on="true"]::before { background: var(--ink); }
.chip:disabled { opacity: 0.55; }
.select-chip { padding-left: 11px; }
.select-chip select { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }

/* ---------- locate button ---------- */
.locate { position: fixed; right: 10px; z-index: 900; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--band); color: #fff; box-shadow: var(--shadow); transition: bottom 0.3s cubic-bezier(0.2, 0.9, 0.25, 1); }
.locate svg { width: 19px; height: 19px; fill: currentColor; }
.locate[aria-busy="true"] svg { opacity: 0.4; }

/* ---------- results sheet ---------- */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1100; height: calc(100dvh - var(--top) + 54px); display: flex; flex-direction: column; background: var(--bg); border-top: 3px solid var(--rule); border-radius: 14px 14px 0 0; box-shadow: 0 -8px 30px rgb(0 0 0 / 0.22); transform: translateY(var(--y, 50%)); transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.25, 1); will-change: transform; overflow: hidden; }
.sheet.dragging { transition: none; }
.grab { flex: none; height: 18px; touch-action: none; cursor: grab; }
.grab::before { content: ""; display: block; width: 36px; height: 4px; margin: 6px auto 0; border-radius: 3px; background: var(--muted); opacity: 0.5; }
.list-view, .detail { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 12px; touch-action: none; }
.list-head h2 { margin: 0; min-width: 0; font-size: 18px; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sort { position: relative; isolation: isolate; flex: none; display: inline-flex; align-items: center; gap: 5px; min-height: 44px; padding: 0 12px; margin-right: -2px; font-weight: 800; font-size: 13px; }
.sort::before { content: ""; position: absolute; inset: 8px 0; z-index: -1; border: 2px solid var(--rule); border-radius: 14px; }
.sort select { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.list-sub { display: flex; justify-content: space-between; margin: 0 12px; padding-bottom: 4px; border-bottom: 2px solid var(--rule); font-weight: 800; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.list-sub span:last-child { color: var(--muted); }
.list { padding: 0 12px; }
.row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; min-height: 56px; padding: 7px 0; border: 0; border-bottom: 1px solid var(--hair); background: none; color: inherit; text-align: left; }
.row:active, .row.on { background: var(--paper); box-shadow: -12px 0 0 var(--paper), 12px 0 0 var(--paper); }
.row .bullet { width: 30px; height: 30px; font-size: 16px; }
.row .name { font-weight: 800; font-size: 14px; line-height: 1.25; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .addr { color: var(--ink2); font-size: 12.5px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { color: var(--muted); font-size: 12px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .score { text-align: right; }
.row .score b { display: block; font-size: 19px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.row .score span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.note { margin: 0; padding: 16px 0; color: var(--muted); font-weight: 700; }
.note b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 4px; }
.note button { margin-top: 12px; min-height: 44px; padding: 0 18px; border: 2px solid var(--rule); border-radius: 22px; background: none; font-weight: 800; }
.skel { height: 56px; border-bottom: 1px solid var(--hair); background: linear-gradient(90deg, transparent, var(--paper), transparent) 0 0 / 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.more { height: 1px; }

/* ---------- restaurant detail (inside the sheet) ---------- */
.d-band { background: var(--band); color: #fff; padding: 0 12px 10px; }
.d-back { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0; border: 0; background: none; color: #fff; font-weight: 800; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.d-band h2 { margin: 0 0 2px; font-size: 20px; font-weight: 800; line-height: 1.05; text-transform: uppercase; overflow-wrap: anywhere; }
.d-band p { margin: 0; color: var(--band-muted); font-size: 13px; }
.scoreline { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px 12px; border-bottom: 2px solid var(--rule); }
.scoreline .bullet { width: 46px; height: 46px; font-size: 26px; }
.scoreline .lbl { color: var(--muted); font-weight: 800; font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; }
.scoreline .n { display: inline; font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.scoreline .gname { display: inline; margin-left: 6px; font-weight: 800; font-size: 14px; }
.strip { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--hair); }
.strip a, .strip button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; border: 0; border-right: 1px solid var(--hair); background: none; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.strip > :last-child { border-right: 0; }
.strip svg { width: 18px; height: 18px; fill: currentColor; }
.strip svg.stroke { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.h { margin: 14px 12px 6px; padding-bottom: 4px; border-bottom: 2px solid var(--rule); font-size: 11.5px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.chart { display: block; width: calc(100% - 24px); height: auto; margin: 0 12px; color: var(--ink); }
.chart .band-a { fill: color-mix(in srgb, var(--A) 13%, transparent); }
.chart .band-b { fill: color-mix(in srgb, var(--B) 13%, transparent); }
.chart .band-c { fill: color-mix(in srgb, var(--C) 15%, transparent); }
.chart .trend { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .band-label { fill: var(--muted); font: 800 10px var(--font); }
.chart .pt { cursor: pointer; outline: none; }
.chart .pt:focus-visible .cb { stroke: var(--focus); stroke-width: 3; }
.chart .hit { fill: transparent; }
.chart .cb { stroke: var(--bg); stroke-width: 2; }
.chart .cb-A { fill: var(--A); } .chart .cb-B { fill: var(--B); } .chart .cb-C { fill: var(--C); } .chart .cb-N { fill: var(--N); }
.chart .cb-P { fill: var(--P); } .chart .cb-Z { fill: var(--Z); } .chart .cb-UNGRADED { fill: var(--U); }
.chart .cb-t { fill: #fff; font: 800 11px var(--font); pointer-events: none; }
.chart .cb-t.dark { fill: #111; }
.chart .yr { font-weight: 600; font-size: 9px; }
.visit { scroll-margin-top: 8px; transition: background-color 0.6s; }
.visit.flash { background: color-mix(in srgb, var(--N) 28%, transparent); }
.chart .val { fill: var(--ink); font: 800 11px var(--font); font-variant-numeric: tabular-nums; }
.chart .axis { fill: var(--muted); font: 700 10px var(--font); }
.visit { padding: 9px 12px; border-bottom: 1px solid var(--hair); }
.visit-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.visit-head b { flex: none; font-weight: 800; font-size: 14px; }
.visit-head span { min-width: 0; color: var(--muted); font-size: 11.5px; font-weight: 700; text-align: right; }
.visit .result { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.visit ol { margin: 6px 0 0; padding: 0; list-style: none; counter-reset: v; display: grid; gap: 5px; }
.visit li { counter-increment: v; display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 6px; color: var(--ink2); font-size: 13.5px; line-height: 1.35; }
.visit li::before { content: counter(v); display: grid; place-items: center; width: 18px; height: 18px; margin-top: 1px; border-radius: 3px; background: var(--ink); color: var(--bg); font-size: 10.5px; font-weight: 800; }
.visit li.crit-item::before { background: var(--crit); color: #fff; }
.crit { color: var(--crit); font-weight: 800; }
.detail { display: flex; flex-direction: column; overflow: hidden; padding-bottom: 0; }
.d-top { flex: none; touch-action: none; cursor: grab; }
/* Handles drag the sheet; don't select their text while swiping. */
.d-top, .grab, .list-head { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.d-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
.d-loading { padding: 0 16px; }
@media (min-width: 900px) { .d-top { cursor: auto; touch-action: auto; } }

/* ---------- offline + info ---------- */
.offline { position: fixed; left: 12px; right: 12px; top: calc(var(--top) + 4px); z-index: 1050; margin: 0; padding: 10px 14px; border-radius: 12px; background: #fccc0a; color: #111; font-size: 14px; font-weight: 700; box-shadow: var(--shadow); }
.info { width: min(100% - 24px, 34rem); max-height: calc(100dvh - 40px); padding: 0; border: 0; border-radius: 18px; background: var(--bg); color: var(--ink); box-shadow: var(--shadow); overflow: hidden; }
.info::backdrop { background: rgb(0 0 0 / 0.6); }
.info-band { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 12px 6px 16px; background: var(--band); color: #fff; }
.info-band h2 { margin: 0; font-size: 18px; font-weight: 800; }
.info-body { max-height: calc(100dvh - 120px); overflow-y: auto; padding: 6px 18px 18px; }
.legend { margin: 0; padding: 0; list-style: none; }
.legend li { display: flex; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--hair); }
.legend b, .legend span:not(.bullet) { display: block; }
.legend span:not(.bullet) { color: var(--muted); font-size: 13px; }
.legend .bullet { width: 28px; height: 28px; font-size: 15px; }
.fine { color: var(--muted); font-size: 13px; }

/* ---------- wide screens: the sheet becomes a side panel ---------- */
@media (min-width: 900px) {
  .top { right: auto; width: 400px; }
  .sheet { top: var(--top); right: auto; width: 400px; height: auto; transform: none !important; border-radius: 0; border-top: 0; border-right: 3px solid var(--rule); box-shadow: 8px 0 24px rgb(0 0 0 / 0.15); }
  .grab { height: 8px; }
  .grab::before { display: none; }
  .map { left: 400px; }
  .chips { background: var(--bg); }
  .locate { bottom: 24px !important; right: 24px; }
  .offline { left: 452px; right: auto; width: 360px; top: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .sheet, .locate { transition: none; }
  .skel { animation: none; }
}

/* Install prompt (shared/install-prompt.js): this site's type and colors; the steps and behavior are shared. */
install-prompt {
  --ip-bg: var(--paper); --ip-fg: var(--ink); --ip-muted: var(--muted); --ip-line: var(--hair); --ip-chip: var(--bg);
  --ip-accent: var(--ink); --ip-on-accent: var(--paper); --ip-font: var(--font);
  --ip-radius: 18px; --ip-radius-inner: 3px; --ip-card-border: 2px solid var(--rule); --ip-shadow: var(--shadow);
}
install-prompt::part(title) { font-weight: 800; letter-spacing: -0.02em; }
