:root {
  --paper: #efe8dc;
  --ink: #1b1713;
  --muted: #6d6458;
  --line: #d8cdb8;
  --card: #fffaf1;
  --card2: #f7f0e4;
  --accent: #9c4324;
  --yes: #215c3c;
  --yesbg: #dceee3;
  --maybe: #8a6414;
  --maybebg: #f3e6c0;
  --no: #6a6258;
  --nobg: #e8e2d8;
  --shadow: 0 1px 0 rgba(27,23,19,.04), 0 12px 32px rgba(27,23,19,.06);
  --list-w: min(380px, 26vw);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  height: 100%;
  overflow: hidden;
  max-width: 100%;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}
body { font: 16px/1.5 "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif; }
.ui, button, select, label, .share-note, .area, .meta, .more, .kicker, .pill, footer, .legend-title, .legend-item, .chip-house, .section-h p, .rate-bar, .voter, .rate-hint, .why, .rate-done, .vote-chip, .fb-comments, .rate-fab {
  font-family: "Avenir Next", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
}
a { color: var(--accent); }
code { font-size: .92em; }

.app {
  height: 100dvh;
  width: 100%;
  max-width: 100vw;
  display: grid;
  grid-template-columns: 1fr var(--list-w);
  grid-template-rows: auto auto 1fr;
  overflow: hidden;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: flex-end;
  justify-content: space-between;
  padding: 10px 14px 10px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  z-index: 6;
  min-width: 0;
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.kicker {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0;
  white-space: nowrap;
}
h1 {
  font-size: clamp(22px, 2.4vw, 32px);
  line-height: 1;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.03em;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1 1 420px;
  min-width: 0;
}
label.f {
  display: grid;
  gap: 3px;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
select, button, input, textarea {
  font-size: 16px;
  line-height: 1.2;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 10px;
}
button.primary { background: var(--ink); color: #f7f0e4; border-color: var(--ink); cursor: pointer; }
button.ghost { cursor: pointer; }
button.compact { padding: 6px 10px; font-size: 13px; }
button:hover { filter: brightness(1.03); }
.share { display: grid; gap: 4px; justify-items: end; }
.share-note { font-size: 12px; color: var(--muted); min-height: 1.2em; max-width: 220px; text-align: right; }
.mobile-only { display: none; }
.view-switch { display: flex; align-items: center; }

.brief {
  grid-column: 1 / -1;
  padding: 8px 14px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--card2);
}
.lede { max-width: 46rem; color: var(--muted); margin: 0 0 10px; font-size: 16px; }
.ask {
  display: grid;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.ask b { font-weight: 600; }
.ask span { font-family: "Avenir Next", ui-sans-serif, system-ui, sans-serif; font-size: 13px; color: var(--muted); }

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
}
#map { width: 100%; height: 100%; background: #e4d8c6; }
.leaflet-container { font-family: "Avenir Next", ui-sans-serif, system-ui, sans-serif; background: #e4d8c6; }

.map-legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 5;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
}
.legend-title { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink); cursor: pointer; }
.swatch { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; display: inline-block; }
.swatch.r1 { color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, transparent); }
.swatch.r2 { color: var(--maybe); background: color-mix(in srgb, var(--maybe) 22%, transparent); }
.swatch.r3 { color: var(--no); background: color-mix(in srgb, var(--no) 18%, transparent); }

.listpane {
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--paper);
  border-left: 1px solid var(--line);
  padding: 10px 12px 28px;
}
.section-h { display: flex; justify-content: space-between; align-items: baseline; margin: 8px 0 8px; gap: 10px; }
.section-h h2 { font-size: 18px; margin: 0; font-weight: 600; }
.section-h p { margin: 0; color: var(--muted); font-size: 12px; }
.short { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.chip-house {
  flex: 0 0 168px;
  background: var(--ink);
  color: #f6efe4;
  border-radius: 12px;
  text-decoration: none;
  overflow: hidden;
  display: block;
}
.chip-house img { width: 100%; height: 72px; object-fit: cover; display: block; background: #2a241c; }
.chip-house .chip-body { padding: 8px 10px 10px; font-size: 13px; }
.chip-house small { display: block; color: #c9bba6; font-size: 11px; }
.empty { color: var(--muted); font-size: 13px; padding: 4px 0 8px; }

.list { display: grid; gap: 12px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0 12px 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
  min-width: 0;
  cursor: pointer;
}
.card.picked { outline: 2px solid var(--ink); outline-offset: 1px; }
.card.active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  background: #fff6e8;
}
.top { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 8px; }
.pill {
  font: 600 11px/1 "Avenir Next", ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
}
.yes { color: var(--yes); background: var(--yesbg); }
.maybe { color: var(--maybe); background: var(--maybebg); }
.no { color: var(--no); background: var(--nobg); }
.pin {
  appearance: none; width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
  font: 14px/28px "Avenir Next", sans-serif; text-align: center; padding: 0; color: var(--muted);
}
.pin.on { background: var(--ink); color: #f7f0e4; border-color: var(--ink); }
.card h3 { margin: 0; font-size: 20px; line-height: 1.15; letter-spacing: -.02em; }
.area { color: var(--muted); font-size: 12px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 13px; }
.meta b { font-weight: 600; }
.price { font-size: 16px; }
.more { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-align: left; font-size: 13px; }
.notes { display: none; color: #3a332b; font-size: 14px; }
.card.open .notes { display: block; }
.vote-chip {
  font: 600 11px/1 "Avenir Next", ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .03em;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--nobg);
  color: var(--no);
  white-space: nowrap;
}
.vote-chip.like { background: var(--yesbg); color: var(--yes); }
.vote-chip.mixed { background: var(--maybebg); color: var(--maybe); }
.fb-comments { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); color: var(--muted); font-size: 13px; }
.fb-comments div { margin: 4px 0; }

.pics {
  position: relative;
  margin: 0 -12px 2px;
  width: calc(100% + 24px);
  height: 120px;
  background: #e8dfd0;
  cursor: pointer;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
}
.pics img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: none;
  background: #ddd4c4;
}
.pics img.on { display: block; }
.pics .nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 50%;
  background: rgba(27,23,19,.55);
  color: #f7f0e4;
  cursor: pointer;
  font: 16px/26px "Avenir Next", ui-sans-serif, system-ui, sans-serif;
  padding: 0;
  text-align: center;
}
.pics .nav.prev { left: 8px; }
.pics .nav.next { right: 8px; }
.pics .dots {
  position: absolute;
  left: 0; right: 0; bottom: 7px;
  display: flex; justify-content: center; gap: 4px;
  pointer-events: none;
}
.pics .dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,250,241,.42);
  display: block;
}
.pics .dots i.on { background: #fffaf1; }

.leaflet-div-icon { background: none; border: none; }
.mk {
  width: 30px;
  height: 30px;
  margin-left: -15px;
  margin-top: -28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--maybe);
  color: #fffaf1;
  border: 2px solid #fffaf1;
  box-shadow: 0 4px 10px rgba(27,23,19,.28);
  display: grid;
  place-items: center;
}
.mk span {
  transform: rotate(45deg);
  font: 700 10px/1 "Avenir Next", ui-sans-serif, system-ui, sans-serif;
}
.mk.fit-yes { background: var(--yes); }
.mk.fit-maybe { background: #b7781c; }
.mk.fit-no { background: #8a8176; }
.mk.pinned { box-shadow: 0 0 0 2px var(--ink), 0 4px 10px rgba(27,23,19,.28); }
.mk.active {
  width: 36px;
  height: 36px;
  margin-left: -18px;
  margin-top: -34px;
  background: var(--accent);
  z-index: 50;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent), 0 6px 14px rgba(27,23,19,.35);
}

.lightbox {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(12,10,8,.92);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px 56px;
}
.lightbox.on { display: flex; }
.lightbox img {
  max-width: min(92vw, 1100px);
  max-height: 86vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.lightbox .x {
  position: absolute; top: 14px; right: 16px;
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: rgba(255,250,241,.12); color: #f7f0e4;
  font: 22px/36px "Avenir Next", ui-sans-serif, system-ui, sans-serif;
  cursor: pointer; padding: 0; text-align: center;
}
.lightbox .nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: rgba(255,250,241,.12); color: #f7f0e4;
  font: 26px/40px "Avenir Next", ui-sans-serif, system-ui, sans-serif;
  cursor: pointer; padding: 0; text-align: center;
}
.lightbox .nav.prev { left: 12px; }
.lightbox .nav.next { right: 12px; }
.lightbox .lb-cap {
  position: absolute; left: 0; right: 0; bottom: 14px;
  text-align: center; color: #c9bba6;
  font: 13px/1.3 "Avenir Next", ui-sans-serif, system-ui, sans-serif;
}

footer { margin-top: 22px; color: var(--muted); font-size: 12px; line-height: 1.45; }

.rate-fab {
  display: none;
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 5;
  box-shadow: var(--shadow);
}

.ratepane {
  display: none;
  grid-column: 1 / -1;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
  background: var(--paper);
}
body.view-rate .app {
  grid-template-columns: 1fr;
  grid-template-rows: auto auto minmax(0, 1fr);
}
body.view-rate .stage,
body.view-rate .listpane,
body.view-rate .filters,
body.view-rate .share,
body.view-rate #filterToggle { display: none; }
body.view-rate .ratepane {
  display: flex;
  grid-row: 3;
}
body.view-rate .rate-fab { display: none; }

.rate-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.rate-progress {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.voter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}
.voter input {
  width: 10.5rem;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 16px;
}
.deck {
  position: relative;
  flex: 1;
  min-height: 0;
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
}
.swipe-card {
  position: absolute;
  inset: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  touch-action: none;
  user-select: none;
  will-change: transform;
}
.swipe-card.next {
  transform: scale(.965);
  opacity: .55;
  z-index: 1;
  pointer-events: none;
}
.swipe-card.current { z-index: 2; }
.swipe-card.fly-like {
  transition: transform .28s ease-out;
  transform: translateX(120vw) rotate(18deg);
}
.swipe-card.fly-pass {
  transition: transform .28s ease-out;
  transform: translateX(-120vw) rotate(-18deg);
}
.swipe-pics {
  position: relative;
  flex: 1 1 58%;
  min-height: 220px;
  background: #e8dfd0;
  cursor: pointer;
}
.swipe-pics img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  background: #ddd4c4;
}
.swipe-pics img.on { display: block; }
.swipe-pics .nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(27,23,19,.55);
  color: #f7f0e4;
  cursor: pointer;
  font: 18px/34px "Avenir Next", ui-sans-serif, system-ui, sans-serif;
  padding: 0;
  text-align: center;
}
.swipe-pics .nav.prev { left: 10px; }
.swipe-pics .nav.next { right: 10px; }
.swipe-pics .dots {
  position: absolute;
  left: 0; right: 0; bottom: 10px;
  display: flex; justify-content: center; gap: 5px;
  pointer-events: none;
}
.swipe-pics .dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255,250,241,.42);
  display: block;
}
.swipe-pics .dots i.on { background: #fffaf1; }
.stamp {
  position: absolute;
  top: 16px;
  font: 800 26px/1 "Avenir Next", ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .14em;
  border: 4px solid;
  padding: 6px 10px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  background: color-mix(in srgb, var(--card) 70%, transparent);
}
.stamp.like { left: 14px; color: var(--yes); border-color: var(--yes); transform: rotate(-14deg); }
.stamp.pass { right: 14px; color: var(--no); border-color: var(--no); transform: rotate(14deg); }
.swipe-card.lean-like .stamp.like,
.swipe-card.fly-like .stamp.like { opacity: 1; }
.swipe-card.lean-pass .stamp.pass,
.swipe-card.fly-pass .stamp.pass { opacity: 1; }
.swipe-body {
  padding: 12px 14px 14px;
  display: grid;
  gap: 4px;
}
.swipe-body h3 { margin: 0; font-size: 24px; line-height: 1.15; letter-spacing: -.03em; }
.swipe-place { color: var(--muted); font-size: 13px; }
.swipe-price { font-size: 18px; }
.swipe-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 13px; color: #3a332b; }
.rate-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
}
.rate-actions button {
  flex: 1;
  min-height: 52px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.rate-actions .pass { background: var(--card); color: var(--no); }
.rate-actions .like { background: var(--yes); color: #f4fff7; border-color: var(--yes); }
.rate-hint { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }
.why {
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}
.why p { margin: 0 0 8px; font-size: 14px; }
.why small { color: var(--muted); font-weight: 400; }
.why-row { display: flex; gap: 8px; align-items: center; }
.why-row input { flex: 1; min-width: 0; font-size: 16px; }
.rate-done {
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 16px 16px;
  box-shadow: var(--shadow);
}
.rate-done h2 { margin: 0 0 8px; font-size: 26px; }
.rate-done .tally { display: flex; gap: 10px; margin: 0 0 12px; }
.rate-done .tally span {
  background: var(--card2);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
}
.rate-done ul { margin: 0 0 14px; padding-left: 1.1em; }
.rate-done .done-actions { display: flex; gap: 8px; }
.rate-done .done-actions button { flex: 1; cursor: pointer; }
.api-note {
  font-size: 12px;
  color: var(--accent);
  text-align: center;
  margin: 0;
}

@media (max-width: 860px) {
  html, body { overflow: hidden; }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 46vh minmax(0, 1fr);
    height: 100dvh;
  }
  body.view-rate .app {
    grid-template-rows: auto auto minmax(0, 1fr);
  }
  .stage {
    height: 46vh;
    min-height: 260px;
  }
  .listpane {
    border-left: 0;
    border-top: 1px solid var(--line);
    min-height: 0;
  }
  .mobile-only { display: inline-block; }
  .filters {
    display: none;
    flex: 1 1 100%;
    padding-top: 4px;
  }
  .filters.open { display: flex; }
  .share { justify-items: start; }
  .share-note { text-align: left; max-width: none; }
  .map-legend { left: 8px; bottom: 8px; padding: 6px 8px; }
  .legend-item { font-size: 11px; }
  h1 { font-size: 24px; }
  .topbar { padding: 8px 10px; }
  .rate-fab { display: inline-block; }
  body.view-rate .rate-fab { display: none; }
  .swipe-body h3 { font-size: 22px; }
  .rate-actions button { min-height: 56px; }
}

@media (max-width: 420px) {
  .stage { height: 42vh; min-height: 240px; }
  .app { grid-template-rows: auto auto 42vh minmax(0, 1fr); }
  .map-legend { max-width: calc(100% - 16px); }
}
