:root {
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-elevated: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-soft: #64748b;
  --brand: #523dfb;
  --brand-hover: #4330d8;
  --brand-soft: #ede7ff;
  --brand-on-soft: #352c8a;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --inline-code-bg: #f1f5f9;
  --inline-code-text: #352c8a;

  --info-bg: #eff6ff;
  --info-border: #3b82f6;
  --info-text: #1e3a8a;

  --warning-bg: #fffbeb;
  --warning-border: #f59e0b;
  --warning-text: #78350f;

  --success-bg: #ecfdf5;
  --success-border: #10b981;
  --success-text: #065f46;

  --example-bg: #f5f3ff;
  --example-border: #7c3aed;
  --example-text: #4c1d95;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.08);
  --radius: 12px;
}

[data-theme="dark"] {
  --bg: #121318;
  --bg-subtle: #181a21;
  --bg-elevated: #1e2029;
  --border: #2c303d;
  --border-strong: #3b4152;
  --text: #f1f5f9;
  --text-muted: #cbd5e1;
  --text-soft: #94a3b8;
  --brand: #7b6bf3;
  --brand-hover: #9081ff;
  --brand-soft: rgba(123, 107, 243, 0.16);
  --brand-on-soft: #c7d2fe;
  --code-bg: #0b0c10;
  --code-text: #e2e8f0;
  --inline-code-bg: #262936;
  --inline-code-text: #c7d2fe;

  --info-bg: rgba(59, 130, 246, 0.12);
  --info-border: #60a5fa;
  --info-text: #dbeafe;

  --warning-bg: rgba(245, 158, 11, 0.12);
  --warning-border: #fbbf24;
  --warning-text: #fef3c7;

  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: #34d399;
  --success-text: #d1fae5;

  --example-bg: rgba(139, 92, 246, 0.14);
  --example-border: #a78bfa;
  --example-text: #ede9fe;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 12px 28px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}

a:hover {
  text-decoration: underline;
}

/* Topbar (oculta em ?embed=1) */
.docs-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 60px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.docs-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.docs-brand:hover {
  text-decoration: none;
}

.docs-brand-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-on-soft);
}

.docs-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.docs-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.docs-search-input {
  width: 240px;
  padding: 7px 12px 7px 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease;
}

.docs-search-input:focus {
  border-color: var(--brand);
}

.docs-search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-soft);
  pointer-events: none;
  font-size: 14px;
}

.docs-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.docs-icon-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

/* Layout shell */
.docs-shell {
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 210px;
  gap: 32px;
  padding: 28px 24px 64px;
}

.docs-sidebar {
  position: sticky;
  top: 84px;
  align-self: start;
}

.docs-nav-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  margin: 16px 0 8px 10px;
}

.docs-nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}

.docs-nav-link:hover {
  background: var(--bg-subtle);
  color: var(--text);
  text-decoration: none;
}

.docs-nav-link.active {
  background: var(--brand-soft);
  color: var(--brand-on-soft);
  font-weight: 700;
}

.docs-toc {
  position: sticky;
  top: 84px;
  align-self: start;
  border-left: 1px solid var(--border);
  padding-left: 16px;
}

.docs-toc-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  margin: 0 0 10px;
}

.docs-toc a {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
  padding: 4px 0;
}

.docs-toc a.active,
.docs-toc a:hover {
  color: var(--brand);
  text-decoration: none;
}

/* Main article */
.docs-main {
  min-width: 0;
}

.docs-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  color: var(--text-soft);
  margin-bottom: 12px;
}

.docs-embed-bar {
  display: none;
}

/* Modo embutido dentro da gaveta/tela do app (?embed=1) */
html.is-embed .docs-topbar,
html.is-embed .docs-sidebar,
html.is-embed .docs-toc,
html.is-embed .docs-footer {
  display: none !important;
}

html.is-embed .docs-shell {
  display: block;
  max-width: 760px;
  padding: 16px 18px 40px;
}

html.is-embed .docs-embed-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.docs-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-on-soft);
  background: var(--brand-soft);
  padding: 4px 10px;
  border-radius: 999px;
}

.docs-article h1 {
  font-size: clamp(24px, 3.2vw, 32px);
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin: 0 0 10px;
}

.docs-lead {
  font-size: 16px;
  color: var(--text-muted);
  margin: 0 0 20px;
}

.docs-article h2 {
  font-size: 20px;
  letter-spacing: -0.015em;
  margin: 28px 0 10px;
  padding-top: 6px;
  scroll-margin-top: 76px;
}

.docs-article h3 {
  font-size: 16px;
  margin: 20px 0 8px;
}

.docs-article p {
  margin: 0 0 14px;
  color: var(--text);
}

.docs-article ul,
.docs-article ol {
  margin: 0 0 16px;
  padding-left: 22px;
}

.docs-article li {
  margin-bottom: 8px;
}

.docs-article hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 26px 0;
}

.docs-article code {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 0.88em;
  background: var(--inline-code-bg);
  color: var(--inline-code-text);
  padding: 2px 6px;
  border-radius: 6px;
}

/* Callouts */
.callout {
  border-left: 4px solid var(--info-border);
  background: var(--info-bg);
  color: var(--info-text);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 16px;
  margin: 18px 0;
  font-size: 14.5px;
}

.callout-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.callout p:last-child {
  margin-bottom: 0;
  color: inherit;
}

.callout.warning {
  border-left-color: var(--warning-border);
  background: var(--warning-bg);
  color: var(--warning-text);
}

.callout.success {
  border-left-color: var(--success-border);
  background: var(--success-bg);
  color: var(--success-text);
}

.callout.example {
  border-left-color: var(--example-border);
  background: var(--example-bg);
  color: var(--example-text);
}

/* Quote */
blockquote.docs-quote {
  margin: 18px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--border-strong);
  background: var(--bg-subtle);
  border-radius: 0 10px 10px 0;
  color: var(--text-muted);
  font-style: italic;
}

/* Collapsible details ([!COLLAPSE]) */
details.docs-collapse {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  margin: 16px 0;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

details.docs-collapse summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  user-select: none;
}

details.docs-collapse summary::-webkit-details-marker {
  display: none;
}

details.docs-collapse summary::after {
  content: "▾";
  font-size: 14px;
  color: var(--text-soft);
  transition: transform 0.2s ease;
}

details.docs-collapse[open] summary {
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}

details.docs-collapse[open] summary::after {
  transform: rotate(180deg);
}

.docs-collapse-body {
  padding: 16px;
}

/* Code block */
.code-card {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin: 18px 0;
  background: var(--code-bg);
  color: var(--code-text);
}

.code-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: #94a3b8;
  font-family: "Geist Mono", ui-monospace, monospace;
}

.copy-btn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.code-card pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.55;
}

/* Media cards: Image & YouTube */
.media-card {
  margin: 20px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.media-card img {
  display: block;
  width: 100%;
  height: auto;
  cursor: zoom-in;
}

.media-caption {
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--text-soft);
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
}

.video-wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Table */
.table-wrap {
  overflow-x: auto;
  margin: 18px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.docs-table th,
table.docs-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.docs-table th {
  background: var(--bg-subtle);
  font-weight: 700;
  font-size: 13px;
}

table.docs-table tr:last-child td {
  border-bottom: 0;
}

/* Cards & Related Links */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.doc-card {
  display: block;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.doc-card:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
  text-decoration: none;
}

.doc-card-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-on-soft);
  margin-bottom: 8px;
}

.doc-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.doc-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text-soft);
}

/* Lightbox modal */
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(2, 6, 23, 0.84);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-backdrop.open {
  display: flex;
}

.lightbox-backdrop img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 12px;
  background: #ffffff;
  padding: 8px;
}

/* Search results dropdown */
.search-results {
  position: absolute;
  top: 42px;
  right: 0;
  width: 320px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  display: none;
  overflow: hidden;
  z-index: 60;
}

.search-results.open {
  display: block;
}

.search-result-item {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.search-result-item:last-child {
  border-bottom: 0;
}

.search-result-item:hover {
  background: var(--bg-subtle);
  text-decoration: none;
}

.search-result-item strong {
  display: block;
  font-size: 13.5px;
}

.search-result-item span {
  font-size: 12px;
  color: var(--text-soft);
}

.docs-footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
  color: var(--text-soft);
  font-size: 13px;
}

@media (max-width: 1020px) {
  .docs-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }
  .docs-toc {
    display: none;
  }
}

@media (max-width: 740px) {
  .docs-shell {
    grid-template-columns: 1fr;
    padding: 18px 16px 48px;
  }
  .docs-sidebar {
    position: static;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
  }
  .docs-search-input {
    width: 150px;
  }
}
