:root {
  color-scheme: light dark;       /* follows the system until the toggle stores an override (see app.js) */
  --paper: light-dark(#f1f0e6, #0d1520);
  --card: light-dark(#fbfaf3, #142030);
  --ink: light-dark(#232b25, #e6edf5);
  --muted: light-dark(#66705f, #93a4b8);
  --line: light-dark(#d7d9c9, #22344a);
  --been: light-dark(#c4512c, #e0674d);
  --want: light-dark(#4b7f52, #d9b44a);
  --both: light-dark(#2a7f8e, #4fd1a1);
  --theirs: light-dark(#7a4fb5, #6ea8fe);
  --link: light-dark(#7a4fb5, #8fb8ff);
  --red: #cb0028;                 /* sRGB fallback for the display-p3 red below */
  --tint: color-mix(in srgb, var(--ink) 8%, var(--paper));
  --tint-2: color-mix(in srgb, var(--ink) 13%, var(--paper));
  --radius: 10px;
  --radius-lg: 14px;
  --pill: 999px;
  --round: 50%;
  --panel-w: 380px;
  --display: "Young Serif", Georgia, "Times New Roman", serif;
  --display-weight: 400;
  --display-scale: .95;
  --display-tracking: 0;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@supports (color: color(display-p3 0 0 0)) { :root { --red: color(display-p3 0.729 0.043 0.184); } }
:root[data-scheme="light"] { color-scheme: light; }
:root[data-scheme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.4 var(--body); -webkit-text-size-adjust: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

#app { position: fixed; inset: 0; overflow: hidden; }
#map { position: absolute; inset: 0; }

/* ---------- panel ---------- */
#panel {
  position: absolute; z-index: 2; display: flex; flex-direction: column;
  background: var(--paper); border: 1px solid var(--line);
}
#handle { display: none; }
.head { padding: 16px 18px 10px; }
.title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
h1 { margin: 0; font-family: var(--display); font-weight: var(--display-weight); font-size: calc(28px * var(--display-scale)); line-height: 1.05; letter-spacing: var(--display-tracking); }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: var(--pill);
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper); font-weight: 600; font-size: 13px; white-space: nowrap;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.small { padding: 5px 11px; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }

.progress { margin-top: 12px; font-size: 13px; }
.bar { display: flex; height: 6px; border-radius: 3px; background: var(--tint-2); overflow: hidden; margin-bottom: 7px; }
.bar i { display: block; height: 100%; }
.bar .b { background: var(--been); }
.bar .w { background: var(--want); }
.bar .g { background: var(--both); }
.bar .t { background: var(--theirs); }
.progress b { font-variant-numeric: tabular-nums; }
.progress .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 4px 0 10px; vertical-align: 0; }
.progress .dot:first-child { margin-left: 0; }

.controls { padding: 4px 18px 10px; display: grid; gap: 8px; border-bottom: 1px solid var(--line); }
.toolbar { display: flex; gap: 8px; }
.toolbar #q { flex: 1; min-width: 0; }
.filters { display: grid; gap: 8px; }
#filters-toggle { padding: 0 12px; flex: none; }
#filters-toggle[aria-expanded="true"] { background: var(--tint-2); border-color: var(--ink); }
.count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--ink); color: var(--paper); font-size: 12px; line-height: 18px; text-align: center; }
#q {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card);
}
#q::placeholder { color: var(--muted); opacity: .7; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 4px 10px; border-radius: var(--pill); border: 1px solid var(--line); background: var(--card);
  font-size: 13px; font-variant-numeric: tabular-nums;
}
.chip { display: inline-flex; align-items: center; --star-h: 13px; }
.chip[aria-pressed="true"] { background: var(--tint-2); border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.chip small { opacity: .65; margin-left: 4px; font-size: 12px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.seg button { flex: 1; border: 0; background: none; padding: 6px 4px; font-size: 13px; border-left: 1px solid var(--line); }
.seg button:first-child { border-left: 0; }
.seg small { margin-left: 5px; font-size: 12px; opacity: .6; font-variant-numeric: tabular-nums; }
.seg button[aria-pressed="true"] { background: var(--tint-2); font-weight: 600; }

.scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-bottom: env(safe-area-inset-bottom); }

/* ---------- list ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.row-main {
  flex: 1; min-width: 0; display: grid; grid-template-columns: 48px 1fr; align-items: center; column-gap: 6px;
  padding: 10px 0 10px 18px; background: none; border: 0; text-align: left;
}
.stars { grid-row: span 2; display: inline-flex; gap: 1px; align-items: center; white-space: nowrap; --star-h: 14px; }
.stars img { display: block; height: var(--star-h); width: auto; }
.name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acts { display: flex; gap: 4px; padding: 0 14px 0 6px; }
.act {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: var(--round);
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
}
.act:disabled { cursor: default; }
.badge { margin-right: 18px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: var(--pill); white-space: nowrap; color: #fff; }
.badge.both { background: var(--both); }
.badge.theirs { background: var(--theirs); }
.badge.mine { background: var(--been); }
.badge.none { display: none; }
.empty { padding: 28px 18px; color: var(--muted); text-align: center; margin: 0; }
.foot { padding: 14px 18px 18px; }
.btn.icon { width: 38px; height: 38px; padding: 0; justify-content: center; border-radius: var(--round); }
.btn.icon svg { width: 20px; height: 20px; }

/* ---------- expanded row (inline detail) ---------- */
.row-line { display: flex; align-items: center; width: 100%; }
.row.expanded { display: block; margin: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--card); box-shadow: 0 2px 10px rgba(35, 32, 27, .07); }
.row.expanded .row-main { padding: 12px 0 8px 12px; }
.row.expanded .name { font-family: var(--display); font-weight: var(--display-weight); font-size: calc(19px * var(--display-scale)); line-height: 1.2; letter-spacing: var(--display-tracking); white-space: normal; }
.row-x { flex: none; width: 38px; height: 38px; margin: 6px 8px 0 0; align-self: flex-start; border: 0; background: none; color: var(--muted); display: grid; place-items: center; border-radius: var(--round); }
.row-body { padding: 0 14px 12px; }
.row-body address { font-style: normal; color: var(--muted); font-size: 13.5px; margin: 2px 0 10px; }
.row { scroll-margin-top: 36px; }   /* clear the sticky city header */
.status { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status button {
  display: flex; align-items: center; justify-content: center; gap: 7px; padding: 10px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--paper); font-weight: 600;
}
.status button:disabled { cursor: default; opacity: .75; }
.compare-line { display: flex; gap: 8px; font-size: 13px; }
.compare-line > div { flex: 1; padding: 8px 10px; border-radius: var(--radius); background: var(--paper); border: 1px solid var(--line); }
.compare-line small { display: block; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.links { display: flex; gap: 6px; margin: 6px -6px -6px; font-size: 14px; }
.links a { padding: 9px 6px; }
.links a { color: var(--link); }

/* ---------- banner + toast ---------- */
#banner {
  position: absolute; z-index: 3; top: 12px; right: 12px; max-width: 460px;
  background: var(--card); border: 1px solid var(--ink); border-radius: var(--radius-lg); padding: 12px 14px;
  box-shadow: 0 6px 24px rgba(35, 32, 27, .22);
}
#banner[hidden] { display: none; }
#banner p { margin: 0 0 10px; font-size: 14px; }
#banner .legend { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 10px; font-size: 12.5px; }
#banner .legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; background: var(--c); }
#banner .btns { display: flex; flex-wrap: wrap; gap: 8px; }
#toast {
  position: absolute; z-index: 5; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); padding: 9px 16px; border-radius: var(--pill); font-size: 14px; transition: .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- layouts ---------- */
@media (min-width: 761px) {
  #panel { top: 12px; bottom: 12px; left: 12px; width: var(--panel-w); border-radius: calc(var(--radius-lg) + 2px); overflow: hidden; box-shadow: 0 6px 28px rgba(35, 32, 27, .2); }
  #banner { right: 64px; }
}
@media (max-width: 760px) {
  #panel {
    left: 0; right: 0; bottom: 0; border-radius: calc(var(--radius-lg) + 4px) calc(var(--radius-lg) + 4px) 0 0; border-bottom: 0;
    box-shadow: 0 -4px 24px rgba(35, 32, 27, .2); transition: height .25s ease;
  }
  #panel[data-sheet="min"] { height: 116px; }
  #panel[data-sheet="half"] { height: 52vh; height: 52dvh; }
  #panel[data-sheet="full"] { height: calc(100% - var(--full-top, 56px)); }
  #panel[data-sheet="min"] .controls, #panel[data-sheet="min"] .scroll { display: none; }
  #handle { display: grid; place-items: center; width: 100%; height: 28px; cursor: grab; touch-action: none; }
  .head { touch-action: none; }
  #panel.dragging { transition: none; user-select: none; -webkit-user-select: none; }
  #panel.dragging .head, #panel.dragging #handle { cursor: grabbing; }
  #handle span { width: 44px; height: 5px; border-radius: 2px; background: var(--line); }
  .head { padding: 0 14px 6px; max-height: 120px; overflow: hidden; transition: max-height .2s ease, padding .2s ease; }
  #panel.tucked .head { max-height: 0; padding-top: 0; padding-bottom: 0; }
  .sort .lbl, #filters-toggle .lbl { display: none; }
  .listbar.idle { display: none; }
  .sub { display: none; }                       /* the sheet is short: spend the pixels on content */
  .progress { margin-top: 6px; }
  #share { width: 38px; height: 38px; padding: 0; justify-content: center; border-radius: var(--round); }
  #share .lbl { display: none; }
  .controls { padding: 2px 14px 8px; gap: 6px; }
  #q { padding: 8px 12px; }
  .status button { padding: 8px; }
  .links { margin-top: 8px; }
  .row.expanded { margin: 6px 8px; }
  h1 { font-size: calc(24px * var(--display-scale)); }
  #banner { left: 10px; right: 10px; top: calc(10px + env(safe-area-inset-top)); max-width: none; }
  #toast { bottom: calc(52vh + 14px); }
}
@media (prefers-reduced-motion: reduce) { #panel, #toast, .head { transition: none; } }

/* ---------- map chrome follows the theme ---------- */
.maplibregl-ctrl-group { background: var(--card); }
.maplibregl-ctrl-attrib { background: color-mix(in srgb, var(--card) 85%, transparent) !important; }
.maplibregl-ctrl-attrib, .maplibregl-ctrl-attrib a { color: var(--ink) !important; }
:root[data-scheme="dark"] .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }
:root[data-scheme="dark"] .maplibregl-ctrl-attrib-button { filter: invert(1); }

.result { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--muted); }
.result .link { border: 0; background: none; padding: 2px 0; color: var(--link); text-decoration: underline; font-size: 13px; }
.empty .link { border: 0; background: none; color: var(--link); text-decoration: underline; font: inherit; padding: 0; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.listbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.listbar .result { flex: 1; min-width: 0; gap: 10px; justify-content: flex-start; }
.toolbar .sort { flex: none; }
.sort { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.sort select { font: inherit; font-size: 13px; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 6px; }
.group { padding: 14px 18px 6px; font: 700 11px/1 var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); background: var(--paper); position: sticky; top: 0; z-index: 1; border-bottom: 1px solid var(--line); }

/* The star is an <img>, so it can't take a token: lift the red a little on dark navy for contrast. */
:root[data-scheme="dark"] .stars img { filter: brightness(1.45) saturate(.9); }
@media (prefers-color-scheme: dark) { :root:not([data-scheme="light"]) .stars img { filter: brightness(1.45) saturate(.9); } }

/* ---------- status glyphs: outlined at rest, filled when set ---------- */
.glyph { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linejoin: round; overflow: visible; }
.act .glyph { width: 22px; height: 22px; transform: translateY(var(--glyph-dy, 2px)); }
.been { --c: var(--been); }
.want { --c: var(--want); }
.act[aria-pressed="true"], .status button[aria-pressed="true"] {
  color: #fff; border-color: transparent;
  background: linear-gradient(170deg, color-mix(in oklch, var(--c) 90%, white), var(--c) 55%, color-mix(in oklch, var(--c) 90%, black));
}
[aria-pressed="true"] > span > .glyph { fill: url(#glyph-fill); stroke: url(#glyph-fill); stroke-width: 1.7; filter: drop-shadow(0 1px 1.2px rgb(0 0 0 / .35)); }
