/* ===== API docs (api-docs.html / docs.js) ===== */
:root {
  --dx-code-bg: #0b1020;
  --dx-code-fg: #e2e8f0;
  --dx-code-border: rgba(148, 163, 184, 0.18);
  --dx-get: #059669;
  --dx-maxw: 1240px;
}
[hidden] { display: none !important; }
html { scroll-padding-top: 84px; }
body { background: var(--bg-primary); }

.skip-link { position: absolute; right: -9999px; top: 8px; z-index: 100; padding: 8px 14px; border-radius: 8px; background: var(--accent); color: #fff; }
.skip-link:focus { right: 12px; }

/* ---------- header ---------- */
.dx-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 20px;
  padding: 12px max(16px, calc((100% - var(--dx-maxw)) / 2));
  /* Opaque: with a translucent bar the text scrolling under it shows through. */
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}
.dx-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text-primary); }
.dx-logo__mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.dx-logo b { display: block; font-size: 16px; font-weight: 900; }
.dx-logo small { display: block; font-size: 11px; color: var(--text-secondary); direction: ltr; text-align: right; }
.dx-nav { display: flex; gap: 4px; margin-inline-start: 12px; }
.dx-nav a { padding: 8px 12px; border-radius: 10px; color: var(--text-secondary); text-decoration: none; font-size: 14px; font-weight: 600; }
.dx-nav a:hover { color: var(--text-primary); background: var(--bg-secondary); }
.dx-actions { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
@media (max-width: 760px) { .dx-nav { display: none; } .dx-actions .dx-btn span.hide-sm { display: none; } }

.dx-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: 12px; border: 1px solid transparent;
  font-family: 'Vazirmatn', sans-serif; font-size: 14px; font-weight: 700; text-decoration: none; cursor: pointer;
  transition: transform .2s, box-shadow .2s, background .2s;
}
.dx-btn--primary { color: #fff; background: linear-gradient(135deg, var(--accent), #4f46e5); box-shadow: 0 8px 20px rgba(99, 102, 241, .28); }
.dx-btn--primary:hover { transform: translateY(-2px); }
.dx-btn--ghost { color: var(--text-primary); background: transparent; border-color: var(--border-bright); }
.dx-btn--ghost:hover { border-color: var(--accent); }
.dx-btn--lg { min-height: 48px; padding: 10px 22px; font-size: 15px; }
.dx-icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border-bright); background: var(--bg-card); color: var(--text-primary); cursor: pointer;
}

/* ---------- hero ---------- */
.dx-hero {
  padding: 56px 16px 48px;
  background:
    radial-gradient(900px 380px at 85% -10%, rgba(99, 102, 241, .22), transparent 60%),
    radial-gradient(700px 320px at 5% 110%, rgba(14, 116, 144, .18), transparent 60%);
  border-bottom: 1px solid var(--border);
}
.dx-hero__inner { max-width: var(--dx-maxw); margin: 0 auto; }
.dx-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px; background: var(--bg-card); border: 1px solid var(--border); font-size: 12px; font-weight: 700; direction: ltr; }
.dx-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(16, 185, 129, .2); }
.dx-hero h1 { margin-top: 18px; font-size: clamp(1.7rem, 4vw, 2.8rem); line-height: 1.45; font-weight: 900; max-width: 820px; }
.dx-hero h1 em { font-style: normal; background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.dx-hero p { margin-top: 14px; max-width: 720px; color: var(--text-secondary); font-size: 16px; line-height: 2; }
.dx-base {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 22px; padding: 8px 8px 8px 14px; max-width: 100%;
  border-radius: 14px; background: var(--dx-code-bg); color: var(--dx-code-fg); border: 1px solid var(--dx-code-border);
}
.dx-base__label { padding: 4px 10px; border-radius: 8px; background: rgba(99, 102, 241, .25); color: #c7d2fe; font-size: 12px; font-weight: 800; direction: ltr; }
.dx-base code { font-size: 14px; overflow-x: auto; white-space: nowrap; }
.dx-hero__ctas { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.dx-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 34px; list-style: none; padding: 0; max-width: 760px; }
.dx-facts li { padding: 14px; border-radius: 14px; background: var(--bg-card); border: 1px solid var(--border); }
.dx-facts b { display: block; font-size: 1.35rem; font-weight: 900; }
.dx-facts span { font-size: 12px; color: var(--text-secondary); }
@media (max-width: 640px) { .dx-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dx-hero { padding-top: 36px; } }

/* ---------- layout ---------- */
.dx-layout {
  display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 40px;
  max-width: var(--dx-maxw); margin: 0 auto; padding: 32px 16px 60px;
}
.dx-toc { position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 100px); overflow-y: auto; }
.dx-toc__group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 22px; }
.dx-toc__group > span { font-size: 11px; font-weight: 800; color: var(--text-muted); margin: 0 10px 6px; letter-spacing: .02em; }
.dx-toc a {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 9px;
  color: var(--text-secondary); text-decoration: none; font-size: 14px; border-inline-start: 2px solid transparent;
}
.dx-toc a:hover { color: var(--text-primary); background: var(--bg-secondary); }
.dx-toc a.active { color: var(--accent); background: rgba(99, 102, 241, .08); border-inline-start-color: var(--accent); font-weight: 700; }
.dx-toc .m { font-size: 9px; padding: 2px 5px; border-radius: 5px; background: rgba(5, 150, 105, .12); color: var(--dx-get); direction: ltr; }
@media (max-width: 960px) {
  /* header (65px) + the sticky contents strip (50px) */
  html { scroll-padding-top: 124px; }
  .dx-layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 0; }
  .dx-toc {
    position: sticky; top: 64px; z-index: 40; max-height: none; display: flex; gap: 6px; overflow-x: auto;
    margin: 0 -16px 18px; padding: 10px 16px; background: var(--bg-primary);
    border-bottom: 1px solid var(--border); scrollbar-width: none;
  }
  .dx-toc__group { flex-direction: row; margin: 0; }
  .dx-toc__group > span { display: none; }
  .dx-toc a { white-space: nowrap; border: 1px solid var(--border); border-radius: 99px; padding: 6px 12px; font-size: 13px; }
  .dx-toc a.active { border-color: var(--accent); }
}

/* ---------- content ---------- */
.dx-content { min-width: 0; }
.dx-section { padding: 26px 0 34px; border-bottom: 1px solid var(--border); }
.dx-section:last-of-type { border-bottom: none; }
.dx-section h2 { display: flex; align-items: center; gap: 10px; font-size: 1.45rem; font-weight: 900; margin-bottom: 12px; }
.dx-section h2 i { color: var(--accent); font-size: .9em; }
.dx-section > p, .dx-card p { color: var(--text-secondary); line-height: 2; font-size: 15px; }
.dx-section a { color: var(--accent); }
.dx-sub { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 800; margin: 22px 0 10px; color: var(--text-primary); }
.dx-muted { color: var(--text-muted) !important; font-size: 13px !important; margin-top: 10px; }
.dx-content :not(pre) > code {
  padding: 2px 6px; border-radius: 6px; background: var(--bg-secondary); border: 1px solid var(--border);
  font-size: .86em; direction: ltr; unicode-bidi: isolate; color: var(--text-primary);
}

.dx-ep { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 10px; padding: 6px 6px 6px 12px; border-radius: 12px; background: var(--bg-card); border: 1px solid var(--border); max-width: 100%; }
.dx-method { padding: 4px 10px; border-radius: 8px; background: rgba(5, 150, 105, .14); color: var(--dx-get); font: 800 12px/1.4 ui-monospace, monospace; direction: ltr; }
.dx-method.sm { padding: 3px 8px; font-size: 11px; }
.dx-path { font: 600 15px/1.4 ui-monospace, monospace; color: var(--text-primary); overflow-x: auto; white-space: nowrap; }
.dx-var { color: var(--accent); }
.dx-tag { padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 800; background: var(--bg-secondary); color: var(--text-secondary); }
.dx-tag.ok { background: rgba(16, 185, 129, .14); color: #047857; }
body.dark-mode .dx-tag.ok { color: var(--green); }

.dx-steps { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 8px 0 18px; }
.dx-steps li { display: flex; gap: 12px; padding: 16px; border-radius: 16px; background: var(--bg-card); border: 1px solid var(--border); }
.dx-steps__n { flex-shrink: 0; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; font-weight: 900; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.dx-steps h3 { font-size: 15px; margin-bottom: 4px; }
.dx-steps p { font-size: 13px; color: var(--text-secondary); line-height: 1.9; }
@media (max-width: 760px) { .dx-steps { grid-template-columns: minmax(0, 1fr); } }

.dx-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 12px; }
@media (max-width: 760px) { .dx-grid-2 { grid-template-columns: minmax(0, 1fr); } }
.dx-card { min-width: 0; padding: 18px; border-radius: 16px; background: var(--bg-card); border: 1px solid var(--border); }
.dx-card h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; margin-bottom: 10px; }
.dx-card.tip > i { display: grid; place-items: center; width: 40px; height: 40px; margin-bottom: 10px; border-radius: 12px; color: var(--accent); background: rgba(99, 102, 241, .1); font-size: 17px; }
.dx-card.tip p { font-size: 14px; }

.dx-callout { display: flex; gap: 14px; margin-top: 16px; padding: 16px; border-radius: 16px; background: rgba(99, 102, 241, .07); border: 1px solid rgba(99, 102, 241, .25); line-height: 2; font-size: 14px; }
.dx-callout > i { color: var(--accent); font-size: 20px; margin-top: 6px; }

/* tables */
.dx-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--bg-card); }
.dx-table th { padding: 11px 14px; text-align: right; font-size: 12px; color: var(--text-secondary); background: var(--bg-secondary); }
.dx-table td { padding: 11px 14px; border-top: 1px solid var(--border); vertical-align: top; line-height: 1.9; }
@media (max-width: 640px) {
  .dx-table, .dx-table tbody, .dx-table tr, .dx-table td { display: block; width: 100%; }
  .dx-table thead { display: none; }
  .dx-table tr { padding: 10px 0; border-top: 1px solid var(--border); }
  .dx-table td { border: none; padding: 3px 14px; }
}
.dx-code-badge { display: inline-block; padding: 3px 9px; border-radius: 8px; font: 800 12px/1.4 ui-monospace, monospace; }
.dx-code-badge.warn { background: var(--gold-bg); color: #b45309; }
.dx-code-badge.bad { background: var(--red-bg); color: #b91c1c; }
body.dark-mode .dx-code-badge.warn { color: var(--gold); }
body.dark-mode .dx-code-badge.bad { color: var(--red); }

/* plans */
.dx-plans { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
@media (max-width: 760px) { .dx-plans { grid-template-columns: minmax(0, 1fr); } }
.dx-plan { padding: 20px; border-radius: 16px; background: var(--bg-card); border: 1px solid var(--border); }
.dx-plan.featured { border: 2px solid var(--accent); }
.dx-plan h3 { font-size: 15px; margin-bottom: 6px; }
.dx-plan__price { font-size: 1.7rem; font-weight: 900; direction: ltr; text-align: right; }
.dx-plan__price small { font-size: 13px; color: var(--text-secondary); font-weight: 600; }
.dx-plan ul { list-style: none; padding: 0; margin-top: 10px; font-size: 14px; color: var(--text-secondary); line-height: 2.1; }
.dx-plan li::before { content: '✓ '; color: var(--green); font-weight: 900; }

/* ---------- code ---------- */
.dx-pre {
  margin: 0; padding: 16px 18px; border-radius: 14px; overflow-x: auto;
  background: var(--dx-code-bg); color: var(--dx-code-fg); border: 1px solid var(--dx-code-border);
  font: 13px/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-align: left; tab-size: 2;
}
.dx-pre .k { color: #93c5fd; }   /* key */
.dx-pre .s { color: #86efac; }   /* string */
.dx-pre .n { color: #fbbf24; }   /* number */
.dx-pre .b { color: #f472b6; }   /* bool / null */
.dx-pre .c { color: #64748b; }   /* comment */

.dx-code { margin: 6px 0; border-radius: 14px; overflow: hidden; border: 1px solid var(--dx-code-border); background: var(--dx-code-bg); }
.dx-code__tabs { display: flex; align-items: center; gap: 2px; padding: 6px; background: rgba(255, 255, 255, .03); border-bottom: 1px solid var(--dx-code-border); direction: ltr; }
.dx-code__tabs button {
  padding: 6px 12px; border: none; border-radius: 8px; background: transparent; color: #94a3b8;
  font: 600 12px/1 ui-monospace, monospace; cursor: pointer;
}
.dx-code__tabs button.active { background: rgba(99, 102, 241, .25); color: #e0e7ff; }
.dx-code__tabs .dx-copy { margin-left: auto; }
.dx-code .dx-pre { border: none; border-radius: 0; }
.dx-copy {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--dx-code-border); background: rgba(255, 255, 255, .06); color: #cbd5e1; cursor: pointer;
}
.dx-copy:hover { color: #fff; background: rgba(255, 255, 255, .12); }

/* ---------- symbols ---------- */
.dx-symfilter { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 14px; }
.dx-symfilter button {
  padding: 7px 14px; border-radius: 99px; border: 1px solid var(--border-bright); background: var(--bg-card);
  color: var(--text-secondary); font-family: 'Vazirmatn', sans-serif; font-size: 13px; font-weight: 700; cursor: pointer;
}
.dx-symfilter button.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.dx-symbols { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.dx-sym {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; min-width: 0;
  background: var(--bg-card); border: 1px solid var(--border); cursor: pointer; text-align: right;
  font-family: 'Vazirmatn', sans-serif; color: var(--text-primary);
}
.dx-sym:hover { border-color: var(--accent); }
.dx-sym code { font: 700 13px/1.3 ui-monospace, monospace; color: var(--accent); direction: ltr; }
.dx-sym span { display: block; font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dx-sym > div { min-width: 0; }

/* ---------- playground ---------- */
.dx-pg { padding: 20px; border-radius: 18px; background: var(--bg-card); border: 1px solid var(--border); }
.dx-pg__row { margin-bottom: 14px; }
.dx-pg__row > label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.dx-input-group { display: flex; align-items: center; gap: 6px; padding: 4px; border-radius: 12px; border: 1px solid var(--border-bright); background: var(--bg-primary); direction: ltr; }
.dx-input-group:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, .15); }
.dx-input-group input { flex: 1; min-width: 0; padding: 9px 10px; border: none; outline: none; background: transparent; color: var(--text-primary); font: 14px ui-monospace, monospace; }
.dx-input-group .dx-icon-btn { width: 36px; height: 36px; }
.dx-prefix { font: 13px ui-monospace, monospace; color: var(--text-muted); }
.dx-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.dx-presets button { padding: 5px 11px; border-radius: 99px; border: 1px dashed var(--border-bright); background: transparent; color: var(--text-secondary); font-family: 'Vazirmatn', sans-serif; font-size: 12px; cursor: pointer; }
.dx-presets button:hover { border-color: var(--accent); color: var(--accent); }
.dx-pg__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.dx-pg__meta { font-size: 13px; color: var(--text-secondary); direction: ltr; }
.dx-pg__meta b.ok { color: var(--green); }
.dx-pg__meta b.bad { color: var(--red); }
.dx-pg__out { border-radius: 14px; overflow: hidden; border: 1px solid var(--dx-code-border); }
.dx-pg__outhead { display: flex; justify-content: space-between; align-items: center; padding: 6px 6px 6px 14px; background: #111832; color: #94a3b8; font: 600 12px ui-monospace, monospace; direction: ltr; }
.dx-pg__out .dx-pre { border: none; border-radius: 0; max-height: 460px; }

.dx-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding-top: 26px; font-size: 13px; color: var(--text-muted); }
.dx-footer a { color: var(--text-secondary); }

.dx-toast {
  position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 16px); z-index: 200;
  padding: 9px 20px; border-radius: 99px; background: #0f172a; color: #fff; font-size: 13px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: all .25s;
}
.dx-toast.show { opacity: 1; transform: translate(-50%, 0); }
