/* ===========================================================
   نصب پرتو لینک — توکن‌ها
   فاصله‌ها روی مقیاس ۴ پیکسلی، اهداف لمسی حداقل ۴۴ پیکسل
   =========================================================== */

:root {
  /* مقیاس فاصله */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --s10: 40px;

  /* شعاع */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --r-pill: 999px;

  /* اندازه‌ها */
  --tap: 44px;              /* حداقل هدف لمسی */
  --bar: 48px;              /* ارتفاع محتوای نوار پایین (بدون ناحیه امن) */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  /* نوار پایین تا انتهای ناحیه امن کشیده می‌شود و محتوایش ته آن می‌نشیند،
     پس هیچ نوار خالی زیرش نمی‌ماند */
  --safe-b-cap: 0px;   /* دیگر لازم نیست؛ نوار تا ته ناحیه امن می‌آید */
  --barfull: calc(var(--bar) + var(--safe-b));
  /* دکمه دوربین از کف نوار لنگر می‌گیرد نه از سقفش: بیرون‌زدگی روی گوشی بدون
     ناحیه امن حداکثر ۱۴ پیکسل می‌شود، روی آیفون کامل داخل نوار می‌ماند، و
     برچسب «دوربین» زیرش آزاد است (۱۸ پیکسل کف نوار مال برچسب است) */
  --fab-lift: 22px;

  /* برند */
  --brand: #FF6B00;
  --brand-ink: #ffffff;
  --danger: #ef4444;
  --ok: #22c55e;
  --warn: #eab308;

  /* لایه‌بندی */
  --z-tabbar: 20;
  --z-topbar: 30;
  --z-view: 40;
  --z-sheet: 60;
  --z-viewer: 70;            /* نمایشگر تمام‌صفحه گالری، روی شیت */
  --z-toast: 80;

  /* حرکت */
  --dur: 200ms;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

/* --- تم تیره (پیش‌فرض) --- */
:root, :root[data-theme="dark"] {
  --bg: #0b0e13;
  --surface: #121722;
  --surface-2: #1a2130;
  --panel: rgba(14, 18, 25, .82);
  --glass: rgba(255, 255, 255, .10);
  --glass-line: rgba(255, 255, 255, .22);
  --line: rgba(255, 255, 255, .14);
  --txt: #f2f4f8;
  --muted: rgba(242, 244, 248, .64);
  --scrim: rgba(0, 0, 0, .55);
  --input-bg: rgba(0, 0, 0, .35);
}

/* --- تم روشن --- */
:root[data-theme="light"] {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --panel: rgba(255, 255, 255, .92);
  --glass: rgba(255, 255, 255, .55);
  --glass-line: rgba(15, 23, 42, .16);
  --line: rgba(15, 23, 42, .14);
  --txt: #0f172a;
  --muted: rgba(15, 23, 42, .62);
  --scrim: rgba(15, 23, 42, .45);
  --input-bg: rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* هر عنصری که display صریح دارد وگرنه hidden را نادیده می‌گیرد */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  /* اگر ویوپورت آی‌اواس یک نوار نازک زیر اپ باقی بگذارد، هم‌رنگ نوار تب باشد
     تا به چشم نیاید */
  background: var(--surface);
  color: var(--txt);
  font-family: Vazirmatn, system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  overscroll-behavior: none;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

button, input { font-family: inherit; color: inherit; }
/* سافاری به دکمه پدینگ و حاشیه پیش‌فرض می‌دهد؛ بدون این ریست، محتوای دکمه
   (مثل دایره داخلی شاتر) از مرکز درمی‌رود */
button { cursor: pointer; padding: 0; margin: 0; border-style: solid; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ===========================================================
   دروازه نصب و ورود
   =========================================================== */

.view-gate, .view-login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-t) + var(--s5)) calc(var(--safe-r) + var(--s5))
           calc(var(--safe-b) + var(--s5)) calc(var(--safe-l) + var(--s5));
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 107, 0, .16), transparent 62%),
    var(--bg);
  overflow-y: auto;
  z-index: var(--z-view);
}

.gate-card, .login-card {
  width: 100%;
  max-width: 400px;
  padding: var(--s6) var(--s5) var(--s5);
  border-radius: var(--r-xl);
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  text-align: center;
}

.gate-logo img, .login-logo img { width: 64px; height: auto; }
.gate-card h1, .login-card h1 { font-size: 20px; margin: var(--s3) 0 var(--s1); }
.gate-sub, .login-sub { margin: 0 0 var(--s5); font-size: 12.5px; color: var(--muted); }
.gate-lead { font-size: 15px; margin: 0 0 var(--s4); }

.gate-steps {
  text-align: start;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s4);
  font-size: 13.5px;
  line-height: 2;
  margin-bottom: var(--s4);
}

.gate-steps b { color: var(--brand); }
.gate-steps ol { margin: 0; padding-inline-start: var(--s5); }

.login-card label {
  display: block;
  text-align: start;
  font-size: 12.5px;
  color: var(--muted);
  margin: var(--s3) var(--s1) var(--s1);
}

.login-card input, #man-search, .set-input {
  width: 100%;
  min-height: var(--tap);
  padding: var(--s3);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--txt);
  font-size: 16px;                 /* زیر ۱۶ روی آی‌اواس زوم می‌کند */
  transition: border-color var(--dur) var(--ease);
}

.login-card input:focus, #man-search:focus, .set-input:focus {
  outline: 2px solid transparent;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 107, 0, .22);
}

.cap-row { display: flex; gap: var(--s2); align-items: stretch; }
.cap-row input { flex: 1; text-align: center; letter-spacing: 2px; }

.cap-img {
  flex: 0 0 118px;
  min-height: var(--tap);
  border-radius: var(--r-md);
  background: #fff;
  display: grid;
  place-items: center;
  overflow: hidden;
  cursor: pointer;
}

.cap-img svg { max-width: 100%; height: auto; }
.cap-wait { color: #333; font-size: 20px; }
.login-err { color: #ff6b6b; font-size: 12.5px; min-height: 18px; margin-top: var(--s3); }

/* ===========================================================
   پوسته
   =========================================================== */

#app { position: fixed; inset: 0; height: 100dvh; background: var(--bg); }

.tab {
  position: absolute;
  inset: 0 0 var(--barfull) 0;
  display: flex;
  flex-direction: column;
}

/* آی‌فریم safe-area نمی‌گیرد؛ خودِ قاب را زیر ناچ می‌بریم */
.tab iframe {
  width: calc(100% - var(--safe-l) - var(--safe-r));
  height: calc(100% - var(--safe-t));
  margin: var(--safe-t) var(--safe-r) 0 var(--safe-l);
  border: 0;
  background: var(--bg);
  display: block;
}

#tab-delivery, #tab-calc, #tab-messenger { background: var(--surface); }

/* نوار پایین */
.tabbar {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: var(--barfull);
  padding: 0 var(--safe-r) 0 var(--safe-l);
  /* دنباله هم‌رنگ زیر نوار: هر فاصله‌ای که سیستم بگذارد پر می‌شود */
  box-shadow: 0 40px 0 0 var(--surface);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: var(--z-tabbar);
}

.tabbtn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  padding: 0 0 4px;
  min-height: var(--tap);
  transition: color var(--dur) var(--ease);
}

.tabbtn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tabbtn.is-on { color: var(--brand); }
.tabbtn:active { opacity: .7; }

/* دوربین وسط، برجسته */
.tabbtn-main { position: relative; }

/* بیرون‌زدگی کم است تا روی محتوای تب‌های دیگر (شاتر دوربین، امضای نقشه) نیفتد:
   دکمه جای آیکن بقیه تب‌ها می‌نشیند و فقط --fab-rise از لبه نوار بالاتر می‌آید. */
.tab-fab {
  position: absolute;
  bottom: var(--fab-lift);
  inset-inline-start: 50%;
  transform: translateX(50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 3px 10px rgba(255, 107, 0, .38);
  border: 3px solid var(--surface);
  transition: transform 140ms var(--ease);
}

.tab-fab svg { width: 20px; height: 20px; }
.tabbtn-main:active .tab-fab { transform: translateX(50%) scale(.94); }
.tabbtn-main.is-on .tab-fab { box-shadow: 0 8px 22px rgba(255, 107, 0, .6); }

/* در حالت خوابیده ستون است، برجستگی به کنار می‌رود */
@media (orientation: landscape) and (max-height: 560px) {
  .tab-fab {
    position: static;
    transform: none;
    width: 42px;
    height: 42px;
    border-width: 2px;
  }
  .tabbtn-main:active .tab-fab { transform: scale(.94); }
  .tab-fab svg { width: 20px; height: 20px; }
}

/* ===========================================================
   دوربین
   =========================================================== */

.stage { position: absolute; inset: 0; background: #000; overflow: hidden; }
#video { width: 100%; height: 100%; object-fit: cover; }
#video.mirror { transform: scaleX(-1); }
.grid-overlay { position: absolute; inset: 0; pointer-events: none; }

/* کادر نسبت ابعاد: بیرونش تیره می‌شود تا همان چیزی که می‌بینی ذخیره شود */
.crop-mask {
  position: absolute;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, .5);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55);
  z-index: 2;
}

.focus-ring {
  position: absolute;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  border: 2px solid var(--brand);
  border-radius: 50%;
  pointer-events: none;
}

.focus-ring.pop { animation: focuspop .45s var(--ease); }
@keyframes focuspop { from { transform: scale(1.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.timer-count {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 84px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 4px 22px rgba(0, 0, 0, .6);
  pointer-events: none;
}

.rec-badge {
  position: absolute;
  top: calc(var(--safe-t) + 58px);
  inset-inline-start: 50%;
  transform: translateX(50%);
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s1) var(--s3);
  border-radius: var(--r-pill);
  background: rgba(239, 68, 68, .92);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: #fff; animation: pulse 1s infinite; }

.zoom-bubble {
  position: absolute;
  top: 45%;
  inset-inline-start: 50%;
  transform: translate(50%, -50%);
  padding: var(--s2) var(--s4);
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, .62);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  z-index: var(--z-topbar);
  backdrop-filter: blur(8px);
}

.cam-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s4);
  padding: var(--s8);
  text-align: center;
  color: rgba(255, 255, 255, .7);
}

.cam-fallback-icon { font-size: 44px; }

.topbar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  padding: calc(var(--safe-t) + var(--s3)) calc(var(--safe-r) + var(--s3))
           var(--s3) calc(var(--safe-l) + var(--s3));
  background: linear-gradient(to bottom, rgba(0, 0, 0, .58), transparent);
}

.topbar-left, .topbar-right { display: flex; gap: var(--s2); }

.ctl-ratio { font-size: 12px; font-weight: 700; }
.ctl-ratio span { font-variant-numeric: tabular-nums; }

.ctl-sm {
  position: relative;
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0 var(--s2);
  border-radius: var(--r-md);
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(0, 0, 0, .45);
  color: #fff;
  display: grid;
  place-items: center;
  backdrop-filter: blur(6px);
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.ctl-sm svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ctl-sm.is-on { border-color: var(--brand); color: var(--brand); }
.ctl-sm:active { opacity: .75; }

.ctl-tag {
  position: absolute;
  bottom: 2px;
  inset-inline: 0;
  font-size: 8.5px;
  color: rgba(255, 255, 255, .72);
  text-align: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: var(--s1) var(--s3);
  min-height: 30px;
  border-radius: var(--r-pill);
  font-size: 12px;
  background: rgba(0, 0, 0, .5);
  border: 1px solid rgba(255, 255, 255, .16);
  color: #fff;
  backdrop-filter: blur(6px);
}

.chip-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: 0 0 auto; }
.chip-ok .chip-dot { background: var(--ok); }
.chip-bad .chip-dot { background: var(--danger); }
.chip-wait .chip-dot { animation: pulse 1.2s infinite; }

@keyframes pulse { 50% { opacity: .25; } }

/* مهر شیشه‌ای زنده — فقط یادآوری است که چه چیزی زیر عکس می‌نشیند، پس کوچک
   می‌ماند: نسخه بزرگ‌ترش نصف پیش‌نمایش را می‌گرفت و کادر عکس دیده نمی‌شد. */
.live-stamp {
  position: relative;
  z-index: 3;
  margin: auto calc(var(--safe-r) + var(--s4)) 0 calc(var(--safe-l) + var(--s4));
  max-width: 320px;
  padding: 4px var(--s2) 6px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .16);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  color: #fff;
  opacity: .92;
}

.ls-brand {
  display: flex;
  align-items: center;
  gap: var(--s1);
  padding-bottom: 3px;
  margin-bottom: 3px;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
  font-size: 8px;
  opacity: .75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ls-brand img { height: 10px; width: auto; }
.ls-body { display: flex; gap: var(--s2); }

.ls-map {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(127, 127, 127, .25);
}

.ls-map canvas { width: 100%; height: 100%; display: block; }
.ls-text { min-width: 0; flex: 1; }

.ls-place {
  font-weight: 700;
  font-size: 10.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .45);
}

.ls-addr {
  font-size: 9px;
  margin-top: 1px;
  opacity: .94;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ls-meta {
  font-size: 8.5px;
  margin-top: 2px;
  opacity: .8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

/* زوم و حالت‌ها */
.zoom-row {
  position: relative;
  z-index: 3;
  direction: ltr;              /* ۰.۵ → ۱ → ۲ مثل دوربین گوشی */
  display: flex;
  gap: var(--s2);
  justify-content: center;
  padding: var(--s3) var(--s3) 0;
}

.zoombtn {
  min-width: var(--tap);
  min-height: 34px;
  border-radius: var(--r-pill);
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(0, 0, 0, .5);
  color: #fff;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(6px);
  transition: background var(--dur) var(--ease), transform 120ms var(--ease);
}

.zoombtn.is-on { background: var(--brand); border-color: var(--brand); font-weight: 700; }
.zoombtn:active { transform: scale(.94); }

.mode-row {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  justify-items: center;
  padding: var(--s2) calc(var(--safe-r) + var(--s5)) 0 calc(var(--safe-l) + var(--s5));
}

.mode {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, .72);
  font-size: 13.5px;
  min-height: 36px;
  padding: 0 var(--s1);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--dur) var(--ease);
}

.mode span {
  display: inline-block;
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: border-color var(--dur) var(--ease);
}

.mode.is-on { color: var(--brand); font-weight: 700; }
.mode.is-on span { border-bottom-color: var(--brand); }

.controls {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: var(--s4);
  /* پایین: جای بیرون‌زدگی دکمه دوربین باز می‌ماند تا روی شاتر نیفتد */
  padding: var(--s2) calc(var(--safe-r) + var(--s5)) var(--s4) calc(var(--safe-l) + var(--s5));
}

.shutter {
  width: 72px;
  height: 72px;
  padding: 0;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, .92);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  transition: transform 120ms var(--ease);
  flex: 0 0 auto;
}

.shutter span {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fff;
  display: block;
  transition: all 180ms var(--ease);
}

.shutter:active { transform: scale(.93); }
.shutter.is-video span { background: var(--danger); }
.shutter.is-rec span { border-radius: 12px; width: 28px; height: 28px; background: var(--danger); }

.ctl {
  position: relative;
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(0, 0, 0, .45);
  color: #fff;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

.ctl svg, .icon-btn svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ctl:active { opacity: .75; }

.ctl-badge {
  position: absolute;
  top: -3px;
  inset-inline-start: -3px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.mini {
  min-height: 36px;
  padding: 0 var(--s3);
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--txt);
  font-size: 12.5px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mini-danger { color: #e11d48; border-color: rgba(225, 29, 72, .45); }

/* ===========================================================
   صفحه‌های تمام‌قد
   =========================================================== */

.view {
  position: fixed;
  inset: 0;
  z-index: var(--z-view);
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.review-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  background: #000;
  padding: var(--s2);
}

#review-img, #review-video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--r-sm);
}

.review-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) calc(var(--safe-r) + var(--s4))
           calc(var(--safe-b) + var(--s4)) calc(var(--safe-l) + var(--s4));
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.review-size { font-size: 11.5px; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }

/* نوار پیشرفت آپلود: روی خط ضعیف باید دیده شود دارد می‌رود یا گیر کرده */
.review-prog {
  padding: var(--s2) calc(var(--safe-r) + var(--s4)) 0 calc(var(--safe-l) + var(--s4));
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.review-bar-track {
  height: 6px;
  border-radius: 99px;
  background: var(--line);
  overflow: hidden;
}

.review-bar-track i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--brand);
  transition: width 150ms var(--ease);
}

.review-prog-txt {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.review-prog.is-bad .review-bar-track i { background: var(--danger); }
.review-prog.is-bad .review-prog-txt { color: var(--danger); }

.btn {
  min-height: var(--tap);
  padding: 0 var(--s6);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 700;
  transition: transform 120ms var(--ease), opacity var(--dur) var(--ease);
}

.btn:active { transform: scale(.97); }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:disabled { opacity: .55; }
.btn-ghost { background: transparent; color: var(--txt); border-color: var(--line); }
.btn-block { display: flex; align-items: center; justify-content: center; width: 100%; margin-top: var(--s3); }
.btn-sm { min-height: 34px; padding: 0 var(--s3); font-size: 12px; font-weight: 600; border-radius: var(--r-pill); flex: 0 0 auto; }

.sheet-head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: calc(var(--safe-t) + var(--s3)) calc(var(--safe-r) + var(--s4))
           var(--s3) calc(var(--safe-l) + var(--s4));
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.sheet-head h1 { flex: 1; font-size: 16px; margin: 0; }

.icon-btn {
  position: relative;              /* نشان شمار سطل زباله روی همین می‌نشیند */
  width: var(--tap);
  height: var(--tap);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--txt);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

/* لوکیشن دستی */
.man-map { flex: 1; min-height: 0; }

.man-map::after {
  content: '';
  position: absolute;
  inset-inline-start: 50%;
  top: 50%;
  width: 26px;
  height: 26px;
  margin: -30px 0 0 -13px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: #e53935;
  border: 3px solid #fff;
  pointer-events: none;
  z-index: 500;
}

.man-info {
  padding: var(--s3) calc(var(--safe-r) + var(--s4))
           calc(var(--safe-b) + var(--s4)) calc(var(--safe-l) + var(--s4));
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.man-addr { font-size: 13.5px; margin-bottom: var(--s2); line-height: 1.6; }

/* دکمه‌های عمل پایین صفحه‌اند، نه یک دکمه بی‌استایل گوشه هدر */
.man-actions {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: var(--s3);
  margin-top: var(--s3);
}

.man-actions .btn { width: 100%; }

.man-me {
  position: absolute;
  left: 12px;                    /* فیزیکی: در RTL هم همین‌جا بماند */
  bottom: 12px;
  z-index: 1000;                 /* لِفلت به کنترل‌هایش ۱۰۰۰ می‌دهد */
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--txt);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28);
}

.man-me svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* گالری — چیدمان گالری گوشی: خانه‌های مربعی چسبیده، بی متن و بی قاب.
   متن هر عکس داخل نمایشگر است، نه زیر بندانگشتی. */
.g-note {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) calc(var(--safe-r) + var(--s4)) var(--s2) calc(var(--safe-l) + var(--s4));
  font-size: 12px;
  color: var(--muted);
}

.g-note span { flex: 1; min-width: 0; }
.g-note:empty { display: none; }

.g-grid {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-content: start;          /* وگرنه کارت‌ها تا ته صفحه کش می‌آیند */
  gap: 2px;
  padding: 0 0 calc(var(--safe-b) + var(--s6));
}

.g-card {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: #000;
  padding: 0;
  color: inherit;
  transition: opacity 120ms var(--ease);
}

.g-card:active { opacity: .72; }

.g-kind {
  position: absolute;
  bottom: 4px;
  inset-inline-start: 5px;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 10px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
}

/* روزهای مانده تا پاک‌شدن قطعی، فقط در سطل زباله */
.g-left-tag {
  position: absolute;
  top: 4px;
  inset-inline-end: 5px;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font-size: 10px;
}

.g-left-tag.urgent { background: rgba(220, 38, 55, .85); }

/* شیت جزئیات گالری */
.ed-label { display: block; font-size: 12.5px; color: var(--muted); margin: var(--s3) 2px var(--s1); }
.ed-input { max-width: none; width: 100%; }
.ed-note { font-size: 12px; color: var(--muted); margin: var(--s3) 0 0; }

/* ===========================================================
   نمایشگر تمام‌صفحه گالری
   عکس باید بی‌دانلود و کامل دیده شود؛ زوم دستی است چون
   ویوپورت اپ user-scalable=no دارد و پینچ مرورگر کار نمی‌کند.
   =========================================================== */

.viewer {
  position: fixed;
  inset: 0;
  z-index: var(--z-viewer);
  background: #000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  touch-action: none;            /* حرکت‌ها را خودمان می‌گیریم */
}

.vw-stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.vw-img, .vw-video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  transform-origin: center center;
  will-change: transform;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.vw-img.is-anim { transition: transform 180ms var(--ease); }

.vw-top, .vw-bottom {
  position: absolute;
  inset-inline: 0;
  z-index: 2;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}

.vw-top > *, .vw-bottom > * { pointer-events: auto; }

.vw-top {
  top: 0;
  padding: calc(var(--safe-t) + var(--s2)) calc(var(--safe-r) + var(--s3))
           var(--s3) calc(var(--safe-l) + var(--s3));
  display: flex;
  align-items: center;
  gap: var(--s2);
  background: linear-gradient(rgba(0, 0, 0, .62), transparent);
}

.vw-title {
  flex: 1;
  min-width: 0;
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}

.vw-icon {
  width: var(--tap);
  height: var(--tap);
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 24, 32, .6);
  color: #fff;
  display: grid;
  place-items: center;
}

.vw-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.vw-icon:active { opacity: .7; }
.vw-icon.is-on { background: var(--brand); }

.vw-bottom {
  bottom: 0;
  padding: var(--s3) calc(var(--safe-r) + var(--s3))
           calc(var(--safe-b) + var(--s3)) calc(var(--safe-l) + var(--s3));
  background: linear-gradient(transparent, rgba(0, 0, 0, .72));
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.vw-meta {
  color: #fff;
  font-size: 12.5px;
  line-height: 1.7;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}

.vw-meta .vw-dim { color: rgba(255, 255, 255, .72); font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* جعبه اطلاعات: کارت شیشه‌ای با ردیف‌های برچسب/مقدار — نه متن روی هم */
.vw-info {
  max-height: 42dvh;
  overflow-y: auto;
  padding: var(--s3);
  border-radius: var(--r-md);
  background: rgba(16, 20, 28, .82);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, .16);
  color: #fff;
}

.vw-row {
  display: flex;
  gap: var(--s3);
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
  font-size: 12.5px;
}

.vw-row:last-child { border-bottom: 0; }

.vw-row b {
  flex: 0 0 84px;
  font-weight: 500;
  font-size: 11.5px;
  color: rgba(255, 255, 255, .62);
}

.vw-row span {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

.vw-actions {
  display: flex;
  gap: var(--s2);
  align-items: stretch;
  overflow-x: auto;
  scrollbar-width: none;
}

.vw-actions::-webkit-scrollbar { display: none; }

.vw-btn {
  flex: 1;
  min-height: var(--tap);
  padding: 0 var(--s2);
  font-size: 13px;
  color: #fff;
  border-color: rgba(255, 255, 255, .35);
  background: rgba(20, 24, 32, .55);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border-radius: var(--r-md);
  border-width: 1px;
}

.vw-danger { color: #ff8098; border-color: rgba(255, 128, 152, .5); }
.vw-btn.is-on { background: var(--brand); border-color: transparent; color: var(--brand-ink); }

.vw-nav {
  width: var(--tap);
  min-height: var(--tap);
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: var(--r-md);
  background: rgba(20, 24, 32, .55);
  color: #fff;
  display: grid;
  place-items: center;
}

.vw-nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.vw-nav[disabled] { opacity: .3; }

/* لمس روی عکس، نوارها را قایم می‌کند تا کل کادر دیده شود */
.viewer.is-bare .vw-top, .viewer.is-bare .vw-bottom { opacity: 0; pointer-events: none; }

.g-card img, .g-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
}

.g-info { padding: var(--s2) var(--s3); flex: 1; }

.g-place { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.g-left { font-size: 11px; color: var(--warn); margin-top: var(--s1); font-variant-numeric: tabular-nums; }
.g-left.urgent { color: var(--danger); }

.g-actions { display: flex; gap: var(--s2); padding: 0 var(--s2) var(--s2); }
.g-actions .mini { flex: 1; }
.g-empty { padding: var(--s10); text-align: center; color: var(--muted); }

/* ===========================================================
   شیت
   =========================================================== */

.sheet-root { position: fixed; inset: 0; z-index: var(--z-sheet); }

.sheet-back {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}

.sheet-root.is-open .sheet-back { opacity: 1; }

.sheet {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  max-height: 88dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  will-change: transform;
  padding: var(--s2) calc(var(--safe-r) + var(--s4))
           calc(var(--safe-b) + var(--s5)) calc(var(--safe-l) + var(--s4));
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  transform: translateY(100%);
  transition: transform 220ms var(--ease);
}

.sheet-root.is-open .sheet { transform: translateY(0); }
.sheet.is-dragging { transition: none; }
.sheet-grip-zone { touch-action: none; }

.sheet-grip {
  width: 42px;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--line);
  margin: var(--s2) auto var(--s3);
}

.sheet-title { font-size: 16px; margin: 0 0 var(--s3); }

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  min-height: var(--tap);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

.seg { display: flex; gap: var(--s1); flex-wrap: wrap; justify-content: flex-end; }

.segbtn {
  min-height: 34px;
  padding: 0 var(--s3);
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.segbtn.is-on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 700; }

.switch {
  width: 48px;
  height: 28px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface-2);
  position: relative;
  flex: 0 0 auto;
  transition: background var(--dur) var(--ease);
}

.switch i {
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: inset-inline-start 160ms var(--ease);
}

.switch.is-on { background: var(--brand); border-color: var(--brand); }
.switch.is-on i { inset-inline-start: calc(100% - 24px); }

.set-input { max-width: 200px; }

.howto { padding-inline-start: var(--s5); font-size: 13.5px; line-height: 2; }
.howto-note { font-size: 12.5px; color: var(--muted); }

/* ===========================================================
   توست
   =========================================================== */

.toast {
  position: fixed;
  z-index: var(--z-toast);
  bottom: calc(var(--safe-b) + 110px);
  left: 50%;
  transform: translateX(-50%);
  max-width: min(88vw, 420px);
  padding: var(--s3) var(--s5);
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  font-size: 13.5px;
  text-align: center;
}

/* ===========================================================
   حالت افقی — نوار پایین به ستون کناری تبدیل می‌شود
   =========================================================== */

@media (orientation: landscape) and (max-height: 560px) {
  :root { --bar: 64px; }

  .tabbar {
    inset: 0 auto 0 0;
    width: calc(var(--bar) + var(--safe-l));
    height: auto;
    grid-template-columns: 1fr;
    grid-template-rows: repeat(5, 1fr);
    padding: var(--safe-t) 0 var(--safe-b) var(--safe-l);
    border-top: 0;
    border-inline-end: 1px solid var(--line);
  }

  .tab { inset: 0 0 0 calc(var(--bar) + var(--safe-l)); }

  /* کنترل‌های دوربین ستونی کنار قاب */
  .controls {
    position: absolute;
    inset-inline-end: 0;
    top: 0;
    bottom: 0;
    width: 92px;
    flex-direction: column-reverse;
    justify-content: center;
    gap: var(--s5);
    padding: var(--s3) var(--s2);
    background: linear-gradient(to left, rgba(0, 0, 0, .45), transparent);
  }

  .mode-row {
    position: absolute;
    inset-inline-end: 92px;
    top: 50%;
    transform: translateY(-50%);
    flex-direction: column;
    gap: var(--s2);
    padding: 0;
  }

  .mode.is-on { border-bottom-color: transparent; border-inline-start: 2px solid var(--brand); }

  .zoom-row {
    position: absolute;
    inset-inline-end: 150px;
    bottom: var(--s4);
    padding: 0;
  }

  .live-stamp {
    position: absolute;
    inset-inline-start: calc(var(--safe-l) + var(--s3));
    bottom: var(--s3);
    max-width: min(44%, 320px);
    margin: 0;
  }

  .ls-map { width: 46px; height: 46px; }

  .g-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .sheet { max-height: 92dvh; }
  .toast { bottom: calc(var(--safe-b) + var(--s5)); }
  .gate-card, .login-card { max-width: 460px; }
}

/* صفحه بزرگ: اپ در ستون میانی می‌ماند (اپ موبایلی است) */
@media (min-width: 760px) and (orientation: portrait) {
  #app, .view { max-width: 560px; margin-inline: auto; border-inline: 1px solid var(--line); }
}
