/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --forest:       #1A2E1F;
  --sage:         #5C8B6A;
  --sage-tint:    rgba(92,139,106,0.18);
  --coral:        #E8624A;
  --coral-tint:   rgba(232,98,74,0.18);
  --surface:      #FFFFFF;
  --bg:           #F0EDE8;
  --text:         #1A1A1A;
  --text-sec:     #666660;
  --text-muted:   #999992;
  --border:       rgba(0,0,0,0.08);
  --shadow-card:  0 8px 32px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.08);
  --shadow-sm:    0 2px 8px rgba(0,0,0,0.08);
  --nav-h:        64px;
  --radius-card:  20px;
  --radius-sm:    10px;
  --font-ui:      'DM Sans', system-ui, sans-serif;
  --font-disp:    'Playfair Display', Georgia, serif;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: pan-y;
}
button { font-family: var(--font-ui); cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ── App shell ─────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: 100vh; /* fallback */
  overflow: hidden;
}
.app__main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* ── Nav bar ───────────────────────────────────────────────── */
.navbar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: var(--nav-h);
  background: var(--forest);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.navbar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 28px;
  color: rgba(255,255,255,0.4);
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.navbar__item.active { color: #fff; }
.navbar__icon { font-size: 22px; position: relative; }
.navbar__label { font-size: 10px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; }
.navbar__badge {
  position: absolute; top: -6px; right: -12px;
  background: var(--coral); color: #fff;
  font-size: 10px; font-weight: 600;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  font-family: var(--font-ui);
}

/* ── Toast ─────────────────────────────────────────────────── */
.toast-container {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  padding: 10px 18px; border-radius: 100px;
  font-size: 13px; font-weight: 500;
  background: var(--text); color: #fff;
  animation: toast-in 0.2s ease;
  text-align: center;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Feed view ─────────────────────────────────────────────── */
.feed {
  display: flex; flex-direction: column;
  height: 100%; padding: 12px 16px 0;
  overflow: hidden;
}
.feed__stack {
  position: relative; flex: 1; min-height: 0;
}

/* Back card (peek) */
.feed__back {
  position: absolute; inset: 0;
  display: flex; align-items: flex-start;
  pointer-events: none; z-index: 1;
}
.feed__back-inner {
  width: 100%; max-width: 480px; margin: 0 auto;
  height: 180px; border-radius: var(--radius-card);
  overflow: hidden; background: var(--surface);
  box-shadow: var(--shadow-card); opacity: 0.65;
  transform: scale(0.96) translateY(8px);
  transform-origin: top center;
}
.feed__back-inner img {
  width: 100%; height: 100%; object-fit: cover;
}

/* Front card wrapper */
.feed__front {
  position: absolute; inset: 0;
  display: flex; align-items: flex-start;
  z-index: 2;
}

/* Action buttons */
.card-actions {
  display: flex; gap: 24px;
  justify-content: center; align-items: center;
  padding: 14px 0 8px; flex-shrink: 0;
}
.card-actions__btn {
  width: 60px; height: 60px; border-radius: 50%;
  font-size: 22px; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.card-actions__btn:active { transform: scale(0.9); }
.card-actions__btn--undo {
  background: var(--surface); color: var(--text-muted);
  font-size: 20px;
  width: 44px; height: 44px; /* slightly smaller — secondary action */
  box-shadow: none;
  border: 1.5px solid var(--border);
  transition: transform 0.12s, color 0.15s, border-color 0.15s;
}
.card-actions__btn--undo:not(:disabled) {
  color: var(--text-sec);
  border-color: rgba(0,0,0,0.15);
}
.card-actions__btn--undo:not(:disabled):active {
  transform: scale(0.9) rotate(-20deg);
}
.card-actions__btn--undo:disabled {
  opacity: 0.3;
  cursor: default;
}
.card-actions__btn--pass { background: var(--surface); color: var(--coral); }
.card-actions__btn--like { background: var(--forest); color: #fff; }

/* Feed states */
.feed-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; gap: 20px; padding: 32px; text-align: center;
}
.feed-state p { font-size: 16px; color: var(--text-sec); line-height: 1.6; }
.feed-state__refresh {
  padding: 12px 28px; border-radius: 100px;
  background: var(--forest); color: #fff;
  font-size: 15px; font-weight: 500; font-family: var(--font-ui);
}

/* Skeleton */
.skeleton {
  border-radius: var(--radius-card); height: 500px;
  background: linear-gradient(90deg,#E8E4DF 25%,#F0EDE8 50%,#E8E4DF 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  width: 100%; max-width: 480px; margin: 0 auto;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Swipe card ────────────────────────────────────────────── */
.swipe-card {
  position: relative;
  width: 100%; max-width: 480px;
  margin: 0 auto;
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 100%;
  -webkit-overflow-scrolling: touch;
  user-select: none; -webkit-user-select: none;
  will-change: transform;
  touch-action: pan-y;
}
.swipe-card__tint {
  position: absolute; inset: 0;
  pointer-events: none; z-index: 5;
  border-radius: var(--radius-card);
  transition: opacity 0.05s;
}
.swipe-card__tint--like { background: var(--sage-tint); }
.swipe-card__tint--pass { background: var(--coral-tint); }
.swipe-card__label {
  position: absolute; top: 24px;
  font-size: 40px; z-index: 6;
  pointer-events: none;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.15));
}
.swipe-card__label--like { right: 24px; color: var(--sage); }
.swipe-card__label--pass { left: 24px; color: var(--coral); }

/* ── Image gallery ─────────────────────────────────────────── */
.gallery {
  position: relative; width: 100%;
  aspect-ratio: 4/3; background: #E8E4DF;
  overflow: hidden;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
  flex-shrink: 0;
}
.gallery img {
  width: 100%; height: 100%; object-fit: cover;
  user-select: none; -webkit-user-drag: none;
  pointer-events: none;
}
.gallery__empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; font-size: 13px; color: var(--text-muted);
}
.gallery__btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,0.75); backdrop-filter: blur(4px);
  font-size: 22px; display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s;
}
.gallery__btn:disabled { opacity: 0; pointer-events: none; }
.gallery__btn--prev { left: 10px; }
.gallery__btn--next { right: 10px; }
.gallery__dots {
  position: absolute; bottom: 10px;
  left: 50%; transform: translateX(-50%);
  display: flex; gap: 5px;
}
.gallery__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(255,255,255,0.5); transition: background 0.2s;
}
.gallery__dot.active { background: #fff; transform: scale(1.25); }

/* ── Listing body ──────────────────────────────────────────── */
.listing-body {
  padding: 20px 20px 24px;
  display: flex; flex-direction: column; gap: 6px;
}
.listing-body__rent {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px;
}
.listing-body__rent-amount {
  font-family: var(--font-disp);
  font-size: 42px; font-weight: 700;
  color: var(--text); letter-spacing: -0.02em; line-height: 1;
}
.listing-body__rent-cold {
  font-size: 13px; color: var(--text-muted);
}
.listing-body__size {
  font-size: 15px; font-weight: 500; color: var(--text-sec);
}
.listing-body__address {
  font-size: 14px; color: var(--text-sec); line-height: 1.4;
}
.listing-body__available {
  font-size: 13px; color: var(--sage); font-weight: 500;
}
.listing-body__desc {
  font-size: 14px; line-height: 1.55; color: var(--text-sec);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; margin-top: 4px;
}
.listing-body__desc.expanded {
  display: block; overflow: visible; -webkit-line-clamp: unset;
}
.listing-body__toggle {
  font-size: 13px; font-weight: 500; color: var(--forest);
  text-decoration: underline; text-underline-offset: 2px;
  margin-top: 4px;
}
.listing-body__link {
  display: inline-flex; align-items: center; margin-top: 10px;
  font-size: 14px; font-weight: 600; color: var(--forest);
  border-bottom: 1.5px solid var(--forest); padding-bottom: 1px;
  align-self: flex-start;
}

/* ── Likes view ────────────────────────────────────────────── */
.likes {
  height: 100%; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.likes__list {
  padding: 8px 16px 24px;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 600px; margin: 0 auto;
}
.like-row {
  background: var(--surface); border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.like-row.offline { opacity: 0.55; }
.like-row__header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.like-row__thumb {
  width: 64px; height: 64px;
  border-radius: var(--radius-sm); object-fit: cover;
  flex-shrink: 0; background: #E8E4DF;
}
.like-row__info {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.like-row__title-row { display: flex; align-items: center; gap: 6px; }
.like-row__title {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 150px;
}
.like-row__badge {
  font-size: 10px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--coral);
  background: rgba(232,98,74,0.1);
  padding: 2px 6px; border-radius: 4px; flex-shrink: 0;
}
.like-row__rent {
  font-family: var(--font-disp); font-size: 18px; font-weight: 700;
  letter-spacing: -0.01em;
}
.like-row__address {
  font-size: 12px; color: var(--text-sec);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.like-row__date { font-size: 11px; color: var(--text-muted); }
.like-row__actions {
  display: flex; flex-direction: column;
  align-items: flex-end; gap: 8px; flex-shrink: 0;
}
.like-row__contact {
  font-size: 13px; font-weight: 600; color: var(--forest);
  border-bottom: 1.5px solid var(--forest);
  white-space: nowrap; padding-bottom: 1px;
}
.like-row__remove {
  font-size: 16px; padding: 4px; border-radius: 6px;
  opacity: 0.45; transition: opacity 0.15s;
}
.like-row__remove:active { opacity: 1; }
.like-row__detail { border-top: 1px solid var(--border); }

.likes-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; gap: 8px; padding: 32px; text-align: center;
}
.likes-empty p { font-size: 16px; color: var(--text-sec); }
.likes-empty .sub { font-size: 14px; color: var(--text-muted); }

.likes__load-more {
  padding: 14px; border-radius: var(--radius-card);
  background: var(--surface); color: var(--forest);
  font-size: 14px; font-weight: 500; font-family: var(--font-ui);
  width: 100%; margin-top: 4px;
  box-shadow: var(--shadow-sm);
}
.likes__load-more:disabled { opacity: 0.5; }

/* ── Responsive ────────────────────────────────────────────── */
@media (min-width: 520px) {
  .feed { align-items: center; }
  .feed__stack { width: 480px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Hidden utility ─────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Login screen ───────────────────────────────────────────── */
.login-screen {
  position: fixed; inset: 0;
  background: var(--forest);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.login-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 40px 32px 36px;
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; align-items: center;
  gap: 6px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.3);
  animation: card-up 0.3s cubic-bezier(0.22,1,0.36,1);
}

@keyframes card-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-logo {
  font-size: 40px;
  margin-bottom: 4px;
  line-height: 1;
}

.login-title {
  font-family: var(--font-disp);
  font-size: 28px; font-weight: 700;
  color: var(--text); letter-spacing: -0.02em;
}

.login-sub {
  font-size: 13px; color: var(--text-muted);
  margin-bottom: 8px;
}

.login-form {
  width: 100%;
  display: flex; flex-direction: column; gap: 10px;
  margin-top: 16px;
}

.login-label {
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-muted);
}

.login-input-wrap {
  position: relative;
}

.login-input {
  width: 100%; padding: 14px 44px 14px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  font-size: 15px; font-family: var(--font-ui);
  color: var(--text); background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

.login-input:focus { border-color: var(--forest); }
.login-input--error { border-color: var(--coral) !important; }

.login-toggle {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 18px; padding: 4px;
  opacity: 0.5; transition: opacity 0.15s;
  line-height: 1;
}
.login-toggle:hover { opacity: 0.9; }

.login-error {
  font-size: 13px; color: var(--coral); margin-top: -4px;
}

.login-btn {
  margin-top: 4px;
  padding: 15px;
  border-radius: 12px;
  background: var(--forest); color: #fff;
  font-size: 15px; font-weight: 600;
  font-family: var(--font-ui);
  transition: opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.login-btn:active { opacity: 0.8; }
.login-btn:disabled { opacity: 0.5; }

/* ── Sign-out button in navbar ──────────────────────────────── */
.navbar__signout {
  font-size: 11px; font-weight: 500;
  font-family: var(--font-ui);
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 12px;
  border-radius: 8px;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.navbar__signout:hover { color: rgba(255,255,255,0.7); }