/* ============================================
   Open Intelligence — Documentation v2
   Wider content, collapsible sidebar,
   scannable endpoints, tighter code blocks
   ============================================ */

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

:root {
  --text:        #1d1d1f;
  --text-sec:    #6e6e73;
  --text-ter:    #86868b;
  --bg:          #ffffff;
  --bg-alt:      #f5f5f7;
  --bg-code:     #1d1d1f;
  --border:      #d2d2d7;
  --border-light:#e8e8ed;
  --accent:      #0071e3;
  --accent-hover:#0077ed;
  --green:       #34c759;
  --orange:      #ff9f0a;
  --red:         #ff3b30;
  --radius:      12px;
  --radius-sm:   8px;
  --radius-xs:   6px;
  --shadow:      0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:   0 4px 12px rgba(0,0,0,.06);
  --mono:        'SF Mono', 'Fira Code', 'Consolas', monospace;
  --sans:        -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --sidebar-w:   240px;
  --header-h:    48px;
}

html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body { font-family: var(--sans); color: var(--text); background: var(--bg); line-height: 1.55; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .8125em; }

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }

/* ---- Top bar (mobile + collapsed) ---- */
.topbar {
  display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-light);
  padding: 0 16px; align-items: center; justify-content: space-between;
}
.topbar .brand { font-size: .875rem; font-weight: 600; color: var(--text); }
.topbar .menu-btn { background: none; border: none; cursor: pointer; padding: 6px; color: var(--text); }
.topbar .menu-btn svg { width: 20px; height: 20px; }

/* ---- Desktop sidebar toggle ---- */
.sidebar-toggle {
  position: fixed; top: 14px; left: var(--sidebar-w); z-index: 95;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--border-light);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: left .2s ease; box-shadow: var(--shadow); transform: translateX(-50%);
}
.sidebar-toggle svg { width: 14px; height: 14px; color: var(--text-sec); transition: transform .2s ease; }
.sidebar-toggle:hover { background: var(--bg-alt); }

/* ---- Sidebar ---- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w); background: var(--bg);
  border-right: 1px solid var(--border-light);
  display: flex; flex-direction: column; z-index: 90;
  overflow-y: auto; overflow-x: hidden;
  transition: width .2s ease, transform .2s ease;
}
.sidebar-brand { padding: 18px 18px 12px; border-bottom: 1px solid var(--border-light); }
.sidebar-brand h1 { font-size: .875rem; font-weight: 600; color: var(--text); white-space: nowrap; }
.sidebar-brand span { font-size: .6875rem; color: var(--text-ter); margin-top: 2px; display: block; white-space: nowrap; }

.sidebar-nav { flex: 1; padding: 6px 8px; }
.nav-section { font-size: .625rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-ter); padding: 10px 10px 4px; white-space: nowrap; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: var(--radius-sm);
  font-size: .8125rem; color: var(--text-sec);
  transition: all .15s ease; text-decoration: none; white-space: nowrap;
}
.sidebar-nav a:hover { background: var(--bg-alt); color: var(--text); text-decoration: none; }
.sidebar-nav a.active { background: var(--bg-alt); color: var(--text); font-weight: 500; }
.sidebar-nav a svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .5; }
.sidebar-nav a.active svg { opacity: .85; }

.sidebar-footer { padding: 10px 18px; border-top: 1px solid var(--border-light); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: .6875rem; color: var(--text-ter); text-decoration: none; white-space: nowrap; }
.status-pill:hover { text-decoration: none; color: var(--text-sec); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px rgba(52,199,89,.2); }

/* Collapsed sidebar (desktop) */
.sidebar.collapsed { width: 0; overflow: hidden; border-right: none; }
.sidebar.collapsed + .sidebar-toggle { left: 16px; }
.sidebar.collapsed + .sidebar-toggle svg { transform: rotate(180deg); }
body.sidebar-collapsed .topbar { display: flex; }
body.sidebar-collapsed .main { margin-left: 0; padding-top: var(--header-h); }

/* ---- Main ---- */
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; transition: margin-left .2s ease; }
.page { max-width: 980px; margin: 0 auto; padding: 28px 32px 60px; }

/* ---- Typography ---- */
.page h1 { font-size: 1.625rem; font-weight: 700; letter-spacing: -.025em; color: var(--text); line-height: 1.2; }
.page .subtitle { font-size: .9375rem; color: var(--text-sec); margin-top: 4px; font-weight: 400; }
.page h2 { font-size: 1.1875rem; font-weight: 600; letter-spacing: -.01em; color: var(--text); margin-top: 32px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border-light); }
.page h2:first-of-type { margin-top: 20px; }
.page h3 { font-size: .9375rem; font-weight: 600; color: var(--text); margin-top: 20px; margin-bottom: 6px; }
.page p { margin-bottom: 10px; color: var(--text-sec); font-size: .875rem; }
.page p strong { color: var(--text); }
.page ul, .page ol { margin-bottom: 10px; padding-left: 20px; color: var(--text-sec); font-size: .875rem; }
.page li { margin-bottom: 3px; }
.page li strong { color: var(--text); }

/* ---- Hero — compact ---- */
.hero { margin-top: 12px; padding: 18px 22px; background: var(--bg-alt); border-radius: 10px; border: 1px solid var(--border-light); }
.hero p { color: var(--text-sec); font-size: .875rem; margin-bottom: 14px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 16px; font-size: .8125rem; font-weight: 500;
  border-radius: 980px; border: none; cursor: pointer;
  transition: all .15s ease; text-decoration: none; font-family: var(--sans);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-alt); }

/* ---- Feature grid — compact ---- */
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.feature-card { padding: 14px; background: var(--bg); border: 1px solid var(--border-light); border-radius: var(--radius-sm); transition: box-shadow .2s ease; }
.feature-card:hover { box-shadow: var(--shadow-md); }
.feature-card svg { width: 20px; height: 20px; color: var(--accent); margin-bottom: 6px; }
.feature-card h4 { font-size: .8125rem; font-weight: 600; margin-bottom: 2px; color: var(--text); }
.feature-card p { font-size: .6875rem; color: var(--text-ter); margin-bottom: 0; line-height: 1.4; }

/* ---- Code blocks — tighter ---- */
.code-block { margin: 10px 0 14px; border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-code); box-shadow: var(--shadow); position: relative; }
.code-header { display: flex; justify-content: space-between; align-items: center; padding: 5px 14px; background: #2a2a2c; border-bottom: 1px solid #38383a; }
.code-header span { font-size: .6875rem; font-weight: 500; color: #a1a1a6; font-family: var(--mono); }
.copy-btn {
  font-size: .625rem; font-weight: 500; padding: 2px 8px;
  background: rgba(255,255,255,.08); color: #a1a1a6;
  border: 1px solid rgba(255,255,255,.1); border-radius: var(--radius-xs);
  cursor: pointer; transition: all .15s ease; font-family: var(--sans);
}
.copy-btn:hover { background: rgba(255,255,255,.14); color: #d1d1d6; }
.code-block pre { padding: 14px 16px; overflow-x: auto; font-size: 13px; line-height: 1.45; margin: 0; }
.code-block code { color: #e5e5ea; font-family: var(--mono); font-size: 13px; }

/* Inline code */
.page :not(pre) > code { background: var(--bg-alt); padding: 1px 5px; border-radius: var(--radius-xs); font-size: .8125rem; color: var(--text); border: 1px solid var(--border-light); }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; margin: 10px 0 14px; font-size: .8125rem; }
thead th { text-align: left; padding: 7px 12px; font-weight: 600; font-size: .6875rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-ter); background: var(--bg-alt); border-bottom: 1px solid var(--border); }
tbody td { padding: 7px 12px; border-bottom: 1px solid var(--border-light); color: var(--text-sec); }
tbody tr:last-child td { border-bottom: none; }

/* Method badges */
.method { display: inline-block; padding: 2px 7px; font-size: .625rem; font-weight: 700; font-family: var(--mono); border-radius: var(--radius-xs); letter-spacing: .02em; }
.method-get { background: #e8f5e9; color: #2e7d32; }
.method-post { background: #e3f2fd; color: #1565c0; }

/* Param badges */
.badge { display: inline-block; padding: 1px 5px; font-size: .5625rem; font-weight: 600; border-radius: 3px; letter-spacing: .02em; text-transform: uppercase; vertical-align: middle; margin-left: 4px; }
.badge-required { background: #ffeaea; color: var(--red); }
.badge-optional { background: var(--bg-alt); color: var(--text-ter); border: 1px solid var(--border-light); }

/* ---- Callouts ---- */
.callout { padding: 10px 14px; border-radius: var(--radius-sm); font-size: .8125rem; margin: 10px 0 14px; border-left: 3px solid; color: var(--text-sec); }
.callout p { margin-bottom: 0; font-size: .8125rem; }
.callout strong { display: block; margin-bottom: 2px; font-size: .75rem; }
.callout ul { margin: 4px 0 0; padding-left: 16px; }
.callout li { font-size: .8125rem; }
.callout-info { background: #f0f7ff; border-color: var(--accent); }
.callout-info strong { color: var(--accent); }
.callout-warn { background: #fffbf0; border-color: var(--orange); }
.callout-warn strong { color: #cc7a00; }
.callout-success { background: #f0faf3; border-color: var(--green); }
.callout-success strong { color: #248a3d; }

/* ---- Tabs ---- */
.tab-bar { display: flex; gap: 0; border-bottom: 1px solid var(--border-light); margin-top: 10px; overflow-x: auto; }
.tab-btn { padding: 7px 14px; font-size: .75rem; font-weight: 500; color: var(--text-ter); background: none; border: none; cursor: pointer; border-bottom: 2px solid transparent; transition: all .15s ease; font-family: var(--sans); white-space: nowrap; }
.tab-btn:hover { color: var(--text-sec); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- Endpoint card — scannable ---- */
.endpoint { margin: 14px 0; border: 1px solid var(--border-light); border-radius: var(--radius); overflow: hidden; }
.endpoint-header { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--bg-alt); border-bottom: 1px solid var(--border-light); }
.endpoint-header code { font-size: .875rem; font-weight: 600; color: var(--text); }
.one-liner { font-size: .8125rem; color: var(--text-sec); margin: 0; padding: 8px 16px; background: var(--bg); border-bottom: 1px solid var(--border-light); }
.endpoint-meta { display: flex; gap: 16px; font-size: .6875rem; color: var(--text-ter); padding: 6px 16px; border-bottom: 1px solid var(--border-light); background: var(--bg); }
.endpoint-meta strong { color: var(--text-sec); font-weight: 600; }
.endpoint-body { padding: 14px 16px; }
.endpoint-body p { font-size: .8125rem; }

/* Example pair */
.example-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.example-pair .label { font-size: .625rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-ter); margin-bottom: 4px; }

/* ---- Auth bar ---- */
.auth-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--bg-alt); border: 1px solid var(--border-light); border-radius: var(--radius-sm); margin: 10px 0 14px; font-size: .8125rem; flex-wrap: wrap; }
.auth-bar code { font-size: .75rem; background: var(--bg-code); color: #e5e5ea; padding: 2px 8px; border-radius: var(--radius-xs); }
.auth-bar .label { font-weight: 600; color: var(--text); white-space: nowrap; }

/* ---- Try-it widget ---- */
.try-it { margin: 14px 0; padding: 14px; background: var(--bg-alt); border: 1px solid var(--border-light); border-radius: var(--radius-sm); }
.try-it h4 { font-size: .8125rem; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.try-it-row { display: flex; gap: 8px; margin-bottom: 6px; }
.try-it input, .try-it-prompt {
  flex: 1; padding: 6px 10px; font-size: .8125rem; font-family: var(--mono);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  background: var(--bg); color: var(--text); outline: none;
}
.try-it-prompt { font-family: var(--sans); resize: none; width: 100%; display: block; }
.try-it input:focus, .try-it-prompt:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,113,227,.08); }
.try-it input::placeholder, .try-it-prompt::placeholder { color: var(--text-ter); }
.try-it-btn {
  padding: 6px 14px; font-size: .8125rem; font-weight: 500;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-xs); cursor: pointer; font-family: var(--sans); white-space: nowrap;
}
.try-it-btn:hover { background: var(--accent-hover); }
.try-it-btn:disabled { opacity: .5; cursor: not-allowed; }
.try-it-output pre { background: var(--bg-code); color: #e5e5ea; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 12px; line-height: 1.4; overflow-x: auto; max-height: 180px; font-family: var(--mono); white-space: pre-wrap; word-break: break-word; margin-top: 8px; }
.try-it .note { font-size: .6875rem; color: var(--text-ter); margin-top: 6px; }

/* ---- Verify + Auth box (quickstart) ---- */
.verify-auth { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.verify-auth > div { padding: 14px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); background: var(--bg); }
.verify-auth h4 { font-size: .8125rem; font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.verify-auth .dot-green { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.verify-auth .dot-blue { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* ---- Base URL pill ---- */
.base-url { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; background: var(--bg-alt); border: 1px solid var(--border-light); border-radius: var(--radius-sm); font-family: var(--mono); font-size: .75rem; color: var(--text); margin: 6px 0 14px; }

/* ---- Steps ---- */
.steps { counter-reset: step; margin: 14px 0; }
.step { counter-increment: step; position: relative; padding: 0 0 20px 40px; border-left: 1px solid var(--border-light); margin-left: 13px; }
.step:last-child { border-left: none; padding-bottom: 0; }
.step::before { content: counter(step); position: absolute; left: -13px; top: 0; width: 26px; height: 26px; background: var(--bg); border: 2px solid var(--border); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .6875rem; font-weight: 600; color: var(--text-sec); }
.step h4 { font-size: .8125rem; font-weight: 600; margin-bottom: 3px; color: var(--text); }
.step p { font-size: .8125rem; color: var(--text-sec); margin-bottom: 4px; }

/* ---- Param rows ---- */
.param-row { display: grid; grid-template-columns: 150px 70px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border-light); font-size: .8125rem; align-items: baseline; }
.param-row:last-child { border-bottom: none; }
.param-name { font-family: var(--mono); font-weight: 500; color: var(--text); }
.param-type { color: var(--accent); font-family: var(--mono); font-size: .6875rem; }
.param-desc { color: var(--text-sec); }

/* ---- Responsive ---- */
@media (max-width: 1200px) { .example-pair { grid-template-columns: 1fr; } }
@media (max-width: 1024px) {
  .features { grid-template-columns: repeat(2, 1fr); }
  .verify-auth { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .topbar { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; width: var(--sidebar-w); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: none; }
  .main { margin-left: 0; padding-top: var(--header-h); }
  .page { padding: 16px 14px 40px; max-width: 100%; }
  .page h1 { font-size: 1.375rem; }
  .features { grid-template-columns: 1fr; }
  .hero { padding: 14px; }
  .param-row { grid-template-columns: 1fr; gap: 2px; }
  .example-pair { grid-template-columns: 1fr; }
  .verify-auth { grid-template-columns: 1fr; }
}
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 80; }
.sidebar-overlay.open { display: block; }
