:root {
  /* Dark is the default */
  --bg: #121417; --card: #1a1d22; --raised: #22262c; --input: #15181c; --ink: #e7e9ec; --muted: #9298a2; --line: #2c3138;
  --hover: #20242a; --sel: #1e2a44; --chip: #2a2f37; --chip-ink: #c3c8cf; --head: #1d2025;
  --accent: #6b8cff; --accent-ink: #0d1020; --good: #3fb37f; --mid: #e0a92e; --low: #d9734a; --bad: #ef6b5b;
  --bad-bg: #3a1f1d; --warn-bg: #3a2f14; --warn-ink: #f2c35b; --claude: #e08a5f; --claude-bg: #3a261c;
  --star: #f0b429; --star-off: #3a3f47; --strong-bg: #e7e9ec; --strong-ink: #121417;
  --shadow: rgba(0,0,0,.45); --scrim: rgba(0,0,0,.6);
  --radius: 10px; color-scheme: dark;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
}
:root[data-theme="light"] {
  --bg: #f7f5f1; --card: #fff; --raised: #fff; --input: #fff; --ink: #1f2328; --muted: #6b6f76; --line: #e6e2da;
  --hover: #faf8f4; --sel: #eef2fd; --chip: #ece8e0; --chip-ink: #4a4d52; --head: #fbfaf7;
  --accent: #2f5bd3; --accent-ink: #fff; --good: #2f9e6b; --mid: #d99a1e; --low: #c2603c; --bad: #c0392b;
  --bad-bg: #fbe5e2; --warn-bg: #fff3d6; --warn-ink: #8a6100; --claude: #c96a3d; --claude-bg: #fbf3ee;
  --star: #e3a008; --star-off: #d8d3c9; --strong-bg: #1f2328; --strong-ink: #fff;
  --shadow: rgba(0,0,0,.08); --scrim: rgba(20,20,20,.35); color-scheme: light;
}
body { background: var(--bg); }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--input); color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.loading, .empty { padding: 60px 20px; text-align: center; color: var(--muted); }

.btn { border: 1px solid var(--line); background: var(--raised); color: var(--ink); padding: 7px 13px; border-radius: 8px; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.sm { padding: 5px 10px; font-size: 13.5px; }
.btn.on { background: var(--strong-bg); color: var(--strong-ink); border-color: var(--strong-bg); }
.btn.danger { color: var(--bad); }
.btn.danger.on { background: var(--bad); color: #fff; border-color: var(--bad); }
.link { background: none; border: 0; color: var(--accent); padding: 0 4px; font-size: 13px; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px 8px; }
.top h1 { font-size: 20px; }
.who { display: flex; gap: 10px; align-items: center; font-size: 14px; }

.tabs { display: flex; gap: 4px; padding: 0 24px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { background: none; border: 0; padding: 10px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab.on { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.count { margin-left: 6px; font-size: 12px; background: var(--chip); border-radius: 10px; padding: 1px 7px; color: var(--muted); }

.toolbar { display: flex; gap: 10px; align-items: center; padding: 14px 24px; flex-wrap: wrap; }
.toolbar input[type=search] { width: 240px; }
.grow { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--raised); }
.seg button { border: 0; background: none; padding: 7px 12px; color: var(--ink); }
.seg button.on { background: var(--strong-bg); color: var(--strong-ink); }

main { padding: 0 24px 40px; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.grid { border-collapse: collapse; width: 100%; font-size: 14px; }
.grid th, .grid td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.grid th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--head); position: sticky; top: 0; user-select: none; white-space: nowrap; }
.grid th.sortable { cursor: pointer; } .grid th.on { color: var(--ink); }
.grid .n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.grid tbody tr { cursor: pointer; } .grid tbody tr:hover { background: var(--hover); } .grid tbody tr.sel { background: var(--sel); }
.grid tbody tr:last-child td { border-bottom: 0; }
.addr { font-weight: 550; }
.sub { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; align-items: center; font-size: 13px; }
.pill { font-size: 11.5px; padding: 2px 8px; border-radius: 10px; background: var(--chip); color: var(--chip-ink); white-space: nowrap; }
.pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill.claude { background: var(--claude-bg); color: var(--claude); }
.est { color: var(--mid); margin-left: 2px; font-weight: 700; }
.score { display: inline-block; min-width: 34px; text-align: center; padding: 2px 7px; border-radius: 6px; font-weight: 700; color: #0f1115; }
.score.hi { background: var(--good); } .score.mid { background: var(--mid); } .score.lo { background: var(--low); } .score.fail { background: #6f747c; }
.hint { color: var(--muted); font-size: 13px; }

#map { height: 68vh; border-radius: var(--radius); border: 1px solid var(--line); }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--card); border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px var(--shadow); overflow-y: auto; padding: 20px 22px 60px; z-index: 1000; }
.drawer-head { display: flex; justify-content: space-between; gap: 12px; }
.drawer-head h2 { font-size: 19px; }
.x { border: 0; background: none; font-size: 26px; line-height: 1; color: var(--muted); }
.drawer section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.drawer section:last-child { border-bottom: 0; }
.drawer h3 { font-size: 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.drawer h3 small { color: var(--muted); font-weight: 400; }
.drawer h4 { font-size: 13px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.status-row { display: flex; gap: 6px; flex-wrap: wrap; }
.ruleout { display: flex; gap: 6px; margin-top: -6px; padding-bottom: 12px; }
.reason { margin: 0; padding: 10px 12px; background: var(--bad-bg); border-radius: 8px; font-size: 14px; }
.stars { display: flex; align-items: center; gap: 2px; font-size: 14px; }
.star { border: 0; background: none; font-size: 24px; color: var(--star-off); padding: 0 2px; }
.star.on { color: var(--star); } .star:hover { color: var(--star); opacity: .8; }
.star-sm { color: var(--star); }
.others { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: 14px; color: var(--muted); }
.summary { margin: 0 0 8px; padding: 10px 12px; background: var(--claude-bg); border-left: 3px solid var(--claude); border-radius: 6px; font-size: 14px; line-height: 1.45; }
table.breakdown { width: 100%; border-collapse: collapse; font-size: 14px; }
.breakdown th { font-size: 11.5px; color: var(--muted); text-align: left; font-weight: 600; padding: 4px 6px; }
.breakdown td { padding: 6px; border-top: 1px solid var(--line); vertical-align: top; }
.breakdown .n { text-align: right; font-variant-numeric: tabular-nums; }
.breakdown select { width: auto; padding: 3px 6px; font-size: 13px; }
.breakdown tfoot td { font-weight: 700; }
.evidence { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.musts { list-style: none; padding: 0; margin: 0; font-size: 14px; display: grid; gap: 4px; }
.musts .ok { color: var(--good); } .musts .bad { color: var(--bad); } .musts .unk { color: var(--mid); }
.musts b { color: var(--ink); font-weight: 550; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.facts label { display: grid; gap: 4px; font-size: 12.5px; color: var(--muted); }
.facts .wide { grid-column: 1 / -1; }
.facts .check { display: flex; gap: 6px; align-items: center; color: var(--ink); font-size: 13.5px; }
.facts .check input { width: auto; }
.comments { display: grid; gap: 10px; margin-bottom: 10px; }
.comment { font-size: 14px; }
.comment .meta { font-size: 12.5px; color: var(--muted); }
.comment .body { white-space: pre-wrap; margin-top: 2px; }
.comment.system .body { color: var(--muted); font-style: italic; }
.newcomment { display: grid; gap: 6px; justify-items: end; }

.modal { position: fixed; inset: 0; background: var(--scrim); display: grid; place-items: center; z-index: 2000; padding: 16px; }
.modal-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: min(520px, 100%); max-height: 90vh; overflow: auto; }
.modal-card h2 { margin-bottom: 8px; }
.weights { display: grid; gap: 12px; margin-top: 14px; }
.weights label { display: grid; grid-template-columns: 1fr 160px 20px; gap: 10px; align-items: center; font-size: 14px; }
.weights input { padding: 0; border: 0; background: none; accent-color: var(--accent); }
.weights h4 { margin: 6px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

.auth { max-width: 380px; margin: 14vh auto; padding: 28px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; text-align: center; }
.auth h1 { margin-bottom: 10px; }
.auth form { display: grid; gap: 10px; margin-top: 14px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--strong-bg); color: var(--strong-ink); padding: 10px 16px; border-radius: 8px; z-index: 3000; font-size: 14px; }

@media (max-width: 700px) {
  .top, .tabs, .toolbar, main { padding-left: 12px; padding-right: 12px; }
  .toolbar input[type=search] { width: 100%; }
  .grid th, .grid td { padding: 8px; }
}

.leaflet-container { background: var(--bg); }
[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.95) contrast(.9); }
.leaflet-tooltip { background: var(--raised); color: var(--ink); border-color: var(--line); }

/* ───────── Cards ───────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; cursor: pointer; transition: transform .12s, box-shadow .12s, border-color .12s; display: flex; flex-direction: column; }
.card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px var(--shadow); border-color: var(--muted); }
.card.sel { border-color: var(--accent); }
.card.failing .card-media { filter: grayscale(.6) brightness(.8); }
.card-media { position: relative; aspect-ratio: 16 / 10; background: var(--raised); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-media .score.big { position: absolute; top: 10px; right: 10px; font-size: 15px; padding: 4px 9px; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.photo-count { position: absolute; bottom: 10px; right: 10px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 10px; }
.ribbon { position: absolute; top: 10px; left: 10px; background: #e2457a; color: #fff; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.ribbon.new { background: var(--claude); top: auto; bottom: 10px; }
.ph { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: rgba(255,255,255,.92); text-align: center; padding: 10px; }
.ph span { font-size: 40px; } .ph b { font-size: 16px; } .ph small { opacity: .7; font-size: 12px; }
.ph.broken { background: var(--raised); color: var(--muted); font-size: 13px; }
.over { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.drop { display: block; padding: 18px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); font-size: 13px; text-align: center; cursor: pointer; }
.drop:hover { border-color: var(--accent); color: var(--ink); }
.drop input { display: none; }
.card-body { padding: 12px 14px 12px; display: grid; gap: 7px; flex: 1; align-content: start; }
.price-row { display: flex; justify-content: space-between; align-items: center; }
.price { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.price small { font-size: 13px; font-weight: 400; color: var(--muted); }
.facts-row { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13.5px; color: var(--chip-ink); }
.facts-row.big { font-size: 14.5px; align-items: baseline; gap: 14px; padding: 12px 0 4px; }
.feat-row { display: flex; gap: 5px; flex-wrap: wrap; }
.feat { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--ink); }
.feat.no { background: var(--chip); opacity: .45; text-decoration: line-through; }
.blurb { margin: 0; font-size: 13.5px; color: var(--muted); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.warnline { font-size: 12.5px; color: var(--bad); }
.card-foot { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: 8px; margin-top: auto; font-size: 13px; }
.mini-ratings { display: flex; gap: 12px; }
.sortby { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.sortby select { width: auto; padding: 6px 8px; }

/* ───────── Drawer gallery & details ───────── */
.gallery { position: relative; margin: 14px -22px 0; aspect-ratio: 16 / 10; background: #000; overflow: hidden; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .nav { position: absolute; top: 50%; transform: translateY(-50%); border: 0; width: 38px; height: 38px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 24px; line-height: 1; }
.gallery .prev { left: 10px; } .gallery .next { right: 10px; }
.thumbs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 0; }
.thumbs img { width: 72px; height: 50px; object-fit: cover; border-radius: 6px; cursor: pointer; opacity: .6; border: 2px solid transparent; flex: none; }
.thumbs img.on, .thumbs img:hover { opacity: 1; border-color: var(--accent); }
.thumbs.edit { flex-wrap: wrap; margin-top: 10px; }
.thumb { position: relative; } .thumb img { opacity: 1; cursor: default; }
.thumb .rm { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--bad); color: #fff; font-size: 13px; line-height: 1; }
.love { margin-top: 12px; padding: 8px 12px; border-radius: 8px; background: color-mix(in srgb, #e2457a 22%, transparent); font-weight: 600; font-size: 14px; }
.highlights { margin: 0 0 12px; padding-left: 18px; font-size: 14px; line-height: 1.5; }
.details { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 16px; margin: 0; }
.details dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.details dd { margin: 2px 0 0; font-size: 14px; }
.desc { margin-top: 12px; font-size: 14px; } .desc summary { cursor: pointer; color: var(--accent); }
.desc p { white-space: pre-wrap; line-height: 1.5; color: var(--chip-ink); }
.inline-form { display: flex; gap: 6px; }
