:root {
  --doc-bg: #f5f6f8;
  --doc-surface: #ffffff;
  --doc-ink: #0b0c0f;
  --doc-body: #272b33;
  --doc-muted: #4b5563;
  --doc-border: #d1d5db;
  --doc-primary: #b91c1c;
  --doc-primary-hover: #991b1b;
  --doc-ok-bg: #f0fdf4;
  --doc-ok-border: #15803d;
  --doc-info-bg: #fffbeb;
  --doc-info-border: #b45309;
  --doc-danger: #b91c1c;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--doc-bg);
  color: var(--doc-body);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.68;
  overflow-x: clip;
}

a[href],
button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--doc-primary);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  top: -120px;
  left: 16px;
  z-index: 2000;
  background-color: var(--doc-primary);
  color: #ffffff;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: 6px;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.doc-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: #ffffff;
  border-bottom: 1px solid var(--doc-border);
}

.doc-nav {
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.doc-back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 8px;
  background-color: var(--doc-primary);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
}

.doc-back-link:hover {
  background-color: var(--doc-primary-hover);
}

.doc-toc {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.doc-toc a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--doc-ink);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}

.doc-toc a:hover {
  background-color: #e5e7eb;
}

.doc-container {
  max-width: 920px;
  margin: 28px auto 48px;
  background-color: var(--doc-surface);
  border: 1px solid var(--doc-border);
  border-radius: 12px;
  padding: 48px 52px;
}

.doc-cover {
  padding-bottom: 32px;
  margin-bottom: 36px;
  border-bottom: 2px solid var(--doc-primary);
}

.doc-kicker {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--doc-primary);
  margin-bottom: 8px;
}

.doc-cover h1 {
  font-size: clamp(1.85rem, 3.6vw, 2.5rem);
  color: var(--doc-ink);
  line-height: 1.15;
  margin-bottom: 12px;
}

.doc-lead {
  font-size: 1.02rem;
  color: var(--doc-muted);
  max-width: 65ch;
}

.doc-section {
  margin-top: 44px;
  scroll-margin-top: 84px;
}

.doc-section h2 {
  font-size: clamp(1.4rem, 2.5vw, 1.75rem);
  color: var(--doc-ink);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--doc-border);
  margin-bottom: 16px;
}

.doc-section h3 {
  font-size: 1.18rem;
  color: var(--doc-primary);
  margin-top: 28px;
  margin-bottom: 12px;
}

.doc-section h4 {
  font-size: 1.02rem;
  color: var(--doc-ink);
  margin-top: 20px;
  margin-bottom: 10px;
}

.doc-section p {
  margin-bottom: 14px;
}

.doc-section ul,
.doc-section ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.doc-section li {
  margin-bottom: 8px;
}

code {
  background-color: #131519;
  color: #fbbf24;
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.88em;
  word-break: break-word;
}

.note-muted {
  color: var(--doc-muted);
  font-size: 0.88rem;
  font-style: italic;
}

.text-danger {
  color: var(--doc-danger);
  font-weight: 700;
}

.callout {
  background-color: var(--doc-info-bg);
  border: 1px solid #fde68a;
  border-left: 4px solid var(--doc-info-border);
  border-radius: 6px;
  padding: 16px 18px;
  margin: 18px 0 22px;
}

.callout.callout-success {
  background-color: var(--doc-ok-bg);
  border-color: #bbf7d0;
  border-left-color: var(--doc-ok-border);
}

.callout p:last-child,
.callout ul:last-child {
  margin-bottom: 0;
}

.subhead-with-icons {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 32px;
  margin-bottom: 14px;
}

.subhead-with-icons h3 {
  margin: 0;
}

.app-badge-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: contain;
}

.figure-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: 20px 0 28px;
  align-items: center;
}

.figure-card {
  width: 100%;
  max-width: 760px;
  background-color: #f3f4f6;
  border: 1px solid var(--doc-border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.figure-card-compact {
  max-width: 420px;
}

.img-zoom-btn {
  display: block;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  border-radius: 6px;
  overflow: hidden;
}

.img-zoom-btn img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.figure-caption {
  margin-top: 10px;
  font-size: 0.86rem;
  color: var(--doc-muted);
}

.figure-fallback {
  padding: 20px;
  font-size: 0.9rem;
  color: var(--doc-muted);
}

.figure-fallback[hidden] {
  display: none;
}

.doc-divider {
  border: 0;
  border-top: 1px solid var(--doc-border);
  margin: 32px 0;
}

.doc-footer {
  max-width: 920px;
  margin: 0 auto 48px;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.88rem;
  color: var(--doc-muted);
}

.doc-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--doc-primary);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Accessible Lightbox Dialog */
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background-color: rgba(11, 12, 15, 0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-backdrop[hidden] {
  display: none;
}

.lightbox-toolbar {
  width: 100%;
  max-width: 1040px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  color: #f4f5f7;
}

.lightbox-caption {
  font-size: 0.92rem;
  color: #cfd4dc;
}

.lightbox-close {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #6b7280;
  background-color: #131519;
  color: #f4f5f7;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
}

.lightbox-close:hover {
  background-color: #1b1e24;
}

.lightbox-img {
  max-width: 100%;
  max-height: 80dvh;
  width: auto;
  height: auto;
  border-radius: 8px;
  background-color: #ffffff;
}

@media (max-width: 768px) {
  .doc-header {
    position: static;
  }

  .doc-nav {
    padding: 10px 14px;
    gap: 10px;
  }

  .doc-toc {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .doc-toc a {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .doc-container {
    margin: 16px 12px 32px;
    padding: 24px 18px;
  }

  .doc-section {
    margin-top: 32px;
    scroll-margin-top: 20px;
  }
}

@media print {
  @page {
    size: A4;
    margin: 18mm;
  }

  .doc-header,
  .lightbox-backdrop,
  .skip-link {
    display: none !important;
  }

  body {
    background-color: #ffffff;
    font-size: 11pt;
  }

  .doc-container {
    margin: 0;
    padding: 0;
    border: 0;
    max-width: 100%;
  }

  .figure-card {
    page-break-inside: avoid;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
