:root {
  --brand: #FF7A45;
  --brand-2: #FFB547;
  --brand-soft: #FFF1EA;
  --teal: #14B8A6;
  --ink: #1F2330;
  --ink-2: #5B6170;
  --ink-3: #9AA0AD;
  --line: #ECEDF1;
  --bg: #F6F7FA;
  --card: #FFFFFF;
  --ok: #16A34A;
  --warn: #F59E0B;
  --danger: #EF4444;
  --vet: #2563EB;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(20, 24, 40, .12);
  --tabbar-h: 68px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Vazirmatn", system-ui, sans-serif;
  background: #E9EBF0;
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
.hidden { display: none !important; }

/* ---------- Mobile frame ---------- */
#app {
  position: relative;
  width: 100%; max-width: 420px;
  height: 100dvh; max-height: 900px;
  background: var(--bg);
  overflow: hidden;
}
@media (min-width: 500px) {
  #app { border-radius: 36px; box-shadow: 0 30px 80px rgba(0,0,0,.25), 0 0 0 10px #1c1f27; height: min(100dvh - 40px, 880px); }
}

.screen { position: absolute; inset: 0 0 var(--tabbar-h) 0; }
.page { background: var(--bg); overflow-y: auto; z-index: 500; padding-bottom: 24px; }
.page.full { bottom: 0; z-index: 900; }

/* ---------- Map ---------- */
#map { position: absolute; inset: 0; z-index: 1; background: #e5e3df; }
.leaflet-control-attribution { font-size: 9px !important; }
.leaflet-control-zoom { display: none; }

.map-top { position: absolute; top: 12px; left: 12px; right: 12px; z-index: 400; }
.searchbar {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border-radius: 16px; padding: 6px 8px 6px 12px;
  box-shadow: var(--shadow);
}
.searchbar .ico { font-size: 16px; opacity: .7; }
.searchbar input { flex: 1; border: 0; outline: 0; background: transparent; padding: 8px 0; font-size: 14px; min-width: 0; }
.icon-btn { position: relative; width: 38px; height: 38px; border-radius: 12px; background: var(--bg); font-size: 17px; display: grid; place-items: center; }
.icon-btn .dot { position: absolute; top: 6px; left: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }

.search-results {
  margin-top: 8px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow);
  max-height: 45vh; overflow-y: auto; padding: 6px;
}
.result { display: flex; align-items: center; gap: 10px; width: 100%; text-align: right; padding: 10px; border-radius: 12px; }
.result:hover, .result:active { background: var(--bg); }
.result .r-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; background: var(--brand-soft); flex: none; }
.result b { display: block; font-size: 14px; font-weight: 600; }
.result small { color: var(--ink-3); font-size: 12px; }
.empty { text-align: center; color: var(--ink-3); padding: 18px; font-size: 13px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 4px;
  padding: 7px 12px; border-radius: 999px; background: var(--card); font-size: 12.5px; font-weight: 500;
  box-shadow: 0 2px 8px rgba(20,24,40,.10); white-space: nowrap; border: 1.5px solid transparent;
}
.chip.active { background: var(--ink); color: #fff; }
.chip.outline { box-shadow: none; border-color: var(--line); }
.chip.outline.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }

.fab {
  position: absolute; left: 12px; bottom: 132px; z-index: 400;
  width: 46px; height: 46px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); font-size: 20px;
}

.insights { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 400; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.insight {
  background: rgba(255,255,255,.96); border-radius: 16px; padding: 10px 12px; box-shadow: var(--shadow);
  text-align: right; display: flex; gap: 8px; align-items: center; min-height: 64px; backdrop-filter: blur(8px);
}
.insight .big { font-size: 28px; line-height: 1; }
.insight small { display: block; color: var(--ink-3); font-size: 11px; }
.insight b { display: block; font-size: 13px; font-weight: 700; }
.insight i { font-style: normal; font-size: 11px; color: var(--ink-2); }

/* markers */
.mk { display: grid; place-items: center; }
.mk-place {
  width: 36px; height: 36px; border-radius: 50% 50% 50% 4px; transform: rotate(-45deg);
  border: 3px solid #fff; box-shadow: 0 4px 10px rgba(0,0,0,.25);
}
.mk-place span { transform: rotate(45deg); font-size: 16px; }
.mk-user {
  position: relative; width: 38px; height: 38px; border-radius: 50%; background: #fff; border: 3px solid var(--brand);
  font-size: 19px; box-shadow: 0 4px 10px rgba(0,0,0,.25);
}
.mk-user.vet { border-color: var(--vet); }
.mk-user .online { position: absolute; bottom: -1px; right: -1px; width: 11px; height: 11px; border-radius: 50%; background: var(--ok); border: 2px solid #fff; }
.mk-user .vbadge { position: absolute; top: -6px; left: -6px; width: 18px; height: 18px; border-radius: 50%; background: var(--vet); color: #fff; font-size: 11px; display: grid; place-items: center; border: 2px solid #fff; font-weight: 800; }
.mk-me { width: 20px; height: 20px; border-radius: 50%; background: #3B82F6; border: 4px solid #fff; box-shadow: 0 0 0 0 rgba(59,130,246,.6); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(59,130,246,.55); } 70% { box-shadow: 0 0 0 18px rgba(59,130,246,0); } 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); } }
.zone-label { background: rgba(255,255,255,.85); border-radius: 10px; padding: 2px 8px; font-family: Vazirmatn, sans-serif; font-size: 11px; font-weight: 600; white-space: nowrap; direction: rtl; box-shadow: 0 2px 6px rgba(0,0,0,.12); }

/* ---------- Tabbar ---------- */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--tabbar-h); z-index: 800;
  background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center; padding-bottom: env(safe-area-inset-bottom);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--ink-3); filter: grayscale(1); opacity: .7; }
.tab span { font-size: 21px; }
.tab small { font-size: 10.5px; font-weight: 600; }
.tab.active { color: var(--ink); filter: none; opacity: 1; }
.tab.create { filter: none; opacity: 1; }
.tab.create span {
  width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; color: #fff; font-weight: 300;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: 0 6px 16px rgba(255,122,69,.45);
}

/* ---------- Pages ---------- */
.header {
  position: sticky; top: 0; z-index: 5; background: rgba(246,247,250,.94); backdrop-filter: blur(10px);
  display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px;
}
.header h1 { margin: 0; font-size: 19px; font-weight: 800; flex: 1; }
.header .logo { font-size: 24px; font-weight: 800; letter-spacing: -.5px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; font-family: system-ui, sans-serif; }
.back { width: 38px; height: 38px; border-radius: 12px; background: var(--card); font-size: 18px; display: grid; place-items: center; }
.pad { padding: 0 16px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; }
.muted { color: var(--ink-2); }
.tiny { font-size: 12px; color: var(--ink-3); }
.section-title { font-size: 15px; font-weight: 700; margin: 18px 16px 10px; }
.seg { display: flex; background: #E9EBF0; border-radius: 12px; padding: 3px; margin: 0 16px 12px; }
.seg button { flex: 1; padding: 8px; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.seg button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: 14px; background: var(--bg); }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 6px 16px rgba(255,122,69,.35); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.sm { padding: 7px 12px; font-size: 12.5px; border-radius: 11px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }

.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--brand-soft); display: grid; place-items: center; font-size: 21px; flex: none; position: relative; }
.avatar.lg { width: 84px; height: 84px; font-size: 44px; }
.badge-vet { display: inline-flex; align-items: center; gap: 3px; background: #E8F0FF; color: var(--vet); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge-pending { display: inline-flex; background: #FEF3C7; color: #B45309; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge-ok { display: inline-flex; gap: 3px; background: #DCFCE7; color: var(--ok); font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.tick { color: var(--vet); font-size: 13px; }

/* forms */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink-2); }
.input { width: 100%; padding: 13px 14px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); outline: 0; font-size: 14px; }
.input:focus { border-color: var(--brand); }
textarea.input { resize: vertical; min-height: 90px; line-height: 1.8; }
.err { color: var(--danger); font-size: 12px; margin-top: 4px; min-height: 0; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice button { padding: 14px 10px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card); font-size: 13px; font-weight: 600; }
.choice button span { display: block; font-size: 26px; margin-bottom: 4px; }
.choice button.active { border-color: var(--brand); background: var(--brand-soft); }

/* auth */
.auth-hero { text-align: center; padding: 28px 20px 18px; }
.auth-hero .mascot { font-size: 64px; }
.auth-hero h2 { margin: 6px 0 4px; font-size: 22px; }
.auth-hero p { margin: 0; color: var(--ink-2); font-size: 13.5px; line-height: 1.9; }
.reason { margin: 0 16px 16px; background: var(--brand-soft); color: #B4471D; border-radius: 14px; padding: 10px 12px; font-size: 12.5px; }

/* feed */
.stories { display: flex; gap: 12px; overflow-x: auto; padding: 4px 16px 14px; scrollbar-width: none; }
.stories::-webkit-scrollbar { display: none; }
.story { flex: none; width: 68px; text-align: center; }
.story .ring { width: 66px; height: 66px; border-radius: 50%; padding: 3px; background: linear-gradient(135deg, var(--brand), #F43F5E, var(--brand-2)); }
.story .ring.seen { background: #D4D7DE; }
.story .ring.add { background: var(--line); }
.story .ring > div { width: 100%; height: 100%; border-radius: 50%; background: var(--card); border: 3px solid var(--card); display: grid; place-items: center; font-size: 28px; position: relative; }
.story .plus { position: absolute; bottom: -2px; left: -2px; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 15px; display: grid; place-items: center; border: 2px solid #fff; }
.story small { display: block; font-size: 11px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.post { background: var(--card); margin: 0 0 12px; border-radius: 0; }
@media (min-width: 0) { .post { margin: 0 12px 12px; border-radius: var(--radius); overflow: hidden; } }
.post-head { display: flex; align-items: center; gap: 10px; padding: 12px; }
.post-head b { font-size: 14px; }
.media { aspect-ratio: 1 / 1; display: grid; place-items: center; font-size: 110px; position: relative; overflow: hidden; }
.media img { width: 100%; height: 100%; object-fit: cover; }
.post-actions { display: flex; gap: 16px; padding: 10px 12px 4px; font-size: 22px; }
.post-actions button { display: flex; align-items: center; gap: 4px; }
.post-actions small { font-size: 13px; font-weight: 600; }
.liked { animation: pop .3s; }
@keyframes pop { 50% { transform: scale(1.3); } }
.post-body { padding: 4px 12px 12px; font-size: 13.5px; line-height: 1.9; }
.post-body .link { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; display: inline-block; }

/* profile */
.profile-top { text-align: center; padding: 6px 16px 14px; }
.profile-top h2 { margin: 10px 0 2px; font-size: 19px; display: flex; gap: 6px; align-items: center; justify-content: center; }
.profile-top .uname { color: var(--ink-3); font-size: 13px; direction: ltr; }
.profile-top .bio { font-size: 13.5px; line-height: 1.9; color: var(--ink-2); margin: 8px 0 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 14px 16px; background: var(--card); border-radius: var(--radius); padding: 12px 0; }
.stats button { text-align: center; }
.stats b { display: block; font-size: 17px; }
.stats small { color: var(--ink-3); font-size: 12px; }
.pets { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px; scrollbar-width: none; }
.pet { flex: none; background: var(--card); border-radius: 16px; padding: 10px 14px; display: flex; gap: 8px; align-items: center; font-size: 13px; }
.pet span { font-size: 24px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 0 12px; }
.grid3 .media { font-size: 40px; border-radius: 8px; }

/* wiki */
.wiki-card { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: var(--radius); padding: 12px; margin: 0 16px 10px; width: calc(100% - 32px); text-align: right; }
.wiki-card .w-ico { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-size: 30px; background: var(--brand-soft); flex: none; }
.wiki-card b { display: block; font-size: 14.5px; }
.wiki-card p { margin: 2px 0 4px; font-size: 12.5px; color: var(--ink-2); line-height: 1.7; }
.article { padding: 0 16px; line-height: 2.05; font-size: 14px; }
.article h2 { font-size: 21px; line-height: 1.6; margin: 6px 0; }
.article h3 { font-size: 15px; margin: 18px 0 6px; }
.article ul { padding-right: 18px; margin: 4px 0; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.facts div { background: var(--card); border-radius: 14px; padding: 10px; text-align: center; font-size: 12px; }
.facts b { display: block; font-size: 13px; margin-top: 2px; }
.verify-box { display: flex; gap: 10px; align-items: center; background: #E8F0FF; border-radius: 14px; padding: 10px 12px; font-size: 12.5px; color: #1E40AF; margin: 10px 0; }
.wiki-hero { font-size: 90px; text-align: center; background: linear-gradient(160deg, var(--brand-soft), #fff); border-radius: 24px; margin: 0 16px 12px; padding: 18px; }

/* ---------- Sheets ---------- */
.backdrop { position: absolute; inset: 0; background: rgba(15,18,28,.42); z-index: 1000; animation: fade .2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1001; background: var(--card);
  border-radius: 24px 24px 0 0; max-height: 86%; overflow-y: auto; padding: 8px 16px 22px;
  animation: up .25s cubic-bezier(.2,.8,.2,1);
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet h3 { margin: 0 0 4px; font-size: 18px; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
.kv { display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border: 0; }
.kv span:first-child { width: 22px; text-align: center; }
.bar { height: 10px; border-radius: 6px; background: var(--bg); overflow: hidden; flex: 1; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-2), var(--brand)); border-radius: 6px; }
.native-item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.native-item .n-ico { font-size: 34px; width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: #EEF8F0; flex: none; }
.native-item b { font-size: 14px; }
.native-item p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.7; }
.comment { display: flex; gap: 10px; padding: 8px 0; font-size: 13px; line-height: 1.8; }
.comment .avatar { width: 32px; height: 32px; font-size: 16px; }
.compose { position: sticky; bottom: -22px; background: var(--card); display: flex; gap: 8px; padding: 10px 0 0; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatches button { width: 34px; height: 34px; border-radius: 10px; border: 3px solid transparent; }
.swatches button.active { border-color: var(--ink); }
.emoji-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.emoji-pick button { width: 40px; height: 40px; border-radius: 12px; font-size: 22px; background: var(--bg); border: 2px solid transparent; }
.emoji-pick button.active { border-color: var(--brand); background: var(--brand-soft); }
.preview { aspect-ratio: 1/1; border-radius: 18px; display: grid; place-items: center; font-size: 90px; overflow: hidden; margin-bottom: 12px; }
.preview img { width: 100%; height: 100%; object-fit: cover; }
.range-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.range-row input { flex: 1; accent-color: var(--brand); }
.switch { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.switch input { width: 42px; height: 24px; accent-color: var(--brand); }

/* ---------- Story viewer ---------- */
.story-view { position: absolute; inset: 0; z-index: 1200; background: #000; color: #fff; display: flex; flex-direction: column; }
.story-view .bars { display: flex; gap: 4px; padding: 12px 10px 6px; }
.story-view .bars i { flex: 1; height: 3px; border-radius: 2px; background: rgba(255,255,255,.35); overflow: hidden; }
.story-view .bars i b { display: block; height: 100%; background: #fff; width: 0; }
.story-view .bars i.done b { width: 100%; }
.story-view .bars i.run b { animation: grow 5s linear forwards; }
@keyframes grow { to { width: 100%; } }
.story-view .s-head { display: flex; align-items: center; gap: 10px; padding: 6px 12px; }
.story-view .s-body { flex: 1; display: grid; place-items: center; font-size: 140px; position: relative; margin: 8px; border-radius: 18px; overflow: hidden; }
.story-view .s-body img { width: 100%; height: 100%; object-fit: cover; }
.story-view .s-text { position: absolute; bottom: 30px; left: 20px; right: 20px; text-align: center; font-size: 18px; font-weight: 700; text-shadow: 0 2px 8px rgba(0,0,0,.5); }
.story-view .tap { position: absolute; top: 80px; bottom: 0; width: 50%; z-index: 2; }

/* ---------- Tour ---------- */
.tour-mask { position: absolute; inset: 0; z-index: 2000; }
.tour-hole { position: absolute; border-radius: 16px; box-shadow: 0 0 0 9999px rgba(10,12,20,.68); transition: all .35s cubic-bezier(.2,.8,.2,1); pointer-events: none; }
.tour-tip {
  position: absolute; left: 16px; right: 16px; background: var(--card); border-radius: 20px; padding: 16px; z-index: 2001;
  box-shadow: 0 20px 40px rgba(0,0,0,.3); transition: top .35s;
}
.tour-tip h4 { margin: 0 0 4px; font-size: 16px; }
.tour-tip p { margin: 0 0 12px; font-size: 13px; line-height: 1.9; color: var(--ink-2); }
.tour-dots { display: flex; gap: 4px; }
.tour-dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--line); }
.tour-dots i.on { width: 18px; background: var(--brand); }
.tour-welcome { position: absolute; inset: 0; z-index: 2002; background: linear-gradient(170deg, #FF7A45, #FFB547); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; }
.tour-welcome .mascot { font-size: 90px; animation: bob 2s infinite ease-in-out; }
.tour-welcome h2 { font-size: 26px; margin: 10px 0; }
.tour-welcome p { line-height: 2; opacity: .95; font-size: 14px; }
@keyframes bob { 50% { transform: translateY(-10px); } }

/* ---------- Toast ---------- */
.toast { position: absolute; left: 50%; top: 18px; transform: translateX(-50%); z-index: 3000; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 14px; font-size: 13px; box-shadow: var(--shadow); max-width: 88%; text-align: center; animation: fade .2s; }

.leaflet-tooltip-plain { background: transparent; border: 0; box-shadow: none; padding: 0; }
.leaflet-tooltip-plain::before { display: none; }
