:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6a64;
  --line: #e4e2da;
  --accent: #0f766e;
  --accent-soft: #ccfbf1;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --vote: #e11d48;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}
button, input, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover { border-color: var(--muted); }
button:disabled { opacity: .55; cursor: wait; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
input, textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--panel);
  width: 100%;
}
input[type=checkbox] { width: auto; vertical-align: -2px; margin: 0 4px 0 0; }

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.trip-title {
  border: none;
  font-size: 20px;
  font-weight: 650;
  padding: 2px 0;
  max-width: 340px;
  background: transparent;
}
.trip-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.trip-select {
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 6px;
  max-width: 190px;
}
.danger-btn { background: var(--bad); border-color: var(--bad); color: #fff; }
.settings { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.settings label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.settings input[type=number] { width: 64px; }
.settings .me input { width: 130px; }

/* Map fills the screen; the list floats over it on the right. */
.layout { flex: 1; position: relative; min-height: 0; }
.sidebar {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  width: 440px;
  max-width: calc(100% - 32px);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(246, 245, 241, .94);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .18);
  overflow: hidden;
}
.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.filter { display: block; color: var(--muted); font-size: 13px; }
.list-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; }
.list-controls select {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px 6px;
}
.list { overflow-y: auto; padding: 12px 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.map { position: absolute; inset: 0; }

.comments { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.comments-toggle { padding-left: 0; }
.comment { padding: 6px 0; border-bottom: 1px dotted var(--line); font-size: 13px; }
.comment-head { display: flex; align-items: center; gap: 6px; }
.comment-head span { color: var(--muted); font-size: 12px; flex: 1; }
.comment-head .ghost { padding: 0 4px; font-size: 16px; line-height: 1; }
.comment-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: flex; gap: 6px; align-items: flex-end; margin-top: 8px; }
.comment-form textarea { resize: vertical; min-height: 38px; }
.empty { color: var(--muted); text-align: center; padding: 40px 12px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: box-shadow .15s, border-color .15s;
}
.card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.card-head { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; }
.card h3 { margin: 0; font-size: 15px; cursor: pointer; }
.card .addr { color: var(--muted); font-size: 12px; margin-top: 2px; }
.rank { font-size: 12px; color: var(--muted); white-space: nowrap; }

.photos {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin: 8px -14px 4px;
  padding: 0 14px 4px;
  scroll-snap-type: x mandatory;
}
.photos a { flex: none; scroll-snap-align: start; }
.photos img { display: block; height: 130px; width: auto; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 8px; background: var(--line); }

/* Yandex vs Google switch, bottom-left over the map (the list panel is on the right). */
.map-switch {
  position: absolute;
  left: 12px;
  bottom: 36px;
  z-index: 1000;
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
.map-switch button { border: none; border-radius: 999px; padding: 4px 12px; background: none; color: var(--muted); }
.map-switch button.on { background: var(--accent); color: #fff; }

/* Google anchors marker content at its bottom center, so the wrapper is exactly pin-sized. */
.gpin { position: relative; width: 240px; height: 74px; }
.gpin .pin { left: 0; top: 0; }

/* Map pin: a card whose bottom-center tip sits on the point (240×74, matches PIN in app.js). */
.pin {
  position: absolute;
  left: -120px;
  top: -74px;
  width: 240px;
  height: 66px;
  display: flex;
  gap: 8px;
  padding: 5px;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
  font: 12px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  cursor: pointer;
  box-sizing: border-box;
}
.pin::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  margin-left: -7px;
  border: 7px solid transparent;
  border-bottom: 0;
  border-top-color: var(--accent);
}
.pin.unfit { border-color: var(--warn); opacity: .85; }
.pin.unfit::after { border-top-color: var(--warn); }
.pin.active { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, .3), 0 4px 14px rgba(0, 0, 0, .3); opacity: 1; }
.pin.active::after { border-top-color: #2563eb; }
.pin img, .pin-nophoto { flex: none; width: 52px; height: 52px; border-radius: 6px; object-fit: cover; background: var(--line); }
.pin-nophoto { display: grid; place-items: center; font-size: 22px; }
.pin-body { min-width: 0; flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.pin-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-price { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-price b { font-size: 13px; }
.pin .muted { color: var(--muted); }
.pin-meta { display: flex; justify-content: space-between; gap: 4px; color: var(--muted); white-space: nowrap; }
.pin-votes { color: var(--vote); font-weight: 600; }

.price { margin: 8px 0 6px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.price b { font-size: 16px; }
.price span { color: var(--muted); }

.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px 12px; margin: 6px 0; font-size: 13px; }
.facts div { display: flex; justify-content: space-between; border-bottom: 1px dotted var(--line); padding: 2px 0; }
.facts dt { color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.chip { font-size: 12px; padding: 1px 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); }

.summary {
  margin: 10px 0 6px;
  padding: 10px 12px;
  background: #f1f7f6;
  border-radius: 8px;
  font-size: 13px;
}
.summary .label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); font-weight: 600; margin-bottom: 4px; }
.summary p { margin: 4px 0; }
.summary ul { margin: 4px 0; padding-left: 18px; }

.card-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.vote { border-color: var(--vote); color: var(--vote); }
.vote.on { background: var(--vote); color: #fff; }
.voters { color: var(--muted); font-size: 12px; flex: 1; min-width: 100px; }
.link { color: var(--accent); font-size: 13px; }
.ghost { border: none; background: none; color: var(--muted); padding: 4px 6px; }
.ghost:hover { color: var(--text); }
.ghost.danger:hover { color: var(--bad); }
.ghost.danger.armed { color: #fff; background: var(--bad); border-radius: 8px; padding: 4px 10px; }


dialog {
  border: none;
  border-radius: 14px;
  padding: 20px;
  width: min(620px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 12px; }
.grid label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.grid .wide { grid-column: 1 / -1; }
.import {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: #f1f7f6;
  border-radius: 8px;
  font-size: 13px;
  color: var(--muted);
}
.row { display: flex; gap: 6px; }
.row button { white-space: nowrap; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.sidebar-head { gap: 8px; align-items: flex-start; }
.head-actions { display: flex; gap: 2px; align-items: center; flex: none; }
.head-actions button { white-space: nowrap; }
.head-actions .ghost { padding: 6px 8px; }
.muted { color: var(--muted); }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 12px; }
.bookmarklet {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  cursor: grab;
}
.price-line { background: #f1f7f6; border-radius: 8px; padding: 8px 10px; font-size: 13px; white-space: pre-wrap; }
.raw summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.raw pre { max-height: 180px; overflow: auto; background: var(--bg); border-radius: 8px; padding: 8px; font-size: 12px; white-space: pre-wrap; user-select: all; }
.price-src { color: var(--muted); font-size: 12px; margin-top: -4px; }
.price-src.bad { color: var(--warn); }
.price-src.ok { color: var(--accent); margin-top: 2px; }
.settings label input[type=date] { width: 140px; }

/* Loading placeholders: the price comes from Airbnb separately, a few seconds after the rest. */
.skeleton {
  display: inline-block;
  height: 1em;
  vertical-align: middle;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--line) 0%, #f4f3ee 50%, var(--line) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}
.price.loading { align-items: center; min-height: 24px; }
.price.loading .skeleton:first-child { height: 20px; }
.spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  vertical-align: -1px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
input.loading { background: linear-gradient(90deg, var(--panel) 0%, var(--accent-soft) 50%, var(--panel) 100%); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .skeleton, .spinner, input.loading { animation: none; }
}
.hint { color: var(--muted); font-size: 12px; min-height: 1em; }
.hint.bad { color: var(--warn); }
.pin-busy { color: var(--warn); font-weight: 600; }
.error { color: var(--bad); min-height: 1em; margin: 8px 0 0; }

.pick-hint, .toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  z-index: 2000;
}
.pick-hint { top: 70px; }
.pick-hint button { background: none; border: none; color: #fff; text-decoration: underline; padding: 0; }
.toast { bottom: 24px; }
.toast.error { background: var(--bad); }

@media (max-width: 800px) {
  /* On phones the panel becomes a sheet over the lower part of the map. */
  .sidebar { top: 40%; left: 8px; right: 8px; bottom: 8px; width: auto; max-width: none; }
  .map-switch { left: auto; right: 10px; bottom: auto; top: 10px; }
  .grid { grid-template-columns: 1fr 1fr; }
}
