:root {
  --bg: #faf6ef;
  --surface: #ffffff;
  --ink: #221d38;
  --muted: #6d6884;
  --line: #ebe4d6;
  --brand: #1d1640;
  --brand-2: #6a35e8;
  --cyan: #1fb6f2;
  --glow: linear-gradient(120deg, #1fb6f2, #6a35e8 55%, #d23bd6);
  --gold: #d9a441;
  --love: #d23bd6;
  --pass: #8c88a3;
  --ok: #2f9e6e;
  --radius: 22px;
  --shadow: 0 10px 30px rgba(34, 29, 56, .12);
  --tab-h: 64px;
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15121f; --surface: #211c31; --ink: #f2eefb; --muted: #a8a2bf; --line: #332c49;
    --brand: #c9b8ff; --brand-2: #a283ff; --love: #ec5ce8; --shadow: 0 10px 30px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); min-height: 100dvh; padding-bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); }
a { color: var(--brand-2); }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; letter-spacing: -.01em; margin: 0 0 .4em; }
button, input, select, textarea { font: inherit; }

/* ---------- Top + bottom nav ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; max-width: 1100px; margin: 0 auto; }
.brand { display: flex; gap: 10px; align-items: center; font-family: Fraunces, serif; font-weight: 700; font-size: 1.4rem; color: var(--ink); text-decoration: none; }
.toptabs { display: none; gap: 4px; }
.toptabs a { padding: 8px 14px; border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 600; }
.toptabs a.active { background: var(--glow); color: #fff; }
.bottomtabs { position: fixed; inset: auto 0 0 0; height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); z-index: 20; }
.bottomtabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .72rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.bottomtabs a .ti { font-size: 1.25rem; line-height: 1; }
.bottomtabs a.active { color: var(--brand); }
@media (min-width: 760px) {
  .toptabs { display: flex; }
  .bottomtabs { display: none; }
  body { padding-bottom: 0; }
}

/* ---------- Counters ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 720px; margin: 0 auto 8px; padding: 0 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 6px; text-align: center; }
.stat b { display: block; font-family: Fraunces, serif; font-size: 1.25rem; color: var(--brand); }
.stat span { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

main { max-width: 1100px; margin: 0 auto; padding: 8px 16px 32px; outline: none; }
.center { text-align: center; }
.muted { color: var(--muted); }

/* ---------- Swipe deck ---------- */
.deck-wrap { max-width: 420px; margin: 0 auto; }
.filters { display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 12px; scrollbar-width: none; scroll-snap-type: x proximity; scroll-padding-inline: 2px; overscroll-behavior-x: contain; }
.filters::-webkit-scrollbar { display: none; }
.filters .chip { scroll-snap-align: start; }
.filters.dragging { cursor: grabbing; scroll-snap-type: none; }
.filters.dragging .chip { pointer-events: none; }
.chip { flex: none; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: .85rem; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--bg); }
/* leave room for header, counters, chips, action buttons and the bottom tab bar */
.deck { position: relative; height: clamp(320px, calc(100dvh - 440px), 540px); }
@media (min-width: 760px) { .deck { height: clamp(360px, calc(100dvh - 420px), 560px); } }
@media (max-width: 759px) { .stat { padding: 6px 4px; } .stat b { font-size: 1.1rem; } .stats { margin-bottom: 4px; } }
.actions { margin-top: 14px !important; }
.card { position: absolute; inset: 0; border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow);
  touch-action: none; user-select: none; cursor: grab; transition: transform .3s ease; display: flex; flex-direction: column; }
.card.dragging { transition: none; cursor: grabbing; }
.card:not(:last-child) { transform: scale(.95) translateY(14px); filter: brightness(.97); }
.card-art { flex: 1; position: relative; display: grid; place-items: center; font-size: 5rem; color: #fff; background-size: cover; background-position: center; }
.card-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 45%, rgba(0,0,0,.55)); }
.card-art .over { position: absolute; left: 18px; right: 18px; bottom: 14px; z-index: 1; color: #fff; }
.card-art .over h2 { font-size: 1.6rem; margin: 0; text-shadow: 0 2px 10px rgba(0,0,0,.35); }
.card-art .over p { margin: 2px 0 0; opacity: .95; font-size: .9rem; }
.card-body { padding: 14px 18px 18px; }
.card-body .tagline { margin: 0 0 10px; font-weight: 500; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .85rem; color: var(--muted); align-items: center; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; background: color-mix(in srgb, var(--gold) 20%, transparent); color: #8a5d0b; font-size: .75rem; font-weight: 700; }
@media (prefers-color-scheme: dark) { .badge { color: var(--gold); } }
.stamp { position: absolute; top: 26px; z-index: 2; padding: 6px 14px; border: 4px solid; border-radius: 10px; font: 800 1.6rem Inter, sans-serif; letter-spacing: .08em; opacity: 0; transform: rotate(-12deg); }
.stamp.save { left: 20px; color: var(--love); border-color: var(--love); background: rgba(255,255,255,.85); }
.stamp.pass { right: 20px; color: var(--pass); border-color: var(--pass); transform: rotate(12deg); background: rgba(255,255,255,.85); }
.actions { display: flex; justify-content: center; gap: 22px; margin-top: 18px; }
.round { width: 62px; height: 62px; border-radius: 50%; border: none; background: var(--surface); box-shadow: var(--shadow); font-size: 1.6rem; cursor: pointer; transition: transform .15s; }
.round:hover { transform: scale(1.08); }
.round:active { transform: scale(.94); }
.round.pass { color: var(--pass); }
.round.save { color: var(--love); width: 72px; height: 72px; font-size: 2rem; }
.round.info { color: var(--brand-2); font-size: 1.3rem; }
.hint { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 10px; }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 3rem; }

/* category art gradients */
.g-0 { background-image: linear-gradient(135deg, #4a3d8f, #e2557a); }
.g-1 { background-image: linear-gradient(135deg, #2f9e6e, #d9a441); }
.g-2 { background-image: linear-gradient(135deg, #1f6fb2, #43c6ac); }
.g-3 { background-image: linear-gradient(135deg, #8e2de2, #4a00e0); }
.g-4 { background-image: linear-gradient(135deg, #f6a04d, #e2557a); }
.g-5 { background-image: linear-gradient(135deg, #2b2350, #4a3d8f); }
.g-6 { background-image: linear-gradient(135deg, #c0392b, #f39c12); }
.g-7 { background-image: linear-gradient(135deg, #0f9b8e, #2b2350); }

/* ---------- Stars + progress ---------- */
.stars { color: var(--gold); letter-spacing: 1px; white-space: nowrap; }
.stars .off { color: var(--line); }
.rate { display: inline-flex; gap: 2px; }
.rate button { background: none; border: none; font-size: 1.6rem; color: var(--line); cursor: pointer; padding: 0 2px; }
.rate button.on { color: var(--gold); }
.progress { height: 12px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--ok), var(--gold)); border-radius: 999px; transition: width .8s ease; }
.progress-row { display: flex; justify-content: space-between; font-size: .85rem; margin-top: 6px; color: var(--muted); }
.progress-row b { color: var(--ink); }

/* ---------- Grid / list ---------- */
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; margin: 6px 0 14px; }
.page-head p { margin: 0; color: var(--muted); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; cursor: pointer; transition: transform .15s, box-shadow .15s; text-align: left; padding: 0; color: inherit; }
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.tile-art { height: 110px; display: grid; place-items: center; font-size: 2.6rem; color: #fff; background-size: cover; background-position: center; }
.tile-body { padding: 12px 14px 14px; }
.tile-body h3 { font-size: 1.1rem; margin-bottom: 4px; }
.row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin-bottom: 10px; }
.row .av { width: 54px; height: 54px; border-radius: 14px; flex: none; display: grid; place-items: center; font-size: 1.6rem; color: #fff; background-size: cover; }
.row .grow { flex: 1; min-width: 0; }
.row h3 { font-size: 1.05rem; margin: 0 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Buttons + forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 18px; border-radius: 999px; border: none; background: var(--brand); color: var(--bg); font-weight: 700; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.love { background: var(--love); color: #fff; }
.btn.gold { background: var(--gold); color: #2b2350; }
.btn.sm { padding: 7px 13px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; max-width: 520px; margin: 0 auto 16px; }
.panel.wide { max-width: 760px; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 12px 0 4px; }
input, select, textarea { width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 1px; }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { width: auto; margin-top: 3px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin-bottom: 8px; }
.seg button { border: none; background: none; padding: 9px; border-radius: 999px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--brand); color: var(--bg); }
.err { color: #c0392b; font-weight: 600; min-height: 1.2em; margin: 8px 0 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.amounts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.amounts button { padding: 12px 0; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-weight: 700; cursor: pointer; }
.amounts button.on { border-color: var(--love); background: color-mix(in srgb, var(--love) 12%, transparent); }
.secure { display: flex; gap: 8px; align-items: center; font-size: .8rem; color: var(--muted); margin-top: 10px; }
.status { font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.status.active { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.status.pending_review, .status.unpaid { background: color-mix(in srgb, var(--gold) 22%, transparent); color: #8a5d0b; }
.status.rejected, .status.expired { background: #f6d5d5; color: #a12b2b; }

/* ---------- Modal + toast ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: end center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 16, 36, .55); backdrop-filter: blur(3px); }
.modal-card { position: relative; width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--surface); border-radius: 26px 26px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); animation: up .25s ease; }
@media (min-width: 760px) { .modal { place-items: center; } .modal-card { border-radius: 26px; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.modal-x { position: absolute; top: 12px; right: 14px; border: none; background: var(--bg); width: 36px; height: 36px; border-radius: 50%; font-size: 1.4rem; cursor: pointer; color: var(--ink); }
.modal-hero { height: 150px; border-radius: 18px; display: grid; place-items: center; font-size: 4rem; color: #fff; margin-bottom: 14px; background-size: cover; background-position: center; }
.counter-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.counter-row div { background: var(--bg); border-radius: 14px; padding: 10px; text-align: center; }
.counter-row b { display: block; font-family: Fraunces, serif; font-size: 1.3rem; color: var(--brand); }
.counter-row span { font-size: .75rem; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 18px); transform: translate(-50%, 30px); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-weight: 600; opacity: 0; pointer-events: none; transition: .25s; z-index: 60; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.footer { text-align: center; font-size: .8rem; color: var(--muted); padding: 10px 16px 30px; }
.footer p { margin: 6px 0 0; }
.footer a { color: var(--muted); }
.demo-note { background: color-mix(in srgb, var(--gold) 18%, transparent); border-radius: 12px; padding: 10px 12px; font-size: .85rem; margin-bottom: 12px; }

/* ---------- Desktop hero beside the deck ---------- */
.discover-layout { display: block; }
.hero { display: none; }
@media (min-width: 1000px) {
  .discover-layout { display: grid; grid-template-columns: 1fr 420px; gap: 56px; align-items: center; max-width: 1000px; margin: 0 auto; }
  .hero { display: block; }
  .mobile-only { display: none; }
  .deck-wrap { margin: 0; }
}
.hero h1 { font-size: 3.2rem; line-height: 1.05; margin-bottom: 14px; }
.hero .lead { font-size: 1.1rem; color: var(--muted); line-height: 1.55; margin: 0 0 22px; }
.how { list-style: none; padding: 0; margin: 0 0 26px; counter-reset: how; display: grid; gap: 12px; }
.how li { counter-increment: how; display: grid; grid-template-columns: 40px 1fr; column-gap: 12px; align-items: start; }
.how li::before { content: counter(how); grid-row: span 2; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--bg); font-weight: 700; font-family: Fraunces, serif; }
.how b { font-size: 1.05rem; }
.how span { color: var(--muted); font-size: .95rem; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }
.linkbtn { background: none; border: none; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: .9rem; }
.photo-pick { display: flex; gap: 12px; align-items: center; }
.photo-prev { width: 84px; height: 84px; flex: none; border-radius: 14px; background: var(--bg) center/cover no-repeat; border: 1px dashed var(--line); display: grid; place-items: center; font-size: 1.6rem; }
.photo-pick input[type=file] { padding: 8px; }
.row .pick { width: 22px; height: 22px; flex: none; accent-color: var(--love); }
.batchbar { position: sticky; top: 8px; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--brand); color: var(--bg); padding: 10px 10px 10px 18px; border-radius: 999px; margin-bottom: 12px; box-shadow: var(--shadow); font-weight: 700; }
.batchbar[hidden] { display: none; }
.verse { font-family: Fraunces, Georgia, serif; font-style: italic; color: var(--brand-2); margin: 0 0 14px; font-size: 1.05rem; }
.verse span { font-style: normal; font-family: Inter, sans-serif; font-size: .8rem; color: var(--muted); margin-left: 6px; }

/* ---------- Housing ---------- */
.crisis { background: color-mix(in srgb, var(--love) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--love) 30%, transparent); border-radius: 16px; padding: 10px 14px; margin-bottom: 12px; }
.crisis summary { font-weight: 700; cursor: pointer; }
.hotlines { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.hotline { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; text-decoration: none; color: var(--ink); }
.hotline b { color: var(--love); font-size: 1.05rem; }
.hotline span { font-size: .8rem; }
.hotline small { color: var(--muted); font-size: .75rem; }
.counter-row.four { grid-template-columns: repeat(4, 1fr); }
.seg.three { grid-template-columns: repeat(3, 1fr); }
.seg.three button { font-size: .85rem; padding: 9px 4px; }
.hfilters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 14px; }
.hfilters select, .hfilters input { width: auto; flex: 1 1 120px; padding: 8px 10px; }
.check.inline { margin: 0; align-items: center; font-weight: 600; font-size: .85rem; }
.row.shelter, .row.person { align-items: flex-start; }
.beds { width: 74px; flex: none; border-radius: 14px; text-align: center; padding: 10px 4px; }
.beds b { display: block; font-family: Fraunces, serif; font-size: 1.6rem; line-height: 1; }
.beds span { font-size: .68rem; font-weight: 600; }
.beds.open { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.beds.full { background: var(--bg); color: var(--muted); }
.beds.full b { font-size: 1.1rem; }
.shelter-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.warn { color: #b26a00; }
.badge.urgent { background: color-mix(in srgb, var(--love) 18%, transparent); color: #b02a52; }
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.need-now { background: linear-gradient(135deg, #2b2350, #4a3d8f); }
.need-later { background: linear-gradient(135deg, #f6a04d, #e2557a); }
.contact { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; padding: 8px 10px; background: var(--bg); border-radius: 12px; }
.contact a { font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 1.2rem; cursor: pointer; }
.stepper b { min-width: 28px; text-align: center; font-size: 1.2rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .chip { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 600; }
.chips .chip input { width: auto; }
@media (max-width: 420px) { .bottomtabs a { font-size: .66rem; } }
.crisis summary .muted { font-weight: 500; font-size: .85rem; margin-left: 4px; }
.quickcall { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.quickcall a { text-align: center; }
.hfilters .check.inline { flex: 0 0 auto; white-space: nowrap; }

/* ---------- Logo ---------- */
.brand-logo { border-radius: 12px; box-shadow: 0 2px 10px rgba(106, 53, 232, .25); }
.hero-logo { width: 150px; height: 150px; border-radius: 28px; box-shadow: 0 12px 40px rgba(106, 53, 232, .28); margin-bottom: 18px; display: block; }
.g-0 { background-image: linear-gradient(135deg, #1fb6f2, #6a35e8 55%, #d23bd6); }
.round.save { color: var(--love); }
.stat b, .counter-row b { background: var(--glow); -webkit-background-clip: text; background-clip: text; color: transparent; }
@media (max-width: 759px) { .brand-logo { width: 36px; height: 36px; border-radius: 10px; } .topbar { padding: 10px 16px; } }
.verse.small { font-size: .9rem; margin: 18px 0 0; opacity: .9; }
.verse.small.center { text-align: center; margin-top: 22px; }

/* ---------- Chip scroller: edge fades + glowing arrows ---------- */
.chip-scroller { position: relative; }
.chip-scroller::before, .chip-scroller::after {
  content: ""; position: absolute; top: 0; bottom: 12px; width: 56px; pointer-events: none; z-index: 1;
  opacity: 0; transition: opacity .25s ease;
}
.chip-scroller::before { left: 0; background: linear-gradient(90deg, var(--bg) 25%, transparent); }
.chip-scroller::after { right: 0; background: linear-gradient(270deg, var(--bg) 25%, transparent); }
.chip-scroller.can-left::before, .chip-scroller.can-right::after { opacity: 1; }
.cs-btn {
  position: absolute; top: calc(50% - 6px); transform: translateY(-50%) scale(.8); z-index: 2;
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--brand-2); font-size: 1.35rem; line-height: 1; padding: 0 0 3px;
  display: grid; place-items: center; cursor: pointer; box-shadow: 0 4px 14px rgba(106, 53, 232, .22);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease, background .2s ease, color .2s ease;
}
.cs-btn.left { left: -2px; }
.cs-btn.right { right: -2px; }
.chip-scroller.can-left .cs-btn.left, .chip-scroller.can-right .cs-btn.right { opacity: 1; pointer-events: auto; transform: translateY(-50%) scale(1); }
.cs-btn:hover { background: var(--glow); color: #fff; border-color: transparent; }
.cs-btn:active { transform: translateY(-50%) scale(.92); }
.cs-btn:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
