/* توکن‌های رنگ: تنها جایی که رنگ تعریف می‌شود. تغییر سبز اصلی = تغییر --brand و --bar */
:root {
  --brand: #009865; --bar: #009865;
  --bg: #f2f6f3; --card: #fff; --text: #14231a; --muted: #67776d; --line: #e0e8e2;
  --r: 18px; --nav-h: 64px; --t: .16s; --ease: cubic-bezier(.2, .8, .2, 1);
  --font: Vazirmatn, system-ui, 'Noto Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  color-scheme: light;
}
:root[data-theme=dark] {
  --brand: #1fc58b; --bar: #0b3d2c;
  --bg: #0e1511; --card: #18211c; --text: #e8f0ea; --muted: #8fa196; --line: #26322b;
  color-scheme: dark;
}
/* رنگ هر آیکون گرد */
.tone-1 { --c: #10b982 } .tone-2 { --c: #6366f1 } .tone-3 { --c: #f59e0b } .tone-4 { --c: #0891b2 }
.tone-5 { --c: #dc2625 } .tone-6 { --c: #8b5cf6 } .tone-7 { --c: #f43f5e } .tone-8 { --c: #e6b00a }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.7 var(--font); overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1, h2, p { margin: 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ico { display: inline-flex; } .ico svg { width: 24px; height: 24px; }

/* پوسته: هدر ثابت، محتوای اسکرول‌شونده، ناوبری پایین */
#app { display: flex; flex-direction: column; height: 100dvh; max-width: 900px; margin: 0 auto; background: var(--bg); }
.header-slot { background: var(--bar); transition: background var(--t); }
.header { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #fff;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 16px; }
.header h1 { font-size: 19px; font-weight: 700; line-height: 1.4; }
.header p { font-size: 13px; opacity: .85; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: rgb(255 255 255 / .16); transition: transform var(--t) var(--ease); }
.icon-btn:active { transform: scale(.9); }

.screen { flex: 1; overflow-y: auto; padding: 20px 16px 24px; }
.screen.enter { animation: enter .2s var(--ease); }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }

/* شبکه‌ی آیکون‌های گرد */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 22px 8px; }
.tile { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.circle { width: 62px; height: 62px; border-radius: 20px; display: grid; place-items: center;
  color: #fff; background: var(--c); transition: transform var(--t) var(--ease); }
.tile:active .circle { transform: scale(.9); }
.tile-label { font-size: 13px; text-align: center; line-height: 1.4; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 16px; }
.row { display: flex; justify-content: space-between; padding: 12px 0; }
.empty { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 56px 24px; }
.empty .circle { width: 72px; height: 72px; margin-bottom: 8px; }
.empty p { color: var(--muted); max-width: 32ch; }

/* ناوبری پایین */
.nav { display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); }
.nav-item { flex: 1; min-height: calc(var(--nav-h) - 12px); display: grid; justify-items: center; align-content: center; gap: 2px;
  font-size: 12px; color: var(--muted); border-radius: 14px; transition: color var(--t), background var(--t); }
.nav-item.on { color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); font-weight: 700; }
.nav-item:active .ico { transform: scale(.88); } .nav-item .ico { transition: transform var(--t) var(--ease); }

.toast { position: fixed; inset-inline: 16px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); margin-inline: auto; width: fit-content; max-width: calc(100% - 32px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px; animation: enter .2s var(--ease); }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* فرم، دکمه، فهرست، برگه‌ی پایین و کلید سه‌حالته (فاز ۳) */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field span, .sheet-section small { font-size: 13px; color: var(--muted); }
.field input, .search { width: 100%; height: 48px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--text); padding: 0 14px; font: inherit; }
.field input:focus, .search:focus { outline: 2px solid var(--brand); border-color: transparent; }
.btn { width: 100%; height: 50px; border-radius: 14px; background: var(--brand); color: #fff; font-weight: 700; transition: transform var(--t) var(--ease), opacity var(--t); }
.btn:active { transform: scale(.98); } .btn:disabled { opacity: .6; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: #dc2625; border: 1px solid var(--line); }
.login { min-height: 100dvh; display: grid; align-content: center; gap: 6px; padding: 24px; max-width: 400px; margin: 0 auto; }
.login h1 { text-align: center; font-size: 20px; margin-bottom: 12px; }
.login-logo { width: 112px; height: 112px; border-radius: 28px; margin: 0 auto 8px; display: block; }
.error { color: #dc2625; min-height: 1.4em; font-size: 13px; margin: 0 0 8px; }
.notice { background: color-mix(in srgb, var(--brand) 12%, var(--card)); border-radius: 12px; padding: 10px 14px; font-size: 13px; margin-bottom: 10px; }
.notice.warn { background: color-mix(in srgb, #f59e0b 18%, var(--card)); }
.stack { display: grid; gap: 14px; } .stack .card { padding: 14px 16px; } .card h2 { font-size: 15px; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 13px; text-align: center; padding: 12px; } .hint.error { color: #dc2625; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; background: color-mix(in srgb, var(--brand) 18%, var(--card)); color: var(--brand); }
.icon-btn .avatar { width: 100%; height: 100%; background: none; color: #fff; }
.row-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row-item.wrap { flex-wrap: wrap; } .row-item .seg, .row-wide { width: 100%; flex: 0 0 100%; }
.row-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; text-align: start; }
.row-text { display: grid; min-width: 0; } .row-text small { color: var(--muted); }
.contact-search { display: grid; gap: 8px; }
.seg { display: flex; gap: 3px; padding: 3px; border-radius: 12px; background: color-mix(in srgb, var(--text) 7%, var(--card)); }
.seg button { flex: 1; padding: 7px 4px; border-radius: 9px; font-size: 13px; transition: background var(--t), color var(--t); }
.seg .on { background: var(--card); color: var(--brand); font-weight: 700; box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.sheet-back { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center; background: rgb(0 0 0 / .45); animation: fade .16s; }
.sheet { width: 100%; max-width: 900px; max-height: 85dvh; overflow: auto; display: grid; gap: 12px; align-content: start; background: var(--bg); border-radius: 24px 24px 0 0; padding: 22px 16px calc(env(safe-area-inset-bottom) + 20px); animation: rise .22s var(--ease); }
.sheet-section { display: grid; gap: 6px; }
pre.out { direction: ltr; text-align: left; margin: 0; max-height: 260px; overflow: auto; padding: 10px; border-radius: 12px; background: var(--bg); font: 12px/1.5 ui-monospace, monospace; white-space: pre-wrap; word-break: break-all; }
@keyframes fade { from { opacity: 0; } } @keyframes rise { from { transform: translateY(40px); } }
.header-actions { display: flex; gap: 8px; flex: none; }
