/* Harfak design system — calm, one accent (violet), RTL-first. */
@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/vazirmatn.woff2") format("woff2-variations"), url("/fonts/vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #FAF8F5;
  --surface: #FFFFFF;
  --surface-2: #F4F1EC;
  --ink: #17112B;
  --muted: #6B6580;
  --line: #ECE7E1;
  --accent: #6B3BFF;
  --accent-press: #5A2EE6;
  --accent-ink: #FFFFFF;
  --accent-soft: #EFE9FF;
  --accent-text: #5527E0;
  --ok: #17754A;
  --ok-soft: #E4F4EC;
  --bad: #B42318;
  --bad-soft: #FDECEA;
  --lime: #D4FF3A;
  --shadow: 0 1px 2px rgba(23, 17, 43, .04), 0 8px 24px rgba(23, 17, 43, .06);
  --r-card: 22px;
  --r-ctl: 16px;
  --gutter: 18px;
  --maxw: 560px;
  --nav-h: 68px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0F0C19;
    --surface: #1A1627;
    --surface-2: #231E33;
    --ink: #F2EFF9;
    --muted: #A49DB9;
    --line: #2B2540;
    --accent: #8B66FF;
    --accent-press: #7A52FF;
    --accent-ink: #FFFFFF;
    --accent-soft: #261E45;
    --accent-text: #B9A3FF;
    --ok: #4CC38A;
    --ok-soft: #14291F;
    --bad: #FF8A80;
    --bad-soft: #3A1A1A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Layout */
.shell { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.page { padding-top: 8px; padding-bottom: calc(var(--nav-h) + 96px + env(safe-area-inset-bottom)); }
.page--plain { padding-bottom: 48px; }
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); }
.topbar .shell { display: flex; align-items: center; gap: 12px; height: 60px; }
.topbar__title { font-weight: 700; font-size: 17px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 900; font-size: 22px; letter-spacing: -.3px; }
.logo:hover { text-decoration: none; }
.logo svg { width: 30px; height: 30px; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 24px; }
.row { display: flex; align-items: center; gap: 12px; }
.row--between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 14px; line-height: 1.7; }
.tiny { font-size: 12.5px; line-height: 1.6; }
.h1 { font-size: 28px; line-height: 1.45; font-weight: 800; margin: 0; letter-spacing: -.3px; }
.h2 { font-size: 20px; line-height: 1.5; font-weight: 800; margin: 0; }
.h3 { font-size: 17px; line-height: 1.6; font-weight: 700; margin: 0; }
.lead { font-size: 17px; color: var(--muted); margin: 0; }
.section-title { font-size: 14px; font-weight: 700; color: var(--muted); margin: 28px 4px 10px; }

/* Cards */
.card { background: var(--surface); border-radius: var(--r-card); padding: 20px; box-shadow: var(--shadow); }
.card--flat { box-shadow: none; border: 1px solid var(--line); }
.card--soft { background: var(--accent-soft); box-shadow: none; }
.hero { background: var(--surface); border-radius: 28px; padding: 28px 22px; box-shadow: var(--shadow); text-align: center; }
.hero__big { font-size: 40px; font-weight: 900; line-height: 1.3; letter-spacing: -.5px; }

/* List rows */
.list { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); overflow: hidden; }
.list__row { display: flex; align-items: center; gap: 14px; padding: 14px 18px; min-height: 64px; color: var(--ink); position: relative; }
.list__row + .list__row::before { content: ""; position: absolute; top: 0; inset-inline: 18px; border-top: 1px solid var(--line); }
a.list__row:hover { background: var(--surface-2); text-decoration: none; }
.list__title { font-weight: 600; line-height: 1.6; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.list__sub { font-size: 13px; color: var(--muted); }
.icon-bubble { width: 44px; height: 44px; flex: none; border-radius: 14px; background: var(--accent-soft); display: grid; place-items: center; font-size: 22px; }
.chev { width: 20px; height: 20px; color: var(--muted); flex: none; }
.dot-new { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 22px; border-radius: var(--r-ctl); border: 0; background: var(--surface-2); color: var(--ink); font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none; transition: transform .15s ease, background .15s ease; -webkit-tap-highlight-color: transparent; }
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-press); }
.btn--ghost { background: transparent; color: var(--accent-text); }
.btn--danger { background: var(--bad-soft); color: var(--bad); }
.btn--block { width: 100%; }
.btn--sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn[disabled], .btn.is-loading { opacity: .6; pointer-events: none; }
.btn .spinner { display: none; }
.btn.is-loading .spinner { display: inline-block; }
.spinner { width: 18px; height: 18px; border: 2.5px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { width: 48px; height: 48px; border-radius: 14px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

/* Bottom action bar: one primary action per screen */
.actionbar { position: fixed; inset-inline: 0; bottom: 0; z-index: 30; padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.actionbar .inner { max-width: var(--maxw); margin: 0 auto; }
.has-nav .actionbar { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: 12px; }

/* Bottom nav */
.nav { position: fixed; inset-inline: 0; bottom: 0; z-index: 31; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav ul { list-style: none; margin: 0 auto; padding: 0; max-width: var(--maxw); display: grid; grid-template-columns: repeat(3, 1fr); height: var(--nav-h); }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 100%; color: var(--muted); font-size: 12.5px; font-weight: 600; position: relative; }
.nav a:hover { text-decoration: none; color: var(--ink); }
.nav a[aria-current="page"] { color: var(--accent-text); }
.nav svg { width: 24px; height: 24px; }
.nav .badge { position: absolute; top: 8px; inset-inline-start: calc(50% + 6px); }

/* Forms */
.field { display: block; }
.field__label { display: block; font-weight: 600; font-size: 14px; margin: 0 4px 8px; }
.input, .textarea, .select { width: 100%; min-height: 54px; padding: 13px 16px; border-radius: var(--r-ctl); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font-size: 16px; line-height: 1.7; transition: border-color .15s; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); }
.input--ltr { direction: ltr; text-align: left; }
.input--big { font-size: 26px; font-weight: 800; letter-spacing: 6px; text-align: center; direction: ltr; }
.textarea { min-height: 150px; resize: vertical; }
.field__hint { font-size: 13px; color: var(--muted); margin: 6px 4px 0; }
.field__error { font-size: 13.5px; color: var(--bad); margin: 6px 4px 0; display: flex; gap: 6px; align-items: center; }
.counter { font-size: 12.5px; color: var(--muted); text-align: left; margin-top: 4px; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 4px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; margin-top: 3px; }
.switch { display: flex; align-items: center; gap: 12px; min-height: 56px; cursor: pointer; }
.switch input { appearance: none; width: 50px; height: 30px; border-radius: 99px; background: var(--line); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: inset-inline-start .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { inset-inline-start: 23px; }

/* Chips & segmented */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px; border-radius: 99px; background: var(--surface); border: 1.5px solid var(--line); color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip:hover { text-decoration: none; border-color: var(--accent); }
.chip[aria-pressed="true"], .chip.is-active, .chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 11.5px; font-weight: 800; }

/* Status pill: icon + word, never color alone */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 99px; font-size: 13px; font-weight: 700; background: var(--surface-2); color: var(--ink); }
.pill svg { width: 15px; height: 15px; }
.pill--ok { background: var(--ok-soft); color: var(--ok); }
.pill--bad { background: var(--bad-soft); color: var(--bad); }
.pill--neutral { background: var(--accent-soft); color: var(--accent-text); }

/* Message bubble */
.bubble { background: var(--surface); border-radius: 22px; padding: 20px 22px; box-shadow: var(--shadow); font-size: 18px; line-height: 1.95; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble--quote { font-size: 20px; font-weight: 600; }
.thread { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 12px 16px; border-radius: 20px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.85; }
.msg--them { background: var(--surface); align-self: flex-start; border-start-start-radius: 6px; box-shadow: var(--shadow); }
.msg--me { background: var(--accent); color: var(--accent-ink); align-self: flex-end; border-start-end-radius: 6px; }
.msg__meta { font-size: 11.5px; opacity: .75; margin-top: 4px; }

/* Template cards */
.tpl { display: block; background: var(--surface); border-radius: 20px; padding: 16px 18px; box-shadow: var(--shadow); color: var(--ink); line-height: 1.9; position: relative; }
.tpl:hover { text-decoration: none; outline: 2px solid var(--accent); }
.tpl__tone { font-size: 12px; color: var(--muted); font-weight: 600; }
.name-slot { background: var(--accent-soft); color: var(--accent-text); border-radius: 6px; padding: 0 6px; font-weight: 700; }
.topic-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.topic { background: var(--surface); border-radius: 20px; padding: 16px; box-shadow: var(--shadow); color: var(--ink); display: flex; flex-direction: column; gap: 6px; min-height: 104px; }
.topic:hover { text-decoration: none; outline: 2px solid var(--accent); }
.topic__emoji { font-size: 28px; line-height: 1; }
.topic__title { font-weight: 700; line-height: 1.5; }

/* Tabs */
.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 4px 0 14px; }
.tabs::-webkit-scrollbar { display: none; }

/* Snackbar */
.snackbar { position: fixed; inset-inline: var(--gutter); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 60; max-width: calc(var(--maxw) - 2 * var(--gutter)); margin: 0 auto; background: var(--ink); color: var(--bg); border-radius: 16px; padding: 12px 16px; display: flex; align-items: center; gap: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.25); animation: snack-in .2s ease; font-size: 15px; }
.no-nav .snackbar { bottom: calc(96px + env(safe-area-inset-bottom)); }
.snackbar--error { background: var(--bad); color: #fff; }
.snackbar form { margin: 0; }
.snackbar button { background: none; border: 0; color: var(--lime); font-weight: 800; cursor: pointer; padding: 8px; min-height: 40px; }
.snackbar--error button { color: #fff; }
@keyframes snack-in { from { opacity: 0; transform: translateY(12px); } }

/* Bottom sheet */
.sheet { border: 0; padding: 0; margin: 0; max-width: none; width: 100%; max-height: 90dvh; position: fixed; inset: auto 0 0 0; background: transparent; }
.sheet::backdrop { background: rgba(15, 12, 25, .45); }
.sheet[open] { animation: sheet-in .22s ease; }
.sheet__panel { max-width: var(--maxw); margin: 0 auto; background: var(--surface); border-radius: 28px 28px 0 0; padding: 10px var(--gutter) calc(20px + env(safe-area-inset-bottom)); max-height: 90dvh; overflow-y: auto; }
.sheet__grip { width: 44px; height: 5px; border-radius: 99px; background: var(--line); margin: 4px auto 14px; }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
.menu { list-style: none; padding: 0; margin: 0; }
.menu button, .menu a { width: 100%; display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 0 8px; border: 0; background: none; color: var(--ink); font-size: 16px; font-weight: 600; cursor: pointer; border-radius: 14px; text-align: start; }
.menu button:hover, .menu a:hover { background: var(--surface-2); text-decoration: none; }
.menu svg { width: 22px; height: 22px; color: var(--muted); }
.menu .danger { color: var(--bad); }
.menu .danger svg { color: var(--bad); }

/* Empty state */
.empty { text-align: center; padding: 40px 16px; }
.empty__art { width: 120px; height: 120px; margin: 0 auto 12px; }

/* Reactions */
.reactions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.reaction { width: 50px; height: 50px; border-radius: 18px; border: 1.5px solid var(--line); background: var(--surface); font-size: 26px; cursor: pointer; }
.reaction[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }

/* Link share card */
.linkbox { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border-radius: 16px; padding: 8px 8px 8px 14px; direction: ltr; }
.linkbox code { flex: 1; font-family: inherit; font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: left; padding-left: 6px; }

/* Home */
.hero-home { padding: 28px 4px 8px; }
.hero-home .h1 { font-size: 34px; line-height: 1.4; }
.path { display: flex; gap: 16px; align-items: center; background: var(--surface); border-radius: 24px; padding: 20px; box-shadow: var(--shadow); color: var(--ink); }
.path:hover { text-decoration: none; outline: 2px solid var(--accent); }
.path__art { width: 64px; height: 64px; flex: none; border-radius: 20px; background: var(--accent-soft); display: grid; place-items: center; font-size: 30px; }
.sms-preview { background: var(--surface-2); border-radius: 20px 20px 20px 6px; padding: 14px 16px; font-size: 14.5px; line-height: 1.85; white-space: pre-wrap; }
.footer { padding: 32px 0 24px; font-size: 13px; color: var(--muted); }
.footer a { color: var(--muted); }
.footer nav { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 16px; background: var(--surface-2); font-size: 14px; line-height: 1.8; }
.notice svg { width: 20px; height: 20px; flex: none; margin-top: 3px; color: var(--accent-text); }
.notice--bad { background: var(--bad-soft); color: var(--bad); }
.notice--bad svg { color: var(--bad); }

.prose { line-height: 2; }
.prose h2 { font-size: 19px; margin: 28px 0 8px; }
.prose p, .prose li { color: var(--ink); }
.prose ul { padding-inline-start: 20px; }

.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }

@media (min-width: 720px) {
  .topic-grid { grid-template-columns: repeat(3, 1fr); }
  .hero-home .h1 { font-size: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Utilities (no inline styles: CSP forbids them) */
.mt-0 { margin-top: 0 !important; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; }
.px-4 { padding-inline: 4px; }
.note { margin: 12px 4px 0; }
.hidden { display: none !important; }
.snackbar svg { width: 20px; height: 20px; flex: none; }
.w-full { width: 100%; }
.gap-8 { gap: 8px; }
.wrap { flex-wrap: wrap; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.theme-violet { background: linear-gradient(160deg, var(--accent-soft), var(--surface) 70%); }
.theme-ink { background: #17112B; color: #F2EFF9; }
.theme-ink .muted { color: #B8B1CC; }
.theme-sand { background: linear-gradient(160deg, #F3E9DA, var(--surface) 75%); }
@media (prefers-color-scheme: dark) { .theme-sand { background: linear-gradient(160deg, #2E2618, var(--surface) 75%); } }
.d-block { display: block; }
details summary { cursor: pointer; list-style: none; min-height: 32px; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "＋"; float: left; color: var(--muted); }
details[open] summary::after { content: "－"; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn { white-space: nowrap; }
.icon-bubble svg { width: 22px; height: 22px; color: var(--accent-text); }
.list__row > svg:not(.chev) { width: 22px; height: 22px; }
.pill svg { flex: none; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { padding: 0; }
