:root {
  --bg: #f7f8fa;
  --paper: #ffffff;
  --paper-strong: #ffffff;
  --sidebar: #ffffff;
  --sidebar-border: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --muted: #64748b;
  --accent: #0f766e;
  --accent-strong: #0f766e;
  --accent-soft: rgba(15, 118, 110, 0.08);
  --code-bg: #0f172a;
  --code-text: #e5eef5;
  --line: rgba(15, 23, 42, 0.08);
  --shadow: none;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --font-ui: "SF Pro Text", "PingFang SC", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-display: "SF Pro Text", "PingFang SC", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-code: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

a {
  color: inherit;
}

.page-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr) 188px;
  min-height: 100vh;
  width: min(1380px, 100%);
  margin: 0 auto;
  gap: 18px;
  padding: 20px;
}

.sidebar {
  padding: 24px 20px;
  background: var(--sidebar);
  color: var(--text);
  border: 1px solid var(--sidebar-border);
  border-radius: 16px;
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  overflow-y: auto;
}

.progress-bar {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(0);
  z-index: 20;
}

.brand {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.brand-kicker,
.nav-title,
.eyebrow,
.doc-meta {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  font-family: var(--font-ui);
}

.brand h1 {
  margin: 6px 0 8px;
  font-size: 1.3rem;
  line-height: 1.1;
  font-family: var(--font-display);
  font-weight: 700;
}

.brand-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.92rem;
}

.nav-title {
  margin: 0 0 14px;
  color: var(--muted);
}

.nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.nav-link {
  display: block;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  color: var(--text);
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
  font-size: 0.88rem;
  line-height: 1.35;
}

.nav-link:hover,
.nav-link:focus-visible {
  border-color: var(--line);
  background: #f8fafc;
  outline: none;
}

.nav-link.active {
  background: #f8fafc;
  border-color: rgba(15, 118, 110, 0.14);
}

.nav-detail {
  display: block;
  max-height: 0;
  overflow: hidden;
  padding: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
  opacity: 0;
  transition: max-height 160ms ease, opacity 140ms ease, padding-top 160ms ease;
}

.nav-link:hover .nav-detail,
.nav-link:focus-visible .nav-detail {
  max-height: 4em;
  padding-top: 6px;
  opacity: 1;
}

.content {
  padding: 10px 0 32px;
  min-width: 0;
}

.mobile-toolbar {
  display: none;
}

.content-header {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 14px;
}

.eyebrow {
  color: var(--accent);
  margin: 0 0 6px;
}

.content-header h2 {
  margin: 0;
  font-size: clamp(1.4rem, 2vw, 1.9rem);
  line-height: 1;
  font-family: var(--font-display);
  font-weight: 700;
}

.doc-summary {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 60ch;
  line-height: 1.55;
  font-size: 0.88rem;
}

.source-link {
  text-decoration: none;
  align-self: start;
  color: var(--accent-strong);
  border: 1px solid rgba(20, 85, 79, 0.12);
  background: #ffffff;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.84rem;
}

.doc-card {
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-strong) 100%);
  border: 1px solid rgba(36, 53, 61, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px 32px;
}

.doc-meta {
  color: var(--muted);
  margin-bottom: 18px;
}

.doc-content {
  font-size: 1rem;
  line-height: 1.78;
  max-width: 78ch;
}

.doc-content > :first-child {
  margin-top: 0;
}

.doc-content h1,
.doc-content h2,
.doc-content h3 {
  line-height: 1.2;
  margin-top: 1.55em;
  margin-bottom: 0.5em;
  scroll-margin-top: 88px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.015em;
}

.doc-content h1 {
  font-size: 1.55rem;
}

.doc-content h2 {
  font-size: 1.2rem;
}

.doc-content h3 {
  font-size: 1.02rem;
}

.doc-content p,
.doc-content ul,
.doc-content ol,
.doc-content pre,
.doc-content blockquote {
  margin: 0 0 0.95rem;
}

.doc-content ul,
.doc-content ol {
  padding-left: 1.4rem;
}

.doc-content li + li {
  margin-top: 0.35rem;
}

.doc-content code {
  font-family: var(--font-code);
  font-size: 0.9em;
  background: #f1f5f9;
  padding: 0.14em 0.35em;
  border-radius: 4px;
}

.doc-content pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 16px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.doc-content pre.code-block {
  position: relative;
}

.doc-content pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  display: block;
  padding-right: 40px;
}

.copy-button {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.08);
  color: var(--code-text);
  border-radius: 999px;
  width: 28px;
  height: 28px;
  padding: 0;
  font-family: var(--font-ui);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 160ms ease, transform 160ms ease, color 160ms ease;
}

.copy-button:hover,
.copy-button:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
  outline: none;
}

.copy-button.copied {
  color: #7dd3fc;
}

.copy-button.copy-failed {
  color: #fda4af;
}

.copy-icon {
  width: 14px;
  height: 14px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.doc-content hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.8rem 0;
}

.doc-content blockquote {
  margin-left: 0;
  padding: 10px 16px;
  border-left: 4px solid rgba(181, 81, 45, 0.55);
  background: rgba(181, 81, 45, 0.08);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.doc-content a {
  color: var(--accent-strong);
}

.error-box {
  background: rgba(157, 32, 32, 0.08);
  color: #721c24;
  border: 1px solid rgba(157, 32, 32, 0.16);
  border-radius: var(--radius-md);
  padding: 18px;
}

.search-box {
  margin-bottom: 18px;
}

.search-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.search-input {
  width: 100%;
  border: 1px solid rgba(20, 85, 79, 0.1);
  background: #ffffff;
  color: var(--text);
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
  font-size: 0.9rem;
}

.search-input::placeholder {
  color: rgba(105, 119, 128, 0.72);
}

.search-input:focus-visible {
  outline: 2px solid rgba(223, 136, 81, 0.55);
  outline-offset: 2px;
}

.sidebar-nav {
  min-height: 0;
}

.outline-panel {
  padding: 10px 0 32px;
}

.outline-card {
  position: sticky;
  top: 20px;
  background: #ffffff;
  border: 1px solid rgba(36, 53, 61, 0.08);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.outline-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.outline-link {
  display: block;
  text-decoration: none;
  color: var(--muted);
  padding: 7px 9px;
  border-radius: 8px;
  line-height: 1.45;
  font-size: 0.84rem;
}

.outline-link:hover,
.outline-link:focus-visible {
  background: var(--accent-soft);
  color: var(--accent-strong);
  outline: none;
}

.outline-link.active {
  background: #f0fdfa;
  color: var(--accent-strong);
  font-weight: 600;
}

.outline-link-sub {
  padding-left: 18px;
  font-size: 0.8rem;
}

.doc-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.pager-link {
  display: block;
  text-decoration: none;
  border: 1px solid rgba(36, 53, 61, 0.08);
  border-radius: 12px;
  padding: 14px 16px;
  background: #ffffff;
  min-height: 84px;
  font-size: 0.92rem;
}

.pager-link-next {
  text-align: right;
}

.pager-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.pager-link.disabled {
  pointer-events: none;
  opacity: 0.55;
}

.empty-state {
  color: var(--muted);
  padding: 8px 6px;
}

.mobile-backdrop {
  display: none;
}

.mobile-backdrop[hidden] {
  display: none !important;
}

@media (max-width: 980px) {
  .page-shell {
    grid-template-columns: 1fr;
    padding: 18px;
    gap: 18px;
  }

  .content {
    order: 1;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(82vw, 320px);
    height: auto;
    border-radius: 0 16px 16px 0;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    z-index: 40;
  }

  .content {
    padding-top: 0;
  }
  .outline-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(78vw, 300px);
    padding: 0;
    transform: translateX(105%);
    transition: transform 180ms ease;
    z-index: 40;
  }

  .outline-card {
    position: absolute;
    inset: 0;
    border-radius: 16px 0 0 16px;
    padding: 18px;
    overflow-y: auto;
  }

  .sidebar.mobile-open,
  .outline-panel.mobile-open {
    transform: translateX(0);
  }

  .mobile-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    width: 100%;
  }

  .mobile-toggle {
    appearance: none;
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--text);
    border-radius: 999px;
    padding: 8px 14px;
    font: inherit;
    font-size: 0.88rem;
  }

  .mobile-toggle:last-child {
    margin-left: auto;
  }

  .mobile-toggle[aria-expanded="true"] {
    border-color: rgba(15, 118, 110, 0.2);
    color: var(--accent-strong);
    background: #f0fdfa;
  }

  .mobile-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.24);
    z-index: 30;
  }
}

@media (max-width: 640px) {
  .sidebar {
    padding: 22px 18px;
  }

  .doc-card {
    padding: 22px 20px;
    border-radius: 22px;
  }

  .doc-content {
    max-width: none;
  }

  .content-header {
    flex-direction: column;
    align-items: start;
  }

  .doc-pager {
    grid-template-columns: 1fr;
  }
}
