@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --ink: #141a2e;
  --ink-2: #4a5272;
  --ink-3: #7c84a3;
  --line: #e1e5f0;
  --brand: #3b5bfd;
  --brand-2: #6d3bfd;
  --brand-ink: #ffffff;
  --accent: #10b39a;
  --warn: #e8890c;
  --danger: #e0435c;
  --ok: #12a46b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 26, 46, .06), 0 8px 28px rgba(20, 26, 46, .07);
  --hero-grad: radial-gradient(1200px 500px at 80% -10%, rgba(109, 59, 253, .18), transparent 60%),
               radial-gradient(900px 500px at 0% 10%, rgba(59, 91, 253, .16), transparent 60%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0f1c;
    --surface: #141a2e;
    --surface-2: #1b2240;
    --ink: #eef0fa;
    --ink-2: #b5bbd6;
    --ink-3: #848cad;
    --line: #262e50;
    --brand: #6f87ff;
    --brand-2: #9b7bff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Vazirmatn", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.9;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.45; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.ltr { direction: ltr; unicode-bidi: plaintext; }

/* ---------- buttons & inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font: inherit; font-weight: 600; font-size: .95rem;
  padding: .7em 1.4em; border-radius: 12px; border: 1px solid transparent;
  cursor: pointer; transition: transform .12s, box-shadow .12s, background .12s;
  background: var(--surface-2); color: var(--ink);
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: var(--brand-ink); box-shadow: 0 6px 20px rgba(59, 91, 253, .35);
}
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--line); }
.btn.sm { padding: .35em .9em; font-size: .85rem; border-radius: 9px; }

input, textarea, select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: .7em .9em; width: 100%;
  outline: none; transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(59, 91, 253, .15); }
textarea { resize: vertical; min-height: 110px; line-height: 1.8; }
label { font-weight: 600; font-size: .9rem; display: block; margin-bottom: .35em; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.pill {
  display: inline-flex; align-items: center; gap: .4em; font-size: .8rem; font-weight: 600;
  padding: .2em .8em; border-radius: 999px; background: var(--surface-2); color: var(--ink-2);
}
.dot { width: .55em; height: .55em; border-radius: 50%; background: var(--ink-3); display: inline-block; }
.dot.ready { background: var(--ok); box-shadow: 0 0 0 3px rgba(18, 164, 107, .2); }
.dot.starting, .dot.downloading, .dot.processing, .dot.queued { background: var(--warn); animation: pulse 1.2s infinite; }
.dot.error { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- nav */
.nav {
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--bg) 80%, transparent); border-bottom: 1px solid var(--line);
}
.nav .wrap { display: flex; align-items: center; gap: 24px; height: 66px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; color: var(--ink); }
.logo-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-size: .8rem; font-weight: 800;
  letter-spacing: .5px;
}
.nav-links { display: flex; gap: 22px; margin-inline-start: auto; }
.nav-links a { color: var(--ink-2); font-weight: 500; font-size: .95rem; }
.nav-links a:hover { color: var(--ink); }
@media (max-width: 820px) { .nav-links { display: none; } .nav .btn { margin-inline-start: auto; } }

/* ---------- hero */
.hero { background: var(--hero-grad); padding: 84px 0 64px; }
.hero-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(2rem, 4.4vw, 3.3rem); font-weight: 900; letter-spacing: -.5px; }
.hero h1 .grad { background: linear-gradient(135deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lead { font-size: 1.15rem; color: var(--ink-2); max-width: 36em; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; margin: 26px 0 22px; }
.trust { display: flex; gap: 18px; flex-wrap: wrap; color: var(--ink-2); font-size: .9rem; }
.trust span::before { content: "✓"; color: var(--accent); font-weight: 800; margin-inline-end: .4em; }
.hero-card { padding: 22px; }
.mock-q { background: var(--surface-2); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-weight: 600; }
.mock-a { font-size: .95rem; color: var(--ink-2); }
.mock-src { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } .hero { padding-top: 48px; } }

/* ---------- sections */
section.block { padding: 76px 0; }
section.alt { background: var(--surface); border-block: 1px solid var(--line); }
.sec-head { text-align: center; max-width: 760px; margin: 0 auto 44px; }
.sec-head h2 { font-size: clamp(1.6rem, 3vw, 2.3rem); font-weight: 800; }
.eyebrow { color: var(--brand); font-weight: 700; font-size: .9rem; margin-bottom: .4em; display: block; }

.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 960px) { .g3, .g4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

.feature { padding: 24px; }
.feature .ic {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem;
  background: color-mix(in srgb, var(--brand) 12%, transparent); margin-bottom: 14px;
}
.feature h3 { font-size: 1.08rem; font-weight: 700; }
.feature p { color: var(--ink-2); font-size: .94rem; margin: 0; }

.stat { text-align: center; padding: 26px 16px; }
.stat b { display: block; font-size: 2.1rem; font-weight: 900; color: var(--brand); }
.stat span { color: var(--ink-2); font-size: .92rem; }

.steps { counter-reset: s; }
.step { padding: 26px; position: relative; }
.step::before {
  counter-increment: s; content: counter(s, persian);
  position: absolute; top: -16px; inset-inline-start: 24px; width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; display: grid; place-items: center; font-weight: 800;
}

.compare { width: 100%; border-collapse: collapse; font-size: .95rem; }
.compare th, .compare td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: start; }
.compare th { background: var(--surface-2); font-weight: 700; }
.compare td.y { color: var(--ok); font-weight: 700; }
.compare td.n { color: var(--danger); }
.table-wrap { overflow-x: auto; }

.plan { padding: 28px; display: flex; flex-direction: column; }
.plan.featured { border: 2px solid var(--brand); position: relative; }
.plan.featured::after {
  content: "پیشنهاد ویژه"; position: absolute; top: -13px; inset-inline-start: 24px; font-size: .78rem; font-weight: 700;
  background: var(--brand); color: #fff; padding: 2px 12px; border-radius: 999px;
}
.plan ul { padding: 0; list-style: none; margin: 14px 0 22px; flex: 1; }
.plan li { padding: 6px 0; color: var(--ink-2); }
.plan li::before { content: "✓"; color: var(--accent); font-weight: 800; margin-inline-end: .6em; }
.plan .price { font-size: 1.35rem; font-weight: 800; margin: 6px 0; }

details.faq { padding: 4px 22px; margin-bottom: 12px; }
details.faq summary { cursor: pointer; font-weight: 700; padding: 14px 0; list-style: none; }
details.faq summary::after { content: "+"; float: left; color: var(--brand); font-size: 1.3rem; }
details.faq[open] summary::after { content: "−"; }
details.faq p { color: var(--ink-2); }

.cta-band {
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  border-radius: 24px; padding: 48px; text-align: center;
}
.cta-band p { opacity: .9; }
.cta-band .btn { background: #fff; color: var(--brand); }

footer { padding: 36px 0; color: var(--ink-3); font-size: .9rem; border-top: 1px solid var(--line); }
footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---------- demo / playground */
.demo { display: grid; grid-template-columns: 260px 1fr; gap: 20px; }
@media (max-width: 860px) { .demo { grid-template-columns: 1fr; } }
.tabs { padding: 10px; display: flex; flex-direction: column; gap: 4px; height: fit-content; }
@media (max-width: 860px) { .tabs { flex-direction: row; overflow-x: auto; } .tabs button { white-space: nowrap; } }
.tabs button {
  font: inherit; text-align: start; padding: .65em 1em; border-radius: 10px; border: 0; cursor: pointer;
  background: transparent; color: var(--ink-2); font-weight: 600;
}
.tabs button.on { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.pane { padding: 22px; min-height: 520px; display: flex; flex-direction: column; }
.chat-log { flex: 1; overflow-y: auto; max-height: 560px; display: flex; flex-direction: column; gap: 14px; padding: 4px; margin-bottom: 14px; }
.msg { max-width: 92%; padding: 12px 16px; border-radius: 14px; }
.msg.user { align-self: flex-start; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border-end-start-radius: 4px; }
.msg.bot { align-self: flex-end; background: var(--surface-2); border-end-end-radius: 4px; width: 92%; }
.msg.bot .md > *:last-child { margin-bottom: 0; }
.msg .meta { font-size: .78rem; color: var(--ink-3); margin-top: 6px; }
.sources { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.src { font-size: .82rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.src summary { cursor: pointer; font-weight: 600; }
.src p { margin: 6px 0 2px; color: var(--ink-2); white-space: pre-wrap; }
.composer { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { min-height: 52px; height: 52px; }
.suggest { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.suggest button { font: inherit; font-size: .85rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: .3em .9em; cursor: pointer; }
.out { margin-top: 14px; padding: 16px; background: var(--surface-2); border-radius: 12px; min-height: 80px; }
.md table { border-collapse: collapse; width: 100%; margin: .6em 0; font-size: .92rem; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; }
.md pre { background: var(--surface); padding: 12px; border-radius: 10px; overflow-x: auto; direction: ltr; text-align: left; }
.md code { font-family: ui-monospace, Consolas, monospace; font-size: .88em; }
.md ul, .md ol { padding-inline-start: 1.4em; margin: .4em 0 .8em; }
.cursor::after { content: "▋"; animation: pulse 1s infinite; color: var(--brand); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.space { flex: 1; }

/* ---------- admin */
.admin-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
@media (max-width: 860px) { .admin-shell { grid-template-columns: 1fr; } .side { position: static !important; height: auto !important; } }
.side { background: var(--surface); border-inline-end: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.side nav { display: flex; flex-direction: column; gap: 4px; margin-top: 26px; }
.side nav button { font: inherit; text-align: start; padding: .65em 1em; border-radius: 10px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; font-weight: 600; }
.side nav button.on { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.main { padding: 28px; min-width: 0; }
.main h1 { font-size: 1.5rem; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
@media (max-width: 960px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { padding: 18px; }
.kpi b { display: block; font-size: 1.7rem; font-weight: 800; }
.kpi span { color: var(--ink-2); font-size: .88rem; }
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 36px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s; background: var(--surface);
}
.drop.over { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, var(--surface)); }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: middle; }
.tbl th { color: var(--ink-3); font-weight: 600; font-size: .82rem; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.model-opt { padding: 16px; cursor: pointer; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); }
.model-opt.on { border-color: var(--brand); }
.toast {
  position: fixed; bottom: 24px; inset-inline-start: 50%; transform: translateX(50%); z-index: 99;
  background: var(--ink); color: var(--bg); padding: 10px 20px; border-radius: 12px; box-shadow: var(--shadow);
  opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: none; place-items: center; z-index: 50; padding: 20px; }
.modal.show { display: grid; }
.modal .card { width: min(860px, 100%); max-height: 85vh; overflow-y: auto; padding: 24px; }
pre.log { direction: ltr; text-align: left; white-space: pre-wrap; font-size: .78rem; background: var(--surface-2); padding: 12px; border-radius: 10px; max-height: 360px; overflow: auto; }
.login { min-height: 100vh; display: grid; place-items: center; background: var(--hero-grad); padding: 20px; }
.login .card { width: min(400px, 100%); padding: 32px; }
.hidden { display: none !important; }
