*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); font-size: 1rem; line-height: var(--lh);
  color: var(--text); background: var(--bg); min-height: 100vh;
  display: flex; flex-direction: column; -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
img, svg, video { max-width: 100%; display: block; }
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.5; margin: 0 0 .5em; font-weight: 700; color: var(--text); }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; } h4 { font-size: 1rem; }
p { margin: 0 0 .85em; }
small { font-size: .86rem; }
ul, ol { margin: 0; padding-inline-start: 1.4em; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--brand-300); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.icon { flex: none; }

.container { width: 100%; max-width: 1240px; margin-inline: auto; padding-inline: max(var(--gutter), env(safe-area-inset-right)) max(var(--gutter), env(safe-area-inset-left)); }
.container-narrow { max-width: 720px; }
main { flex: 1; padding-block: 20px 32px; }
.stack > * + * { margin-top: var(--gap, 14px); }
.row { display: flex; align-items: center; gap: var(--gap, 10px); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 14px; } .mt-3 { margin-top: 20px; }
.mb-0 { margin-bottom: 0 !important; } .mb-2 { margin-bottom: 14px; }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: left; }

/* ───────── هدر ───────── */
.site-header {
  background: linear-gradient(180deg, var(--brand-600), var(--brand-700));
  color: #fff; position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 10px rgba(42,31,92,.25);
}
.site-header { padding-top: env(safe-area-inset-top); }
.site-header .inner { display: flex; align-items: center; gap: 16px; min-height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; }
.main-nav { display: flex; gap: 4px; margin-inline-start: 6px; }
.main-nav a {
  color: rgba(255,255,255,.88); padding: 6px 12px; border-radius: 9px; font-weight: 500; font-size: .95rem;
  display: inline-flex; align-items: center; gap: 6px;
}
.main-nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; color: #fff; }
.main-nav a.active { background: rgba(255,255,255,.2); color: #fff; }
.header-end { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.user-chip {
  display: flex; align-items: center; gap: 8px; color: #fff; padding: 4px 5px 4px 12px; min-height: var(--touch);
  background: rgba(255,255,255,.14); border-radius: 999px;
}
.user-chip:hover { background: rgba(255,255,255,.22); text-decoration: none; }
.user-chip .who { display: flex; flex-direction: column; line-height: 1.35; }
.user-chip .who strong { font-size: .92rem; font-weight: 600; }
.user-chip .who span { font-size: .86rem; opacity: .85; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand-100); color: var(--brand-800);
  display: grid; place-items: center; font-weight: 700; overflow: hidden; flex: none; object-fit: cover;
}
.avatar-lg { width: 80px; height: 80px; font-size: 1.8rem; }
.avatar-sm { width: 30px; height: 30px; font-size: .9rem; }
.rank-pill {
  display: inline-flex; align-items: center; gap: 4px; font-size: .86rem; font-weight: 600;
  padding: 1px 9px; border-radius: 999px; background: var(--brand-100); color: var(--brand-800);
}
.rank-t1 { background: #E3F4EA; color: #146B3A; } .rank-t2 { background: #E1ECFB; color: #1B4CA8; }
.rank-t3 { background: #EEE3FB; color: #5A2BCB; } .rank-t4 { background: #FFEBD6; color: #9A4B00; }
.rank-t5 { background: #FFE0E6; color: #A31F3C; } .rank-t6 { background: #FFF1B8; color: #7A5A00; }
.rank-t7 { background: linear-gradient(90deg,#FFD66B,#FF9F6B); color: #5B2E00; }

/* ───────── دکمه‌ها ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 600;
  padding: 7px 18px; border-radius: 10px; border: 1.5px solid transparent; line-height: 1.5;
  background: var(--surface); color: var(--text); text-decoration: none !important; min-height: var(--ctl-h);
  transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-600); color: #fff; box-shadow: 0 2px 8px rgba(109,59,234,.35); }
.btn-primary:hover { background: var(--brand-700); }
.btn-soft { background: var(--brand-50); color: var(--brand-800); border-color: var(--brand-100); }
.btn-soft:hover { background: var(--brand-100); }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--brand-300); }
.btn-light { background: #fff; color: var(--brand-800); }
.btn-light:hover { background: var(--brand-50); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-lg { min-height: var(--ctl-h-lg); padding: 9px 24px; font-size: 1rem; }
.btn-sm { min-height: var(--ctl-h-sm); padding: 3px 12px; font-size: .9rem; border-radius: 9px; }
.btn-block { display: flex; width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .55; cursor: not-allowed; box-shadow: none; pointer-events: none; }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 50%;
  background: transparent; border: 0; color: inherit;
}
.icon-btn:hover { background: rgba(127,127,160,.16); }

/* ───────── فرم ───────── */
.field { margin-bottom: 14px; }
.label { display: block; font-weight: 600; margin-bottom: 5px; font-size: .95rem; }
.input, .textarea, select.input {
  width: 100%; padding: 8px 12px; font: inherit; color: var(--text); background: #fff;
  border: 1.5px solid var(--border-strong); border-radius: 10px; min-height: 42px;
}
.input:focus, .textarea:focus { border-color: var(--brand-500); outline: 3px solid var(--brand-100); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
.help { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.field-error, .errorlist { color: var(--bad); font-size: .9rem; margin: 5px 0 0; padding: 0; list-style: none; }
.input.is-error { border-color: var(--bad); }
.checkbox { display: flex; align-items: center; gap: 10px; cursor: pointer; min-height: 32px; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--brand-600); }
input[type="file"].input { padding: 8px; }
.otp-input { font-size: 1.6rem; letter-spacing: .5em; text-align: center; direction: ltr; font-weight: 700; }
.phone-input { direction: ltr; text-align: left; font-size: 1.1rem; letter-spacing: .05em; }

/* ───────── کارت و برچسب ───────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 16px; }
.card-title { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 12px; }
.card-title .icon { color: var(--brand-600); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 11px; border-radius: 999px;
  font-size: .86rem; background: var(--brand-50); color: var(--brand-800); font-weight: 500;
}
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 8px; font-size: .86rem; font-weight: 600; }
.badge-free { background: var(--ok-bg); color: var(--ok); }
.badge-paid, .badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }

.progress { height: 8px; background: var(--brand-100); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-500), var(--brand-600)); border-radius: 99px; transition: width .4s; }
.progress-ok > span { background: linear-gradient(90deg, #26b36a, var(--ok)); }

.notice { padding: 11px 14px; border-radius: var(--radius-sm); display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; }
.notice-info { background: var(--info-bg); color: #173C8A; }
.notice-warn { background: var(--warn-bg); color: #6E4600; }
.notice-ok { background: var(--ok-bg); color: #0C6334; }
.notice-bad { background: var(--bad-bg); color: #8A1730; }

/* ───────── پیام‌ها ───────── */
.messages { position: fixed; top: calc(var(--header-h) + 12px + env(safe-area-inset-top)); inset-inline: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding-inline: 16px; }
.toast {
  pointer-events: auto; background: #fff; border-radius: 10px; padding: 9px 14px; box-shadow: var(--shadow-lg);
  border-inline-start: 4px solid var(--brand-600); max-width: 520px; display: flex; gap: 10px; align-items: center; font-size: .95rem;
  animation: toast-in .25s ease-out;
}
.toast-success { border-inline-start-color: var(--ok); } .toast-error { border-inline-start-color: var(--bad); }
.toast button { background: none; border: 0; color: var(--muted); padding: 0; min-width: 32px; min-height: 32px; display: grid; place-items: center; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* ───────── ناوبری پایین (موبایل) ───────── */
.bottom-nav { display: none; }
.site-footer { padding: 18px 0 22px; color: var(--muted); font-size: .9rem; }
/* The assistant's round button sits fixed at the bottom-left: keep the seal and the text on the right, away from it. */
.footer-row { display: flex; align-items: center; justify-content: flex-start; gap: 24px; flex-wrap: wrap; }
.footer-links { display: flex; gap: 16px; margin-top: 4px; }
.footer-seal { flex: none; line-height: 0; order: -1; }
.footer-seal img { display: block; max-height: 72px; width: auto; }
/* Zibal's trust badge: Zibal's own script draws it, 120px high (the size Zibal gives) */
#zibal img { height: 120px !important; max-height: none; }
@media (max-width: 640px) { .footer-row { justify-content: center; text-align: center; } .footer-links { justify-content: center; } .footer-seal { order: 0; } }

/* ───────── صفحه‌بندی ───────── */
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.pager a, .pager span { min-width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; background: #fff; border: 1px solid var(--border); padding-inline: 10px; }
.pager .current { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }

/* ───────── موبایل و تبلت (تا ۹۰۰ پیکسل) ─────────
   قاعده‌ها: نوشته‌ی پایه ۱۴ پیکسل، هدف لمسی دست‌کم ۴۴ پیکسل، حاشیه‌ی کناری ۱۶، نوار پایین با جای امن، بدون اسکرول افقی. */
:root { --bottom-nav-h: 58px; }
@media (max-width: 900px) {
  :root { --header-h: 54px; --gutter: 16px; }
  body { padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); }
  .main-nav { display: none; }
  .user-chip .who span { display: none; }
  .bottom-nav {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; inset-inline: 0; bottom: 0; z-index: 60;
    background: #fff; border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(42,31,92,.08);
    padding-bottom: env(safe-area-inset-bottom); padding-inline: env(safe-area-inset-right) env(safe-area-inset-left);
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    min-height: var(--bottom-nav-h); padding: 6px 2px 5px; font-size: .86rem; line-height: 1.4; color: var(--muted);
  }
  .bottom-nav a .icon { width: 21px; height: 21px; }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav a.active { color: var(--brand-700); font-weight: 700; }
  main { padding-block: 14px 24px; }
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.12rem; }
}

/* صفحه‌ی لمسی: هر چیزی که با انگشت زده می‌شود دست‌کم ۴۴ پیکسل؛ بدون تأخیر دوزدن؛ بدون رنگ خاکستری هنگام لمس */
@media (pointer: coarse) {
  a, button, summary, label, input, select, textarea, [role="button"] { touch-action: manipulation; }
  a, button, summary { -webkit-tap-highlight-color: transparent; }
  .btn, .btn-sm { min-height: var(--touch); }
  .btn-sm { padding-block: 6px; }
  .icon-btn { width: var(--touch); height: var(--touch); }
  .input, select.input { min-height: var(--touch); }
  .pager a, .pager span { min-width: var(--touch); height: var(--touch); }
  .menu-pop a, .menu-pop button { min-height: var(--touch); }
  .checkbox { min-height: var(--touch); }
  .checkbox input { width: 22px; height: 22px; }
  /* a link that stands alone (not inside a sentence) is a button for a finger: give it the same height */
  .brand, .section-head > a, .card-title a, .footer-links a, .row-between > a.small { display: inline-flex; align-items: center; min-height: var(--touch); }
  .user-chip { min-width: var(--touch); justify-content: center; }
}

/* منوی حساب */
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; inset-inline-end: 0; top: calc(100% + 8px); min-width: 200px; max-width: calc(100vw - 2 * var(--gutter)); background: #fff; border-radius: 12px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border); padding: 5px; z-index: 80; color: var(--text);
}
.menu-pop a, .menu-pop button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; border-radius: 9px; color: var(--text);
  background: none; border: 0; text-align: start; font: inherit; font-size: .95rem;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--brand-50); text-decoration: none; }
.menu-pop .icon { color: var(--brand-600); }
.menu-pop form { margin: 0; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
