/* ===== فونت (محلی؛ بدون نیاز به اینترنت خارجی) ===== */
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --accent: #c2255c;
  --accent-ink: #a3174b;
  --accent-soft: #fdecf2;
  --danger: #b42318;
  --ok: #1b7a33;
  --bg: #f3f3f5;
  --card: #fff;
  --ink: #1f2328;
  --muted: #555b66;
  --line: #e3e4e8;
  --field: #d9dbe0;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Vazirmatn", Tahoma, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.7;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
h1, h2, h3, p { margin: 0; }

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg); position: relative; }
.page { flex: 1; padding: 12px 12px 88px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ===== هدر ===== */
.topbar { background: var(--card); padding: 12px 14px; box-shadow: 0 1px 0 var(--line); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 20px; font-weight: 800; }
.topbar-row { display: flex; align-items: center; gap: 8px; }
.topbar .back { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; margin: -6px -8px -6px 0; }

.search { display: flex; gap: 8px; flex: 1; }
.search input[type="search"] { flex: 1; min-width: 0; height: 44px; border: 1px solid var(--field); border-radius: 12px; padding: 0 14px; background: #fff; }
.btn-outline { height: 44px; border: 1px solid var(--field); background: #fff; border-radius: 12px; padding: 0 14px; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; font-size: 13px; }
.chip span { font-size: 18px; line-height: 1; }

/* ===== کارت کاربر ===== */
.cards { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border-radius: 20px; padding: 10px; }
.card-photo { position: relative; border-radius: 14px; overflow: hidden; background: #f5efe8; aspect-ratio: 4 / 3; }
.card-photo img { width: 100%; height: 100%; object-fit: cover; }
.dot { position: absolute; top: 12px; right: 12px; width: 13px; height: 13px; border-radius: 50%; background: #2f9e44; border: 2px solid #fff; }
.gem { position: absolute; top: 10px; left: 10px; background: rgba(255,255,255,.92); color: var(--accent-ink); font-size: 12px; font-weight: 700; padding: 1px 10px; border-radius: 10px; }
.card-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; padding: 0 4px; gap: 8px; }
.card-row h2 { font-size: 18px; font-weight: 800; }
.card-row p { font-size: 13px; color: var(--muted); min-height: 22px; }
.card-actions { display: flex; align-items: center; }
.icon-btn { width: 44px; height: 44px; border: 0; background: none; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); border-radius: 50%; }
.icon-btn:active { background: var(--accent-soft); }
.icon-btn.danger { color: var(--danger); }
.card-actions form { margin: 0; }

.empty { text-align: center; color: var(--muted); padding: 56px 20px; background: var(--card); border-radius: var(--radius); }
.pager { display: flex; justify-content: center; gap: 10px; padding: 14px 0; }
.pager a { min-height: 44px; display: inline-flex; align-items: center; padding: 0 18px; background: var(--card); border: 1px solid var(--field); border-radius: 12px; font-weight: 600; }

/* ===== فرم‌ها ===== */
.panel { background: var(--card); border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.field label, .field .lb { display: block; font-size: 13px; font-weight: 600; color: #3a3f47; margin-bottom: 6px; }
.fld, .sel, textarea.fld { width: 100%; height: 48px; border: 1px solid var(--field); border-radius: 12px; padding: 0 14px; background: #fff; }
textarea.fld { height: 80px; padding: 10px 14px; resize: none; }
.fld:focus, .sel:focus, textarea:focus, .search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }
.err { color: var(--danger); font-size: 13px; margin-top: 4px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.8; }
.btn { height: 52px; border: 0; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 800; font-size: 16px; width: 100%; display: inline-flex; align-items: center; justify-content: center; }
.btn.danger { background: var(--danger); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--field); font-weight: 600; }
.btn.small { height: 40px; font-size: 14px; width: auto; padding: 0 16px; }

.seg { display: flex; gap: 12px; }
.seg label { flex: 1; margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: flex; align-items: center; justify-content: center; height: 48px; border-radius: 12px; border: 1px solid var(--field); background: #fff; font-weight: 600; color: #3a3f47; margin: 0; }
.seg input:checked + span { border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.hero { padding: 36px 8px 18px; }
.hero h1 { font-size: 26px; font-weight: 800; color: var(--accent); }
.hero p { margin-top: 8px; color: var(--muted); font-size: 14px; line-height: 1.9; }

/* فیلتر */
.fcard { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.fcard .lb { display: block; color: var(--accent-ink); font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.range-val { font-weight: 800; margin-bottom: 6px; }
/* اسلایدر دوسره‌ی بازه سن */
.dual { position: relative; height: 36px; margin: 4px 0 2px; }
.dual-track, .dual-fill { position: absolute; top: 16px; height: 4px; border-radius: 2px; }
.dual-track { right: 11px; left: 11px; background: #d9dbe0; }
.dual-fill { background: var(--accent); right: 11px; left: 11px; }
.dual input[type="range"] { position: absolute; inset: 0; width: 100%; height: 36px; margin: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.dual input[type="range"]::-webkit-slider-runnable-track { background: transparent; height: 36px; }
.dual input[type="range"]::-moz-range-track { background: transparent; }
.dual input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; pointer-events: auto; width: 22px; height: 22px; margin-top: 7px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.25); cursor: pointer; }
.dual input[type="range"]::-moz-range-thumb { pointer-events: auto; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); cursor: pointer; }
.dual input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--ink); outline-offset: 2px; }
.bottom-actions { position: sticky; bottom: 0; background: var(--card); padding: 12px 14px calc(14px + env(safe-area-inset-bottom)); display: flex; gap: 10px; box-shadow: 0 -1px 0 var(--line); margin-top: auto; }
.bottom-actions .btn { flex: 1; }
.bottom-actions .btn.ghost { flex: 0 0 auto; width: auto; padding: 0 18px; }

/* ===== لیست گفتگوها ===== */
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.conv { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #eee; min-height: 72px; }
.conv:last-child { border-bottom: 0; }
.conv .av { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: #f5efe8; flex: none; }
.conv .mid { flex: 1; min-width: 0; }
.conv .name { font-weight: 700; }
.conv .prev { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 12px; color: var(--muted); }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; line-height: 20px; text-align: center; font-weight: 700; }

/* ===== نوار پایین ===== */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; max-width: 480px; margin: 0 auto; background: var(--card); box-shadow: 0 -1px 0 var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tab { flex: 1; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; color: var(--muted); position: relative; }
.tab.on { color: var(--accent-ink); font-weight: 700; }
.tab .badge { position: absolute; top: 6px; right: calc(50% - 24px); }

/* ===== پروفایل ===== */
.me-head { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.me-head img { width: 76px; height: 76px; border-radius: 50%; object-fit: cover; background: #f5efe8; }
.me-head h2 { font-size: 18px; font-weight: 800; }
.blocked-row { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }

/* ===== اتاق چت ===== */
.room { height: 100vh; height: 100dvh; display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; background: var(--bg); }
.room-top { background: var(--card); display: flex; align-items: center; gap: 6px; padding: 8px 6px; box-shadow: 0 1px 0 var(--line); position: relative; }
.room-top .who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.room-top .who img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: #f5efe8; }
.room-top .nm { font-weight: 800; font-size: 15px; line-height: 1.3; }
.room-top .st { font-size: 12px; color: var(--muted); }
.room-top .st.on { color: var(--ok); }
.link-danger { min-height: 44px; display: inline-flex; align-items: center; padding: 0 10px; color: var(--danger); font-weight: 600; font-size: 13px; }
details.menu { position: relative; }
details.menu summary { list-style: none; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; left: 0; top: 46px; background: #fff; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.18); min-width: 180px; padding: 6px; z-index: 20; }
.menu-pop button, .menu-pop a { display: flex; width: 100%; min-height: 44px; align-items: center; padding: 0 12px; border: 0; background: none; text-align: right; border-radius: 8px; font-weight: 600; }
.menu-pop button:hover, .menu-pop a:hover { background: var(--bg); }

.msgs { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 8px; -webkit-overflow-scrolling: touch; }
.msg { max-width: 80%; display: flex; flex-direction: column; gap: 2px; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; }
.bubble { padding: 9px 14px; border-radius: 16px; line-height: 1.8; word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.in .bubble { background: #fff; border-bottom-left-radius: 4px; }
.msg.out .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble.media { padding: 4px; white-space: normal; }
.bubble img { border-radius: 12px; max-height: 280px; width: auto; object-fit: cover; }
.msg .time { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 4px; padding: 0 4px; }
.msg.out .time { justify-content: flex-start; }
.msg .flag { border: 0; background: none; color: var(--muted); width: 32px; height: 28px; display: inline-flex; align-items: center; justify-content: center; }
.voice { display: flex; align-items: center; gap: 10px; min-width: 190px; padding: 6px 8px; }
.voice .play { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); display: flex; align-items: center; justify-content: center; flex: none; }
.msg.out .voice .play { background: #fff; color: var(--accent); }
.msg.in .voice .play { color: #fff; }
.voice .bars { flex: 1; height: 24px; background: repeating-linear-gradient(90deg, currentColor 0 3px, transparent 3px 7px); opacity: .35; -webkit-mask: linear-gradient(#000 0 0); border-radius: 2px; }
.voice .dur { font-size: 12px; opacity: .85; }
.sys { align-self: center; font-size: 12px; color: var(--muted); background: #e9e9ee; border-radius: 10px; padding: 2px 12px; }

.composer { background: var(--card); padding: 8px 8px calc(10px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 4px; box-shadow: 0 -1px 0 var(--line); }
.composer .txt { flex: 1; min-width: 0; height: 44px; border: 1px solid var(--field); border-radius: 22px; padding: 0 16px; background: #f7f7f8; }
.composer .send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; flex: none; }
.composer .send:disabled { opacity: .5; }
.composer.recording .txt, .composer.recording #pick-img { display: none; }
.rec-bar { display: none; flex: 1; align-items: center; gap: 10px; padding: 0 8px; font-weight: 700; color: var(--danger); }
.composer.recording .rec-bar { display: flex; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
#mic.active { color: var(--danger); }
.blocked-note { background: var(--card); padding: 16px; text-align: center; color: var(--muted); box-shadow: 0 -1px 0 var(--line); }

/* ===== گزارش ===== */
.sheet-wrap { min-height: 100vh; min-height: 100dvh; background: #6b6d74; display: flex; flex-direction: column; justify-content: flex-end; max-width: 480px; margin: 0 auto; }
.sheet { background: #fff; border-radius: 24px 24px 0 0; padding: 20px 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--field); align-self: center; }
.sheet h1 { font-size: 18px; font-weight: 800; margin-top: 8px; }
.opt { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; }
.opt input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
.quote { background: var(--bg); border-radius: 12px; padding: 8px 12px; font-size: 13px; color: var(--muted); }

/* ===== پیام‌های سیستم ===== */
.toasts { position: fixed; top: 12px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 50; pointer-events: none; padding: 0 12px; }
.toast { pointer-events: auto; background: #1f2328; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 440px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.err { background: var(--danger); }

.center-note { text-align: center; padding: 80px 24px; color: var(--muted); }
.center-note h1 { color: var(--ink); font-size: 20px; margin-bottom: 8px; }

.composer .txt:focus { outline: none; border-color: var(--accent); background: #fff; }
