:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-muted: #f8f9fb;
  --text: #121417;
  --text-soft: #4b4f56;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --radius-lg: 26px;
  --radius-md: 18px;
  font-size: clamp(15px, 1.1vw, 16px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

main {
  width: min(1280px, 100%);
  padding: clamp(0.7rem, 3vw, 1.6rem) 0;
  margin: 0 auto;
}

.layout {
  display: grid;
  gap: clamp(0.9rem, 3vw, 1.4rem);
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  align-items: start;
}

.anchor-panel {
  position: sticky;
  top: clamp(0.35rem, 2vw, 1rem);
  display: grid;
  gap: clamp(0.55rem, 2vw, 1rem);
  align-self: start;
}

.search-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: clamp(0.45rem, 1.6vw, 0.75rem);
  box-shadow: 0 24px 70px -40px rgba(10, 20, 40, 0.35);
  display: grid;
  gap: 0.55rem;
}


.search-controls {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.sort-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.sort-options {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 auto;
  min-width: 240px;
}

.sort-option {
  border: 1px solid rgba(17, 24, 39, 0.12);
  border-radius: 999px;
  background: var(--surface-muted);
  font: inherit;
  font-size: 0.85rem;
  color: var(--text-soft);
  padding: 0.32rem 0.85rem;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.sort-option:hover {
  color: var(--accent);
  border-color: rgba(37, 99, 235, 0.45);
}

.sort-option.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(37, 99, 235, 0.55);
}

.sort-option:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.source-filter {
  display: inline-flex;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-soft);
  flex: 0 0 auto;
}

.source-select {
  appearance: auto;
  -webkit-appearance: auto;
  -moz-appearance: auto;
  border-radius: var(--radius-md);
  border: 1px solid rgba(17, 24, 39, 0.12);
  background-color: var(--surface-muted);
  padding: 0.3rem 0.65rem;
  font: inherit;
  color: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  width: clamp(7.5rem, 28vw, 10.5rem);
}

.source-select:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

@media (max-width: 720px) {
  .sort-controls {
    flex-wrap: nowrap;
  }

  .sort-options {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-start;
    gap: 0.25rem;
  }

  .source-filter {
    flex: 0 0 auto;
  }

  .source-select {
    width: clamp(6.5rem, 34vw, 9rem);
    font-size: 0.95rem;
  }
}

.search-input-wrap {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
}

.search-input {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--surface-muted);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  border: 1px solid rgba(17, 24, 39, 0.08);
  font: inherit;
  color: inherit;
}

.search-input-wrap .search-input {
  padding-right: 2.1rem;
}

.autocomplete-list {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  width: 100%;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid rgba(17, 24, 39, 0.15);
  border-radius: var(--radius-md);
  box-shadow: 0 14px 30px -18px rgba(15, 23, 42, 0.45);
  padding: 0.25rem;
  display: none;
  z-index: 10;
}

.autocomplete-list.visible {
  display: block;
}

.autocomplete-item {
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.6rem;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.autocomplete-item.location-option {
  font-weight: 600;
  color: var(--accent);
}

.autocomplete-item:hover,
.autocomplete-item:focus-visible,
.autocomplete-item.active {
  background: rgba(37, 99, 235, 0.1);
  color: var(--accent);
  outline: none;
}

.autocomplete-item.location-option:hover,
.autocomplete-item.location-option:focus-visible,
.autocomplete-item.location-option.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.search-input::-webkit-calendar-picker-indicator {
  display: none !important;
}

.search-clear {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}

.search-clear:hover,
.search-clear:focus-visible {
  color: var(--accent);
  background: rgba(37, 99, 235, 0.08);
}

.search-clear[hidden] {
  display: none;
}

.clear-icon {
  width: 0.9rem;
  height: 0.9rem;
}

.search-input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: rgba(37, 99, 235, 0.3);
}

.search-button {
  flex: 0 0 auto;
  border: none;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  font: inherit;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.55rem;
  height: 2.55rem;
}

.search-button .search-icon {
  width: 1rem;
  height: 1rem;
}

.search-button:hover {
  transform: translateY(-1px);
  background: #1d4ed8;
}

.map-shell {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 28px 60px -40px rgba(10, 20, 40, 0.35);
  background: #d1d5db;
}

#map {
  width: 100%;
  height: clamp(120px, 20vh, 200px);
}

.results-panel {
  display: grid;
  gap: clamp(0.75rem, 2.5vw, 1.1rem);
}

.results-grid {
  display: grid;
  gap: clamp(0.75rem, 2.5vw, 1.1rem);
}

.results-footer {
  display: grid;
  gap: 0.85rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: clamp(1.2rem, 3vw, 1.6rem);
  border: 1px solid rgba(17, 24, 39, 0.08);
  box-shadow: 0 28px 60px -48px rgba(10, 20, 40, 0.35);
}

.results-footer[hidden] {
  display: none;
}

.results-footer-intro,
.results-footer-note {
  margin: 0;
  line-height: 1.5;
  color: var(--text-soft);
}

.results-footer-note {
  font-weight: 500;
  color: var(--text);
}

.feedback-form {
  display: grid;
  gap: 0.75rem;
}

.feedback-label {
  font-weight: 600;
  color: var(--text);
}

.feedback-form textarea {
  width: 100%;
  min-height: 120px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(17, 24, 39, 0.12);
  padding: 0.85rem;
  font: inherit;
  resize: vertical;
  background: rgba(255, 255, 255, 0.75);
  color: var(--text);
}

.feedback-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.feedback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

#feedbackSubmit {
  border: none;
  border-radius: var(--radius-md);
  padding: 0.65rem 1.2rem;
  font-weight: 600;
  font-size: 0.95rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease-in-out, transform 0.15s ease-in-out;
}

#feedbackSubmit:hover:not(:disabled) {
  background: #1d4ed8;
  transform: translateY(-1px);
}

#feedbackSubmit:disabled {
  background: rgba(37, 99, 235, 0.55);
  cursor: not-allowed;
  transform: none;
}

.feedback-status {
  min-height: 1.2em;
  font-size: 0.9rem;
  color: var(--text-soft);
}

.feedback-status.success {
  color: #047857;
}

.feedback-status.error {
  color: #b91c1c;
}

.status {
  display: none;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: clamp(1rem, 3vw, 1.4rem);
  border: 1px solid rgba(17, 24, 39, 0.07);
  box-shadow: 0 24px 48px -42px rgba(10, 20, 40, 0.35);
  color: var(--text-soft);
  font-size: 0.95rem;
}

.status.visible {
  display: block;
}

.status.loading {
  border-color: rgba(37, 99, 235, 0.3);
  color: var(--accent);
}

.status.error {
  border-color: rgba(220, 38, 38, 0.35);
  color: #b91c1c;
  background: rgba(254, 226, 226, 0.6);
}

.status.success {
  border-color: rgba(16, 185, 129, 0.35);
  color: #047857;
  background: rgba(236, 253, 245, 0.65);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 40;
}

.modal-card {
  position: relative;
  background: var(--surface);
  color: inherit;
  border-radius: var(--radius-lg);
  padding: clamp(1rem, 3vw, 1.5rem);
  max-width: min(480px, 100%);
  box-shadow: 0 24px 60px -30px rgba(10, 20, 40, 0.45);
  display: grid;
  gap: 0.85rem;
}

.modal-card h2 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-card p {
  margin: 0;
  line-height: 1.5;
}

.modal-instructions {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.55rem;
  font-size: 0.92rem;
}

.modal-instructions li strong {
  color: var(--accent);
}

.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0.2rem;
  border-radius: var(--radius-md);
}

.modal-close:hover {
  background: rgba(17, 24, 39, 0.08);
}

.modal-close-icon {
  width: 1rem;
  height: 1rem;
}

.modal-primary {
  justify-self: start;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  font: inherit;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.modal-primary:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}

.result-card {
  display: grid;
  gap: clamp(0.9rem, 3vw, 1.1rem);
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(17, 24, 39, 0.05);
  box-shadow: 0 24px 48px -40px rgba(10, 20, 40, 0.35);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease, opacity 0.3s ease;
}

.result-card:not(.active) {
  opacity: 0.45;
  filter: grayscale(0.25);
}

.result-card:not(.active) .card-body h3,
.result-card:not(.active) .card-body p {
  color: var(--text-soft);
}

.result-card:not(.active) .card-actions a {
  opacity: 0.65;
}

.result-card.active {
  transform: translateY(-4px);
  box-shadow: 0 28px 56px -44px rgba(37, 99, 235, 0.45);
  border-color: rgba(37, 99, 235, 0.25);
  opacity: 1;
  filter: none;
}

.result-card.active .card-body h3 {
  color: var(--text);
}

.result-card.active .card-body p {
  color: var(--text-soft);
}

.result-card.active .card-actions a {
  opacity: 1;
}

.card-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-body {
  padding: clamp(1.1rem, 3vw, 1.5rem);
  display: grid;
  gap: 0.55rem;
}

.card-body .badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
}

.card-body h3 {
  margin: 0;
  font-size: clamp(1.1rem, 2.5vw, 1.4rem);
  font-weight: 600;
  transition: color 0.25s ease;
}

.article-headline {
  color: #1d4ed8;
}

.card-address {
  margin: 0.35rem 0 0.4rem;
  font-weight: 600;
}

.card-details {
  margin: 0;
  line-height: 1.55;
  color: var(--text-soft);
}

.card-status {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.card-meta span::before {
  content: "\2022";
  margin-right: 0.4rem;
  opacity: 0.55;
}

.card-meta span:first-child::before {
  content: "";
  margin: 0;
}

.rentcast-specs {
  margin: 0.4rem 0 0.6rem;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.rentcast-specs li {
  display: flex;
  gap: 0.35rem;
  align-items: baseline;
}

.rentcast-specs .spec-label {
  font-weight: 600;
  color: var(--text);
}

.rentcast-specs .spec-value {
  color: var(--text);
}

.card-body p {
  margin: 0;
  line-height: 1.55;
  color: var(--text-soft);
  transition: color 0.25s ease;
}

.card-actions a {
  text-decoration: none;
  font-weight: 600;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: opacity 0.25s ease;
}

.card-actions a:hover {
  opacity: 1;
}

.result-card.no-image .card-body {
  padding-top: clamp(1.2rem, 3vw, 1.6rem);
}

.marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  box-shadow: 0 6px 16px -6px rgba(12, 20, 40, 0.6);
  transition: transform 0.25s ease, opacity 0.25s ease, box-shadow 0.25s ease;
}

.marker.marker-user {
  background: #2563eb;
  opacity: 1;
}

.marker.marker-result {
  background: #ef4444;
  opacity: 0.7;
}

.marker.marker-result.active {
  transform: scale(1.25);
  opacity: 1;
  box-shadow: 0 10px 24px -8px rgba(37, 99, 235, 0.6);
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .anchor-panel {
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(var(--bg), var(--bg));
    padding-bottom: 1rem;
  }

  .card-meta span::before {
    display: none;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #111826;
    --surface-muted: #151c2c;
    --text: #eef1f8;
    --text-soft: #9aa3b5;
    --accent: #60a5fa;
    --accent-soft: rgba(96, 165, 250, 0.14);
  }

  .search-input {
    border-color: rgba(255, 255, 255, 0.07);
  }

  .autocomplete-list {
    border: 1px solid rgba(96, 165, 250, 0.25);
    background: var(--surface);
  }

  .autocomplete-item:hover,
  .autocomplete-item:focus-visible,
  .autocomplete-item.active {
    background: rgba(96, 165, 250, 0.18);
  }

  .search-clear:hover,
  .search-clear:focus-visible {
    background: rgba(96, 165, 250, 0.16);
  }

  .result-card {
    border: 1px solid rgba(255, 255, 255, 0.05);
  }

  .result-card.active {
    border-color: rgba(96, 165, 250, 0.35);
  }

  .status {
    border: 1px solid rgba(96, 165, 250, 0.18);
  }
}
