:root {
  --bg: #fbf7f0; --surface: #ffffff; --surface-2: #f3ede3; --text: #1d2a27; --muted: #5d6b67; --line: #e4dccf;
  --primary: #1f6f5c; --primary-ink: #ffffff; --primary-soft: #dcefe8;
  --lost: #c8372d; --lost-soft: #fde7e4; --found: #1f7a3a; --found-soft: #e1f4e6;
  --loose: #b86a00; --loose-soft: #fff1d9; --reunited: #6a3fb5; --reunited-soft: #efe7fb;
  --radius: 18px; --shadow: 0 2px 10px rgba(40, 30, 10, .07), 0 1px 2px rgba(40, 30, 10, .06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121816; --surface: #1b2321; --surface-2: #232d2a; --text: #ecf1ef; --muted: #a3b1ad; --line: #33403c;
    --primary: #4cbf9d; --primary-ink: #0b1a15; --primary-soft: #1d3a32;
    --lost: #ff7b70; --lost-soft: #3c1f1c; --found: #6fd38c; --found-soft: #1b3423;
    --loose: #ffb54a; --loose-soft: #3a2c14; --reunited: #b99bff; --reunited-soft: #2c2342;
    --shadow: 0 2px 10px rgba(0, 0, 0, .3);
  }
}
:root[data-theme="dark"] {
  --bg: #121816; --surface: #1b2321; --surface-2: #232d2a; --text: #ecf1ef; --muted: #a3b1ad; --line: #33403c;
  --primary: #4cbf9d; --primary-ink: #0b1a15; --primary-soft: #1d3a32;
  --lost: #ff7b70; --lost-soft: #3c1f1c; --found: #6fd38c; --found-soft: #1b3423;
  --loose: #ffb54a; --loose-soft: #3a2c14; --reunited: #b99bff; --reunited-soft: #2c2342;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 500 17px/1.5 Nunito, system-ui, -apple-system, Segoe UI, sans-serif; padding-bottom: 76px; }
img { max-width: 100%; display: block; }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; font-weight: 900; }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); }
h2 { font-size: 1.35rem; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 99; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* top + bottom nav */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-size: 1.1rem; font-weight: 700; }
.brand b { color: var(--primary); font-weight: 900; }
.topnav { display: flex; align-items: center; gap: 18px; }
.topnav a:not(.btn) { color: var(--text); text-decoration: none; font-weight: 700; }
.topnav a[aria-current="page"]:not(.btn) { color: var(--primary); }
.bottomnav { display: none; }
@media (max-width: 720px) {
  .topnav { display: none; }
  .brand { font-size: 1rem; }
  .bottomnav { display: flex; position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; font-size: .8rem; font-weight: 800; color: var(--muted); text-decoration: none; padding: 4px; }
  .bottomnav a span { font-size: 1.35rem; line-height: 1.2; }
  .bottomnav .bn-post span { background: var(--primary); color: var(--primary-ink); width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center;
    margin-top: -22px; box-shadow: var(--shadow); font-size: 1.6rem; }
  .bottomnav a[aria-current="page"] { color: var(--primary); }
}
@media (min-width: 721px) { body { padding-bottom: 0; } }

main { max-width: 1120px; margin: 0 auto; padding: 18px 16px 40px; min-height: 60vh; outline: none; }
.footer { max-width: 1120px; margin: 0 auto; padding: 24px 16px 36px; border-top: 1px solid var(--line); font-size: .92rem; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 20px; border-radius: 999px;
  border: 2px solid transparent; font: inherit; font-weight: 800; cursor: pointer; text-decoration: none; background: var(--surface-2); color: var(--text); }
.btn:hover { filter: brightness(.97); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-outline { background: transparent; border-color: var(--line); }
.btn-danger { background: var(--lost); color: #fff; }
.btn-sm { min-height: 40px; padding: 6px 16px; }
.btn-block { width: 100%; }
.btn-lg { min-height: 58px; font-size: 1.15rem; padding: 12px 28px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* hero + action cards */
.hero { text-align: center; padding: 18px 0 8px; }
.hero p { font-size: 1.12rem; color: var(--muted); max-width: 640px; margin: 0 auto 18px; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 8px 0 22px; }
.action { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 22px 14px; border-radius: var(--radius);
  text-decoration: none; color: var(--text); background: var(--surface); border: 2px solid var(--line); box-shadow: var(--shadow); transition: transform .12s; }
.action:hover { transform: translateY(-2px); }
.action .emoji { font-size: 2.4rem; line-height: 1; }
.action b { font-size: 1.2rem; font-weight: 900; }
.action small { color: var(--muted); font-size: .92rem; }
.action.lost { border-color: var(--lost); } .action.lost b { color: var(--lost); }
.action.found { border-color: var(--found); } .action.found b { color: var(--found); }
.action.loose { border-color: var(--loose); } .action.loose b { color: var(--loose); }
@media (max-width: 640px) {
  .actions { grid-template-columns: 1fr; gap: 10px; }
  .action { flex-direction: row; text-align: left; padding: 16px; gap: 14px; }
  .action .emoji { font-size: 2rem; }
}
.stats { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: .95rem; font-weight: 700; }
.stat b { font-weight: 900; }

/* filters */
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); margin-bottom: 18px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip { flex: none; min-height: 42px; padding: 8px 16px; border-radius: 999px; border: 2px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 800; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.filter-row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 10px; margin-top: 12px; }
@media (max-width: 720px) { .filter-row { grid-template-columns: 1fr 1fr; } .filter-row .search { grid-column: 1 / -1; } }

/* form controls */
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 2px solid var(--line); border-radius: 12px;
  min-height: 50px; padding: 10px 14px; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; }
label { display: block; font-weight: 800; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.hint { font-size: .9rem; color: var(--muted); font-weight: 600; margin-top: 4px; }
.optional { color: var(--muted); font-weight: 600; font-size: .88rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; margin: 6px 0; cursor: pointer; }
.check input { width: 24px; height: 24px; min-height: 0; accent-color: var(--primary); }

/* big choice tiles (type / species / size) */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { position: relative; }
.tile input { position: absolute; opacity: 0; pointer-events: none; }
.tile span { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 2px; min-height: 92px; padding: 10px 8px;
  border: 2px solid var(--line); border-radius: 16px; background: var(--surface); font-weight: 900; cursor: pointer; font-size: 1.05rem; }
.tile span em { font-style: normal; font-size: 2rem; line-height: 1.1; }
.tile span small { font-weight: 600; color: var(--muted); font-size: .82rem; }
.tile input:checked + span { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 2px var(--primary) inset; }
.tile input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }
.tiles.small span { min-height: 54px; flex-direction: row; gap: 6px; }
.tiles.small span em { font-size: 1.3rem; }

/* wizard */
.wizard { max-width: 680px; margin: 0 auto; }
.progress { display: flex; gap: 6px; margin: 4px 0 18px; }
.progress i { flex: 1; height: 8px; border-radius: 99px; background: var(--line); }
.progress i.on { background: var(--primary); }
.step-label { font-weight: 800; color: var(--muted); font-size: .92rem; margin-bottom: 2px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.wizard-nav { display: flex; gap: 10px; margin-top: 18px; }
.wizard-nav .btn-primary { flex: 1; }
.error-box { background: var(--lost-soft); color: var(--lost); border-radius: 12px; padding: 10px 14px; font-weight: 800; margin-bottom: 14px; }
.draft-note { background: var(--primary-soft); border-radius: 12px; padding: 10px 14px; font-weight: 700; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

/* photos */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.photo-slot { aspect-ratio: 1; border-radius: 16px; border: 2px dashed var(--line); background: var(--surface-2); display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; cursor: pointer; position: relative; overflow: hidden; font-weight: 800; color: var(--muted); padding: 6px; }
.photo-slot.drag { border-color: var(--primary); background: var(--primary-soft); }
.photo-slot .plus { font-size: 2rem; line-height: 1; }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.photo-slot .rm { position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff;
  font-size: 1.1rem; cursor: pointer; z-index: 2; }
.photo-slot .main-tag { position: absolute; left: 6px; bottom: 6px; background: var(--primary); color: var(--primary-ink); font-size: .75rem; padding: 2px 8px; border-radius: 99px; z-index: 2; }
.photo-slot.busy::after { content: 'Adding…'; position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 80%, transparent); }

/* maps */
.map { height: 300px; border-radius: 16px; border: 2px solid var(--line); z-index: 1; }
.map-lg { height: 520px; }
@media (max-width: 720px) { .map-lg { height: 65vh; } }

/* listing cards */
.results-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 6px 0 12px; flex-wrap: wrap; }
.view-toggle { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 4px; }
.view-toggle button { border: 0; background: transparent; font: inherit; font-weight: 800; padding: 6px 16px; border-radius: 999px; cursor: pointer; color: var(--text); min-height: 38px; }
.view-toggle button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.pet-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--text);
  box-shadow: var(--shadow); display: flex; flex-direction: column; transition: transform .12s; }
.pet-card:hover { transform: translateY(-2px); }
.pet-card .ph { aspect-ratio: 4/3; background: var(--surface-2); position: relative; display: grid; place-items: center; font-size: 3.4rem; }
.pet-card .ph img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }
.pet-card .body { padding: 12px 14px 14px; }
.pet-card h3 { font-size: 1.1rem; margin: 0 0 2px; }
.pet-card .meta { color: var(--muted); font-size: .92rem; font-weight: 600; }
.safe-tag { display: inline-block; margin-top: 6px; background: var(--found-soft); color: var(--found); font-weight: 900; font-size: .85rem; padding: 3px 10px; border-radius: 999px; }
.badge { display: inline-block; font-weight: 900; font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; padding: 4px 10px; border-radius: 999px; }
.pet-card .badge { position: absolute; top: 10px; left: 10px; z-index: 1; }
.badge.lost { background: var(--lost); color: #fff; }
.badge.found { background: var(--found); color: #fff; }
.badge.loose { background: var(--loose); color: #fff; }
.badge.reunited { background: var(--reunited); color: #fff; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .big { font-size: 3rem; }

/* detail */
.detail { display: grid; grid-template-columns: 1.1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 820px) { .detail { grid-template-columns: 1fr; } }
.gallery .main-photo { border-radius: var(--radius); overflow: hidden; background: var(--surface-2); aspect-ratio: 4/3; display: grid; place-items: center; font-size: 5rem; }
.gallery .main-photo img { width: 100%; height: 100%; object-fit: contain; background: #000; }
.thumbs { display: flex; gap: 8px; margin-top: 8px; }
.thumbs button { width: 76px; height: 76px; border-radius: 12px; overflow: hidden; border: 3px solid transparent; padding: 0; cursor: pointer; background: none; }
.thumbs button[aria-current="true"] { border-color: var(--primary); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0; }
.facts dt { color: var(--muted); font-weight: 700; }
.facts dd { margin: 0; font-weight: 800; }
.contact-card { background: var(--primary-soft); border-radius: var(--radius); padding: 16px; margin: 14px 0; }
.contact-card .btn { flex: 1; min-width: 120px; }
.banner { border-radius: var(--radius); padding: 14px 16px; font-weight: 800; margin-bottom: 16px; }
.banner.reunited { background: var(--reunited-soft); color: var(--reunited); }
.banner.success { background: var(--found-soft); color: var(--found); }
.title-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }

/* manage link box */
.linkbox { display: flex; gap: 8px; margin: 10px 0; }
.linkbox input { font-size: .9rem; }

/* tips */
.tips-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .tips-grid { grid-template-columns: 1fr; } }
.tips-grid ol, .tips-grid ul { padding-left: 1.2em; margin: 0; }
.tips-grid li { margin-bottom: 8px; }
.resource { padding: 10px 0; border-bottom: 1px solid var(--line); }
.resource:last-child { border-bottom: 0; }
.resource b { display: block; }

/* toast */
#toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 12px 20px;
  border-radius: 999px; font-weight: 800; opacity: 0; transition: .2s; pointer-events: none; z-index: 100; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* flyer (print) */
.flyer { background: #fff; color: #111; max-width: 8.5in; margin: 0 auto; padding: .45in; border: 1px solid #ddd; text-align: center; }
.flyer .hdr { font-size: 5rem; font-weight: 900; line-height: 1; letter-spacing: .02em; margin-bottom: 4px; }
.flyer .hdr.lost { color: #c8372d; } .flyer .hdr.found { color: #1f7a3a; } .flyer .hdr.loose { color: #b86a00; }
.flyer .sub { font-size: 1.6rem; font-weight: 900; margin-bottom: 12px; }
.flyer .fphotos { display: grid; gap: 8px; margin-bottom: 12px; }
.flyer .fphotos img { width: 100%; height: 4.2in; object-fit: cover; border-radius: 8px; }
.flyer .fphotos.n2, .flyer .fphotos.n3 { grid-template-columns: 2fr 1fr; }
.flyer .fphotos.n2 img:first-child, .flyer .fphotos.n3 img:first-child { grid-row: span 2; }
.flyer .fphotos.n2 img:not(:first-child), .flyer .fphotos.n3 img:not(:first-child) { height: calc(2.1in - 4px); }
.flyer .fphotos.n2 img:nth-child(2) { height: 4.2in; grid-row: span 2; }
.flyer .ftext { font-size: 1.25rem; font-weight: 700; margin-bottom: 6px; }
.flyer .fcall { font-size: 2.3rem; font-weight: 900; margin: 10px 0 6px; }
.flyer .ffoot { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 10px; font-size: 1rem; text-align: left; }
.flyer .ffoot #qr img, .flyer .ffoot #qr canvas { width: 110px; height: 110px; }
.flyer-tools { max-width: 8.5in; margin: 0 auto 14px; }
@media print {
  @page { size: letter; margin: .3in; }
  body { background: #fff; padding: 0; }
  .topbar, .footer, .bottomnav, .flyer-tools, #toast, .skip { display: none !important; }
  main { padding: 0; max-width: none; }
  .flyer { border: 0; padding: 0; max-width: none; }
}
