:root {
  --bg: #07080b;
  --bg-elev: #0f1117;
  --bg-hover: #161922;
  --border: #222634;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #c084fc;
  --accent-soft: rgba(192, 132, 252, 0.14);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.1);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.1);
  --code-bg: #11141e;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}

html[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #f8fafc;
  --bg-hover: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  --accent: #9333ea;
  --accent-soft: rgba(147, 51, 234, 0.1);
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.08);
  --warn: #d97706;
  --warn-soft: rgba(217, 119, 6, 0.08);
  --code-bg: #f1f5f9;
  --shadow: 0 16px 48px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand:hover { text-decoration: none; }

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  box-shadow: 0 0 12px rgba(192, 132, 252, 0.25);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.brand:hover .brand-logo {
  transform: scale(1.06) rotate(-3deg);
  box-shadow: 0 0 16px rgba(192, 132, 252, 0.45);
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--text);
  color: var(--bg);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 700;
}

.version-pill {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.topbar-center {
  flex: 1;
  max-width: 420px;
}

.search-bar {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.search-bar:hover { border-color: var(--text-dim); color: var(--text-muted); }
.search-bar span { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-bar kbd, .modal-search-row kbd {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.nav-link:hover { color: var(--text); text-decoration: none; }

.nav-cta {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 7px;
  background: var(--text);
  color: var(--bg);
}
.nav-cta:hover { opacity: 0.9; text-decoration: none; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-dim); }
.mobile-only { display: none; }

.layout {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 230px;
  min-height: calc(100vh - 60px);
}

.sidebar {
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.nav-group { margin-bottom: 20px; }
.nav-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 0 10px 6px;
}

.nav-item {
  display: block;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 2px;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px 10px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}

.main-wrap {
  padding: 36px 48px 64px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

.article h1 {
  font-size: 32px;
  line-height: 1.25;
  margin: 0 0 10px;
  letter-spacing: -0.02em;
}
.article .page-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  margin: 0 0 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.article h2 {
  font-size: 21px;
  margin: 34px 0 12px;
  padding-top: 8px;
  letter-spacing: -0.01em;
}
.article h3 {
  font-size: 16px;
  margin: 22px 0 8px;
  color: var(--text);
}
.article p { margin: 0 0 14px; color: var(--text-muted); }
.article ul, .article ol {
  margin: 0 0 18px;
  padding-left: 20px;
  color: var(--text-muted);
}
.article li { margin-bottom: 7px; }
.article li strong { color: var(--text); }

.article code {
  font-family: "JetBrains Mono", monospace;
  font-size: 12.5px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--text);
}

.callout {
  border-radius: 10px;
  padding: 14px 16px;
  margin: 18px 0 22px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.callout.info { border-left: 3px solid var(--accent); background: var(--accent-soft); }
.callout.warn { border-left: 3px solid var(--warn); background: var(--warn-soft); }
.callout.success { border-left: 3px solid var(--success); background: var(--success-soft); }
.callout-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}
.callout-body { font-size: 14px; color: var(--text-muted); }

.table-wrap {
  overflow-x: auto;
  margin: 16px 0 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
th {
  background: var(--bg-elev);
  font-weight: 600;
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
td { color: var(--text-muted); }

.slider-tag {
  font-family: "JetBrains Mono", monospace;
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--accent);
}

.pager {
  margin-top: 44px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.pager-card {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elev);
  transition: border-color 0.15s ease;
}
.pager-card:hover { border-color: var(--accent); text-decoration: none; }
.pager-card.next { text-align: right; align-items: flex-end; }
.pager-label { font-size: 11.5px; color: var(--text-dim); margin-bottom: 2px; }
.pager-title { font-size: 14.5px; font-weight: 600; color: var(--text); }

.toc-wrap {
  padding: 28px 16px;
}
.toc-sticky {
  position: sticky;
  top: 88px;
}
.toc-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}
.toc-list a {
  display: block;
  padding: 4px 12px;
  font-size: 12.5px;
  color: var(--text-dim);
  border-left: 2px solid transparent;
  margin-left: -1px;
}
.toc-list a:hover { color: var(--text); text-decoration: none; }
.toc-list a.active { color: var(--accent); border-left-color: var(--accent); }
.toc-list a.sub { padding-left: 22px; font-size: 12px; }

.modal.hidden { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  width: min(600px, 92vw);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-search-row input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 14.5px;
}
.search-results {
  max-height: 360px;
  overflow-y: auto;
  padding: 8px;
}
.search-hit {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
}
.search-hit:hover { background: var(--bg-hover); text-decoration: none; }
.search-hit-title { font-size: 14px; font-weight: 600; }
.search-hit-desc { font-size: 12.5px; color: var(--text-dim); }
.search-empty { padding: 20px; text-align: center; color: var(--text-dim); font-size: 13.5px; }

.sidebar-backdrop { display: none; }

@media (max-width: 1120px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
  .toc-wrap { display: none; }
}

@media (max-width: 820px) {
  .mobile-only { display: inline-flex; }
  .nav-link { display: none; }
  .layout { grid-template-columns: 1fr; }
  .main-wrap {
    padding: 18px 14px 56px;
    max-width: 100vw;
    overflow-x: hidden;
  }
  .sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: min(300px, 84vw);
    z-index: 60;
    background: rgba(11, 13, 18, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 12px 0 36px rgba(0, 0, 0, 0.7);
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 60px 0 0 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }
  .sidebar-nav .nav-item {
    min-height: 44px;
    padding: 11px 14px;
    font-size: 14px;
    display: flex;
    align-items: center;
  }
  .search-bar kbd { display: none; }
  .pager { grid-template-columns: 1fr; gap: 10px; }
  .article h1 { font-size: 24px; line-height: 1.25; word-break: break-word; }
  .article h2 { font-size: 18px; margin-top: 26px; word-break: break-word; }
  .article h3 { font-size: 16px; word-break: break-word; }
  .card-grid { grid-template-columns: 1fr; gap: 12px; }
  .table-wrap { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  pre { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; font-size: 12px; }
}

@media (max-width: 580px) {
  .topbar {
    padding: 0 10px;
    gap: 8px;
  }
  .brand { gap: 6px; }
  .brand-name {
    font-size: 12.5px;
    letter-spacing: 0;
  }
  .brand-logo {
    width: 28px;
    height: 28px;
  }
  .version-pill {
    font-size: 10px;
    padding: 1px 5px;
  }
  .topbar-center {
    max-width: 140px;
  }
  .search-bar {
    height: 34px;
    padding: 0 8px;
    font-size: 12px;
  }
  .search-bar span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .nav-cta {
    font-size: 11.5px;
    padding: 6px 9px;
    border-radius: 7px;
  }
  .icon-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }
}

@media (max-width: 400px) {
  .brand-name { display: none; }
  .topbar-center { max-width: none; flex: 1; }
}

/* ==========================================================================
   TEMPO-STYLE ANIMATIONS (Blur-In & Staggered Reveal)
   ========================================================================== */
@keyframes tempStyleBlurIn {
  0% {
    opacity: 0;
    filter: blur(12px);
    transform: translateY(16px) scale(0.98);
  }
  60% {
    filter: blur(2px);
  }
  100% {
    opacity: 1;
    filter: blur(0px);
    transform: translateY(0) scale(1);
  }
}

.article > * {
  animation: tempStyleBlurIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.article > *:nth-child(1)  { animation-delay: 0.04s; }
.article > *:nth-child(2)  { animation-delay: 0.08s; }
.article > *:nth-child(3)  { animation-delay: 0.12s; }
.article > *:nth-child(4)  { animation-delay: 0.16s; }
.article > *:nth-child(5)  { animation-delay: 0.20s; }
.article > *:nth-child(6)  { animation-delay: 0.24s; }
.article > *:nth-child(7)  { animation-delay: 0.28s; }
.article > *:nth-child(8)  { animation-delay: 0.32s; }
.article > *:nth-child(9)  { animation-delay: 0.36s; }
.article > *:nth-child(10) { animation-delay: 0.40s; }
.article > *:nth-child(n+11) { animation-delay: 0.44s; }

.feature-card, .faq-item, .stat-card, .quick-card {
  animation: tempStyleBlurIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.card-grid > *:nth-child(1)  { animation-delay: 0.05s; }
.card-grid > *:nth-child(2)  { animation-delay: 0.10s; }
.card-grid > *:nth-child(3)  { animation-delay: 0.15s; }
.card-grid > *:nth-child(4)  { animation-delay: 0.20s; }
.card-grid > *:nth-child(5)  { animation-delay: 0.25s; }
.card-grid > *:nth-child(6)  { animation-delay: 0.30s; }
.card-grid > *:nth-child(n+7) { animation-delay: 0.35s; }
