/* ==========================================================================
   Hamdars · همدرس — design system
   Apple-inspired clarity, Persian palette & ornament. RTL/LTR via logical
   properties, light/dark via tokens.
   ========================================================================== */

@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Variable.f6d31671339d.woff2") format("woff2-variations"),
       url("../fonts/Vazirmatn-Variable.f6d31671339d.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Persian palette */
  --firoozeh: #14A3A6;      /* turquoise — Isfahan tilework */
  --firoozeh-deep: #0B7F83;
  --lajvard: #2F57C8;       /* lapis lazuli */
  --lajvard-deep: #1C2F66;
  --zaferan: #E9A21B;       /* saffron */
  --anar: #D2424F;          /* pomegranate */
  --peste: #7FAE3E;         /* pistachio */
  --yasi: #8E6CD1;          /* lilac */

  --firoozeh-soft: #E2F4F3;
  --lajvard-soft: #E8EDFB;
  --zaferan-soft: #FCF1D8;
  --anar-soft: #FBE7E9;
  --peste-soft: #EDF5E2;
  --yasi-soft: #F0EBFA;

  --accent: var(--firoozeh);
  --accent-deep: var(--firoozeh-deep);
  --accent-soft: var(--firoozeh-soft);
  --on-accent: #fff;

  /* Surfaces — warm paper, like a well-loved notebook */
  --bg: #FBF8F2;
  --bg-elev: #FFFFFF;
  --bg-sunken: #F3EEE4;
  --bg-hover: rgba(60, 45, 20, .045);
  --glass: rgba(251, 248, 242, .74);
  --text: #1D1D1F;
  --text-2: #5E5A54;
  --text-3: #8F8A82;
  --line: rgba(60, 45, 20, .10);
  --line-2: rgba(60, 45, 20, .17);
  --focus: 0 0 0 4px color-mix(in srgb, var(--accent) 28%, transparent);

  --shadow-1: 0 1px 2px rgba(40, 30, 10, .06), 0 1px 1px rgba(40, 30, 10, .03);
  --shadow-2: 0 10px 30px rgba(40, 30, 10, .08), 0 2px 6px rgba(40, 30, 10, .05);
  --shadow-3: 0 30px 70px rgba(28, 47, 102, .20), 0 6px 18px rgba(28, 47, 102, .10);

  --radius-s: 10px;
  --radius: 16px;
  --radius-l: 22px;
  --radius-xl: 30px;

  --font-fa: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --font-en: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI",
             Roboto, "Helvetica Neue", Arial, "Vazirmatn", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
  --nav-h: 60px;

  /* Girih — eight-pointed star and cross (شمسه و چلیپا), used as a mask */
  --girih: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' fill='none' stroke='black' stroke-width='1'%3E%3Cpolygon points='32,14 37.27,19.27 44.73,19.27 44.73,26.73 50,32 44.73,37.27 44.73,44.73 37.27,44.73 32,50 26.73,44.73 19.27,44.73 19.27,37.27 14,32 19.27,26.73 19.27,19.27 26.73,19.27'/%3E%3Cpath d='M32 14V0M50 32H64M32 50V64M14 32H0M44.73 19.27L57.64 6.36M44.73 44.73L57.64 57.64M19.27 44.73L6.36 57.64M19.27 19.27L6.36 6.36'/%3E%3Cg id='c'%3E%3Cpolygon points='0,-9 2.64,-6.36 6.36,-6.36 6.36,-2.64 9,0 6.36,2.64 6.36,6.36 2.64,6.36 0,9 -2.64,6.36 -6.36,6.36 -6.36,2.64 -9,0 -6.36,-2.64 -6.36,-6.36 -2.64,-6.36'/%3E%3C/g%3E%3Cuse href='%23c' x='64'/%3E%3Cuse href='%23c' y='64'/%3E%3Cuse href='%23c' x='64' y='64'/%3E%3C/svg%3E");
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0C111D;
    --bg-elev: #151B2B;
    --bg-sunken: #090D17;
    --bg-hover: rgba(255, 255, 255, .05);
    --glass: rgba(12, 17, 29, .72);
    --text: #F3F0EA;
    --text-2: #B4AFA6;
    --text-3: #7D786F;
    --line: rgba(255, 255, 255, .08);
    --line-2: rgba(255, 255, 255, .15);
    --firoozeh-soft: rgba(20, 163, 166, .17);
    --lajvard-soft: rgba(47, 87, 200, .20);
    --zaferan-soft: rgba(233, 162, 27, .17);
    --anar-soft: rgba(210, 66, 79, .18);
    --peste-soft: rgba(127, 174, 62, .18);
    --yasi-soft: rgba(142, 108, 209, .20);
    --accent: #2BBDBF;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 10px 30px rgba(0, 0, 0, .35), 0 2px 6px rgba(0, 0, 0, .3);
    --shadow-3: 0 30px 70px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0C111D;
  --bg-elev: #151B2B;
  --bg-sunken: #090D17;
  --bg-hover: rgba(255, 255, 255, .05);
  --glass: rgba(12, 17, 29, .72);
  --text: #F3F0EA;
  --text-2: #B4AFA6;
  --text-3: #7D786F;
  --line: rgba(255, 255, 255, .08);
  --line-2: rgba(255, 255, 255, .15);
  --firoozeh-soft: rgba(20, 163, 166, .17);
  --lajvard-soft: rgba(47, 87, 200, .20);
  --zaferan-soft: rgba(233, 162, 27, .17);
  --anar-soft: rgba(210, 66, 79, .18);
  --peste-soft: rgba(127, 174, 62, .18);
  --yasi-soft: rgba(142, 108, 209, .20);
  --accent: #2BBDBF;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 10px 30px rgba(0, 0, 0, .35), 0 2px 6px rgba(0, 0, 0, .3);
  --shadow-3: 0 30px 70px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
html[lang="fa"] body { font-family: var(--font-fa); line-height: 1.85; font-feature-settings: "ss01" 0; }
html[lang="en"] body { font-family: var(--font-en); }
/* Persian must never get negative tracking — it breaks letter joining */
html[lang="en"] .tight { letter-spacing: -0.022em; }
html[lang="fa"] .tight { letter-spacing: 0; }

h1, h2, h3, h4 { margin: 0; font-weight: 750; line-height: 1.25; color: var(--text); }
html[lang="fa"] h1, html[lang="fa"] h2, html[lang="fa"] h3 { line-height: 1.5; font-weight: 800; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 10px; }

/* Math & numbers always read left-to-right, even inside Persian text */
mjx-container, .ltr, bdi.num { direction: ltr; unicode-bidi: isolate; }
mjx-container[display="true"] { margin: .6em 0 !important; overflow-x: auto; overflow-y: hidden; }

.container { width: 100%; max-width: 1140px; margin-inline: auto; padding-inline: 22px; }
.stack > * + * { margin-block-start: var(--gap, 16px); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.flip-rtl { transition: transform .2s var(--ease); }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

/* ---------- Navigation ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border-block-end: 1px solid var(--line);
}
.nav-inner { height: 100%; display: flex; align-items: center; gap: 18px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; flex-shrink: 0; }
.brand-mark { width: 30px; height: 30px; filter: drop-shadow(0 2px 4px rgba(20, 163, 166, .35)); }
.brand-mark .star { fill: var(--firoozeh); }
.brand-mark .core { fill: var(--zaferan); }
.brand-mark .ring { fill: none; stroke: #fff; stroke-width: 1.1; opacity: .9; }
.nav-links { display: flex; gap: 2px; margin-inline: auto; }
.nav-link {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  font-size: 14.5px; font-weight: 550; color: var(--text-2);
  transition: background .2s var(--ease), color .2s var(--ease);
}
.nav-link svg { width: 17px; height: 17px; }
.nav-link:hover { color: var(--text); background: var(--bg-hover); }
.nav-link.active { color: var(--accent-deep); background: var(--accent-soft); }
:root[data-theme="dark"] .nav-link.active { color: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nav-link.active { color: var(--accent); } }
.nav-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 999px; border: 0;
  display: inline-grid; place-items: center;
  background: transparent; color: var(--text-2);
  transition: background .2s var(--ease), color .2s var(--ease), transform .15s var(--ease);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 19px; height: 19px; }
.lang-btn {
  height: 32px; padding-inline: 12px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--bg-elev);
  font-size: 13.5px; font-weight: 700; color: var(--text-2);
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .2s var(--ease);
}
.lang-btn:hover { color: var(--text); border-color: var(--accent); }
.lang-btn svg { width: 15px; height: 15px; }
html[lang="en"] .lang-btn .lang-label { font-family: var(--font-fa); }
.theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-icon-dark { display: block; }
:root[data-theme="dark"] .theme-icon-light { display: none; }

/* Bottom tab bar (iOS-style) on small screens */
.tabbar { display: none; }
@media (max-width: 820px) {
  .nav-links { display: none; }
  .nav-inner { justify-content: space-between; }
  .tabbar {
    display: grid; grid-template-columns: repeat(6, 1fr);
    position: fixed; inset-inline: 0; bottom: 0; z-index: 60;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--glass);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    backdrop-filter: saturate(180%) blur(22px);
    border-block-start: 1px solid var(--line);
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 5px 2px; font-size: 10.5px; font-weight: 600; color: var(--text-3);
    border-radius: 12px;
  }
  .tab svg { width: 23px; height: 23px; }
  .tab.active { color: var(--accent); }
  body { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
}

/* ---------- Buttons ---------- */
.btn {
  --b-bg: var(--bg-elev); --b-fg: var(--text); --b-bd: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding-inline: 22px; border-radius: 999px;
  border: 1px solid var(--b-bd); background: var(--b-bg); color: var(--b-fg);
  font-size: 15.5px; font-weight: 650; white-space: nowrap;
  transition: transform .15s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease), filter .2s;
  box-shadow: var(--shadow-1);
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { box-shadow: var(--shadow-2); }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-primary {
  --b-bg: linear-gradient(180deg, color-mix(in srgb, var(--firoozeh) 92%, #fff) 0%, var(--firoozeh-deep) 100%);
  --b-fg: #fff; --b-bd: transparent;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--firoozeh) 38%, transparent), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn-primary:hover { filter: brightness(1.05); box-shadow: 0 12px 28px color-mix(in srgb, var(--firoozeh) 45%, transparent); }
.btn-soft { --b-bg: var(--accent-soft); --b-fg: var(--accent-deep); --b-bd: transparent; box-shadow: none; }
:root[data-theme="dark"] .btn-soft { --b-fg: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-soft { --b-fg: var(--accent); } }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--bg-hover); box-shadow: none; }
.btn-danger { --b-bg: var(--anar-soft); --b-fg: var(--anar); --b-bd: transparent; box-shadow: none; }
.btn-sm { height: 36px; padding-inline: 15px; font-size: 14px; }
.btn-lg { height: 54px; padding-inline: 28px; font-size: 17px; }
.btn-block { width: 100%; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: 24px; }
.card-hover { transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .35s; }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--line-2); }

/* ---------- Page header ---------- */
.page { padding-block: 40px 72px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-block-end: 30px; }
.page-title { font-size: clamp(30px, 4.2vw, 42px); }
.page-subtitle { margin-block-start: 8px; color: var(--text-2); font-size: 17px; max-width: 60ch; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13.5px; font-weight: 700; color: var(--accent-deep);
  letter-spacing: .02em;
}
html[lang="en"] .eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; }
.eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--zaferan); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 8px; }
.label { font-size: 14px; font-weight: 650; color: var(--text-2); }
.input, .textarea, .select {
  width: 100%; border: 1px solid var(--line-2); background: var(--bg-elev);
  border-radius: 14px; padding: 12px 15px; font-size: 16px;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { min-height: 120px; resize: vertical; line-height: 1.8; }
.input-lg { height: 56px; font-size: 17px; border-radius: 16px; padding-inline: 18px; }

/* Segmented control — the Apple way */
.segmented {
  position: relative; display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 3px; border-radius: 12px; background: var(--bg-sunken);
  border: 1px solid var(--line);
}
.segmented button {
  position: relative; z-index: 1; border: 0; background: transparent;
  padding: 7px 16px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--text-2);
  transition: color .2s var(--ease);
  white-space: nowrap;
}
.segmented button[aria-pressed="true"], .segmented button.active { color: var(--text); }
.segmented .thumb {
  position: absolute; z-index: 0; top: 3px; bottom: 3px;
  border-radius: 9px; background: var(--bg-elev);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 1px 1px rgba(0, 0, 0, .04);
  transition: inset-inline-start .32s var(--ease), width .32s var(--ease);
}

/* Stepper */
.stepper { display: inline-flex; align-items: center; gap: 4px; padding: 4px; border-radius: 14px; background: var(--bg-sunken); border: 1px solid var(--line); }
.stepper button { width: 38px; height: 38px; border: 0; border-radius: 10px; background: var(--bg-elev); box-shadow: var(--shadow-1); display: grid; place-items: center; }
.stepper button svg { width: 16px; height: 16px; }
.stepper button:disabled { opacity: .4; }
.stepper output { min-width: 44px; text-align: center; font-size: 19px; font-weight: 750; font-variant-numeric: tabular-nums; }

/* Toggle switch */
.switch { position: relative; width: 50px; height: 30px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); transition: background .25s var(--ease); }
.switch span::after {
  content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 26px; height: 26px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .2);
  transition: inset-inline-start .25s var(--ease-spring);
}
.switch input:checked + span { background: var(--peste); }
.switch input:checked + span::after { inset-inline-start: 22px; }
.switch input:focus-visible + span { box-shadow: var(--focus); }

/* ---------- Badges, chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding-inline: 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700;
  background: var(--bg-sunken); color: var(--text-2);
}
.badge-accent { background: var(--accent-soft); color: var(--accent-deep); }
.badge-zaferan { background: var(--zaferan-soft); color: #9A6405; }
.badge-anar { background: var(--anar-soft); color: var(--anar); }
.badge-peste { background: var(--peste-soft); color: #4F7420; }
.badge-lajvard { background: var(--lajvard-soft); color: var(--lajvard); }
:root[data-theme="dark"] .badge-zaferan { color: var(--zaferan); }
:root[data-theme="dark"] .badge-peste { color: var(--peste); }
:root[data-theme="dark"] .badge-accent { color: var(--accent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge-zaferan { color: var(--zaferan); }
  :root:not([data-theme="light"]) .badge-peste { color: var(--peste); }
  :root:not([data-theme="light"]) .badge-accent { color: var(--accent); }
}
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--bg-elev);
  font-size: 14.5px; font-weight: 550; color: var(--text);
  transition: border-color .2s var(--ease), background .2s var(--ease), transform .15s var(--ease);
}
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.chip:active { transform: scale(.97); }
.notice {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 15px; border-radius: 14px;
  background: var(--zaferan-soft); color: var(--text);
  font-size: 14px; font-weight: 500;
}
.notice svg { width: 18px; height: 18px; color: var(--zaferan); flex-shrink: 0; }

/* ---------- Persian ornament ---------- */
.girih {
  position: absolute; inset: 0; pointer-events: none;
  background: var(--girih-color, var(--firoozeh));
  -webkit-mask-image: var(--girih); mask-image: var(--girih);
  -webkit-mask-size: var(--girih-size, 64px); mask-size: var(--girih-size, 64px);
  opacity: var(--girih-opacity, .09);
}
.divider-ornament { display: flex; align-items: center; gap: 14px; color: var(--text-3); }
.divider-ornament::before, .divider-ornament::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, transparent, var(--line-2), transparent); }
.divider-ornament svg { width: 18px; height: 18px; color: var(--zaferan); }

/* Score ring */
.ring { --size: 64px; --stroke: 7px; width: var(--size); height: var(--size); position: relative; flex-shrink: 0; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--bg-sunken); }
.ring .value { stroke: var(--ring-color, var(--accent)); stroke-linecap: round; transition: stroke-dashoffset 1.2s var(--ease); }
.ring .label { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: calc(var(--size) * .24); font-variant-numeric: tabular-nums; }

/* ---------- Sheet / modal ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 14, 25, .32);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 20px;
  opacity: 0; transition: opacity .25s var(--ease);
}
.sheet-backdrop.open { opacity: 1; }
.sheet {
  width: 100%; max-width: 460px; max-height: calc(100vh - 40px); overflow: auto;
  background: var(--bg-elev); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-3); border: 1px solid var(--line);
  transform: translateY(16px) scale(.97); transition: transform .35s var(--ease-spring);
}
.sheet-backdrop.open .sheet { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px 8px; }
.sheet-title { font-size: 19px; font-weight: 800; }
.sheet-body { padding: 10px 22px 22px; }
.sheet-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 0 22px 22px; }
@media (max-width: 560px) {
  .sheet-backdrop { place-items: end center; padding: 0; }
  .sheet { max-width: none; border-radius: 26px 26px 0 0; padding-bottom: env(safe-area-inset-bottom); transform: translateY(100%); }
}

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; inset-inline: 0; bottom: 26px; z-index: 200; display: grid; justify-items: center; pointer-events: none; }
@media (max-width: 820px) { .toast-wrap { bottom: calc(86px + env(safe-area-inset-bottom)); } }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px; border-radius: 999px;
  background: color-mix(in srgb, var(--text) 92%, transparent); color: var(--bg);
  font-size: 14.5px; font-weight: 600; box-shadow: var(--shadow-3);
  transform: translateY(20px); opacity: 0; transition: all .35s var(--ease-spring);
}
.toast.show { transform: none; opacity: 1; }
.toast svg { width: 17px; height: 17px; color: var(--peste); }

/* ---------- Footer ---------- */
.footer { border-block-start: 1px solid var(--line); padding-block: 34px 44px; margin-block-start: 24px; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; color: var(--text-3); font-size: 14px; }
.footer-brand { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-weight: 650; }
.footer-brand .brand-mark { width: 22px; height: 22px; filter: none; }

/* ---------- Utilities ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.fade-up { animation: fadeUp .6s var(--ease) both; }
.fade-up.d1 { animation-delay: .06s; } .fade-up.d2 { animation-delay: .12s; } .fade-up.d3 { animation-delay: .18s; } .fade-up.d4 { animation-delay: .24s; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* Section heading */
.section { padding-block: 56px; }
.section-head { text-align: center; max-width: 640px; margin: 0 auto 34px; }
.section-title { font-size: clamp(26px, 3.4vw, 36px); }
.section-subtitle { margin-block-start: 10px; color: var(--text-2); font-size: 17px; }

/* Icon tile (subject / feature) */
.tile {
  --tile: var(--firoozeh); --tile-soft: var(--firoozeh-soft);
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center;
  background: var(--tile-soft); color: var(--tile); flex-shrink: 0;
}
.tile svg { width: 26px; height: 26px; }
.tile-lajvard { --tile: var(--lajvard); --tile-soft: var(--lajvard-soft); }
.tile-zaferan { --tile: #C98708; --tile-soft: var(--zaferan-soft); }
.tile-anar { --tile: var(--anar); --tile-soft: var(--anar-soft); }
.tile-peste { --tile: #5E8A26; --tile-soft: var(--peste-soft); }
.tile-yasi { --tile: var(--yasi); --tile-soft: var(--yasi-soft); }

/* Empty state */
.empty { text-align: center; padding: 56px 24px; }
.empty .brand-mark { width: 56px; height: 56px; margin: 0 auto 18px; opacity: .9; }
.empty h3 { font-size: 20px; margin-block-end: 6px; }
.empty p { color: var(--text-2); margin-block-end: 20px; }

/* Spinner — a rotating shamseh */
.spin { animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pulse { animation: pulse 1.6s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ==========================================================================
   Home
   ========================================================================== */
.hero { position: relative; overflow: hidden; padding-block: 64px 40px; }
.hero .girih { --girih-opacity: .07; -webkit-mask-image: var(--girih); mask-image: var(--girih);
  -webkit-mask-composite: source-in; }
.hero::after { /* soften the pattern toward the bottom */
  content: ""; position: absolute; inset: auto 0 0 0; height: 45%;
  background: linear-gradient(to bottom, transparent, var(--bg)); pointer-events: none;
}
.hero-grid { position: relative; z-index: 1; display: grid; grid-template-columns: 1.15fr 1fr; gap: 48px; align-items: center; }
.greeting { display: inline-flex; align-items: center; gap: 10px; padding: 6px 14px 6px 8px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--line); box-shadow: var(--shadow-1);
  font-size: 14px; font-weight: 600; color: var(--text-2); margin-block-end: 22px; }
[dir="rtl"] .greeting { padding: 6px 8px 6px 14px; }
.greeting .sun { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--zaferan-soft); color: #C98708; }
.greeting .sun svg { width: 15px; height: 15px; }
.hero-title { font-size: clamp(38px, 5.6vw, 64px); line-height: 1.12; margin-block: 14px 18px; }
html[lang="fa"] .hero-title { line-height: 1.35; }
.hero-title .accent {
  background: linear-gradient(100deg, var(--firoozeh) 10%, var(--lajvard) 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-subtitle { font-size: clamp(17px, 1.6vw, 19.5px); color: var(--text-2); max-width: 34em; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-block-start: 30px; }

.verse { margin: 40px 0 0; width: fit-content; max-width: 100%; display: flex; align-items: center; gap: 16px; }
.verse-text { font-family: var(--font-fa); direction: rtl; font-size: 17px; font-weight: 600; color: var(--lajvard-deep); line-height: 1.9; }
:root[data-theme="dark"] .verse-text { color: #9FB4F2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .verse-text { color: #9FB4F2; } }
.verse-text span { display: block; }
.verse-bar { width: 3px; align-self: stretch; border-radius: 3px; background: linear-gradient(var(--zaferan), var(--firoozeh)); }
.verse-meta { font-size: 13px; color: var(--text-3); margin-block-start: 2px; }
.verse-meta em { font-style: normal; display: block; color: var(--text-2); }

/* The arch (طاق) — pointed Persian arch silhouette */
.arch-wrap { position: relative; justify-self: center; width: min(100%, 440px); aspect-ratio: 5 / 6.2; }
.arch {
  position: absolute; inset: 0;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 124' preserveAspectRatio='none'%3E%3Cpath d='M0 124V52C0 26 26 10 50 0c24 10 50 26 50 52v72z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 124' preserveAspectRatio='none'%3E%3Cpath d='M0 124V52C0 26 26 10 50 0c24 10 50 26 50 52v72z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  background:
    radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--zaferan) 40%, transparent), transparent 60%),
    linear-gradient(170deg, var(--firoozeh) 0%, var(--firoozeh-deep) 42%, var(--lajvard-deep) 100%);
}
.arch .girih { --girih-color: #fff; --girih-opacity: .16; --girih-size: 56px; }
.arch-frame { position: absolute; inset: 10px; pointer-events: none;
  -webkit-mask: inherit; mask: inherit; }
.arch-line { position: absolute; inset: 0; pointer-events: none; }
.float-card {
  position: absolute; z-index: 2; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow-3); padding: 14px 16px;
  animation: float 7s ease-in-out infinite;
}
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.float-chat { inset-inline-start: -8%; top: 22%; width: 74%; animation-delay: -1s; }
.float-score { inset-inline-end: -3%; top: 52%; display: flex; align-items: center; gap: 12px; animation-delay: -3s; }
.float-event { inset-inline-start: 4%; bottom: 6%; width: 64%; animation-delay: -5s; }
.bubble-mini { font-size: 13.5px; line-height: 1.7; padding: 9px 13px; border-radius: 16px; max-width: 92%; }
.bubble-mini.me { margin-inline-start: auto; background: var(--firoozeh); color: #fff; border-end-end-radius: 6px; }
.bubble-mini.ai { background: var(--bg-sunken); border-end-start-radius: 6px; margin-block-start: 8px; }
.event-mini { display: flex; gap: 10px; align-items: stretch; font-size: 13.5px; }
.event-mini .bar { width: 4px; border-radius: 4px; background: var(--zaferan); }
.event-mini b { display: block; font-size: 14px; }
.event-mini span { color: var(--text-3); font-size: 12.5px; }

.subjects { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.subject-card { position: relative; overflow: hidden; padding: 26px; display: flex; flex-direction: column; gap: 14px; min-height: 250px; }
.subject-card h3 { font-size: 22px; }
.subject-card p { color: var(--text-2); font-size: 15.5px; flex: 1; }
.subject-card .girih { --girih-opacity: .05; --girih-size: 48px; -webkit-mask-position: center; }
.subject-card .go { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 15px; color: var(--tile); }
.subject-card .go svg { width: 16px; height: 16px; transition: transform .25s var(--ease); }
.subject-card:hover .go svg { transform: translateX(4px); }
[dir="rtl"] .subject-card:hover .go svg { transform: scaleX(-1) translateX(4px); }

.loop { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; position: relative; }
.loop-step { padding: 24px 22px; position: relative; }
.loop-num {
  width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 800; font-size: 16px; color: #fff; margin-block-end: 16px;
  background: linear-gradient(135deg, var(--firoozeh), var(--lajvard));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--firoozeh) 35%, transparent);
}
.loop-step h3 { font-size: 18px; margin-block-end: 6px; }
.loop-step p { color: var(--text-2); font-size: 15px; }

.glance { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
.glance-card { padding: 24px; display: flex; flex-direction: column; gap: 16px; min-height: 220px; }
.glance-card h3 { font-size: 17px; display: flex; align-items: center; gap: 9px; }
.glance-card h3 svg { width: 19px; height: 19px; color: var(--accent); }
.agenda { display: grid; gap: 10px; }
.agenda-item { display: flex; gap: 12px; align-items: stretch; padding: 10px 12px; border-radius: 14px; background: var(--bg-sunken); }
.agenda-item .bar { width: 4px; border-radius: 4px; flex-shrink: 0; }
.agenda-item .when { font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.agenda-item .what { font-weight: 650; font-size: 15px; }
.glance-empty { color: var(--text-3); font-size: 15px; flex: 1; display: grid; place-items: center; text-align: center; }
.last-exam { display: flex; align-items: center; gap: 18px; flex: 1; }
.last-exam b { display: block; font-size: 16px; line-height: 1.5; }
.last-exam span { color: var(--text-3); font-size: 13.5px; }

@media (max-width: 1100px) {
  .float-chat { inset-inline-start: -4%; }
  .float-score { inset-inline-end: 0; }
}
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; gap: 56px; }
  .arch-wrap { width: min(86%, 380px); }
  .subjects, .loop { grid-template-columns: 1fr 1fr; }
  .glance { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .hero { padding-block: 36px 20px; }
  .subjects, .loop { grid-template-columns: 1fr; }
  .subject-card { min-height: 0; }
}

/* ==========================================================================
   Chat (teacher & advisor)
   ========================================================================== */
.chat-page { height: calc(100dvh - var(--nav-h)); display: flex; }
@media (max-width: 820px) { .chat-page { height: calc(100dvh - var(--nav-h) - 70px - env(safe-area-inset-bottom)); } }
.chat-layout { flex: 1; display: grid; grid-template-columns: 290px 1fr; min-height: 0; }
.chat-side {
  border-inline-end: 1px solid var(--line); background: color-mix(in srgb, var(--bg-sunken) 55%, var(--bg));
  display: flex; flex-direction: column; min-height: 0;
}
.chat-side-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 10px 18px; }
.chat-side-head h2 { font-size: 16px; }
.chat-list { flex: 1; overflow-y: auto; padding: 4px 10px 16px; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 2px; }
.chat-item {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 12px; border: 0; background: transparent; text-align: start;
  transition: background .15s var(--ease);
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-elev); box-shadow: var(--shadow-1); }
.chat-item .ci-body { flex: 1; min-width: 0; }
.chat-item .ci-title { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .ci-date { font-size: 12px; color: var(--text-3); }
.chat-item .ci-menu { opacity: 0; width: 30px; height: 30px; }
.chat-item:hover .ci-menu, .chat-item.active .ci-menu, .chat-item .ci-menu:focus-visible { opacity: 1; }
.chat-list-empty { color: var(--text-3); font-size: 14px; text-align: center; padding: 30px 12px; }

.menu {
  position: fixed; z-index: 120; min-width: 180px; padding: 6px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-3);
  animation: menuIn .18s var(--ease);
}
@keyframes menuIn { from { opacity: 0; transform: scale(.96); } }
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 9px;
  background: transparent; font-size: 14.5px; text-align: start;
}
.menu button:hover { background: var(--bg-hover); }
.menu button svg { width: 17px; height: 17px; color: var(--text-2); }
.menu button.danger, .menu button.danger svg { color: var(--anar); }

.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 22px; border-block-end: 1px solid var(--line); }
.chat-head .avatar { width: 42px; height: 42px; }
.chat-head h1 { font-size: 17px; line-height: 1.4; }
.chat-head p { font-size: 13.5px; color: var(--text-3); }
.chat-toggle { display: none; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--firoozeh), var(--firoozeh-deep));
  box-shadow: 0 4px 12px color-mix(in srgb, var(--firoozeh) 35%, transparent);
}
.avatar svg { width: 55%; height: 55%; }
.avatar.tutor { background: linear-gradient(135deg, var(--lajvard), var(--lajvard-deep)); box-shadow: 0 4px 12px color-mix(in srgb, var(--lajvard) 35%, transparent); }

.messages { flex: 1; overflow-y: auto; padding: 26px 22px 12px; scroll-behavior: smooth; }
.messages-inner { max-width: 780px; margin: 0 auto; display: grid; gap: 14px; }
.msg { display: flex; gap: 10px; align-items: flex-end; animation: msgIn .35s var(--ease-spring) both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.msg .avatar { width: 30px; height: 30px; }
.msg.me { flex-direction: row-reverse; }
.bubble {
  max-width: min(76%, 600px); padding: 11px 16px; border-radius: 22px; font-size: 16px; line-height: 1.75;
  overflow-wrap: anywhere; white-space: pre-wrap;
}
html[lang="fa"] .bubble { line-height: 1.95; }
.msg.ai .bubble { background: var(--bg-elev); border: 1px solid var(--line); border-end-start-radius: 7px; box-shadow: var(--shadow-1); }
.msg.me .bubble {
  background: linear-gradient(180deg, color-mix(in srgb, var(--firoozeh) 88%, #fff), var(--firoozeh-deep)); color: #fff;
  border-end-end-radius: 7px;
}
.msg.me .bubble mjx-container { color: #fff; }
.typing { display: inline-flex; gap: 5px; padding: 15px 18px; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); animation: dot 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { transform: translateY(0); opacity: .45; } 40% { transform: translateY(-5px); opacity: 1; } }

.welcome { max-width: 560px; margin: 6vh auto 0; text-align: center; animation: fadeUp .6s var(--ease) both; }
.welcome .avatar { width: 72px; height: 72px; margin: 0 auto 20px; }
.welcome h2 { font-size: 24px; margin-block-end: 8px; }
.welcome p { color: var(--text-2); margin-block-end: 24px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.composer-wrap { padding: 10px 22px 16px; }
.composer {
  max-width: 780px; margin: 0 auto; display: flex; align-items: flex-end; gap: 10px;
  padding: 8px 8px 8px 18px; border-radius: 26px; background: var(--bg-elev);
  border: 1px solid var(--line-2); box-shadow: var(--shadow-2);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
[dir="rtl"] .composer { padding: 8px 18px 8px 8px; }
.composer:focus-within { border-color: var(--accent); box-shadow: var(--shadow-2), var(--focus); }
.composer textarea {
  flex: 1; border: 0; background: transparent; resize: none; outline: none;
  font-size: 16px; line-height: 1.6; padding: 7px 0; max-height: 180px; min-height: 26px;
}
.composer textarea::placeholder { color: var(--text-3); }
.composer textarea:focus-visible { box-shadow: none; }
.send-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; background: var(--firoozeh);
  transition: transform .15s var(--ease), background .2s, opacity .2s;
}
.send-btn:disabled { background: var(--line-2); opacity: .8; }
.send-btn:not(:disabled):active { transform: scale(.9); }
.send-btn svg { width: 20px; height: 20px; }
.composer-note { max-width: 780px; margin: 8px auto 0; text-align: center; font-size: 12.5px; color: var(--text-3); }

@media (max-width: 820px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-side {
    position: fixed; inset-block: var(--nav-h) 0; inset-inline-start: 0; z-index: 70; width: min(86vw, 320px);
    background: var(--bg); box-shadow: var(--shadow-3);
    transform: translateX(-105%); transition: transform .35s var(--ease);
  }
  [dir="rtl"] .chat-side { transform: translateX(105%); }
  .chat-side.open { transform: none; }
  .chat-toggle { display: inline-grid; }
  .messages { padding-inline: 14px; }
  .composer-wrap { padding-inline: 12px; }
  .bubble { max-width: 84%; }
}

/* ==========================================================================
   Exam — create
   ========================================================================== */
.narrow { max-width: 720px; margin-inline: auto; }
.form-card { padding: 30px; display: grid; gap: 28px; }
.subject-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.subject-option { position: relative; }
.subject-option input { position: absolute; opacity: 0; pointer-events: none; }
.subject-option label {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 10px; border-radius: 18px;
  border: 1.5px solid var(--line-2); background: var(--bg-elev); cursor: pointer; font-weight: 700;
  transition: border-color .2s var(--ease), background .2s var(--ease), transform .15s var(--ease);
}
.subject-option label:active { transform: scale(.97); }
.subject-option input:checked + label { border-color: var(--tile); background: var(--tile-soft); }
.subject-option input:focus-visible + label { box-shadow: var(--focus); }
.subject-option label .check { position: absolute; top: 10px; inset-inline-end: 10px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--tile); color: #fff; display: grid; place-items: center; transform: scale(0); transition: transform .3s var(--ease-spring); }
.subject-option label .check svg { width: 13px; height: 13px; }
.subject-option input:checked + label .check { transform: scale(1); }
.topic-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-block-start: 4px; }
.topic-chips .chip { padding: 6px 13px; font-size: 13.5px; }
.form-row { display: flex; gap: 28px; flex-wrap: wrap; align-items: flex-end; }
.building {
  position: fixed; inset: 0; z-index: 150; display: grid; place-items: center; text-align: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  animation: fadeUp .3s var(--ease) both;
}
.building .brand-mark { width: 72px; height: 72px; margin: 0 auto 22px; }
.building h2 { font-size: 22px; }
.building p { color: var(--text-2); margin-block-start: 6px; }

/* ==========================================================================
   Exam — take
   ========================================================================== */
.start-card { padding: 40px 34px; text-align: center; position: relative; overflow: hidden; }
.start-card .girih { --girih-opacity: .05; }
.start-card .tile { margin: 0 auto 20px; width: 64px; height: 64px; border-radius: 20px; }
.start-card h1 { font-size: clamp(24px, 3vw, 32px); }
.start-card .desc { color: var(--text-2); margin: 10px auto 22px; max-width: 46ch; }
.meta-chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-block-end: 26px; }
.meta-chips .badge { height: 30px; padding-inline: 13px; font-size: 13.5px; }
.meta-chips .badge svg { width: 15px; height: 15px; }
.start-card .hint { font-size: 14px; color: var(--text-3); margin-block-start: 16px; }

.exam-bar {
  position: sticky; top: var(--nav-h); z-index: 40; margin-block-end: 22px;
  background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-block-end: 1px solid var(--line);
}
.exam-bar-inner { display: flex; align-items: center; gap: 16px; padding-block: 12px; }
.exam-bar .title { font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exam-bar .progress-text { font-size: 13px; color: var(--text-3); }
.progress { height: 4px; border-radius: 4px; background: var(--bg-sunken); overflow: hidden; margin-block-start: 6px; }
.progress span { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--firoozeh), var(--lajvard)); transition: width .5s var(--ease); }
[dir="rtl"] .progress span { background: linear-gradient(270deg, var(--firoozeh), var(--lajvard)); }
.timer {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding-inline: 14px; border-radius: 999px;
  background: var(--bg-elev); border: 1px solid var(--line-2); font-weight: 750; font-variant-numeric: tabular-nums;
}
.timer svg { width: 17px; height: 17px; color: var(--accent); }
.timer.warn { background: var(--zaferan-soft); border-color: transparent; color: #9A6405; }
.timer.warn svg { color: #C98708; }
.timer.danger { background: var(--anar-soft); border-color: transparent; color: var(--anar); animation: pulse 1s infinite; }
.timer.danger svg { color: var(--anar); }

.questions { display: grid; gap: 18px; }
.q-card { padding: 26px; scroll-margin-top: calc(var(--nav-h) + 90px); }
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-block-end: 14px; }
.q-num { font-size: 13.5px; font-weight: 700; color: var(--accent-deep); }
:root[data-theme="dark"] .q-num { color: var(--accent); }
.q-text { font-size: 18px; font-weight: 600; line-height: 1.9; margin-block-end: 18px; }
html[lang="en"] .q-text { line-height: 1.7; }
.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 14px; width: 100%; padding: 13px 16px; text-align: start;
  border-radius: 16px; border: 1.5px solid var(--line-2); background: var(--bg-elev); font-size: 16px;
  transition: border-color .2s var(--ease), background .2s var(--ease), transform .12s var(--ease);
}
.option:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line-2)); }
.option:active { transform: scale(.99); }
.option .key {
  width: 30px; height: 30px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center;
  background: var(--bg-sunken); font-weight: 750; font-size: 15px; color: var(--text-2);
  transition: all .2s var(--ease);
}
.option[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.option[aria-checked="true"] .key { background: var(--accent); color: #fff; }
.answer-box { display: grid; gap: 10px; }
.math-toolbar { display: flex; flex-wrap: wrap; gap: 6px; }
.math-toolbar button {
  min-width: 38px; height: 34px; padding-inline: 9px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-sunken); font-size: 15px; direction: ltr; font-family: "Times New Roman", serif; font-style: italic;
}
.math-toolbar button:hover { border-color: var(--accent); background: var(--accent-soft); }
.answer-preview { padding: 14px 16px; border-radius: 14px; background: var(--bg-sunken); font-size: 16px; line-height: 1.9; min-height: 50px; white-space: pre-wrap; overflow-wrap: anywhere; }
.answer-preview:empty::before { content: attr(data-empty); color: var(--text-3); }
.preview-label { font-size: 12.5px; font-weight: 700; color: var(--text-3); }
.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); min-height: 22px; }
.save-state svg { width: 15px; height: 15px; }
.save-state.ok { color: #5E8A26; }
.save-state.err { color: var(--anar); }
.exam-foot { display: flex; justify-content: center; margin-block: 30px 10px; }

/* ==========================================================================
   Results (history) & review
   ========================================================================== */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-block-end: 22px; }
.stat { padding: 18px 20px; }
.stat .v { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.3; }
.stat .k { font-size: 13.5px; color: var(--text-3); }
.result-list { display: grid; gap: 12px; }
.result {
  display: flex; align-items: center; gap: 18px; padding: 16px 20px;
}
.result .ring { --size: 58px; --stroke: 6px; }
.result .r-body { flex: 1; min-width: 0; }
.result .r-title { font-weight: 700; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result .r-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13.5px; color: var(--text-3); margin-block-start: 3px; }
.result .r-meta span { display: inline-flex; align-items: center; gap: 5px; }
.result .r-meta svg { width: 14px; height: 14px; }
.result .r-score { text-align: end; }
.result .r-score b { display: block; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.result .r-score span { font-size: 12.5px; color: var(--text-3); }
.result .chev { width: 18px; height: 18px; color: var(--text-3); }

.review-hero { padding: 28px; display: flex; align-items: center; gap: 26px; flex-wrap: wrap; margin-block-end: 22px; position: relative; overflow: hidden; }
.review-hero .girih { --girih-opacity: .05; }
.review-hero .ring { --size: 120px; --stroke: 11px; }
.review-hero h1 { font-size: clamp(22px, 2.8vw, 30px); }
.review-hero .big-score { font-size: 17px; color: var(--text-2); margin-block-start: 6px; }
.review-hero .big-score b { font-size: 26px; color: var(--text); font-variant-numeric: tabular-nums; }
.review-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-block-start: 16px; }
.ans-block { margin-block-start: 14px; padding: 14px 16px; border-radius: 14px; background: var(--bg-sunken); }
.ans-block .k { font-size: 12.5px; font-weight: 750; color: var(--text-3); margin-block-end: 4px; }
.ans-block .v { font-size: 16px; line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; }
.ans-block.correct { background: var(--peste-soft); }
.ans-block.correct .k { color: #5E8A26; }
.ans-block.feedback { background: var(--lajvard-soft); }
.ans-block.feedback .k { color: var(--lajvard); }
.opt-review { display: grid; gap: 8px; margin-block-start: 6px; }
.opt-review div { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 13px; border: 1.5px solid var(--line); font-size: 15.5px; }
.opt-review .key { width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center; background: var(--bg-sunken); font-weight: 750; font-size: 13.5px; flex-shrink: 0; }
.opt-review .is-correct { border-color: var(--peste); background: var(--peste-soft); }
.opt-review .is-correct .key { background: var(--peste); color: #fff; }
.opt-review .is-wrong { border-color: var(--anar); background: var(--anar-soft); }
.opt-review .is-wrong .key { background: var(--anar); color: #fff; }
.opt-review .tag { margin-inline-start: auto; font-size: 12.5px; font-weight: 700; }
@media (max-width: 600px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:last-child { grid-column: span 2; }
  .result { gap: 14px; padding: 14px 16px; }
  .result .r-score { display: none; }
  .form-card, .q-card { padding: 20px; }
  .subject-picker { gap: 8px; }
}

/* Segmented thumb needs more lift in dark mode */
:root[data-theme="dark"] .segmented .thumb { background: rgba(255, 255, 255, .15); box-shadow: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .segmented .thumb { background: rgba(255, 255, 255, .15); box-shadow: none; } }

/* ==========================================================================
   Accounts
   ========================================================================== */
.auth-page { position: relative; min-height: calc(100dvh - var(--nav-h)); display: grid; place-items: center; padding: 40px 18px 60px; overflow: hidden; }
.auth-page .girih { --girih-opacity: .06; }
.auth-card { position: relative; width: 100%; max-width: 440px; padding: 34px 30px 26px; box-shadow: var(--shadow-2); }
.auth-head { text-align: center; margin-block-end: 22px; }
.auth-head .brand-mark { width: 50px; height: 50px; margin: 0 auto 14px; }
.auth-head h1 { font-size: 25px; margin-block-end: 4px; }
.auth-form { display: grid; gap: 16px; }
.auth-alt { text-align: center; margin-block-start: 20px; font-size: 14.5px; color: var(--text-2); }
.auth-alt a { color: var(--accent-deep); font-weight: 700; }
:root[data-theme="dark"] .auth-alt a { color: var(--accent); }
.field-help { font-size: 13px; color: var(--text-3); }
.field-error { font-size: 13.5px; font-weight: 600; color: var(--anar); }
.notice-error { background: var(--anar-soft); margin-block-end: 16px; }
.notice-error svg { color: var(--anar); }
.pw-wrap { position: relative; direction: ltr; }   /* the field is LTR: keep the eye on the same side as the padding */
.latin-hint { font-size: 13px; font-weight: 600; color: #9A6405; }
.google-chip { justify-content: center; padding: 10px 14px; margin-block-end: 18px; border-radius: 999px; background: var(--bg-sunken); font-weight: 600; font-size: 14.5px; }
.google-chip .g-logo { width: 20px; height: 20px; }
.pw-wrap .input { padding-inline-end: 50px; }
.pw-wrap .icon-btn { position: absolute; top: 50%; transform: translateY(-50%); inset-inline-end: 8px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin-block: 18px 14px; color: var(--text-3); font-size: 13.5px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line-2); }
.btn-google { --b-bg: var(--bg-elev); --b-fg: var(--text); --b-bd: var(--line-2); font-weight: 600; }
.g-logo { width: 20px; height: 20px; flex-shrink: 0; }
.google-row { display: flex; align-items: center; gap: 12px; margin-block-end: 14px; }
.google-row .g-logo { width: 28px; height: 28px; }
.google-row b { display: block; }
.google-row span { font-size: 13.5px; }
.privacy-note { display: flex; align-items: center; gap: 8px; justify-content: center; font-size: 13px; color: var(--text-3); }
.privacy-note svg { width: 16px; height: 16px; color: var(--peste); flex-shrink: 0; }
.avatar-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 0; flex-shrink: 0; color: #fff; font-weight: 800; font-size: 15px;
  background: linear-gradient(135deg, var(--firoozeh), var(--lajvard)); box-shadow: 0 3px 10px color-mix(in srgb, var(--firoozeh) 35%, transparent);
  transition: transform .15s var(--ease);
}
.avatar-btn:active { transform: scale(.92); }
.account-card { margin-block-end: 18px; }
.account-id { display: flex; align-items: center; gap: 16px; margin-block-end: 22px; }
.account-id b { display: block; font-size: 19px; }
.account-id span { font-size: 13.5px; }
.avatar-lg { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 26px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--firoozeh), var(--lajvard)); }
.account-h { font-size: 17px; margin-block-end: 14px; }
.danger-zone { border-color: color-mix(in srgb, var(--anar) 30%, var(--line)); }
.glance-signup { padding: 30px; display: flex; align-items: center; gap: 22px; flex-wrap: wrap; position: relative; overflow: hidden; }
.glance-signup .girih { --girih-opacity: .06; }
.glance-signup h3 { font-size: 20px; margin-block-end: 6px; }
.glance-signup p { color: var(--text-2); }
@media (max-width: 560px) { .hide-sm { display: none !important; } .auth-card { padding: 26px 20px 20px; } }

/* ==========================================================================
   Teacher & advisor portals, sharing
   ========================================================================== */
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.group-card { display: flex; align-items: center; gap: 14px; padding: 18px; }
.group-card b { display: block; font-size: 16.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-card .faint { font-size: 13.5px; }
.group-card .chev { width: 18px; height: 18px; color: var(--text-3); }
.code-box { display: flex; align-items: center; gap: 16px; padding: 12px 14px 12px 18px; }
.code-box .k { font-size: 12.5px; color: var(--text-3); }
.code-box .v { font-family: var(--font-mono); font-size: 22px; font-weight: 700; letter-spacing: .12em; }
.small-help { font-size: 14px; margin-block-end: 14px; }
.small { font-size: 13px; }
.up { color: #4F7420; }
.down { color: var(--anar); }
:root[data-theme="dark"] .up { color: var(--peste); }
.avatar-sm { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; color: #fff; font-weight: 800;
  background: linear-gradient(135deg, var(--firoozeh), var(--lajvard)); }
.flag { height: 22px; gap: 4px; }
.flag svg { width: 13px; height: 13px; }
.attention-row, .member-main { display: flex; align-items: center; gap: 12px; padding: 12px; margin-inline: -12px; border-radius: var(--radius); color: inherit; min-width: 0; }
.attention-row:hover, .member-main:hover { background: var(--bg-hover); }
.attention-row .chev, .member-main .chev { width: 18px; height: 18px; color: var(--text-3); flex-shrink: 0; }
.insight { font-size: 14.5px; color: var(--text-2); margin-block-start: 3px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.two-col .account-card { margin-block-end: 18px; }
.topic-row { padding-block: 9px; }
.topic-row + .topic-row { border-block-start: 1px solid var(--line); }
.topic-name { font-weight: 600; min-width: 0; }
.bar { height: 7px; border-radius: 99px; background: var(--bg-sunken); overflow: hidden; margin-block: 7px 5px; }
.bar span { display: block; height: 100%; border-radius: inherit; background: var(--peste); }
.bar span.mid { background: var(--zaferan); }
.bar span.bad { background: var(--anar); }
.missed-row { padding-block: 10px; }
.missed-row + .missed-row { border-block-start: 1px solid var(--line); }
.missed-text { font-weight: 600; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-block-end: 4px; }
.member-row { display: flex; align-items: center; gap: 6px; }
.member-row + .member-row { border-block-start: 1px solid var(--line); }
.member-main { flex: 1; }
.member-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; margin-block-start: 3px; }
.soft-rule { border: 0; border-block-start: 1px solid var(--line); margin-block: 18px; }
.study-compare { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-block-end: 18px; }
.study-compare > div { background: var(--bg-sunken); border-radius: var(--radius); padding: 14px 16px; }
.study-compare .k { font-size: 12.5px; color: var(--text-3); }
.study-compare .v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.study-compare .small-v { font-size: 15px; font-weight: 700; }
.sub-h { font-size: 14.5px; font-weight: 700; color: var(--text-2); margin-block: 14px 8px; }
.event-row { display: flex; align-items: center; gap: 10px; padding-block: 8px; font-size: 14.5px; }
.event-row + .event-row { border-block-start: 1px solid var(--line); }
.event-row .event-when { font-size: 13px; flex-shrink: 0; }
.dot-c { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.share-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.share-list li { display: flex; align-items: flex-start; gap: 9px; font-size: 14.5px; }
.share-list svg { width: 18px; height: 18px; flex-shrink: 0; margin-block-start: 2px; }
.share-list .yes svg { color: #4F7420; }
.share-list .no svg { color: var(--anar); }
:root[data-theme="dark"] .share-list .yes svg { color: var(--peste); }
.share-row .share-list { margin-block-start: 8px; }
.share-row .share-list li { font-size: 13.5px; color: var(--text-2); }
.consent { border-color: color-mix(in srgb, var(--firoozeh) 35%, var(--line)); }
.share-row { display: flex; align-items: flex-start; gap: 12px; padding-block: 12px; }
.share-row + .share-row { border-block-start: 1px solid var(--line); }
.log-row { display: flex; align-items: flex-start; gap: 10px; padding-block: 9px; font-size: 14.5px; }
.log-row + .log-row { border-block-start: 1px solid var(--line); }
.log-row > svg { width: 18px; height: 18px; color: var(--text-3); flex-shrink: 0; margin-block-start: 3px; }
.code-input { font-family: var(--font-mono); letter-spacing: .12em; text-transform: uppercase; }
@media (max-width: 720px) {
  .two-col { grid-template-columns: 1fr; gap: 0; }
  .study-compare { grid-template-columns: 1fr 1fr; }
  .code-box { width: 100%; justify-content: space-between; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .up, :root:not([data-theme="light"]) .share-list .yes svg { color: var(--peste); }
}

/* ==========================================================================
   Class management: tabs, gradebook, exam builder, grading, assignments
   ========================================================================== */
.class-head { margin-block-end: 18px; }
.class-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-block-end: 22px; padding: 4px;
  background: var(--bg-sunken); border-radius: 999px; }
.class-tabs::-webkit-scrollbar { display: none; }
.class-tabs a { display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0; height: 38px; padding-inline: 16px; border-radius: 999px;
  color: var(--text-2); font-weight: 600; font-size: 14.5px; transition: background .15s var(--ease), color .15s var(--ease); }
.class-tabs a svg { width: 17px; height: 17px; }
.class-tabs a:hover { color: var(--text); }
.class-tabs a.active { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-1); }
.inline-ic { width: 15px; height: 15px; vertical-align: -3px; margin-inline-end: 4px; }
.rot180 { transform: rotate(180deg); }
.table-wrap { overflow-x: auto; margin-inline: -8px; }
.gradebook { width: 100%; border-collapse: collapse; font-size: 14.5px; min-width: 760px; }
.gradebook th { text-align: start; font-size: 12.5px; font-weight: 700; color: var(--text-3); padding: 8px; white-space: nowrap; cursor: pointer; user-select: none; }
.gradebook th[data-dir="asc"]::after { content: " ↑"; }
.gradebook th[data-dir="desc"]::after { content: " ↓"; }
.gradebook td { padding: 10px 8px; border-block-start: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.gradebook tbody tr:hover { background: var(--bg-hover); }
.gb-name { display: flex; align-items: center; gap: 10px; color: inherit; }
.gb-name b { display: block; }
.gb-flags { margin-block-start: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
.gb-flags:empty { display: none; }
.lock { width: 15px; height: 15px; }
.lock-note { display: flex; align-items: center; gap: 6px; margin-block-start: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1.4fr .8fr; gap: 14px; }
.builder-bar { margin: 22px 4px 12px; }
.builder-bar .warn b { color: var(--anar); }
.builder-q { display: grid; gap: 10px; }
.builder-q .q-head { align-items: center; gap: 8px; }
.builder-q .icon-btn[disabled] { opacity: .3; }
.choice-edit { display: grid; gap: 8px; }
.choice-row { display: flex; align-items: center; gap: 8px; }
.choice-row .input { flex: 1; height: 44px; }
.choice-correct { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; font-weight: 700; min-width: 54px; }
.choice-correct input { accent-color: var(--peste); width: 18px; height: 18px; }
.builder-points { gap: 10px; }
.builder-points .input { width: 96px; height: 42px; }
.builder-add { display: flex; gap: 10px; flex-wrap: wrap; margin-block: 14px; }
.builder-save { display: flex; justify-content: flex-end; margin-block: 18px 40px; }
.bank-list { display: grid; gap: 8px; margin-block-start: 12px; max-height: 50vh; overflow-y: auto; }
.bank-item { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; font-size: 14.5px; }
.bank-item:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.bank-item input { margin-block-start: 5px; accent-color: var(--accent); }
.action-row { display: flex; gap: 10px; flex-wrap: wrap; margin-block: -10px 22px; }
.to-grade { border-color: color-mix(in srgb, var(--zaferan) 45%, var(--line)); }
.result-row { padding-block: 10px; gap: 12px; }
.score-input { width: 92px; height: 40px; text-align: center; font-variant-numeric: tabular-nums; }
.q-preview { margin: 0; padding-inline-start: 1.4em; display: grid; gap: 12px; }
.q-preview ul { margin: 6px 0; padding-inline-start: 1.2em; color: var(--text-2); }
.q-preview .is-correct { color: #4F7420; font-weight: 700; }
.due-row { display: flex; gap: 10px; flex-wrap: wrap; }
.due-row > .input { width: auto; flex: 1; min-width: 140px; }
.jdate { display: flex; gap: 8px; flex: 2; min-width: 240px; }
.jdate select { flex: 1; min-width: 0; }
.assistant .avatar { background: linear-gradient(135deg, var(--yasi), var(--lajvard)); }
.assistant-log { display: grid; gap: 10px; margin-block: 14px; }
.assistant-log:empty { display: none; }
.a-msg { max-width: 88%; padding: 10px 14px; border-radius: 18px; font-size: 14.5px; }
.a-msg p { margin: 0; }
.a-msg p + p { margin-block-start: 6px; }
.a-msg.me { justify-self: end; background: var(--accent); color: var(--on-accent); border-end-end-radius: 6px; }
.a-msg.ai { justify-self: start; background: var(--bg-sunken); border-end-start-radius: 6px; }
.composer-lite { display: flex; gap: 10px; align-items: flex-end; }
.composer-lite .textarea { flex: 1; }
.needs-grade { border-color: color-mix(in srgb, var(--zaferan) 55%, var(--line)); }
.answer-box.key { border-style: dashed; }
.grade-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.grade-row .label { margin: 0; }
.quick-pts { display: flex; gap: 6px; }
.quick-pts .chip { height: 32px; padding-inline: 12px; }
.consent-update { margin-block-start: 10px; padding: 10px 12px; border-radius: var(--radius); background: var(--zaferan-soft); font-size: 13.5px; }
.consent-update p { margin: 0 0 8px; }
@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .composer-lite { flex-direction: column; align-items: stretch; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .q-preview .is-correct { color: var(--peste); }
  :root:not([data-theme="light"]) .consent-update { background: color-mix(in srgb, var(--zaferan) 14%, transparent); }
}
:root[data-theme="dark"] .q-preview .is-correct { color: var(--peste); }
:root[data-theme="dark"] .consent-update { background: color-mix(in srgb, var(--zaferan) 14%, transparent); }
