:root {
  --bg: #fafafa;
  --sidebar-bg: #1e1e2e;
  --sidebar-text: #cdd6f4;
  --sidebar-active: #89b4fa;
  --sidebar-hover: #313244;
  --text: #1e1e2e;
  --muted: #6c7086;
  --border: #e6e9ef;
  --card: #ffffff;
  --accent: #1e66f5;
  --code-bg: #f4f4f5;
  --green: #40a02b;
  --orange: #df8e1d;
}

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

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

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

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  border-right: 1px solid #313244;
}

.sidebar-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid #313244;
}

.sidebar-header h1 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
}

.sidebar-header p {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.sidebar nav { padding: 0.75rem 0; }

.nav-section {
  padding: 0.5rem 1rem 0.25rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6c7086;
  font-weight: 600;
}

.sidebar a {
  display: block;
  padding: 0.45rem 1rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  border-left: 3px solid transparent;
}

.sidebar a:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar a.active {
  background: var(--sidebar-hover);
  color: var(--sidebar-active);
  border-left-color: var(--sidebar-active);
  font-weight: 500;
}

/* Main content */
.main {
  margin-left: 260px;
  flex: 1;
  padding: 2rem 2.5rem 4rem;
  max-width: 900px;
}

.main h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.lead {
  color: var(--muted);
  font-size: 1rem;
  margin-bottom: 2rem;
}

.main h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.main h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
  color: var(--muted);
}

.main a { color: var(--accent); }

.main p { margin-bottom: 1rem; }

.main ul, .main ol {
  margin: 0 0 1rem 1.25rem;
}

.main li { margin-bottom: 0.35rem; }

/* Cards & tables */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.card h3 {
  font-size: 0.9rem;
  margin: 0 0 0.25rem;
}

.card .port {
  font-size: 0.75rem;
  color: var(--muted);
}

.card a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.875rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

th, td {
  padding: 0.6rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: #f4f4f5;
  font-weight: 600;
  font-size: 0.8rem;
}

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

/* Code */
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
  font-size: 0.8rem;
  line-height: 1.5;
}

code {
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 0.85em;
}

p code, li code, td code {
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.label {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-right: 0.35rem;
}

.label-green { background: #d8f3dc; color: #1b4332; }
.label-blue { background: #dbeafe; color: #1e3a8a; }
.label-orange { background: #ffedd5; color: #9a3412; }

/* Diagram box */
.diagram {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  overflow-x: auto;
}

.flow {
  font-family: monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: pre;
  color: var(--text);
}

.callout {
  background: #eff6ff;
  border-left: 4px solid var(--accent);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: 0 6px 6px 0;
  font-size: 0.9rem;
}

.callout-warn {
  background: #fffbeb;
  border-left-color: var(--orange);
}

.checklist { list-style: none; margin-left: 0; }
.checklist li::before { content: "☐ "; color: var(--muted); }

.mobile-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 200;
  background: var(--sidebar-bg);
  color: #fff;
  border: none;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 3.5rem 1.25rem 2rem; }
  .mobile-toggle { display: block; }
}
