:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --text: #1d2420;
  --muted: #6b746e;
  --line: #e2ded4;
  --accent: #1f6f54;
  --accent-soft: #e3f1ea;
  --new: #d9480f;
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 6px 20px rgba(20, 30, 25, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --surface: #1e2421;
    --text: #e9ece9;
    --muted: #98a39c;
    --line: #2f3833;
    --accent: #5fc39c;
    --accent-soft: #23382f;
    --new: #ff8a4c;
    --danger: #ff8a80;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

h1 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.logo { font-size: 28px; }

.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 999px; }
.tab {
  border: 0;
  background: transparent;
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.count {
  display: inline-block;
  min-width: 22px;
  padding: 0 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  text-align: center;
}

.ghost {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 7px 12px;
  border-radius: 10px;
  white-space: nowrap;
}
.ghost:hover { border-color: var(--accent); color: var(--accent); }
.ghost.small { font-size: 13px; padding: 5px 10px; }

.layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  align-items: start;
}

.filters {
  position: sticky;
  top: 84px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  max-height: calc(100vh - 104px);
  overflow-y: auto;
}
.filters summary { font-weight: 700; font-size: 16px; cursor: pointer; list-style: none; }
.filters summary::-webkit-details-marker { display: none; }
fieldset { border: 0; padding: 0; margin: 16px 0 0; min-width: 0; }
legend { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }

input[type="text"], input[type="number"], select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Fully custom slider so it looks the same in Safari, Chrome and Firefox. */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 22px;
  margin: 2px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--fill, 100%), var(--line) var(--fill, 100%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 999px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 999px; background: var(--accent); }
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
.range-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
legend output { float: right; margin-left: 8px; color: var(--accent); }
.range { display: flex; align-items: center; gap: 6px; }
.range span { color: var(--muted); }
.hint { margin-top: 5px; font-size: 12px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:not(:empty) { margin-bottom: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}
.chip button { border: 0; background: transparent; color: inherit; padding: 0 5px; font-size: 15px; line-height: 1; }

.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.toggles button {
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
}
.toggles button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .toggles button.on { color: #10201a; } }
#reset { margin-top: 18px; }

.toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar #summary { margin-right: auto; }
.check, .sort { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.sort select {
  width: auto;
  appearance: none;
  -webkit-appearance: none;
  padding: 7px 34px 7px 12px;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%236b746e' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  transition: border-color .15s, box-shadow .15s;
}
.sort select:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.card.is-new { border-color: var(--new); }
.card .photo { position: relative; display: block; aspect-ratio: 3 / 2; background: var(--line); }
.card .photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; }
.badge {
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(20, 24, 22, .78);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.badge.new { background: var(--new); letter-spacing: .04em; }
.card .body { padding: 12px 14px 4px; flex: 1; }
.price { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.price small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.address { margin-top: 2px; font-weight: 600; }
.address a { color: inherit; text-decoration: none; }
.address a:hover { text-decoration: underline; }
.facts { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 14px; }
.layout-text { margin-top: 6px; font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { padding: 2px 8px; border-radius: 6px; background: var(--bg); font-size: 12px; color: var(--muted); }

.actions { display: flex; gap: 8px; padding: 12px 14px 14px; }
.actions button {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
}
.actions .reject:hover { border-color: var(--danger); color: var(--danger); }
.actions .save { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .actions .save { color: #10201a; } }
.actions .save:hover { filter: brightness(1.08); }

/* Save celebration: the button turns warm, the heart beats and a burst of hearts floats up. */
.actions .save { position: relative; transition: background .25s, border-color .25s; }
.actions .save.saving { background: #e5484d; border-color: #e5484d; color: #fff; animation: save-pop .5s cubic-bezier(.3, 1.6, .5, 1); }
.actions .save.saving .heart { display: inline-block; animation: heart-beat .5s ease-in-out 2; }
.card.saving { animation: card-glow 1s ease-out; }
.card.saving .reject { opacity: .35; pointer-events: none; }
.burst {
  position: absolute;
  left: 50%;
  top: 40%;
  pointer-events: none;
  color: #e5484d;
  font-size: var(--size);
  animation: burst 1s cubic-bezier(.2, .7, .3, 1) var(--delay) both;
}
@keyframes save-pop { 0% { transform: scale(1); } 35% { transform: scale(.92); } 70% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes heart-beat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.5); } }
@keyframes card-glow { 0% { box-shadow: 0 0 0 0 rgba(229, 72, 77, .5); } 100% { box-shadow: 0 0 0 18px rgba(229, 72, 77, 0); } }
@keyframes burst {
  0% { transform: translate(-50%, 0) scale(.3) rotate(0); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), var(--dy)) scale(1) rotate(var(--rot)); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .actions .save.saving, .actions .save.saving .heart, .card.saving { animation: none; }
  .burst { display: none; }
}

.empty {
  grid-column: 1 / -1;
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

#more { display: block; margin: 20px auto 0; }
.footer-note { margin-top: 24px; text-align: center; }
.footer-note button { border: 0; background: none; color: var(--accent); text-decoration: underline; padding: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-radius: 12px;
  background: #1d2420;
  color: #fff;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .3);
  z-index: 20;
}
.toast[hidden] { display: none; }
.toast button { border: 0; background: none; color: #8fe0bd; font-weight: 700; padding: 0; }

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .tabs { order: 3; width: 100%; }
  .tab { flex: 1; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px; gap: 16px; }
  .filters { position: static; max-height: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}
