:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f3f8;
  --text: #172033;
  --muted: #657085;
  --line: #dbe1ec;
  --accent: #315eeb;
  --accent-soft: #e9efff;
  --success: #178a54;
  --warning: #bd7a13;
  --danger: #c64242;
  --code-bg: #101725;
  --code-text: #e6edf7;
  --shadow: 0 12px 40px rgba(18, 28, 45, .08);
  --radius: 16px;
  --topbar-h: 68px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f141d;
  --surface: #151c29;
  --surface-2: #1c2535;
  --text: #e9edf5;
  --muted: #a2adbf;
  --line: #2b3649;
  --accent: #7ea2ff;
  --accent-soft: rgba(126, 162, 255, .14);
  --success: #5ed59a;
  --warning: #f0b35b;
  --danger: #ff7a7a;
  --code-bg: #0a0f18;
  --code-text: #f1f6ff;
  --shadow: 0 14px 45px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 18px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; font-size: .92em; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand { display: inline-flex; align-items: center; gap: 11px; min-width: 210px; }
.brand-mark {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  letter-spacing: .02em;
}
.brand-text { display: grid; line-height: 1.2; }
.brand-text strong { font-size: 15px; }
.brand-text small { color: var(--muted); font-size: 12px; }

.sdk-switch {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 999px;
}
.sdk-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
}
.sdk-tab.active { background: var(--surface); color: var(--accent); box-shadow: 0 2px 10px rgba(20, 30, 45, .08); }

.topnav { display: flex; align-items: center; justify-content: center; gap: 8px; }
.topnav a {
  color: var(--muted);
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
}
.topnav a:hover { color: var(--text); background: var(--surface-2); }

.top-actions { display: flex; align-items: center; gap: 8px; }
.theme-btn, .menu-btn, .button, .code-title button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
}
.theme-btn { display: inline-flex; align-items: center; gap: 8px; padding: 8px 11px; font-size: 13px; font-weight: 650; }
.theme-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.menu-btn { display: none; width: 38px; height: 38px; font-size: 20px; }

.page-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 28px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px;
}

.sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + 22px);
  align-self: start;
  height: calc(100vh - var(--topbar-h) - 44px);
  overflow: auto;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.search-card { display: grid; gap: 6px; margin-bottom: 16px; }
.search-card label, .side-heading { color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.search-card input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
  font: inherit;
}
.search-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.side-nav { display: grid; gap: 4px; margin-top: 8px; }
.side-nav a {
  color: var(--muted);
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
}
.side-nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav a.active { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }

.content { min-width: 0; display: grid; gap: 18px; }
.doc-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.doc-section.hidden-by-search { display: none; }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: stretch; }
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(28px, 4vw, 42px); line-height: 1.12; margin-bottom: 14px; letter-spacing: -.03em; }
h2 { font-size: 22px; line-height: 1.25; margin-bottom: 4px; letter-spacing: -.02em; }
h3 { font-size: 17px; line-height: 1.3; margin-bottom: 8px; }
p { color: var(--muted); margin-bottom: 14px; }
.hero-copy p { max-width: 790px; font-size: 15px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.button { display: inline-flex; align-items: center; justify-content: center; padding: 10px 14px; font-weight: 700; font-size: 13px; }
.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.button.soft { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.status-card {
  display: grid;
  align-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}
.status-card span, .cards-row span { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.status-card strong { font-size: 20px; }
.status-card p { margin: 0; }

.cards-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; background: transparent; border: 0; box-shadow: none; padding: 0; }
.cards-row article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.cards-row b { display: block; margin: 6px 0 5px; font-size: 15px; }
.cards-row p { margin: 0; font-size: 13px; }

.section-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.section-head > span {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
}
.section-head p { margin: 0; }

.code-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--code-bg);
  margin: 12px 0;
}
.code-card.compact { max-width: 560px; }
.code-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.04);
  color: #b8c5d9;
  font-size: 12px;
  font-weight: 750;
}
.code-title button { padding: 5px 9px; border-radius: 9px; font-size: 12px; color: #e8effc; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); }
pre { margin: 0; padding: 15px; overflow: auto; color: var(--code-text); font-size: 12.5px; line-height: 1.55; }
.code-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; margin: 12px 0; }
table { width: 100%; border-collapse: collapse; min-width: 620px; background: var(--surface); }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
td code { background: var(--surface-2); border: 1px solid var(--line); padding: 2px 5px; border-radius: 6px; }
tr:last-child td { border-bottom: 0; }

.note { border: 1px solid var(--line); border-radius: 14px; padding: 13px 14px; margin-top: 14px; background: var(--surface-2); color: var(--muted); }
.note b { color: var(--text); }
.note.info { border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); background: var(--accent-soft); }
.note.success { border-color: color-mix(in srgb, var(--success) 35%, var(--line)); background: color-mix(in srgb, var(--success) 10%, var(--surface)); }

.currency-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.currency-list span {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-weight: 750;
  color: var(--text);
  font-size: 12px;
}
.rules-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.rules-grid article { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: var(--surface-2); }
.rules-grid b { display: block; margin-bottom: 6px; }
.rules-grid p { margin: 0; font-size: 13px; }

.tabs { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.tab-nav { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.tab-nav button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 10px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}
.tab-nav button.active { color: var(--accent); background: var(--surface); border-color: var(--line); }
.tab-panel { display: none; padding: 18px; }
.tab-panel.active { display: block; }
.endpoint {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 10px;
}
.endpoint b { color: var(--success); font-size: 12px; }

.steps { counter-reset: item; display: grid; gap: 10px; padding-left: 0; margin: 0; list-style: none; }
.steps li { padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); color: var(--muted); }
.steps li b { color: var(--text); }

html[data-sdk="php"] .node-only { display: none !important; }
html[data-sdk="node"] .php-only { display: none !important; }

@media (max-width: 1100px) {
  .topnav { display: none; }
  .page-shell { grid-template-columns: 1fr; padding: 18px; }
  .sidebar { position: fixed; left: 18px; right: 18px; top: calc(var(--topbar-h) + 10px); height: auto; max-height: calc(100vh - var(--topbar-h) - 28px); transform: translateY(-12px); opacity: 0; pointer-events: none; transition: .18s ease; }
  body.sidebar-open .sidebar { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .menu-btn { display: inline-grid; place-items: center; }
  .hero { grid-template-columns: 1fr; }
  .cards-row, .rules-grid, .code-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .topbar { grid-template-columns: auto 1fr auto; padding: 0 14px; gap: 10px; }
  .brand { min-width: 0; }
  .brand-text small { display: none; }
  .sdk-switch { justify-self: center; }
  .theme-label { display: none; }
  .doc-section { padding: 16px; }
  h1 { font-size: 28px; }
  h2 { font-size: 19px; }
  pre { font-size: 11.5px; }
}

.lang-select {
  min-width: 132px;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 0 34px 0 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  outline: none;
  cursor: pointer;
}
.lang-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
html[dir="rtl"] body { direction: rtl; }
html[dir="rtl"] pre,
html[dir="rtl"] code,
html[dir="rtl"] .code-card { direction: ltr; text-align: left; }
html[dir="rtl"] th,
html[dir="rtl"] td { text-align: right; }
html[dir="rtl"] .code-title { direction: rtl; }
html[dir="rtl"] .brand-text,
html[dir="rtl"] .section-head,
html[dir="rtl"] .status-card,
html[dir="rtl"] .search-card { text-align: right; }

@media (max-width: 680px) {
  .lang-select { min-width: 96px; max-width: 118px; padding-left: 8px; padding-right: 8px; }
}
