:root {
  --bg: #eef2ea;
  --paper: #f7faf5;
  --ink: #1c1914;
  --muted: #6b6458;
  --line: #d5e0d4;
  --accent: #2f6b4f;
  --accent-dark: #1e4a35;
  --green: #2f6b4f;
  --green-soft: #e7f3eb;
  --gold: #b8862a;
  --danger: #9b2c2c;
  --barn: #8b3a2a;
  --shadow: 0 10px 30px rgba(28, 25, 20, 0.08);
  --radius: 18px;
  --bottom-nav-h: 58px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
}
button, input, select, textarea {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}
a { color: inherit; }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px;
  background: rgba(238, 242, 234, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent); color: white; display: grid; place-items: center;
  font-family: "Avenir Next", sans-serif; font-weight: 800;
}
.brand h1 { margin: 0; font-size: 20px; letter-spacing: -0.03em; }
.brand span { display: block; font-size: 11px; color: var(--muted); font-family: sans-serif; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav button, .ghost, .primary, .danger {
  border: 0; border-radius: 999px; padding: 8px 13px; cursor: pointer;
}
.nav button { background: transparent; color: var(--ink); font-size: 13px; }
.nav button.active, .nav button:hover { background: #dde8dc; }
.primary { background: var(--accent); color: white; font-weight: 700; }
.primary:hover { background: var(--accent-dark); }
.primary:disabled { opacity: .45; cursor: not-allowed; }
.ghost { background: #dde8dc; }
.danger { background: #f3d6d6; color: var(--danger); }

.wrap { max-width: 1100px; margin: 0 auto; padding: 22px 16px 80px; }
.hero {
  background: linear-gradient(135deg, #1a3326, #2f6b4f);
  color: #f0f7f2; border-radius: 28px; padding: 28px 24px; margin-bottom: 22px;
}
.hero h2 { margin: 0 0 8px; font-size: 34px; line-height: 1.1; }
.hero p { margin: 0 0 16px; color: #d4e8d8; max-width: 620px; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.pill {
  font-family: sans-serif; font-size: 12px; padding: 6px 10px; border-radius: 999px;
  background: #dde8dc; border: 1px solid transparent; cursor: pointer;
}
.pill.on { background: #1a3326; color: white; }
.filters { display: grid; grid-template-columns: 1.3fr .8fr .8fr; gap: 8px; margin-bottom: 12px; }
.filters.location-filters { grid-template-columns: .7fr .7fr 1.2fr; margin-bottom: 18px; }
.filters input, .filters select, form input, form select, form textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--paper);
}
.dist { color: var(--accent-dark); font-weight: 700; }
.match-strip {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.match-strip-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; margin-bottom: 10px; }
.match-strip-head strong { font-size: 15px; }
.match-strip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.match-chip {
  text-align: left; border: 1px solid var(--line); border-radius: 14px;
  background: #f0f7f2; padding: 10px 12px; cursor: pointer;
  font-family: inherit; color: inherit; max-width: 260px;
}
.match-chip:hover { border-color: var(--accent); }
.match-chip-title { display: block; font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.match-hint {
  background: #f0f7f2; border: 1px dashed var(--accent); border-radius: 14px;
  padding: 12px 14px; margin: 10px 0; font-family: sans-serif; font-size: 13px;
}
.match-hint ul { margin: 8px 0 0; padding-left: 18px; }
.match-pill {
  display: inline-block; margin-left: 8px; font-family: sans-serif; font-size: 10px;
  font-weight: 800; padding: 2px 7px; border-radius: 999px;
  background: var(--accent); color: white; vertical-align: middle;
}
.match-pill.soft { background: #dde8dc; color: var(--ink); }
.pick-card.best-match { border-color: var(--accent); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(28, 25, 20, 0.12); }
.thumb {
  height: 160px; background: #c5d4c0 center/cover no-repeat; position: relative;
}
.badge {
  position: absolute; top: 10px; left: 10px; font-family: sans-serif; font-size: 11px;
  padding: 4px 8px; border-radius: 999px; background: white; font-weight: 700;
}
.badge.free { background: var(--green); color: white; }
.badge.swap { background: #1a3326; color: white; }
.badge.sell { background: var(--gold); color: white; }
.badge.claimed {
  left: auto; right: 10px;
  background: #1c1914; color: #f7faf5;
}
.badge.status-pending { background: #dde8dc; color: var(--ink); }
.card-body { padding: 12px 13px 14px; }
.card-body h3 { margin: 0 0 4px; font-size: 17px; }
.meta { color: var(--muted); font-size: 12px; font-family: sans-serif; }
.row { display: flex; justify-content: space-between; gap: 8px; align-items: center; }

.panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: 22px;
  padding: 18px; box-shadow: var(--shadow);
}
.detail-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; }
.photos { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.photos img { width: 100%; height: 220px; object-fit: cover; border-radius: 14px; background: #c5d4c0; }
.photos img.small { height: 106px; }
form .field { margin-bottom: 12px; }
label { display: block; font-family: sans-serif; font-size: 12px; font-weight: 700; margin-bottom: 5px; }
.help { color: var(--muted); font-size: 12px; font-family: sans-serif; margin-top: 4px; }
.warn {
  background: #e8f0d8; border: 1px solid #a8c090; padding: 10px 12px;
  border-radius: 12px; margin-bottom: 12px; font-family: sans-serif; font-size: 13px;
}
.ok {
  background: var(--green-soft); border-radius: 12px; padding: 10px 12px;
  font-family: sans-serif; font-size: 13px;
}
.safety {
  background: #e8efe6; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-top: 12px; font-family: sans-serif; font-size: 13px;
}
.safety h4 { margin: 0 0 8px; font-family: Georgia, serif; font-size: 15px; }
.safety ul { margin: 0; padding-left: 18px; color: var(--muted); }
.safety li { margin-bottom: 4px; }
.claimed-banner {
  background: #1c1914; color: #f0f7f2; border-radius: 12px;
  padding: 12px 14px; margin-bottom: 12px; font-family: sans-serif; font-size: 14px;
}
.countdown {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 22px; font-weight: 800; color: var(--accent);
  letter-spacing: -0.02em; margin: 6px 0 10px;
}
.countdown.urgent { color: var(--danger); }
.pay-note {
  background: #dde8dc; border-radius: 12px; padding: 10px 12px;
  font-family: sans-serif; font-size: 13px; margin: 10px 0;
}
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.status-chip {
  display: inline-block; font-family: sans-serif; font-size: 11px; font-weight: 700;
  padding: 4px 9px; border-radius: 999px; background: #dde8dc;
}
.status-chip.Approved { background: var(--green-soft); color: var(--green); }
.status-chip.Claimed { background: #1c1914; color: white; }
.status-chip.Pending-Review { background: #e8f0d8; color: #8a6a20; }
.status-chip.Rejected, .status-chip.Expired, .status-chip.Hidden { background: #f3d6d6; color: var(--danger); }
.status-chip.Completed { background: #e7f3eb; color: var(--green); }
.status-chip.Draft { background: #dde8dc; color: var(--muted); }

/* Filters disclosure (desktop: always open visually via open attr + hidden summary) */
.filters-disclosure {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.filters-disclosure > summary {
  list-style: none;
  cursor: pointer;
  display: none; /* desktop: filters always expanded, summary hidden */
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 14px;
  font-weight: 700;
  user-select: none;
}
.filters-disclosure > summary > span:first-child::after {
  content: " ▾";
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
}
.filters-disclosure[open] > summary > span:first-child::after { content: " ▴"; }
.filters-disclosure > summary::-webkit-details-marker { display: none; }
.filters-summary-meta {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 58%;
}
.filters-body { padding: 12px 14px 14px; }
.filters-disclosure .pills { margin-bottom: 12px; }
.filters-disclosure .filters { margin-bottom: 10px; }
.filters-disclosure .location-filters { margin-bottom: 0; }

/* Bottom nav: desktop hidden */
.bottom-nav { display: none; }

@media (max-width: 799px) {
  .filters, .filters.location-filters, .detail-grid { grid-template-columns: 1fr; }
  .hero h2 { font-size: 26px; }
  .hero { padding: 22px 16px; border-radius: 20px; }
  .photos { grid-template-columns: 1fr; }
  .photos img, .photos img.small { height: 180px; }
  .topbar {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    padding: 10px 14px;
    padding-top: calc(10px + var(--safe-top));
    gap: 8px;
  }
  .brand h1 { font-size: 18px; }
  .brand span { display: none; }
  .top-nav .nav-desktop { display: none; }
  .top-nav { flex-wrap: nowrap; gap: 4px; }
  .top-nav .nav-admin { font-size: 12px; padding: 7px 11px; }

  .wrap {
    padding: 16px 14px calc(28px + var(--bottom-nav-h) + var(--safe-bottom));
  }

  .filters-disclosure > summary {
    display: flex;
  }
  .filters-disclosure:not([open]) .filters-body { display: none; }
  .filters-disclosure:not([open]) { background: #f0f7f2; }
  .filters-disclosure[open] > summary {
    border-bottom: 1px solid var(--line);
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    height: calc(var(--bottom-nav-h) + var(--safe-bottom));
    padding: 4px 6px var(--safe-bottom);
    background: rgba(247, 250, 245, 0.96);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgba(28, 25, 20, 0.06);
    justify-content: space-around;
    align-items: stretch;
    gap: 2px;
  }
  .bottom-nav button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    border-radius: 14px;
    padding: 6px 4px;
    font-family: "Avenir Next", "Segoe UI", sans-serif;
    min-width: 0;
  }
  .bottom-nav button.active {
    color: var(--accent-dark);
    background: #dde8dc;
  }
  .bottom-nav .bn-icon {
    position: relative;
    font-size: 18px;
    line-height: 1.2;
    height: 22px;
  }
  .bottom-nav .bn-msg .nav-badge {
    position: absolute;
    top: -6px;
    right: -14px;
    margin-left: 0;
    min-width: 16px;
    padding: 1px 5px;
    font-size: 9px;
  }
  .bottom-nav .bn-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.01em;
    white-space: nowrap;
  }

  .panel { padding: 14px; border-radius: 18px; }
  .actions .primary, .actions .ghost, .actions .danger,
  form .primary, form .ghost {
    min-height: 42px;
  }
  .compose {
    bottom: calc(10px + var(--bottom-nav-h) + var(--safe-bottom));
    background: var(--bg);
    padding-top: 8px;
  }
  .msg-list { max-height: 36vh; }
  .pick-card { grid-template-columns: auto 56px 1fr; gap: 10px; }
  .grid { grid-template-columns: 1fr; }
}

@media (min-width: 800px) {
  .filters-disclosure {
    border: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
  }
  .filters-body { padding: 0; }
}

/* Messaging + swap-offer */
.nav-badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 800;
  vertical-align: middle;
  line-height: 1.4;
}
.thread-list { display: flex; flex-direction: column; gap: 10px; }
.thread-item {
  display: block; width: 100%; text-align: left;
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 16px; cursor: pointer; box-shadow: var(--shadow);
  font-family: inherit; color: inherit;
}
.thread-item:hover { border-color: #a8b89a; }
.thread-item.has-unread { border-color: var(--accent); background: #f0f7f2; }
.thread-preview {
  margin-top: 6px; font-family: sans-serif; font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.unread-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); margin-right: 6px; vertical-align: middle;
}
.thread-view { max-width: 720px; }
.thread-header { margin: 12px 0; }
.msg-list {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 48vh; overflow-y: auto; padding: 8px 2px 16px;
}
.msg-bubble {
  max-width: 85%; padding: 10px 12px; border-radius: 14px;
  font-family: sans-serif; font-size: 14px;
}
.msg-bubble.mine {
  align-self: flex-end; background: #1a3326; color: #f0f7f2;
}
.msg-bubble.theirs {
  align-self: flex-start; background: var(--paper); border: 1px solid var(--line);
}
.msg-meta { font-size: 11px; opacity: 0.7; margin-bottom: 4px; }
.msg-bubble.mine .msg-meta { color: #d4e8d8; }
.compose {
  display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end;
  position: sticky; bottom: 12px;
}
.compose textarea { margin: 0; resize: vertical; min-height: 56px; }
.offer-card {
  background: #e8efe6; border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; margin-top: 12px; font-family: sans-serif; font-size: 13px;
}
.offer-card .status-chip { margin-left: 8px; }
.status-chip.Pending { background: #e8f0d8; color: #8a6a20; }
.status-chip.Accepted { background: var(--green-soft); color: var(--green); }
.status-chip.Declined, .status-chip.Withdrawn { background: #f3d6d6; color: var(--danger); }
.pick-grid { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.pick-card {
  display: grid; grid-template-columns: auto 72px 1fr; gap: 12px; align-items: center;
  padding: 12px; border: 2px solid var(--line); border-radius: 16px;
  background: var(--paper); cursor: pointer;
}
.pick-card.selected { border-color: var(--accent); background: #f0f7f2; }
.pick-card input { margin: 0; }
.pick-thumb {
  width: 72px; height: 72px; border-radius: 12px;
  background: #c5d4c0 center/cover no-repeat;
}
.empty-state {
  text-align: center; padding: 28px 18px; margin-top: 12px;
  background: #e8efe6; border-radius: 16px; border: 1px dashed var(--line);
}
.empty-state h3 { margin: 0 0 8px; }
.empty-state .actions { justify-content: center; }

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

/* Auth / profile */
.auth-panel { max-width: 520px; margin: 0 auto; }
.auth-hero .auth-actions { margin-top: 4px; }
.auth-actions { gap: 10px; }
.demo-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.demo-card {
  display: block; width: 100%; text-align: left;
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 16px; cursor: pointer; font-family: inherit; color: inherit;
  box-shadow: var(--shadow);
}
.demo-card:hover { border-color: var(--accent); background: #f0f7f2; }
.poster-line { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.poster-name { font-weight: 600; }
.role-badge {
  display: inline-block; font-family: sans-serif; font-size: 10px; font-weight: 800;
  padding: 2px 7px; border-radius: 999px; letter-spacing: 0.02em;
  vertical-align: middle;
}
.role-badge.contractor { background: #8b3a2a; color: #f7f1e6; }
.role-badge.homeowner { background: #dde8dc; color: var(--ink); }
.role-badge.admin { background: var(--accent); color: white; }
code {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: #dde8dc;
  padding: 1px 5px;
  border-radius: 4px;
}


/* Trust & safety */
.trust-actions { margin-top: 12px; }
.report-panel { border: 1px solid #b8c9b0; background: #f0f7f2; }
.blocked-list { list-style: none; margin: 0; padding: 0; }
.blocked-list li { padding: 8px 0; border-bottom: 1px solid #d0ddd0; }
.blocked-list li:last-child { border-bottom: none; }
.thread-item.blocked-thread { opacity: 0.72; }


/* Avatars / profile pictures */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent);
  color: #f0f7f2;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-weight: 800;
  line-height: 1;
  vertical-align: middle;
  box-shadow: 0 0 0 2px #e7f3eb;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-fallback { letter-spacing: 0.02em; }
.avatar-xs { width: 22px; height: 22px; font-size: 9px; }
.avatar-sm { width: 32px; height: 32px; font-size: 11px; }
.avatar-md { width: 44px; height: 44px; font-size: 14px; }
.avatar-lg { width: 72px; height: 72px; font-size: 22px; box-shadow: 0 0 0 3px #dde8dc; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: #dde8dc;
  border-radius: 999px;
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--ink);
}
.user-chip.active, .user-chip:hover { background: #c9dbc8; }
.user-chip-name {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.signout-chip {
  padding: 7px 12px;
  font-size: 12px;
  white-space: nowrap;
}

.account-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.account-signout {
  margin-top: 16px;
  background: #f8ecec;
  box-shadow: none;
  border: 1px solid #e8c8c8;
}
.avatar-edit-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.avatar-edit-controls {
  flex: 1;
  min-width: 180px;
}
.avatar-edit-controls input[type="file"] {
  display: block;
  width: 100%;
  margin-bottom: 6px;
  font-size: 13px;
}

.bn-avatar { display: inline-flex; align-items: center; justify-content: center; }
.bn-avatar .avatar { box-shadow: none; }
.bn-avatar .bn-avatar-inner.avatar-xs { width: 22px; height: 22px; }

.msg-meta.poster-line { gap: 6px; }
.thread-item .poster-line { gap: 8px; }

@media (max-width: 799px) {
  .signout-chip { display: none; }
  .user-chip-name { display: none; }
  .user-chip { padding: 3px; }
}

/* ---------- Notifications ---------- */
.notif-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  margin: 10px 16px 0;
  padding: 12px 14px;
  background: #e8f0d8;
  border: 1px solid #a8c090;
  border-radius: 14px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--ink);
}
.notif-banner-text { flex: 1; min-width: 180px; line-height: 1.35; }
.notif-banner-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.notif-panel .notif-status {
  display: inline-block;
  font-weight: 700;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
}
.notif-status-granted { background: #c9dbc8; color: #1e4a32; }
.notif-status-default { background: #ebe4d6; color: #5a5040; }
.notif-status-denied { background: #f0d4d4; color: #7a2e2e; }
.notif-toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  font-family: sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.notif-toggle-row input { margin-top: 2px; flex-shrink: 0; }
.watch-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
}
.watch-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-family: sans-serif;
  font-size: 13px;
}
.watch-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.watch-form input {
  flex: 1;
  min-width: 140px;
}
@media (max-width: 799px) {
  .notif-banner { margin: 8px 10px 0; }
}
