:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-elevated: #0b1120;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 16px;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: #7dd3fc;
  text-decoration: underline;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none !important;
}

.brand-badge {
  background: var(--accent-strong);
  color: #fff;
  font-size: 0.78rem;
  padding: 3px 9px;
  border-radius: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-title {
  font-size: 1.05rem;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent);
}

/* Hero */
.hero {
  padding: 56px 0 36px;
  background: radial-gradient(circle at 20% 0%, rgba(2, 132, 199, 0.22), transparent 55%),
              linear-gradient(180deg, #0b1120 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.pill {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.pill-accent {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.45);
  color: var(--accent);
}

.hero h1 {
  font-size: clamp(1.75rem, 3.2vw, 2.5rem);
  line-height: 1.2;
  margin-bottom: 14px;
  color: #f8fafc;
}

.hero-subtitle {
  font-size: 1.1rem;
  color: #cbd5e1;
  max-width: 860px;
  margin-bottom: 28px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 14px;
}

.meta-card {
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.meta-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.meta-value {
  font-weight: 700;
  font-size: 0.98rem;
  color: #fff;
  margin-bottom: 3px;
}

.meta-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Main Content & Sections */
.main-content {
  padding-top: 36px;
  padding-bottom: 56px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 10px 25px -10px rgba(0, 0, 0, 0.35);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.section-num {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 5px 11px;
  border-radius: 8px;
}

.section-card h2 {
  font-size: 1.45rem;
  color: #f8fafc;
}

.section-card h3 {
  font-size: 1.16rem;
  color: #f1f5f9;
  margin-top: 26px;
  margin-bottom: 10px;
}

.section-card h4 {
  font-size: 1rem;
  color: #e2e8f0;
  margin-top: 18px;
  margin-bottom: 8px;
}

.section-card p {
  margin-bottom: 14px;
  color: #cbd5e1;
}

.section-card ul,
.section-card ol {
  margin: 10px 0 16px 22px;
  color: #cbd5e1;
}

.section-card li {
  margin-bottom: 8px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.87em;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.22);
  padding: 2px 6px;
  border-radius: 5px;
  color: #7dd3fc;
}

/* Callouts */
.callout {
  border-radius: 10px;
  padding: 18px 20px;
  margin: 18px 0;
  border-left: 4px solid var(--accent);
  background: rgba(15, 23, 42, 0.65);
}

.callout h3,
.callout h4 {
  margin-top: 0;
  margin-bottom: 6px;
  color: #fff;
}

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

.callout-important {
  border-left-color: var(--accent);
  background: rgba(2, 132, 199, 0.12);
}

.callout-note {
  border-left-color: var(--warning);
  background: rgba(245, 158, 11, 0.1);
}

/* Feature Grid */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.feature-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}

.feature-box h4 {
  margin-top: 0;
  margin-bottom: 8px;
  color: var(--accent);
}

.feature-box p {
  font-size: 0.93rem;
  margin-bottom: 0;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 14px 0 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  font-size: 0.93rem;
}

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

th {
  background: rgba(30, 41, 59, 0.9);
  color: #f8fafc;
  font-weight: 600;
}

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

/* Diagram Box */
.diagram-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin: 14px 0 22px;
}

.diagram-flow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.flow-step {
  flex: 1 1 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.flow-tag {
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  font-weight: 700;
}

.flow-step span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.flow-arrow {
  font-size: 1.5rem;
  color: var(--accent);
  font-weight: 700;
}

.flow-branch {
  flex: 1.5 1 320px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.branch-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.branch-item small {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.branch-admin {
  border-left-color: var(--success);
}

.branch-user {
  border-left-color: var(--accent);
}

.branch-err {
  border-left-color: var(--danger);
}

/* Code Panels */
.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
}

.code-panel {
  margin: 12px 0 18px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(30, 41, 59, 0.85);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #cbd5e1;
}

.copy-btn {
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 0.76rem;
  cursor: pointer;
  transition: background 0.15s;
}

.copy-btn:hover {
  background: rgba(56, 189, 248, 0.25);
}

.code-panel pre {
  padding: 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  line-height: 1.55;
  color: #e2e8f0;
}

.code-panel pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.mono-badge {
  display: inline-block;
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--text-muted);
}

.small-caption {
  font-size: 0.86rem;
  color: var(--text-muted);
}

/* Video Card */
.video-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 12px;
}

.video-wrapper {
  background: #000;
  width: 100%;
  max-height: 480px;
  display: flex;
  justify-content: center;
}

.video-wrapper video {
  width: 100%;
  max-height: 460px;
}

.video-info {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.video-info p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 4px 0 0;
}

/* Audio Recording Card */
.audio-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.audio-card audio {
  width: 100%;
  height: 44px;
  border-radius: 8px;
}

.audio-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.audio-info p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 4px 0 0;
}

.btn-outline {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  text-decoration: none !important;
}

.btn-outline:hover {
  background: rgba(56, 189, 248, 0.14);
}

.ref-list li {
  margin-bottom: 10px;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  background: #0b1120;
  padding: 28px 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

@media (max-width: 720px) {
  .section-card {
    padding: 20px;
  }
  .two-col {
    grid-template-columns: 1fr;
  }
  .flow-arrow {
    display: none;
  }
}
