/* =============================================================
   FindSF — clean modern app aesthetic
   Sans throughout (Inter), tight layout, soft-rounded inputs,
   bold black CTA, single subtle accent for personality.
   ============================================================= */

:root {
  --bg: #fafafa;
  --bg-page: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f5f4;
  --ink: #09090b;
  --ink-2: #18181b;
  --muted: #71717a;
  --muted-2: #a1a1aa;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --accent: #d84a36;
  --accent-soft: #fff1ed;
  --focus-ring: rgba(9, 9, 11, 0.12);
  --header-height: 61px;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow-soft: 0 1px 2px rgba(9, 9, 11, 0.04), 0 0 0 1px rgba(9, 9, 11, 0.04);
  --shadow-pop: 0 8px 24px rgba(9, 9, 11, 0.08), 0 2px 6px rgba(9, 9, 11, 0.06);

  --ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--ui);
  background: var(--bg-page);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: var(--ink);
  color: var(--bg);
}

/* ============================================================
   Header
   ============================================================ */

.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  letter-spacing: -0.015em;
  font-size: 1rem;
}

.brand-mark {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 700;
  letter-spacing: -0.018em;
  font-size: 1.04rem;
}

.hamburger-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  cursor: pointer;
  color: var(--ink-2);
  transition: background 120ms ease;
}

.hamburger-btn:hover {
  background: var(--surface-2);
}

.hamburger-btn[hidden] {
  display: none;
}

@media (max-width: 768px) {
  .hamburger-btn {
    display: flex;
  }
}

.header-spacer {
  flex: 1;
}

.header-link {
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  color: var(--ink-2);
  transition: background 120ms ease, border-color 120ms ease;
}

.header-link:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.history-header-btn[hidden] {
  display: none;
}

@media (max-width: 768px) {
  .history-header-btn {
    display: none !important;
  }
}

.header-action {
  background: var(--ink);
  color: #fff;
  border: none;
  font-weight: 500;
  font-size: 0.88rem;
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}

.header-action:hover {
  background: #27272a;
}

.header-action:active {
  transform: scale(0.98);
}

.credits-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  font-family: inherit;
  transition: background 120ms ease, border-color 120ms ease;
}

/* `display: inline-flex` above overrides the [hidden] attribute's default
   display:none, so we restore it explicitly. */
.credits-badge[hidden] {
  display: none;
}

.credits-badge:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.credits-badge::before {
  content: "◈";
  color: var(--accent);
  font-size: 0.78rem;
}

.user-menu {
  position: relative;
}

.user-avatar-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  transition: border-color 120ms ease;
}

.user-avatar-btn:hover {
  border-color: var(--border-strong);
}

.user-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-avatar-fallback {
  font-weight: 600;
  font-size: 0.84rem;
  color: var(--ink-2);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: 8px;
  z-index: 40;
}

.user-dropdown[hidden] {
  display: none;
}

.user-dropdown-info {
  padding: 8px 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-dropdown-email {
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ink);
  word-break: break-all;
}

.user-dropdown-credits {
  font-size: 0.78rem;
  color: var(--muted);
}

.user-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--ink-2);
}

.user-dropdown-toggle[hidden] {
  display: none;
}

.user-dropdown-toggle:hover {
  background: var(--surface-2);
}

.user-dropdown-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.user-dropdown-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--ink-2);
}

.user-dropdown-btn:hover {
  background: var(--surface-2);
}

/* ============================================================
   Layout
   ============================================================ */

main {
  min-height: calc(100vh - 56px);
}

.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 24px;
  color: var(--muted);
  font-size: 0.84rem;
}

.app-footer a {
  color: var(--ink-2);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: rgba(113, 113, 122, 0.45);
  text-underline-offset: 3px;
}

.app-footer a:hover {
  color: var(--ink);
  text-decoration-color: currentColor;
}

.view[hidden] {
  display: none;
}

.view-search {
  padding: 56px 24px 80px;
  background: radial-gradient(ellipse 80% 45% at 50% -5%, rgba(216, 74, 54, 0.10) 0%, transparent 65%);
}

.search-shell {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.search-shell .search-form {
  width: 100%;
}

.prompt-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
  letter-spacing: -0.005em;
}

/* ============================================================
   Hero
   ============================================================ */

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 12px 5px 10px;
  border-radius: var(--radius-pill);
  margin-bottom: 22px;
}

.eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.hero-title {
  font-size: clamp(2.4rem, 6vw, 3.8rem);
  line-height: 1.05;
  letter-spacing: -0.036em;
  font-weight: 800;
  margin: 0 0 20px;
  color: var(--ink);
  text-align: center;
}

.hero-accent {
  background: linear-gradient(135deg, #c54130 0%, #f97316 58%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-tagline {
  font-size: 1rem;
  color: var(--muted);
  max-width: 50ch;
  margin: 0 0 14px;
  text-align: center;
}

.hero-trust {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 0 0 32px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
}

.hero-trust-green-soft {
  position: relative;
  padding: 8px 13px;
  border: 1px solid #86efac;
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, #f7fee7 0%, #ecfdf5 100%);
  color: #166534;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.08), 0 10px 26px rgba(22, 101, 52, 0.08);
}

.hero-trust-green-soft strong {
  color: #14532d;
}

.hero-trust-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18), 0 0 12px rgba(34, 197, 94, 0.36);
  flex: 0 0 auto;
  animation: hero-trust-pulse 1.8s ease-in-out infinite;
}

.hero-trust strong {
  color: var(--ink);
  font-weight: 800;
}

@keyframes hero-trust-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.82);
    opacity: 0.78;
  }
}


/* ============================================================
   Sources strip
   ============================================================ */

.sources-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.sources-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  flex-shrink: 0;
}

.sources-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-2);
  white-space: nowrap;
}

.source-icon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  display: block;
  flex-shrink: 0;
}

.source-name {
  line-height: 1;
}

.source-pill--soon {
  opacity: 0.45;
}

.source-coming-soon {
  font-size: 0.74rem;
  color: var(--muted-2);
  letter-spacing: 0.01em;
  text-align: center;
}

.search-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.05), 0 12px 40px rgba(0, 0, 0, 0.08);
}

/* ============================================================
   Form
   ============================================================ */

.search-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.prompt-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px 12px;
  box-shadow: var(--shadow-soft);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.prompt-block:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

#search-prompt {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  font: inherit;
  /* 16px is the iOS Safari threshold below which form inputs auto-zoom on focus. */
  font-size: 1rem;
  color: var(--ink);
  resize: vertical;
  min-height: 76px;
  line-height: 1.5;
  padding: 0;
}

#search-prompt::placeholder {
  color: var(--muted-2);
}

.search-prompt-counter {
  display: block;
  text-align: right;
  font-size: 11px;
  color: var(--muted-2);
  margin-top: 4px;
}

.search-prompt-counter--over {
  color: var(--error, #c0392b);
  font-weight: 600;
}

/* ----- Filter row ----- */

.filters-row {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 10px;
}

.price-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px 12px;
  box-shadow: var(--shadow-soft);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.filter-cell:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.filter-cell-label {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.filter-cell-control {
  display: flex;
  align-items: center;
}

.neighborhood-cell {
  display: flex;
  flex-direction: column;
  position: relative;
  cursor: pointer;
}

.neighborhood-cell .filter-cell-label {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.neighborhood-cell .filter-cell-control {
  position: absolute;
  inset: 0;
  display: block;
}

.neighborhood-cell .dropdown {
  height: 100%;
}

.neighborhood-cell .dropdown-trigger {
  height: 100%;
  padding: 32px 14px 12px;
  align-items: flex-start;
}

.type-cell {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 6px 0 0;
}

.type-cell:focus-within {
  border: none;
  box-shadow: none;
}

.type-cell .filter-cell-label {
  margin-bottom: 8px;
}

/* ----- Price ----- */

.price-inline {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  font-family: var(--mono);
  /* 16px to avoid iOS Safari zoom-on-focus on the inner input. */
  font-size: 1rem;
}

.price-prefix {
  color: var(--muted);
  font-weight: 500;
}

.price-divider {
  color: var(--muted);
  margin: 0 6px;
}

.price-suffix {
  color: var(--muted);
  font-family: var(--ui);
  font-size: 0.86rem;
  margin-left: 6px;
}

.price-inline input {
  width: 70px;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  color: var(--ink);
  padding: 0;
  font-weight: 500;
}

.price-inline input::-webkit-outer-spin-button,
.price-inline input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.price-inline input[type="number"] {
  -moz-appearance: textfield;
}

/* ----- Dropdown (neighborhood) ----- */

.dropdown {
  position: relative;
  width: 100%;
}

.dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0;
  background: transparent;
  border: none;
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.dropdown-trigger-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.dropdown-trigger-label[data-empty="true"] {
  color: var(--muted-2);
  font-weight: 400;
}

.dropdown-caret {
  margin-left: 10px;
  color: var(--muted);
  transition: transform 200ms ease;
}

.dropdown-trigger[aria-expanded="true"] .dropdown-caret {
  transform: rotate(180deg);
  color: var(--ink);
}

.dropdown-panel {
  position: absolute;
  top: calc(100% + 12px);
  left: -14px;
  right: -14px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  padding: 6px;
  z-index: 30;
}

.dropdown-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  font-size: 0.93rem;
  color: var(--ink-2);
}

.dropdown-option:hover {
  background: var(--surface-2);
}

.dropdown-option[aria-selected="true"] {
  background: var(--ink);
  color: #fff;
  font-weight: 500;
}

.dropdown-checkbox {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  transition: background 140ms ease, border-color 140ms ease;
  background: var(--surface);
}

.dropdown-option[aria-selected="true"] .dropdown-checkbox {
  background: #fff;
  border-color: #fff;
}

.dropdown-checkbox::before {
  content: "";
  display: block;
  width: 9px;
  height: 9px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none'><path d='M2.5 6.2 L4.8 8.5 L9.5 3.5' stroke='%2309090b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0;
}

.dropdown-option[aria-selected="true"] .dropdown-checkbox::before {
  opacity: 1;
}

/* ----- Type chips ----- */

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink-2);
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 120ms ease;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.chip[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

/* ============================================================
   CTA
   ============================================================ */

.cta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--ink);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-pill);
  font-weight: 500;
  font-size: 0.96rem;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 4px 14px rgba(9, 9, 11, 0.18);
  transition: background 140ms ease, transform 120ms ease, opacity 140ms ease;
}

.cta:hover:not(:disabled) {
  background: #27272a;
  transform: translateY(-1px);
}

.cta:active:not(:disabled) {
  transform: translateY(0);
}

.cta:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
}

.cta[data-state="loading"] {
  opacity: 0.86;
  cursor: wait;
}

.cta[data-state="loading"] .cta-arrow {
  display: none;
}

.cta[data-state="loading"] .cta-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  animation: image-spin 0.85s linear infinite;
}

.cta-accent {
  background: linear-gradient(135deg, #c54130 0%, #f97316 58%, #fbbf24 100%);
}

.cta-accent:hover:not(:disabled) {
  background: linear-gradient(135deg, #b83f2e 0%, #ea580c 58%, #f59e0b 100%);
}

.cta-arrow {
  display: inline-block;
  transition: transform 200ms ease;
  font-weight: 500;
}

.cta:hover:not(:disabled) .cta-arrow {
  transform: translateX(3px);
}

.cta-hint {
  color: var(--muted);
  font-size: 0.84rem;
}

.cta-hint[hidden] {
  display: none;
}

/* ============================================================
   Shared flow surface: Checking credits, Preview, and Results
   ============================================================ */

.view-results {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 32px;
  scroll-margin-top: calc(var(--header-height) + 24px);
}

.results-header {
  margin-bottom: 24px;
}

.admin-results-banner {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin: 0 0 12px;
  padding: 7px 11px;
  border: 1px solid #f59e0b;
  border-radius: var(--radius-pill);
  background: #fffbeb;
  color: #92400e;
  font-size: 0.82rem;
  font-weight: 600;
}

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

.results-header h2 {
  font-size: clamp(1.4rem, 2.6vw, 1.7rem);
  font-weight: 700;
  letter-spacing: -0.024em;
  margin: 0 0 4px;
}

.results-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.results-header .results-subtitle {
  margin-top: 12px;
  padding: 12px 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 3px solid #15803d;
  border-radius: var(--radius);
  color: var(--ink-2);
  font-size: 0.88rem;
  line-height: 1.5;
}

.results-header .results-subtitle::before {
  content: "AI reason";
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #15803d;
  margin-bottom: 5px;
}

.results-agent-status {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 18px;
  margin: 8px 0 6px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(9, 9, 11, 0.48);
}

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

.results-error {
  background: var(--accent-soft);
  color: #991b1b;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin: 16px 0;
  font-size: 0.92rem;
}

/* ============================================================
   Preview overlay ("Get AI results" gate)
   Centers the paywall over a faded sample of the result grid.
   ============================================================ */

.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 96px 24px 32px;
  pointer-events: auto;
  animation: overlay-fade-in 240ms ease;
}

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

.preview-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.74) 42%, #fff 100%),
    radial-gradient(circle at 50% 46%, rgba(216, 74, 54, 0.13), rgba(216, 74, 54, 0) 34%);
  pointer-events: auto;
}

.preview-overlay[data-mode="searching"]::before {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0.32) 100%),
    radial-gradient(circle at 50% 46%, rgba(216, 74, 54, 0.08), rgba(216, 74, 54, 0) 30%);
  backdrop-filter: blur(0.8px);
  -webkit-backdrop-filter: blur(0.8px);
}

@keyframes overlay-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.preview-overlay-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(500px, 100%);
  padding: 24px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: saturate(170%) blur(18px);
  -webkit-backdrop-filter: saturate(170%) blur(18px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 24px 70px rgba(9, 9, 11, 0.18),
    0 8px 22px rgba(9, 9, 11, 0.10);
  text-align: center;
  pointer-events: auto;
}

.preview-overlay[data-mode="searching"] .preview-overlay-card {
  width: min(460px, 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 18px 48px rgba(9, 9, 11, 0.13),
    0 6px 16px rgba(9, 9, 11, 0.08);
}

.preview-overlay-text {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-overlay-headline {
  max-width: 420px;
  margin: 0;
  font-size: clamp(1.28rem, 2.6vw, 1.72rem);
  font-weight: 700;
  letter-spacing: -0.012em;
  color: var(--ink);
  line-height: 1.18;
}

.preview-signal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.3;
}

.preview-signal strong {
  color: var(--ink);
  font-weight: 600;
}

.preview-overlay-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.preview-overlay[data-mode="searching"] .preview-overlay-cta {
  display: none;
}

.cta-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--ink);
  color: #fff;
  border: none;
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  font-weight: 500;
  font-size: 0.94rem;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 4px 14px rgba(9, 9, 11, 0.18);
  transition: background 140ms ease, transform 120ms ease;
  min-width: 220px;
}

.cta-primary:hover {
  background: #27272a;
  transform: translateY(-1px);
}

.cta-preview {
  background: linear-gradient(135deg, #c54130 0%, #f97316 58%, #fbbf24 100%);
}

.cta-preview:hover {
  background: linear-gradient(135deg, #b83f2e 0%, #ea580c 58%, #f59e0b 100%);
}

.cta-cost {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.14);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.cta-cost[hidden] {
  display: none;
}

.cta-cost-icon {
  color: var(--accent);
  font-size: 0.78rem;
  line-height: 1;
}

/* Searching state — overlay during /search round-trip */
.cta-primary[data-state="loading"] {
  pointer-events: none;
  opacity: 0.85;
}

.cta-primary[data-state="loading"] .cta-label::after {
  content: "…";
  display: inline-block;
  animation: searching-dots 1.2s steps(4, end) infinite;
  margin-left: 1px;
  width: 14px;
  text-align: left;
  overflow: hidden;
  vertical-align: bottom;
}

@keyframes searching-dots {
  0% { width: 0; }
  100% { width: 14px; }
}

.cta-primary[data-state="loading"] .cta-label {
  animation: agent-breathe 2.8s ease-in-out infinite;
}

@keyframes agent-breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.preview-agent-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(9, 9, 11, 0.45);
  margin: 0 0 12px;
}

.agent-spinner-char {
  font-family: monospace;
  width: 1ch;
  display: inline-block;
  color: #f97316;
  flex-shrink: 0;
  transition: opacity 0.35s ease;
}

.results-loading-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(9, 9, 11, 0.14);
  border-top-color: #f97316;
  border-radius: 50%;
  animation: image-spin 0.85s linear infinite;
  flex-shrink: 0;
}

.agent-word {
  transition: opacity 0.35s ease;
}

.agent-word::after {
  content: "…";
}

.agent-word.is-fading,
.agent-spinner-char.is-fading {
  opacity: 0;
}


.preview-agent-status[data-done="true"] .agent-word::after {
  content: "";
}

.preview-overlay-card[data-loading] .preview-overlay-headline,
.preview-overlay-card[data-loading] .preview-overlay-cta,
.preview-overlay-card[data-loading] .preview-score-group {
  display: none;
}

.cta-primary[data-state="loading"] .cta-cost {
  display: none;
}

.cta-primary[data-state="loading"] .cta-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  animation: image-spin 0.85s linear infinite;
}

.cta-spinner {
  display: none;
}

/* Cards in preview state: visible but disabled */
.listings-grid.is-preview {
  position: relative;
  max-height: min(680px, calc(100vh - 160px));
  overflow: hidden;
}

.listings-grid.is-preview .listing-card {
  opacity: 0.78;
  pointer-events: none;
  filter: saturate(0.9);
  transition: opacity 200ms ease;
}

.listings-grid.is-preview .listing-card:nth-child(n + 4) {
  opacity: 0.38;
  filter: saturate(0.75) blur(0.6px);
}

.listings-grid.is-preview .listing-card:hover {
  transform: none;
  box-shadow: var(--shadow-soft);
  border-color: var(--border);
}

.listings-grid.is-searching .listing-card {
  pointer-events: none;
  opacity: 0.82;
}

.listings-grid.is-searching .listing-card:nth-child(n + 7) {
  opacity: 0.52;
}

/* Mobile: keep the preview CTA compact and centered */
@media (max-width: 640px) {
  .preview-overlay {
    padding: 88px 14px 20px;
  }
  .preview-overlay-card {
    gap: 18px;
    padding: 20px;
  }
  .preview-signal {
    flex-wrap: wrap;
  }
  .preview-overlay-cta {
    align-items: center;
  }
  .listings-grid.is-preview {
    max-height: calc(100vh - 138px);
  }
}

/* ============================================================
   Listing cards
   ============================================================ */

.listings-grid {
  display: grid;
  /* min(100%, 280px) prevents overflow when the viewport is narrower than 280px. */
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 24px 18px;
}

.listing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
  display: flex;
  flex-direction: column;
}

@media (hover: hover) {
  .listing-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-pop);
    border-color: var(--border-strong);
  }
}

.card-link {
  display: flex;
  flex-direction: column;
  flex: 1;
  cursor: pointer;
}

.card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 11;
  background: #1f1f23;
  overflow: hidden;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 700ms cubic-bezier(0.2, 0, 0.1, 1);
}

@media (hover: hover) {
  .listing-card:hover .card-image {
    transform: scale(1.04);
  }
}

.image-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.7rem;
}

/* The [hidden] attribute's default display:none gets overridden by display:grid above,
   so we restore it explicitly. */
.image-placeholder[hidden] {
  display: none;
}

.image-placeholder[data-state="loading"] .image-placeholder-label {
  display: none;
}

.image-placeholder[data-state="empty"] .image-spinner {
  display: none;
}

.image-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  animation: image-spin 0.9s linear infinite;
}

@keyframes image-spin {
  to {
    transform: rotate(360deg);
  }
}

.type-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  backdrop-filter: blur(6px);
}

.match-quality-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.match-quality-badge[data-quality="strong"] {
  background: #15803d;
}

.match-quality-badge[data-quality="preview"] {
  background: rgba(9, 9, 11, 0.88);
  box-shadow: 0 6px 18px rgba(9, 9, 11, 0.16);
}

.match-quality-badge[data-quality="partial"] {
  background: #b45309;
}

.match-quality-badge[data-quality="borderline"] {
  background: var(--muted);
}

.card-match-reason {
  margin: 10px 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--ink-2);
  background: #f0fdf4;
  padding: 10px 12px;
  border: 1px solid #bbf7d0;
  border-left: 3px solid #15803d;
  border-radius: var(--radius);
}

.card-match-reason::before {
  content: "Why";
  display: block;
  margin-bottom: 4px;
  color: #15803d;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.2;
  text-transform: uppercase;
}

.card-body {
  padding: 14px 16px 16px;
  margin-top: auto;
}

.card-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.card-price {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 700;
  letter-spacing: -0.018em;
  color: var(--ink);
}

.card-date {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.card-title {
  margin: 0 0 6px;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.6em;
}

.card-location {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 720px) {
  .app-header {
    padding: 12px 18px;
  }
  :root {
    --header-height: 56px;
  }

  .view-search {
    padding: 36px 18px 64px;
  }

  .filters-row {
    grid-template-columns: 1fr;
  }

  .view-results {
    padding: 24px 18px;
  }
}

/* ============================================================
   Thumbnail strip on listing cards
   ============================================================ */

.card-thumbs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 6px;
  background: var(--surface-2);
}

.card-thumbs[hidden] {
  display: none;
}

.card-thumb-cell,
.card-thumb-empty {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 6px;
  background: #1f1f23;
}

.card-thumb-empty {
  background: var(--surface);
  border: 1px dashed var(--border);
}

.card-thumb-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 200ms ease;
}

@media (hover: hover) {
  .listing-card:hover .card-thumb-cell img {
    transform: scale(1.05);
  }
}

.card-thumb-more {
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--muted-2);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  aspect-ratio: 1;
}

/* ============================================================
   Checkout modal
   ============================================================ */

/* Cursor feedback while navigation is locked (loading/searching). */
body.nav-locked,
body.nav-locked * {
  cursor: wait !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(9, 9, 11, 0.46);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  animation: modal-fade-in 180ms ease-out;
}

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

@keyframes modal-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-card {
  position: relative;
  width: min(560px, calc(100vw - 48px));
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px 28px 28px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 24px 64px rgba(9, 9, 11, 0.24),
    0 8px 16px rgba(9, 9, 11, 0.08);
  animation: modal-pop-in 220ms cubic-bezier(0.2, 0.6, 0.2, 1);
}

@keyframes modal-pop-in {
  from {
    transform: translateY(8px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 120ms ease, color 120ms ease;
}

.modal-close:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.modal-title {
  margin: 0 0 4px;
  font-size: 1.34rem;
  font-weight: 700;
  letter-spacing: -0.022em;
  color: var(--ink);
}

.modal-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 0.92rem;
}

.auth-browser-card {
  width: min(480px, calc(100vw - 48px));
}

.auth-browser-actions {
  display: grid;
  gap: 10px;
}

.auth-browser-primary,
.auth-browser-secondary,
.auth-browser-link {
  min-height: 44px;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.auth-browser-primary {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
}

.auth-browser-secondary {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
}

.auth-browser-link {
  border: none;
  background: transparent;
  color: var(--muted);
}

.auth-browser-primary:hover,
.auth-browser-secondary:hover {
  transform: translateY(-1px);
}

.auth-browser-link:hover {
  color: var(--ink);
}

.pack-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.pack-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px 14px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--ink);
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.pack-btn:hover {
  border-color: var(--border-strong);
}

.pack-btn[aria-checked="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-pop);
}

.pack-btn[aria-checked="true"]:hover {
  background: #27272a;
}

.pack-tag {
  position: absolute;
  top: -8px;
  right: 10px;
  padding: 2px 8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: var(--radius-pill);
}

.pack-name {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.pack-btn[aria-checked="true"] .pack-name {
  color: rgba(255, 255, 255, 0.7);
}

.pack-credits {
  font-size: 0.94rem;
  font-weight: 500;
  color: inherit;
}

.pack-price {
  margin-top: 6px;
  font-size: 1.34rem;
  font-weight: 700;
  letter-spacing: -0.018em;
  color: inherit;
}

.pack-rate {
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

.pack-discount {
  margin-top: 2px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #15803d;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.pack-btn[aria-checked="true"] .pack-rate {
  color: rgba(255, 255, 255, 0.62);
}

.pack-btn[aria-checked="true"] .pack-discount {
  color: #4ade80;
}

.checkout-loading {
  margin: 18px 0 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.checkout-loading[hidden] {
  display: none;
}

.checkout-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: image-spin 0.85s linear infinite;
}

.admin-backdrop {
  align-items: stretch;
  justify-content: flex-end;
}

.admin-panel-card {
  width: min(960px, 100%);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 20px;
  overflow: auto;
  box-shadow: -18px 0 48px rgba(0, 0, 0, 0.16);
}

.admin-panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.admin-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.admin-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 10px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font: inherit;
}

.admin-tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.admin-status,
.admin-empty {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 12px 0;
}

.admin-status[data-kind="error"] {
  color: #9b2c2c;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.admin-table th,
.admin-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.admin-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 0.78rem;
}

.admin-run-details summary {
  cursor: pointer;
  color: var(--ink-2);
}

.admin-run-detail-body {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  color: var(--ink-2);
}

.admin-run-detail-body p {
  margin: 0;
}

.admin-load-more-btn {
  display: block;
  margin: 12px auto 0;
  padding: 6px 18px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--ink-2);
  font-size: 0.85rem;
  cursor: pointer;
}

.admin-load-more-btn:hover {
  background: var(--surface-2);
}

.admin-user-runs-btn,
.admin-user-history-btn,
.admin-view-results-btn {
  padding: 2px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--ink-2);
  font-size: 0.8rem;
  cursor: pointer;
}

.admin-user-runs-btn:hover,
.admin-user-history-btn:hover,
.admin-view-results-btn:hover {
  background: var(--surface-2);
}

.admin-filter-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  margin-bottom: 10px;
  background: var(--surface-2);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--ink-2);
}

.admin-filter-clear {
  padding: 4px 10px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--ink-2);
  font-size: 0.8rem;
  cursor: pointer;
}

.admin-filter-clear:hover {
  background: var(--surface);
}

@media (max-width: 560px) {
  .pack-grid {
    grid-template-columns: 1fr;
  }
  .modal-card {
    padding: 26px 20px 22px;
  }
}

/* ============================================================
   Toast
   ============================================================ */

.toast-slot {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(9, 9, 11, 0.18);
  animation: toast-slide-in 200ms cubic-bezier(0.2, 0.6, 0.2, 1);
  pointer-events: auto;
  max-width: 360px;
}

.toast[data-kind="success"] {
  background: #15803d;
}

.toast[data-kind="error"] {
  background: #b91c1c;
}

.toast[data-kind="muted"] {
  background: var(--ink-2);
  color: var(--muted-2);
}

.toast.is-leaving {
  animation: toast-slide-out 200ms ease forwards;
}

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-slide-out {
  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}


/* ============================================================
   Mobile-first overrides at <=640 px (CTA full-width) and <=480 px
   (header tightening + touch-target floors + toast width).
   ============================================================ */

@media (max-width: 640px) {
  /* Search submit goes full-width — bigger thumb target. */
  .cta {
    width: 100%;
    justify-content: center;
  }
  .cta-row {
    flex-direction: column;
    align-items: stretch;
  }
  .cta-hint {
    text-align: center;
  }
}

@media (max-width: 480px) {
  /* Header tightens but stays one row. */
  .app-header {
    padding: 10px 12px;
    gap: 8px;
  }
  :root {
    --header-height: 52px;
  }
  .credits-badge {
    font-size: 0.8rem;
    padding: 8px 12px;
    min-height: 40px;
  }
  .header-action {
    padding: 9px 14px;
    font-size: 0.86rem;
    min-height: 40px;
  }
  .header-link {
    padding: 9px 12px;
    font-size: 0.82rem;
    min-height: 40px;
  }

  /* Search view padding — a hair tighter so content has room to breathe. */
  .view-search {
    padding: 28px 14px 56px;
  }
  .hero-eyebrow {
    font-size: 0.74rem;
    padding: 4px 10px 4px 8px;
  }

  /* Modal padding tightens; extra room for the stacked overlay above the grid. */
  .modal-card {
    padding: 24px 18px 22px;
  }
  .listings-grid.is-preview {
    padding-bottom: 240px;
  }

  /* Toast becomes a top-anchored bar instead of a right-aligned pill —
     360px max-width doesn't fit at 320px viewport. */
  .toast-slot {
    top: 72px;
    left: 12px;
    right: 12px;
  }
  .toast {
    max-width: none;
    text-align: center;
  }
}

/* ============================================================
   History Sidebar
   ============================================================ */

.history-sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--bg-page);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transform: translateX(0);
  transition: transform 200ms ease;
}

@media (min-width: 900px) {
  body.is-results-view.history-sidebar-open main {
    margin-left: 280px;
  }

  body.is-results-view.history-sidebar-open .view-results {
    max-width: 1180px;
  }
}

.history-sidebar[hidden] {
  display: flex;
  transform: translateX(-100%);
}

@media (max-width: 768px) {
  .history-sidebar {
    width: 100%;
    max-width: 320px;
    z-index: 50;
  }

  .history-sidebar[hidden] {
    transform: translateX(-100%);
  }
}

.history-sidebar-overlay {
  display: none;
  position: fixed;
  top: var(--header-height);
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 45;
}

.history-sidebar-overlay:not([hidden]) {
  display: block;
}

@media (min-width: 769px) {
  .history-sidebar-overlay {
    display: none !important;
  }
}

.history-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.history-sidebar-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.history-sidebar-close {
  display: none;
  background: transparent;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: background 120ms ease;
}

.history-sidebar-close:hover {
  background: var(--surface-2);
}

@media (max-width: 768px) {
  .history-sidebar-close {
    display: block;
  }
}

.history-sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.history-sidebar-new-search {
  display: flex;
  padding: 16px 12px 8px;
}

.history-sidebar-new-search-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--ink);
  color: #fff;
  border: none;
  font-weight: 500;
  font-size: 0.86rem;
  padding: 10px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 120ms ease;
}

.history-sidebar-new-search-btn:hover {
  background: #27272a;
}

.history-sidebar-new-search-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.history-sidebar-footer {
  padding: 16px 20px;
  flex-shrink: 0;
}

.history-empty,
.history-signin-prompt,
.history-loading,
.history-error {
  font-size: 0.86rem;
  color: var(--muted);
  margin: 0;
  text-align: center;
}

.history-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(9, 9, 11, 0.48);
}

.history-loading-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(9, 9, 11, 0.14);
  border-top-color: #f97316;
  border-radius: 50%;
  animation: image-spin 0.85s linear infinite;
  flex-shrink: 0;
}

.history-loading[hidden] {
  display: none;
}

.history-signin-prompt a {
  color: var(--accent);
  text-decoration: underline;
}

.history-error {
  color: #dc2626;
}

.history-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 120ms ease;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.history-item:hover {
  background: var(--surface-2);
}

.history-item.is-active {
  background: var(--border);
}

.history-item-query {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

.history-item-match-count {
  font-weight: 500;
}
