/* House Search styles. Warm but restrained: cream paper, terracotta accent,
   sage for positive signals. No framework, no build step. */

:root {
  --paper: #faf6f0;
  --surface: #ffffff;
  --ink: #2f2a26;
  --ink-soft: #6f665d;
  --line: #e7ddd0;
  --accent: #c1632f;        /* terracotta */
  --accent-dark: #a44f22;
  --sage: #5f7d54;          /* fenced-yes / good */
  --sage-soft: #e6efe1;
  --muted: #b9aea0;
  --warn: #b23b3b;
  --warn-soft: #f7e3e1;
  --shadow: 0 1px 2px rgba(47, 42, 38, 0.06), 0 6px 18px rgba(47, 42, 38, 0.07);
  --radius: 12px;
  --radius-sm: 8px;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Header ---------- */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.app-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.app-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-weight: 600;
}
.app-brand__mark { font-size: 1.4rem; }
.app-brand__name { font-size: 1.15rem; letter-spacing: 0.01em; }
.app-nav { display: flex; gap: 1.1rem; margin-left: 0.5rem; }
.app-nav__link {
  text-decoration: none;
  color: var(--ink-soft);
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}
.app-nav__link:hover { color: var(--accent); border-bottom-color: var(--accent); }
.app-logout { margin-left: auto; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  background: var(--surface);
}
.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-dark);
}
.btn--primary:hover { background: var(--accent-dark); }
.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}
.btn--ghost:hover { color: var(--accent); border-color: var(--accent); }
.btn--block { width: 100%; }

/* ---------- Main ---------- */
.app-main { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 500px at 50% -10%, #fff3e6 0%, transparent 60%),
    var(--paper);
  padding: 1.5rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 2rem 2.25rem;
  width: 100%;
  max-width: 380px;
}
.login-card__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}
.login-card__brand .app-brand__mark { font-size: 1.8rem; }
.login-card__title { margin: 0; font-size: 1.5rem; }
.login-card__subtitle { color: var(--ink-soft); margin: 0 0 1.5rem; }
.login-form { display: flex; flex-direction: column; gap: 1rem; }

.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field__label { font-size: 0.85rem; color: var(--ink-soft); }
.field__input {
  font: inherit;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
}
.field__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(193, 99, 47, 0.15);
}

.banner {
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
}
.banner--error { background: var(--warn-soft); color: var(--warn); border: 1px solid #eccac7; }

/* ---------- Grid page ---------- */
.grid-page__intro { margin-bottom: 1rem; }
.grid-page__heading { margin: 0; font-size: 1.6rem; }
.grid-page__hello { margin: 0.15rem 0 0; color: var(--ink-soft); }

.controls {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 1.25rem;
}
.controls__row { display: flex; flex-wrap: wrap; gap: 1rem 1.25rem; align-items: flex-end; }
.controls__row--weights {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--line);
  align-items: center;
}
.control { display: flex; flex-direction: column; gap: 0.3rem; }
.control--check { flex-direction: row; align-items: center; gap: 0.4rem; }
.control__label { font-size: 0.8rem; color: var(--ink-soft); }
.control__input {
  font: inherit;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  min-width: 8rem;
}
.control__input:focus { outline: none; border-color: var(--accent); }

.weights__title { font-size: 0.8rem; color: var(--ink-soft); font-weight: 600; margin-right: 0.3rem; }
.weights__sliders { display: flex; flex-wrap: wrap; gap: 1.1rem; }
.weight {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 9rem;
}
.weight__head { display: flex; justify-content: space-between; font-size: 0.8rem; }
.weight__name { text-transform: capitalize; color: var(--ink-soft); }
.weight__value { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); }
.weight input[type="range"] { width: 100%; accent-color: var(--accent); }

.grid-status { color: var(--ink-soft); margin: 0 0 1rem; }

/* ---------- Cards ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.1rem;
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(47, 42, 38, 0.12); }
.card--dealbreaker { filter: grayscale(0.7); opacity: 0.62; }

.card__media {
  position: relative;
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, #efe6d8, #e3d6c3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card__placeholder { font-size: 2.2rem; opacity: 0.5; }
.card__score {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  min-width: 2.6rem;
  height: 2.6rem;
  padding: 0 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow);
}
.card__score--none { background: var(--muted); }

.card__body { padding: 0.85rem 0.95rem 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.card__address { font-size: 1.05rem; font-weight: 600; line-height: 1.25; }
.card__city { color: var(--ink-soft); font-size: 0.85rem; }
.card__rent { font-size: 1.05rem; }
.card__rent strong { font-weight: 700; }
.card__rent-pp { color: var(--ink-soft); font-size: 0.85rem; }
.card__specs { color: var(--ink-soft); font-size: 0.88rem; }

.badges { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.1rem; }
.badge {
  font-size: 0.72rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  white-space: nowrap;
}
.badge--fenced { background: var(--sage-soft); color: var(--sage); border-color: #cfe0c6; }
.badge--fenced-muted { background: var(--paper); color: var(--muted); }
.badge--acorn { background: #f5ead8; color: var(--accent-dark); border-color: #ecd9bf; }
.badge--status { background: #eef1f4; color: #4a5568; border-color: #dde3ea; }

/* ---------- Shared panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.2rem 1.25rem;
}
.panel__title {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.panel__hint { font-size: 0.82rem; color: var(--ink-soft); font-weight: 400; margin: -0.4rem 0 0.75rem; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 0.85rem 1rem;
}
.edit-field { display: flex; flex-direction: column; gap: 0.3rem; }
.edit-field--wide { grid-column: 1 / -1; }
.edit-field__label { font-size: 0.78rem; color: var(--ink-soft); }
.edit-input,
.notes-area {
  font: inherit;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  width: 100%;
  resize: vertical;
}
.edit-input:focus,
.notes-area:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(193, 99, 47, 0.15);
}

/* ---------- Save toast ---------- */
.save-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--sage);
  color: #fff;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(0.5rem);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 50;
}
.save-toast--show { opacity: 1; transform: translateY(0); }
.save-toast--error { background: var(--warn); }

/* ---------- Detail page ---------- */
.detail-back {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.9rem;
}
.detail-back:hover { color: var(--accent); }
.detail-status { color: var(--ink-soft); }

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.detail-title { margin: 0; font-size: 1.6rem; line-height: 1.2; }
.detail-sub { margin: 0.3rem 0 0; color: var(--ink-soft); }
.detail-score-box { text-align: center; flex-shrink: 0; }
.detail-score {
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  min-width: 3.5rem;
  padding: 0.4rem 0.7rem;
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.detail-score-label { font-size: 0.72rem; color: var(--ink-soft); margin-top: 0.25rem; }

.detail-links { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.detail-links .btn { text-decoration: none; }

.gallery { margin-bottom: 1.25rem; }
.gallery__main {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 420px;
  background: linear-gradient(135deg, #efe6d8, #e3d6c3);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery__placeholder { font-size: 3rem; opacity: 0.5; }
.gallery__caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0.5rem 0.75rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
  color: #fff;
  font-size: 0.85rem;
}
.gallery__thumbs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.6rem; }
.gallery__thumb {
  width: 5rem;
  height: 3.5rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  background: var(--paper);
}
.gallery__thumb:hover { border-color: var(--accent); }
.gallery__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.detail-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 1.1rem;
  margin-bottom: 1.1rem;
}

.ratings-table,
.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.25rem;
}
.ratings-table th,
.breakdown-table th {
  text-align: left;
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--line);
}
.ratings-table td,
.breakdown-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.rating-dim,
.breakdown-dim { text-transform: capitalize; color: var(--ink-soft); }
.rating-input {
  width: 4rem;
  font: inherit;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
}
.rating-input:focus { outline: none; border-color: var(--accent); }
.rating-cell--ro { color: var(--ink); }
.breakdown-table tfoot td {
  font-weight: 700;
  border-bottom: none;
  border-top: 2px solid var(--line);
}

/* ---------- Inbox page ---------- */
.inbox-submit { margin-bottom: 1.25rem; }
.inbox-submit__actions { display: flex; align-items: center; gap: 0.8rem; margin-top: 0.8rem; }
.inbox-submit__msg { color: var(--ink-soft); font-size: 0.9rem; }
.inbox-submit__msg--error { color: var(--warn); }

.inbox-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.inbox-table th {
  text-align: left;
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 0.6rem 0.75rem;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.inbox-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.9rem;
}
.inbox-table tr:last-child td { border-bottom: none; }
.inbox-url { max-width: 22rem; }
.inbox-url a {
  display: inline-block;
  max-width: 22rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent-dark);
}
.inbox-time { color: var(--ink-soft); white-space: nowrap; }
.inbox-house-link { color: var(--accent-dark); }
.inbox-error { color: var(--warn); font-size: 0.85rem; }

.pill {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  text-transform: capitalize;
}
.pill--pending { background: #f5ead8; color: var(--accent-dark); border-color: #ecd9bf; }
.pill--processing { background: #eef1f4; color: #4a5568; border-color: #dde3ea; }
.pill--done { background: var(--sage-soft); color: var(--sage); border-color: #cfe0c6; }
.pill--failed { background: var(--warn-soft); color: var(--warn); border-color: #eccac7; }

/* ---------- Settings page ---------- */
.settings-form { display: flex; flex-direction: column; gap: 1.1rem; }
.settings-actions { display: flex; align-items: center; gap: 0.9rem; }
