:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2d3348;
  --text: #e4e7f1;
  --text-muted: #8b92a8;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --green: #22c55e;
  --green-bg: rgba(34,197,94,.12);
  --orange: #f59e0b;
  --orange-bg: rgba(245,158,11,.12);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,.12);
  --blue: #3b82f6;
  --blue-bg: rgba(59,130,246,.12);
  --purple: #a855f7;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 15px;
}

/* ========== SIDEBAR ========== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 100;
  transition: transform .3s ease;
  padding-bottom: 40px;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
  font-size: 18px;
  font-weight: 700;
}

.sidebar-header h1 .accent { color: var(--accent); }

.sidebar-header p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.sidebar nav { padding: 12px 0; }

.nav-section {
  padding: 0 12px;
  margin-bottom: 4px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  padding: 12px 12px 6px;
}

.nav-link {
  display: block;
  padding: 7px 12px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  border-radius: 6px;
  transition: all .15s;
}

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

.nav-link.active {
  background: rgba(99,102,241,.12);
  color: var(--accent);
}

.nav-link .icon {
  display: inline-block;
  width: 20px;
  text-align: center;
  margin-right: 6px;
  font-size: 14px;
}

/* ========== MAIN CONTENT ========== */
.content {
  margin-left: 280px;
  max-width: 820px;
  padding: 40px 48px 80px;
}

/* ========== MOBILE TOGGLE ========== */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 90;
}

/* ========== TYPOGRAPHY ========== */
h2 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
  padding-top: 32px;
  color: var(--text);
}

h2 .section-num {
  color: var(--accent);
  font-weight: 800;
}

h3 {
  font-size: 18px;
  font-weight: 600;
  margin-top: 28px;
  margin-bottom: 10px;
  color: var(--text);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

h4 {
  font-size: 15px;
  font-weight: 600;
  margin-top: 20px;
  margin-bottom: 8px;
  color: var(--accent);
}

p { margin-bottom: 12px; }

.section-intro {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

/* ========== COMPONENTS ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .ct-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.card-title .ct-icon.purple { background: rgba(168,85,247,.15); color: var(--purple); }
.card-title .ct-icon.blue { background: var(--blue-bg); color: var(--blue); }
.card-title .ct-icon.green { background: var(--green-bg); color: var(--green); }
.card-title .ct-icon.orange { background: var(--orange-bg); color: var(--orange); }
.card-title .ct-icon.red { background: var(--red-bg); color: var(--red); }
.card-title .ct-icon.accent { background: rgba(99,102,241,.15); color: var(--accent); }

.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
}

.steps li {
  counter-increment: step;
  padding: 8px 0 8px 36px;
  position: relative;
  font-size: 14px;
  color: var(--text);
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 8px;
  width: 24px;
  height: 24px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.steps li + li { border-top: 1px solid var(--border); }

.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.tag-blue { background: var(--blue-bg); color: var(--blue); }
.tag-green { background: var(--green-bg); color: var(--green); }
.tag-orange { background: var(--orange-bg); color: var(--orange); }
.tag-red { background: var(--red-bg); color: var(--red); }
.tag-accent { background: rgba(99,102,241,.15); color: var(--accent); }
.tag-muted { background: rgba(107,114,128,.15); color: var(--text-muted); }

.url-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 14px;
  color: var(--accent);
  margin-bottom: 12px;
  word-break: break-all;
}

.url-box .label {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  display: block;
  margin-bottom: 4px;
}

.info-box {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 14px 18px;
  margin: 16px 0;
  font-size: 13px;
  color: var(--text-muted);
}

.info-box.warn {
  border-left-color: var(--orange);
}

.info-box.danger {
  border-left-color: var(--red);
}

.info-box strong {
  color: var(--text);
}

.key {
  display: inline-block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 8px;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--text);
}

table.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 12px 0 16px;
}

table.ref-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--surface2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .3px;
  border-bottom: 1px solid var(--border);
}

table.ref-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

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

/* ========== COLLAPSIBLE ========== */
details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}

details summary {
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  transition: background .15s;
}

details summary:hover { background: var(--surface2); }

details summary::before {
  content: '\25B6';
  font-size: 10px;
  color: var(--text-muted);
  transition: transform .2s;
  flex-shrink: 0;
}

details[open] summary::before {
  transform: rotate(90deg);
}

details .detail-body {
  padding: 0 18px 18px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
}

/* ========== STATUS REFERENCE ========== */
.status-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 12px 0;
}

.status-flow .arrow {
  color: var(--text-muted);
  font-size: 14px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .mobile-toggle { display: flex; }
  .content { margin-left: 0; padding: 60px 20px 60px; }
}

@media (max-width: 600px) {
  h2 { font-size: 22px; }
  .content { padding: 56px 16px 60px; }
  .card { padding: 16px; }
  table.ref-table { font-size: 12px; }
  table.ref-table th, table.ref-table td { padding: 6px 8px; }
}

/* ========== SCROLL SPY HIGHLIGHT ========== */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ========== PRINT ========== */
@media print {
  .sidebar, .mobile-toggle, .sidebar-overlay { display: none !important; }
  .content { margin-left: 0; max-width: 100%; }
  body { background: #fff; color: #111; }
  .card, details { border-color: #ddd; }
  .url-box { background: #f5f5f5; color: #333; }
}
