/* ─── Design tokens ────────────────────────────────────────────── */
:root {
  --bg: #f9fafb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-soft: #f0f1f3;
  --text: #111827;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --accent: #2563eb;
  --accent-bg: #eff6ff;
  --accent-border: #bfdbfe;
  --sidebar-w: 260px;
  --toc-w: 220px;
  --topbar-h: 57px;
  --font: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}

/* ─── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
code, pre { font-family: var(--font-mono); }
img { display: block; max-width: 100%; }

/* ─── Shell ─────────────────────────────────────────────────────── */
.site-shell { display: flex; flex-direction: column; min-height: 100vh; }

/* ─── Topbar ─────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* Brand zone (same width as sidebar) */
.brand {
  flex: 0 0 var(--sidebar-w);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-right: 1px solid var(--border);
  height: 100%;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  background: #111827;
  flex-shrink: 0;
}

/* Battery icon inside brand mark */
.brand-mark::after {
  content: "";
  display: block;
  width: 14px;
  height: 9px;
  border: 2px solid #fff;
  border-radius: 2px;
  position: relative;
  box-shadow: 3px 0 0 0 #fff inset;
}

.brand-mark-inner { display: none; }

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-copy strong {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand-copy span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

/* Search bar */
.topbar-search {
  flex: 1 1 320px;
  min-width: 180px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  position: relative;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  width: min(360px, 100%);
  cursor: text;
}

.search-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.search-input-wrap svg {
  width: 14px;
  height: 14px;
  fill: var(--text-faint);
  flex-shrink: 0;
}

.search-input-wrap input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  outline: none;
}

.search-input-wrap input::placeholder { color: var(--text-faint); }

.search-input-wrap kbd {
  flex-shrink: 0;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 20px;
  right: 20px;
  width: min(460px, calc(100% - 40px));
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  z-index: 200;
}

.search-result, .search-empty {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
}

.search-result:hover { background: var(--accent-bg); }

.search-result-meta {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.search-result strong { font-size: 13px; }

.search-result span, .search-empty span {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

/* Topbar right nav */
.topbar-nav {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  padding: 0 20px 0 12px;
  margin-left: auto;
  height: 100%;
}

.top-link {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color 0.1s, background 0.1s;
}

.top-link:hover { color: var(--text); background: var(--bg); }

.top-link.active { color: var(--text); font-weight: 600; }

/* GitHub button */
.top-link-cta {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius);
  background: var(--text);
  color: #fff !important;
  font-size: 13px;
  font-weight: 600;
  margin-left: 4px;
  gap: 6px;
  white-space: nowrap;
  transition: opacity 0.15s;
}

.top-link-cta:hover { opacity: 0.85; }

/* Subnav strip (hidden for Docly style — we use topbar only) */
.subnav { display: none; }

.mobile-nav-button {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  padding: 0;
}
.mobile-nav-button span {
  display: block;
  width: 14px;
  height: 1.5px;
  margin: 0 auto;
  border-radius: 2px;
  background: var(--text);
}

/* ─── Layout ─────────────────────────────────────────────────────── */
.layout-shell {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ─── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  flex: 0 0 var(--sidebar-w);
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 0 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-scroll { display: contents; }

.nav-group {
  margin-bottom: 24px;
}

.nav-group h2 {
  padding: 0 16px 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

nav { display: flex; flex-direction: column; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 16px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  transition: color 0.1s, background 0.1s;
}

.nav-link svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.6;
}

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

.nav-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-bg);
  font-weight: 600;
}

.nav-link.active svg { opacity: 1; }

/* ─── Content area ────────────────────────────────────────────────── */
.content-shell {
  flex: 1;
  min-width: 0;
  padding: 40px 48px 80px;
  max-width: calc(var(--toc-w) + 760px + 96px);
}

/* Page hero */
.page-hero {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.page-eyebrow {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 8px;
}

.page-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
  margin-bottom: 10px;
}

.page-description {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.65;
  max-width: 640px;
}

/* Article */
.doc-article { max-width: 720px; }

.doc-article h2 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-top: 40px;
  margin-bottom: 12px;
  scroll-margin-top: calc(var(--topbar-h) + 20px);
}

.doc-article h2:first-child { margin-top: 0; }

.doc-article h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-top: 24px;
  margin-bottom: 8px;
  scroll-margin-top: calc(var(--topbar-h) + 20px);
}

.doc-article p {
  font-size: 14.5px;
  color: #374151;
  line-height: 1.75;
  margin-bottom: 14px;
}

.doc-article ul, .doc-article ol {
  padding-left: 20px;
  margin-bottom: 14px;
}

.doc-article li {
  font-size: 14.5px;
  color: #374151;
  line-height: 1.75;
  margin-bottom: 4px;
}

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

.doc-article p code,
.doc-article li code,
.doc-table code {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  font-size: 12.5px;
  color: #dc2626;
}

.lead {
  font-size: 15px;
  color: var(--text-muted);
  line-height: 1.75;
}

/* Callout */
.callout {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-lg);
  background: var(--accent-bg);
  margin: 16px 0;
  font-size: 13.5px;
  color: #1e40af;
  line-height: 1.65;
}

.callout::before {
  content: "ⓘ";
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1.4;
}

.callout strong {
  display: inline;
  font-weight: 700;
  margin-right: 4px;
}

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.info-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.info-card:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow);
}

.info-card h3 {
  margin-top: 0;
  margin-bottom: 6px;
  font-size: 13.5px;
  font-weight: 700;
}

.info-card h3 a { color: var(--accent); }
.info-card h3 a:hover { text-decoration: underline; }

.info-card p {
  margin-bottom: 0;
  font-size: 13px;
  color: var(--text-muted);
}

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

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

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

.doc-table th {
  background: var(--bg);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.doc-table td { color: #374151; line-height: 1.6; }

/* Code block */
.code-block {
  margin: 14px 0;
  padding: 16px 18px;
  border: 1px solid #1f2937;
  border-radius: var(--radius-lg);
  background: #0f1117;
  color: #e5e7eb;
  overflow-x: auto;
}

.code-block code {
  font-size: 12.5px;
  line-height: 1.8;
}

/* Chip list */
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Step list */
.step-list {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 16px 0;
}

.step-list li {
  position: relative;
  padding-left: 44px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #374151;
  line-height: 1.7;
}

.step-list li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

/* ─── ToC (right panel) ─────────────────────────────────────────── */
.toc {
  flex: 0 0 var(--toc-w);
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 32px 20px 40px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* .toc-card — no visual card wrapper in this style */

.toc-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 10px;
}

.toc-links {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.toc-link {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 3px 8px;
  border-radius: 4px;
  transition: color 0.1s;
}

.toc-link:hover { color: var(--text); background: var(--bg); }
.toc-link.active { color: var(--accent); font-weight: 600; }

.toc-link.sub {
  padding-left: 16px;
  font-size: 12px;
}

/* ─── Status / loading ──────────────────────────────────────────── */
.loading-state, .error-state {
  display: grid;
  place-items: center;
  min-height: 240px;
  color: var(--text-muted);
  text-align: center;
  font-size: 13px;
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .toc { display: none; }
  .content-shell { max-width: none; }
}

@media (max-width: 900px) {
  .content-shell { padding: 28px 24px 60px; }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.08);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .mobile-nav-button { display: inline-flex; }
  .brand { border-right: none; padding-right: 8px; }
  .content-shell { padding: 24px 16px 60px; }
  .card-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
  .brand { flex: none; }
}

@media (max-width: 480px) {
  .search-input-wrap kbd { display: none; }
  .page-title { font-size: 22px; }
}
