*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; max-width: 100%; overflow-x: clip; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
  line-height: 1.55;
  overflow-x: clip;
}
code, pre { font-family: var(--font-mono); font-size: 0.875rem; }
code { background: var(--muted); padding: 0.1rem 0.35rem; border-radius: 4px; }
pre {
  margin: 0;
  padding: 0.9rem 1rem;
  background: hsl(153 35% 11%);
  color: var(--primary-foreground);
  overflow-x: auto;
  max-width: 100%;
  border-radius: 0 0 var(--radius) var(--radius);
}
pre code { background: transparent; padding: 0; color: inherit; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link {
  position: absolute; left: -9999px; top: 0.5rem; z-index: 100;
  background: var(--secondary); color: var(--secondary-foreground);
  padding: 0.55rem 0.9rem; border-radius: var(--radius-sm); font-weight: 700; text-decoration: none;
}
.skip-link:focus { left: 0.75rem; outline: 3px solid var(--primary); }

.mobile-topbar {
  display: none; position: sticky; top: 0; z-index: 40;
  height: var(--topbar-height); padding: 0 1rem;
  background: var(--sidebar-background); color: var(--primary-foreground);
  align-items: center; justify-content: space-between; gap: 0.5rem;
}
.brand-inline { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.brand-logo { height: 2rem; width: auto; display: block; border-radius: 4px; background: var(--card); padding: 0.15rem 0.35rem; }
.nav-toggle {
  background: var(--sidebar-accent); color: var(--primary-foreground);
  border: 1px solid hsl(153 25% 32%); border-radius: var(--radius-sm);
  padding: 0.45rem 0.85rem; font: inherit; font-weight: 600; cursor: pointer;
}
.nav-toggle:focus-visible, .nav-link:focus-visible, .copy-btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--secondary); outline-offset: 2px;
}

.portal-layout { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.portal-sidebar {
  position: sticky; top: 0; height: 100vh; padding: 1.5rem 1rem;
  background: var(--sidebar-background); color: var(--primary-foreground);
  display: flex; flex-direction: column; gap: 1.5rem;
}
.sidebar-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
.sidebar-title { margin: 0.25rem 0 0; font-size: 0.95rem; font-weight: 600; color: var(--primary-foreground); }
.portal-nav { display: flex; flex-direction: column; gap: 0.35rem; }
.nav-link {
  color: var(--primary-foreground); text-decoration: none;
  padding: 0.55rem 0.75rem; border-radius: var(--radius-sm); font-weight: 500;
  transition: background-color 0.15s ease;
}
.nav-link:hover { background: var(--sidebar-accent); }
.nav-link.is-active, .nav-link[aria-current="page"] {
  background: var(--sidebar-accent); border-left: 3px solid var(--secondary); font-weight: 700;
}

.portal-content { min-width: 0; display: flex; flex-direction: column; }
.portal-main { flex: 1; min-width: 0; padding: 2rem clamp(1rem, 3vw, 2.5rem); max-width: calc(var(--content-max-width) + 5rem); }
.portal-section { scroll-margin-top: 4.5rem; margin-bottom: 2.75rem; min-width: 0; }
.portal-section h1, .portal-section h2 { margin: 0 0 1rem; color: var(--primary); line-height: 1.25; }
.portal-section h1 { font-size: clamp(1.5rem, 2.5vw, 2rem); }
.portal-section h2 { font-size: 1.35rem; border-bottom: 1px solid var(--border); padding-bottom: 0.45rem; }
.portal-section h3 { margin: 0 0 0.65rem; font-size: 1.05rem; color: var(--foreground); }
.eyebrow { display: inline-block; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--primary); margin-bottom: 0.35rem; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; min-width: 0;
}
.card p:last-child { margin-bottom: 0; }

.notice {
  border-radius: var(--radius); padding: 0.9rem 1rem; margin-bottom: 1rem;
  border: 1px solid var(--border); background: var(--card);
}
.notice-demo { border-left: 4px solid var(--secondary); background: hsl(45 70% 95%); color: var(--secondary-foreground); }
.notice-info { border-left: 4px solid var(--primary); background: hsl(153 30% 95%); }

.badge {
  display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700; background: var(--muted); color: var(--foreground);
}
.badge-demo { background: var(--secondary); color: var(--secondary-foreground); }
.badge-active { background: var(--primary); color: var(--primary-foreground); }
.badge-warn { background: var(--destructive); color: var(--primary-foreground); }

.table-wrap { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55rem 0.65rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--muted); font-weight: 600; }

.key-list, .status-list, .step-list { margin: 0.5rem 0 0; padding-left: 1.2rem; display: grid; gap: 0.45rem; }
.status-list { list-style: none; padding-left: 0; }
.examples-block { display: grid; gap: 1rem; margin-top: 1rem; min-width: 0; }
.code-card { padding: 0; overflow: hidden; }
.code-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.6rem 0.9rem; background: var(--muted); border-bottom: 1px solid var(--border); font-weight: 600; font-size: 0.875rem;
}
.copy-btn {
  background: var(--primary); color: var(--primary-foreground);
  border: 0; border-radius: var(--radius-sm); padding: 0.35rem 0.75rem;
  font: inherit; font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
.copy-btn:hover { opacity: 0.92; }

.swagger-shell { padding: 0.75rem; overflow-x: auto; }
.portal-footer {
  margin-top: 1rem; padding: 1.25rem clamp(1rem, 3vw, 2.5rem) 2rem; border-top: 1px solid var(--border);
  font-size: 0.875rem; color: var(--muted-foreground); max-width: calc(var(--content-max-width) + 5rem);
}
.portal-footer p { margin: 0.25rem 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.footer-links a { color: var(--primary); font-weight: 600; }

@media (max-width: 900px) {
  .mobile-topbar { display: flex; }
  .portal-layout { grid-template-columns: minmax(0, 1fr); }
  .portal-sidebar {
    display: none; position: fixed; inset: var(--topbar-height) 0 0 0;
    height: auto; z-index: 35; overflow-y: auto;
  }
  .portal-sidebar.is-open { display: flex; }
  .sidebar-brand { display: none; }
  .portal-main { padding: 1.25rem 0.9rem; }
  .portal-footer { padding: 1rem 0.9rem 1.5rem; }
  .card-grid { grid-template-columns: minmax(0, 1fr); }
}
