:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --fg: var(--tg-theme-text-color, #111111);
  --muted: var(--tg-theme-hint-color, #8a8a8a);
  --accent: var(--tg-theme-button-color, #2ea6ff);
  --accent-fg: var(--tg-theme-button-text-color, #ffffff);
  --card: var(--tg-theme-secondary-bg-color, #f4f4f6);
  --link: var(--tg-theme-link-color, #2ea6ff);
  --danger: #e5484d;
  --warn: #d67c00;
  --ok: #1a9c56;
  --radius: 16px;
  --radius-sm: 12px;
  --gap: 14px;
  /* One hairline + one soft shadow, reused everywhere for a single depth system. */
  --hair: color-mix(in srgb, var(--muted) 16%, transparent);
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 6px 20px rgba(0, 0, 0, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Vazirmatn", Tahoma, system-ui, sans-serif;
  line-height: 1.65;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 480px; margin: 0 auto; padding: 16px; min-height: 100dvh; }

/* ---- screen system ---- */
.screen { display: none; flex-direction: column; gap: var(--gap); animation: fade .2s ease; }
.screen.is-active { display: flex; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen, .card { animation: none !important; } }

.center { min-height: 70dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--muted) 32%, transparent);
  border-top-color: var(--accent); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- typography ---- */
h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.02em; line-height: 1.25; font-weight: 700; }
h2 { font-size: 1.05rem; margin: 0; letter-spacing: -.01em; font-weight: 600; }
.lead { color: var(--muted); margin: 0; font-size: .95rem; }
.muted { color: var(--muted); }
/* Groups the long dashboard scroll into labelled sections (Persian: no casing, so weight+size+color carry it). */
.section-label {
  font-size: .8rem; font-weight: 700; color: var(--muted);
  letter-spacing: .02em; margin: 8px 4px -4px; opacity: .9;
}

/* ---- hero (onboarding) ---- */
.hero { text-align: center; padding: 24px 6px 6px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.badge {
  width: 68px; height: 68px; border-radius: 22px; display: grid; place-items: center;
  font-size: 30px; background: color-mix(in srgb, var(--accent) 16%, var(--card));
  box-shadow: var(--shadow);
}

/* ---- notes ---- */
.note {
  background: var(--card); border-radius: var(--radius); padding: 12px 14px;
  font-size: .88rem; color: var(--fg); border: 1px solid var(--hair);
}
.note--warn {
  background: color-mix(in srgb, var(--warn) 12%, var(--card));
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
  color: var(--warn); font-weight: 500;
}

/* ---- steps ---- */
.steps { display: flex; gap: 7px; justify-content: center; padding: 4px 0 2px; }
.steps .dot { width: 8px; height: 8px; border-radius: 50%; background: color-mix(in srgb, var(--muted) 40%, transparent); transition: width .2s, background .2s; }
.steps .dot.is-on { background: var(--accent); width: 22px; border-radius: 999px; }
.steps .dot.is-done { background: color-mix(in srgb, var(--accent) 70%, transparent); }

/* ---- forms ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: .9rem; color: var(--muted); }
.hint { color: var(--muted); font-size: .78rem; }
/* Inputs sit on the page bg + a hairline so they read as fields even inside a same-colour card. */
input, textarea, select {
  width: 100%; padding: 13px 14px; font: inherit; font-size: 1rem;
  color: var(--fg); background: var(--bg);
  border: 1.5px solid var(--hair); border-radius: var(--radius-sm); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.inline { display: flex; gap: 10px; align-items: center; }
.inline > * { flex: 1; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { width: auto; accent-color: var(--accent); }
.switch span { font-size: .92rem; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
textarea { min-height: 92px; resize: vertical; }
.input--otp { text-align: center; letter-spacing: .5em; font-size: 1.35rem; font-variant-numeric: tabular-nums; }

.err { color: var(--danger); font-size: .85rem; min-height: 1.2em; margin: 0; }

/* ---- buttons ---- */
.btn {
  width: 100%; padding: 14px; border: none; border-radius: var(--radius-sm); cursor: pointer;
  font: inherit; font-size: 1rem; font-weight: 600; transition: filter .15s, transform .06s, opacity .15s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: default; }
.btn--primary { background: var(--accent); color: var(--accent-fg); box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn--primary:not(:disabled):active { filter: brightness(.95); }
.btn--ghost { background: transparent; color: var(--link); font-weight: 500; box-shadow: none; }

/* ---- dashboard ---- */
.topbar { padding: 8px 2px 0; display: flex; flex-direction: column; gap: 2px; }
.topbar .lead { font-size: .88rem; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  border: 1px solid var(--hair); box-shadow: var(--shadow);
  animation: fade .24s ease backwards;
}
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card__head h2 { margin: 0; }
.chip-btn {
  background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--link);
  border: none; border-radius: 999px; padding: 7px 13px; font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer;
  transition: filter .15s, transform .06s;
}
.chip-btn:active { transform: scale(.96); filter: brightness(.97); }

/* ---- home hub menu (one row per feature slug) ---- */
.menu { display: flex; flex-direction: column; gap: 10px; }
.menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: inherit;
  background: var(--card); border: 1px solid var(--hair); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); cursor: pointer; font: inherit; color: var(--fg);
  transition: filter .15s, transform .06s;
}
.menu-item:active { transform: scale(.99); filter: brightness(.98); }
.menu-ic {
  flex: none; width: 42px; height: 42px; display: grid; place-items: center;
  font-size: 21px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 13%, transparent);
}
.menu-tx { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.menu-tx b { font-size: .98rem; font-weight: 600; }
.menu-tx small { font-size: .8rem; color: var(--muted); }
.menu-ch { flex: none; color: var(--muted); font-size: 1.4rem; line-height: 1; }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--hair); }
.row:last-child { border-bottom: none; }
.status { color: var(--accent); font-size: .84rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.result { min-height: 1.4em; font-size: .9rem; margin: 0; color: var(--muted); }

/* ---- status tiles ---- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--bg); border: 1px solid var(--hair); border-radius: var(--radius-sm);
  padding: 12px 6px; text-align: center; display: flex; flex-direction: column; gap: 3px;
}
.stat b { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat span { font-size: .74rem; color: var(--muted); }
.badge-on { color: var(--warn); }
.badge-off { color: var(--ok); }
