/* ── Reset & base ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0d0d;
  --surface:   #161616;
  --surface2:  #1e1e1e;
  --border:    #2a2a2a;
  --accent:    #4da6ff;
  --accent2:   #7ec8ff;
  --danger:    #ff5555;
  --text:      #e8e8e8;
  --muted:     #888;
  --sidebar-w: 260px;
  --radius:    10px;
}

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

/* ── Sidebar ──────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 28px 20px 20px;
  z-index: 100;
}

.sidebar-header h2 {
  font-size: 1.3rem;
  color: var(--accent);
  margin-bottom: 4px;
}

.sidebar-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 28px;
}

.sidebar ul {
  list-style: none;
  flex: 1;
}

.sidebar li {
  margin: 6px 0;
}

.sidebar a {
  display: block;
  padding: 9px 14px;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  transition: background 0.15s, color 0.15s;
}

.sidebar a:hover,
.sidebar a.active {
  background: var(--surface2);
  color: var(--accent);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.sidebar-footer a {
  font-size: 0.82rem;
  color: var(--muted);
  text-decoration: none;
}

.sidebar-footer a:hover { color: var(--accent); }

/* ── Main content ────────────────────────────── */
.content {
  margin-left: var(--sidebar-w);
  padding: 48px 52px;
  max-width: 1000px;
}

.page { display: none; }
.page.active { display: block; }

/* ── Typography ─────────────────────────────── */
h1 { font-size: 1.9rem; margin-bottom: 10px; color: #fff; }
h2 { font-size: 1.2rem; margin: 32px 0 12px; color: var(--accent2); }
p  { margin-bottom: 14px; color: #ccc; }

a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.85em;
  color: #f8c77e;
}

pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
  margin-bottom: 20px;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.88rem;
  color: #c9d1d9;
}

/* ── Tables ─────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 0.9rem;
}

th {
  text-align: left;
  padding: 9px 12px;
  background: var(--surface2);
  color: var(--accent2);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: #ccc;
  vertical-align: top;
}

tr:hover td { background: rgba(77,166,255,0.04); }

/* ── Badges ─────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.required { background: rgba(255,85,85,0.18); color: #ff8080; }
.badge.optional { background: rgba(77,166,255,0.15); color: var(--accent); }

/* ── Flow diagram ────────────────────────────── */
.flow-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 28px 0;
}

.flow-box {
  padding: 14px 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  text-align: center;
  font-weight: 600;
  min-width: 240px;
}

.flow-box span {
  display: block;
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
  margin-top: 3px;
}

.flow-box.authority  { border-color: #4da6ff; background: rgba(77,166,255,0.08); }
.flow-box.execution  { border-color: #7ec8ff; background: rgba(126,200,255,0.07); }
.flow-box.blockchain { border-color: #a78bfa; background: rgba(167,139,250,0.08); }
.flow-box.access     { border-color: #34d399; background: rgba(52,211,153,0.07); }
.flow-box.registry   { border-color: #f59e0b; background: rgba(245,158,11,0.07); }

.flow-arrow { color: var(--muted); font-size: 1.1rem; }

.flow-arrow-branch {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── Accordion (workers) ─────────────────────── */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.accordion-header:hover { background: var(--surface2); }

.accordion-title { font-weight: 600; font-size: 1rem; }
.accordion-layer {
  font-size: 0.78rem;
  color: var(--muted);
  margin-left: 10px;
}

.accordion-chevron {
  color: var(--muted);
  font-size: 0.85rem;
  transition: transform 0.2s;
}

.accordion.open .accordion-chevron { transform: rotate(180deg); }

.accordion-body {
  display: none;
  padding: 20px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.accordion.open .accordion-body { display: block; }

/* ── Env tables ─────────────────────────────── */
.env-section { margin-bottom: 40px; }
.env-section h2 { margin-top: 0; }

/* ── Deploy steps ───────────────────────────── */
.deploy-order { margin: 20px 0 32px; }

.deploy-step {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--surface);
}

.step-num {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Diagram grid ────────────────────────────── */
.diagram-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 20px;
}

.diagram-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.diagram-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.diagram-card .placeholder {
  height: 160px;
  background: var(--surface2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.85rem;
  gap: 8px;
}

.diagram-card .placeholder .icon { font-size: 2rem; }

.diagram-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}

.diagram-card .diagram-label {
  padding: 10px 14px;
  font-size: 0.85rem;
  color: #ccc;
  border-top: 1px solid var(--border);
}

/* ── Modal / lightbox ────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  z-index: 999;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 10px; right: 14px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-close:hover { color: #fff; }

#modalImg {
  max-width: 100%;
  max-height: 75vh;
  border-radius: 6px;
  display: block;
  margin: 0 auto 12px;
}

#modalCaption { color: var(--muted); font-size: 0.88rem; }

/* ── Responsive ─────────────────────────────── */
@media (max-width: 700px) {
  .sidebar { width: 100%; height: auto; position: relative; }
  .content { margin-left: 0; padding: 24px 18px; }
}

/* ── Screenshot thumb in accordion ─────────── */
.screenshot-thumb {
  cursor: pointer;
  margin-bottom: 16px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  max-width: 480px;
}
.screenshot-thumb img {
  width: 100%;
  display: block;
}
