:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #475569;
  --accent: #1d4ed8;
  --accent-soft: #eff6ff;
  --everyone: #15803d;
  --everyone-bg: #f0fdf4;
  --expert: #b91c1c;
  --expert-bg: #fef2f2;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --sidebar-w: 280px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.brand {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.9rem;
}
.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  display: block;
}
.brand-sub {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s;
}
.nav-link:hover { background: #f1f5f9; }
.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.tab-pill {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.12rem 0.42rem;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  flex-shrink: 0;
}
.nav-link.active .tab-pill {
  background: var(--accent);
  color: #fff;
}

.pdf-cta {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.pdf-btn {
  display: block;
  text-align: center;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.88rem;
}
.pdf-btn:hover { background: #1e40af; }
.build-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.6rem;
  text-align: center;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 2rem 2.5rem 4rem;
  max-width: 1080px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
}
.badge-everyone { background: var(--everyone-bg); color: var(--everyone); border: 1px solid #bbf7d0; }
.badge-expert { background: var(--expert-bg); color: var(--expert); border: 1px solid #fecaca; }
.badge-support { background: var(--accent-soft); color: var(--accent); border: 1px solid #bfdbfe; }
.badge-system { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; }
.badge-diagrams { background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a; }

.content h1 { font-size: 1.9rem; margin: 0 0 1rem; line-height: 1.25; }
.content h2 { font-size: 1.38rem; margin: 2rem 0 0.75rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--border); }
.content h3 { font-size: 1.12rem; margin: 1.4rem 0 0.5rem; }
.content p { margin: 0 0 0.9rem; }
.content ul, .content ol { margin: 0 0 1rem; padding-left: 1.5rem; }
.content li { margin-bottom: 0.35rem; }

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.92rem;
}
.content th, .content td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.75rem;
  text-align: left;
  vertical-align: top;
}
.content th {
  background: #f1f5f9;
  font-weight: 600;
}

.content code {
  background: #f1f5f9;
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
  font-size: 0.88em;
}
.content pre {
  background: #0f172a;
  color: #f8fafc;
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
}
.content pre code { background: none; padding: 0; color: inherit; }

.content img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: zoom-in;
}

.diagram-frame {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  margin: 1.25rem 0;
  overflow-x: auto;
  cursor: zoom-in;
}
.diagram-frame svg {
  width: 100%;
  height: auto;
  display: block;
}
.diagram-hint {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: right;
  margin-top: 0.35rem;
}

.callout {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 0.85rem 1rem;
  border-radius: 0 8px 8px 0;
  margin: 1rem 0 1.25rem;
}
.callout-title {
  font-weight: 700;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
}
.callout-warning, .callout-caution { border-left-color: var(--expert); background: var(--expert-bg); }
.callout-warning .callout-title, .callout-caution .callout-title { color: var(--expert); }
.callout-important { border-left-color: var(--warn); background: var(--warn-bg); }
.callout-important .callout-title { color: var(--warn); }
.callout-tip { border-left-color: var(--everyone); background: var(--everyone-bg); }
.callout-tip .callout-title { color: var(--everyone); }

.verify-badge {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 700;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  vertical-align: middle;
}

.page-footer-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.page-footer-nav a {
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.92rem;
}

/* Lightbox modal for zooming diagrams and photos */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
}
.lightbox.open { display: flex; }
.lightbox-inner {
  background: #fff;
  border-radius: 10px;
  max-width: 96vw;
  max-height: 92vh;
  overflow: auto;
  padding: 1rem;
  position: relative;
}
.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1.25rem;
  background: #fff;
  color: #0f172a;
  border: none;
  border-radius: 999px;
  width: 36px;
  height: 36px;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--border); }
  .main { padding: 1.25rem 1rem 3rem; }
}
