:root {
  --bg: #101418;
  --bg-soft: #171d23;
  --bg-card: #1d242b;
  --text: #eef3f7;
  --muted: #aab6c2;
  --line: rgba(226, 234, 241, 0.14);
  --primary: #21a7c8;
  --primary-2: #49b86f;
  --green: #55d98b;
  --yellow: #f0bf4c;
  --red: #ee6a71;
  --code: #0b1015;
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.28);
  --radius: 8px;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f5f7f8;
  --bg-soft: #ffffff;
  --bg-card: #ffffff;
  --text: #17202a;
  --muted: #566474;
  --line: rgba(23, 32, 42, 0.14);
  --primary: #00799b;
  --primary-2: #27824e;
  --code: #101820;
  --shadow: 0 14px 34px rgba(23, 32, 42, 0.10);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

code, pre { font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; }
a { color: inherit; }
button, input, select { font: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: 292px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: rgba(16, 20, 24, 0.94);
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 20;
}

html[data-theme="light"] .sidebar { background: rgba(255, 255, 255, 0.96); }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 10px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  object-fit: contain;
  padding: 3px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
}

.brand-title { font-weight: 800; }
.brand-subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}

.search-box input::placeholder { color: var(--muted); }

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  padding-right: 4px;
}

.nav-label {
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 12px 12px 4px;
}

.nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  transition: 160ms ease;
}

.nav a:hover,
.nav a.active {
  color: var(--text);
  background: rgba(33, 167, 200, 0.14);
}

.nav a.hidden { display: none; }

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.theme-toggle,
.mobile-menu {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
}

.small-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

.content {
  width: min(1080px, calc(100vw - 292px));
  margin: 0 auto;
  padding: 28px 32px 56px;
}

.mobile-menu { display: none; margin-bottom: 16px; }
.section { scroll-margin-top: 28px; margin-bottom: 22px; }

.hero {
  padding: 54px 0 28px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.section-kicker {
  color: var(--primary);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 12px;
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: 0;
}

h1 { font-size: clamp(42px, 6vw, 72px); max-width: 900px; }
h2 { font-size: clamp(28px, 3.2vw, 40px); margin-bottom: 16px; }
h3 { font-size: 21px; margin: 28px 0 12px; }

p {
  color: var(--muted);
  line-height: 1.7;
  margin: 0 0 14px;
}

.hero-text {
  font-size: 20px;
  max-width: 780px;
  margin-top: 18px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  margin-top: 26px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  padding: 12px 16px;
  text-decoration: none;
  border: 1px solid var(--line);
  font-weight: 750;
  min-height: 44px;
}

.btn.primary {
  background: var(--primary);
  color: #ffffff;
  border-color: transparent;
}

.btn.ghost {
  background: var(--bg-soft);
  color: var(--text);
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 34px;
}

.metric-card,
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.metric-card strong {
  font-size: 24px;
  overflow-wrap: anywhere;
}

.metric-card span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.metric-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 900;
  font-size: 11px !important;
  color: var(--primary-2) !important;
}

.card { padding: clamp(22px, 4vw, 34px); }

.feature-list,
.schema-grid,
.agent-rules {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 20px;
}

.feature-list.two { grid-template-columns: repeat(2, 1fr); }

.feature-list div,
.schema-grid div,
.agent-rules div,
.glossary-grid div,
.ai-flow div,
.try-summary div,
.status {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  border-radius: var(--radius);
  padding: 16px;
}

.feature-list strong,
.schema-grid code,
.agent-rules code,
.glossary-grid code,
.ai-flow strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
}

.feature-list span,
.schema-grid span,
.agent-rules span,
.glossary-grid span,
.ai-flow span,
.status span {
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.endpoint-line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--code);
  color: #eaf3ff;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 18px 0;
}

.method {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  border-radius: var(--radius);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 900;
}

.method.get {
  background: rgba(85, 217, 139, 0.14);
  color: var(--green);
  border: 1px solid rgba(85, 217, 139, 0.34);
}

.code-card {
  margin: 16px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--code);
  color: #eaf3ff;
}

.code-card.compact pre { max-height: 480px; }

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  color: #c7d7eb;
  font-size: 13px;
  font-weight: 750;
}

.copy-btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
  color: #eaf3ff;
  border-radius: var(--radius);
  padding: 7px 10px;
  cursor: pointer;
  font-weight: 750;
  min-height: 34px;
}

.copy-btn.copied {
  color: var(--green);
  border-color: rgba(85, 217, 139, 0.55);
}

pre {
  margin: 0;
  padding: 18px;
  overflow: auto;
  line-height: 1.55;
  font-size: 13.5px;
}

.note {
  padding: 14px 16px;
  border-radius: var(--radius);
  margin: 18px 0;
  line-height: 1.65;
  color: var(--text);
  border: 1px solid var(--line);
}

.note.warning {
  background: rgba(240, 191, 76, 0.12);
  border-color: rgba(240, 191, 76, 0.28);
}

.note.info {
  background: rgba(33, 167, 200, 0.12);
  border-color: rgba(33, 167, 200, 0.28);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 14px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th, td {
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--text);
  font-size: 13px;
  background: rgba(255, 255, 255, 0.045);
}

td {
  color: var(--muted);
  line-height: 1.55;
}

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

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.status strong {
  display: block;
  margin-bottom: 8px;
}

.status.open strong { color: var(--green); }
.status.limited strong { color: var(--yellow); }
.status.nofly strong { color: var(--red); }

.glossary-grid,
.ai-flow {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 16px 0 22px;
}

.tabs { margin-top: 18px; }
.tab-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.tab-buttons button {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  padding: 10px 13px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 750;
  min-height: 42px;
}

.tab-buttons button.active {
  color: #ffffff;
  background: var(--primary);
  border-color: transparent;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.try-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.2fr);
  gap: 12px;
  margin: 18px 0;
  align-items: end;
}

.form-group {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
}

.form-group[hidden] { display: none; }

.try-form label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.try-form input[type="text"],
.try-form input[type="password"],
.try-form input[type="number"],
.try-form select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: var(--radius);
  padding: 12px 13px;
  outline: none;
  min-height: 44px;
}

.try-form input:focus,
.try-form select:focus,
.theme-toggle:focus,
.mobile-menu:focus,
.btn:focus,
.copy-btn:focus,
.tab-buttons button:focus,
.nav a:focus {
  border-color: rgba(33, 167, 200, 0.62);
  box-shadow: 0 0 0 4px rgba(33, 167, 200, 0.14);
  outline: none;
}

.check-row {
  flex-direction: row !important;
  align-items: center;
  align-self: center;
  min-height: 44px;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.try-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.try-actions button[disabled] {
  opacity: 0.68;
  cursor: progress;
}

.try-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 18px 0;
}

.try-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 900;
  margin-bottom: 8px;
}

.try-summary strong {
  display: block;
  font-size: 23px;
  overflow-wrap: anywhere;
}

.try-summary.open strong:first-letter { color: var(--green); }
.try-summary.limited strong:first-letter { color: var(--yellow); }
.try-summary.no-fly strong:first-letter { color: var(--red); }

.code-card.try-error {
  border-color: rgba(238, 106, 113, 0.48);
}

.code-card.try-error .code-head { color: #ffd6d9; }

.contact-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 20px;
  background: rgba(255, 255, 255, 0.035);
}

.contact-card h3 { margin-top: 0; }

.doc-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 22px;
  margin-top: 34px;
  font-size: 13px;
}

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

  .sidebar {
    position: fixed;
    transform: translateX(-105%);
    transition: 220ms ease;
    width: min(320px, 88vw);
  }

  .sidebar.open { transform: translateX(0); }
  .content { width: 100%; padding: 18px 18px 44px; }
  .mobile-menu { display: inline-flex; position: sticky; top: 12px; z-index: 10; }
  .hero { padding-top: 30px; }

  .hero-grid,
  .feature-list,
  .feature-list.two,
  .schema-grid,
  .status-grid,
  .agent-rules,
  .try-summary,
  .glossary-grid,
  .ai-flow {
    grid-template-columns: 1fr;
  }

  .try-form,
  .form-group {
    grid-template-columns: 1fr 1fr;
  }

  .contact-card {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 560px) {
  .card { padding: 20px; }
  h1 { font-size: 40px; }
  .hero-text { font-size: 17px; }
  .endpoint-line {
    align-items: flex-start;
    flex-direction: column;
  }
  .try-form,
  .form-group {
    grid-template-columns: 1fr;
  }
  .btn {
    width: 100%;
  }
  table {
    min-width: 640px;
  }
}

/* Traffic documentation: preserve existing API components and mobile width. */
#traffic-awareness pre { max-width: 100%; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
#traffic-awareness code { overflow-wrap: anywhere; }
#traffic-awareness .table-wrap { max-width: 100%; overflow-x: auto; }
