:root {
  color-scheme: light;

  --bg:             light-dark(#f3f5f9, #15171f);
  --dot:            light-dark(#dce0e8, #262a37);
  --surface:        light-dark(#ffffff, #1c1f29);
  --surface-border: light-dark(#e4e7ee, #2c3040);
  --surface-disabled: light-dark(#eaecf1, #23262f);
  --text:           light-dark(#202433, #e7e9f4);
  --text-dim:       light-dark(#6b7280, #9aa0b8);
  --accent:         light-dark(#4f6df5, #7c93ff);
  --accent-soft:    light-dark(rgba(79,109,245,.10), rgba(124,147,255,.16));
  --online:         light-dark(#22c55e, #4ade80);
  --dev:            light-dark(#d97706, #fbbf24);
  --beta:           light-dark(#9333ea, #c084fc);
  --offline:        light-dark(#94a3b8, #6b7280);
  --danger:         light-dark(#dc2626, #f87171);
  --danger-soft:    light-dark(rgba(220,38,38,.12), rgba(248,113,113,.16));

  --shadow-sm: 0 1px 3px light-dark(rgba(16,24,40,.08), rgba(0,0,0,.4));
  --shadow-md: 0 6px 20px light-dark(rgba(16,24,40,.10), rgba(0,0,0,.45));
  --shadow-lg: 0 12px 32px light-dark(rgba(16,24,40,.16), rgba(0,0,0,.55));

  --radius: 16px;
  --radius-sm: 10px;

  --sidebar-w: 276px;
  --content-max: 720px;
  --topbar-h: 56px;
}

:root[data-theme="dark"] { color-scheme: dark; }

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

*:focus,
*:focus-visible {
  outline: none !important;
}

.material-symbols-rounded {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
}

html, body {
  width: 100%;
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: var(--bg);
}

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.brand {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .5px;
  color: var(--text-dim);
}

.brand b { color: var(--accent); font-weight: 600; }

.brand-link {
  color: inherit;
  text-decoration: none;
}

.mobile-bar {
  display: none;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  flex-shrink: 0;
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--surface-border);
  position: relative;
  z-index: 120;
}

.mobile-bar-kicker {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.menu-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.menu-btn:hover {
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.layout {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 20, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 190;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--surface-border);
}

.sidebar-header {
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--surface-border);
  margin-bottom: 8px;
}

.sidebar-kicker {
  margin-top: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.sidebar-nav {
  padding: 4px 0 28px;
}

.nav-loading,
.doc-loading {
  padding: 16px 20px;
  font-size: 13px;
  color: var(--text-dim);
}

.tool-group { margin-bottom: 6px; }

.tool-group-title {
  padding: 14px 20px 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.page-link {
  display: block;
  margin: 1px 10px;
  padding: 8px 10px 8px 12px;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.page-link:hover {
  background: var(--accent-soft);
}

.page-link.active {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.page-link.active .page-link-title {
  color: var(--accent);
}

.page-link-title {
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
}

.page-link-subtitle {
  margin-top: 2px;
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.main {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  background: var(--bg);
}

.doc {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 56px 32px 120px;
}

.doc-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.doc h1 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -.01em;
  margin: 0 0 10px;
}

.doc-subtitle {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-dim);
  margin: 0 0 36px;
}

.doc h2 {
  font-size: 21px;
  font-weight: 700;
  margin: 40px 0 14px;
  padding-top: 20px;
  border-top: 1px solid var(--surface-border);
}

.doc > *:first-child,
.doc h2:first-of-type {
  padding-top: 0;
  border-top: none;
}

.doc h3 {
  font-size: 16.5px;
  font-weight: 600;
  margin: 26px 0 10px;
}

.doc h4, .doc h5, .doc h6 {
  font-size: 14.5px;
  font-weight: 600;
  margin: 20px 0 8px;
}

.doc p {
  font-size: 15px;
  line-height: 1.75;
  margin: 0 0 16px;
}

.doc a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.doc a:hover { border-bottom-color: currentColor; }

.doc strong { font-weight: 600; }

.doc code {
  font-family: 'JetBrains Mono', monospace;
  font-size: .85em;
  background: var(--surface-disabled);
  padding: .15em .45em;
  border-radius: 6px;
}

.doc pre {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  overflow-x: auto;
  margin: 0 0 20px;
}

.doc pre code {
  background: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.6;
}

.doc blockquote {
  margin: 0 0 18px;
  padding: 10px 18px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-dim);
}

.doc blockquote p:last-child { margin-bottom: 0; }

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

.doc li {
  font-size: 15px;
  line-height: 1.75;
  margin-bottom: 4px;
}

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

.doc img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: 0 0 16px;
}

.doc .table-wrap {
  overflow-x: auto;
  margin: 0 0 20px;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
}

.doc table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

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

.doc th {
  font-weight: 600;
  font-size: 11px;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--surface-disabled);
}

.doc tr:last-child td { border-bottom: none; }

.doc-not-found {
  padding: 8px 0;
}

.doc-not-found .doc-eyebrow { color: var(--danger); }

.theme-fab {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  box-shadow: var(--shadow-sm);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 210;
  transition: all 0.2s ease;
}

.theme-fab:hover {
  color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-overlay,
  .page-link,
  .theme-fab {
    transition: none !important;
  }
}

@media (max-width: 860px) {
  .mobile-bar { display: flex; }

  .layout { position: relative; }

  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: min(82vw, 320px);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
    z-index: 200;
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar .sidebar-header { display: none; }

  .theme-fab { bottom: 16px; left: 16px; }
}

@media (min-width: 861px) {
  .sidebar-overlay { display: none; }
}

@media (max-width: 480px) {
  .doc { padding: 36px 20px 100px; }
  .doc h1 { font-size: 25px; }
  .doc-subtitle { font-size: 15px; margin-bottom: 28px; }
  .mobile-bar-kicker { display: none; }
  .sidebar { width: min(88vw, 300px); }
}
