@font-face {
  font-family: 'RuderPlakatLLVar';
  src: url('../fonts/RuderPlakatLLVarWeb.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'RuderPlakatLLVar';
  src: url('../fonts/RuderPlakatLLVarSub.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}


:root {
  --ruder: 'RuderPlakatLLVar', 'Impact', sans-serif;
  --mono: 'Menlo', 'Monaco', 'Consolas', 'Liberation Mono', 'Courier New', monospace;
  --sans: system-ui, -apple-system, sans-serif;
  --sidebar-width: 260px;
  --header-height: 52px;
  --content-max: 860px;
  --transition: 0.15s ease;
}

body.scheme-dark {
  --red: #c0392b;
  --red-dim: #922b21;
  --bg: #0e0e0e;
  --bg-sidebar: #141414;
  --bg-content: #111111;
  --bg-card: #1a1a1a;
  --bg-hover: #1f1f1f;
  --border: rgba(255,255,255,0.08);
  --border-active: rgba(192,57,43,0.4);
  --text-primary: #e8e6e0;
  --text-secondary: #888580;
  --text-muted: #555250;
  --text-red: #e05a4a;
}

body.scheme-light {
  --red: #c0392b;
  --red-dim: #922b21;
  --bg: #f5f4f0;
  --bg-sidebar: #eae8e4;
  --bg-content: #f0eeea;
  --bg-card: #e5e3df;
  --bg-hover: #dddbd7;
  --border: rgba(0,0,0,0.10);
  --border-active: rgba(192,57,43,0.4);
  --text-primary: #1a1816;
  --text-secondary: #666360;
  --text-muted: #999690;
  --text-red: #c0392b;
}

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

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

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

/* ── HEADER ── */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 100;
  gap: 16px;
}

#header .wordmark {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--red);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

#header .wordmark span {
  color: var(--text-secondary);
  font-weight: 400;
}

#header .separator {
  color: var(--border);
  font-size: 18px;
}

#header .doc-title {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#header .spacer { flex: 1; }

#header .header-links {
  display: flex;
  gap: 16px;
  align-items: center;
}

#header .header-links a {
  font-size: 10px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: color var(--transition);
}
#header .header-links a:hover { color: var(--text-primary); text-decoration: none; }

/* ── LAYOUT ── */
#layout {
  display: flex;
  padding-top: var(--header-height);
  min-height: 100vh;
}

/* ── SIDEBAR ── */
#sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px 0 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.nav-section { margin-bottom: 8px; }

.nav-section-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 16px 20px 6px;
  display: block;
}

.nav-item {
  display: block;
  padding: 6px 20px;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  border-left: 2px solid transparent;
  line-height: 1.4;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
  text-decoration: none;
}

.nav-item.active {
  color: var(--text-red);
  border-left-color: var(--red);
  background: rgba(192,57,43,0.06);
}

.nav-sub {
  padding-left: 32px;
  font-size: 12px;
}

/* ── MAIN CONTENT ── */
#content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
}

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

.page-inner {
  max-width: var(--content-max);
  padding: 48px 60px 80px;
}

/* ── PAGE HEADER ── */
.page-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 10px;
}

.page-title {
  font-family: var(--ruder);
  font-size: 28px;
  font-weight: 500;
  font-variation-settings: 'YTUC' 900;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 12px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 40px;
  max-width: 600px;
}

/* ── SECTION HEADERS ── */
.section-title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 48px 0 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.content-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 32px 0 10px;
}

.content-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 16px;
}

/* ── DIAGRAM CARDS ── */
.diagram-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin: 24px 0;
}

.diagram-card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.diagram-card-title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.diagram-card-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 3px;
  background: rgba(192,57,43,0.12);
  color: var(--text-red);
  letter-spacing: 0.05em;
}

.diagram-card-body {
  padding: 24px 20px;
  overflow-x: auto;
}

.diagram-card svg {
  display: block;
  width: 100%;
  height: auto;
}

/* ── SVG DIAGRAM SYSTEM ── */
.d-node {
  cursor: pointer;
  transition: opacity 0.12s;
}
.d-node:hover { opacity: 0.82; }

.d-box-purple { fill: #2a1f3d; stroke: #6b4fa0; }
.d-box-red { fill: #2d1414; stroke: #c0392b; }
.d-box-teal { fill: #0f2520; stroke: #2a9d7a; }
.d-box-amber { fill: #2a1f0a; stroke: #c8891a; }
.d-box-gray { fill: #1e1e1e; stroke: #444; }
.d-box-blue { fill: #0f1e2d; stroke: #2a6da0; }

.d-text-primary { fill: #e8e6e0; font-family: var(--mono); font-size: 12px; font-weight: 700; }
.d-text-secondary { fill: #888580; font-family: var(--mono); font-size: 11px; font-weight: 400; }
.d-text-red { fill: #e05a4a; font-family: var(--mono); font-size: 12px; font-weight: 700; }
.d-text-muted { fill: #555250; font-family: var(--mono); font-size: 10px; }
.d-text-label { fill: #555250; font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; }

.d-arrow { stroke: #444; stroke-width: 1; fill: none; }
.d-arrow-red { stroke: #c0392b; stroke-width: 1; fill: none; }
.d-line { stroke: #2a2a2a; stroke-width: 1; fill: none; }
.d-divider { stroke: rgba(255,255,255,0.06); stroke-width: 1; stroke-dasharray: 3 4; }

/* ── DETAIL PANEL ── */
#detail-panel {
  position: fixed;
  right: 0; top: var(--header-height); bottom: 0;
  width: 320px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 90;
  overflow-y: auto;
  padding: 28px 24px;
}

#detail-panel.open {
  transform: translateX(0);
}

#detail-panel .panel-close {
  position: absolute;
  top: 16px; right: 16px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 11px;
  transition: color var(--transition), border-color var(--transition);
}
#detail-panel .panel-close:hover { color: var(--text-primary); border-color: var(--text-muted); }

#detail-panel .panel-eyebrow {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 8px;
  margin-top: 8px;
}

#detail-panel .panel-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  line-height: 1.3;
}

#detail-panel .panel-body {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.75;
}

#detail-panel .panel-body p { margin-bottom: 12px; }

#detail-panel .panel-code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 14px;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 12px 0;
  white-space: pre;
  overflow-x: auto;
}

/* ── CODE BLOCKS ── */
.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 20px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin: 16px 0;
  overflow-x: auto;
  white-space: pre;
}

.code-block .hl { color: var(--text-red); }
.code-block .cm { color: var(--text-muted); }
.code-block .kw { color: #7eb8d4; }

/* ── CALLOUT ── */
.callout {
  border-left: 2px solid var(--red);
  padding: 12px 16px;
  background: rgba(192,57,43,0.06);
  border-radius: 0 4px 4px 0;
  margin: 16px 0;
}
.callout p { font-size: 12.5px; color: var(--text-secondary); margin: 0; line-height: 1.65; }
.callout strong { color: var(--text-red); }

/* ── TABLE ── */
.doc-table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 12px; }
.doc-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: 0.05em;
  font-size: 10px;
  text-transform: uppercase;
}
.doc-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}
.doc-table tr:last-child td { border-bottom: none; }
.doc-table code { color: var(--text-red); font-size: 11px; }

/* ── BADGES ── */
.badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 3px;
  font-weight: 700;
  letter-spacing: 0.04em;
  vertical-align: middle;
  margin-left: 6px;
}
.badge-live { background: rgba(42,157,122,0.15); color: #2a9d7a; }
.badge-pending { background: rgba(200,137,26,0.15); color: #c8891a; }
.badge-planned { background: rgba(68,68,68,0.4); color: #888; }

/* ── SCROLLBAR ── */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── THEME TOGGLE ── */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  opacity: 0.6;
  transition: opacity var(--transition);
}

.theme-toggle:hover {
  opacity: 1;
}

.theme-toggle-icon {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid currentColor;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

body.scheme-light .theme-toggle-icon::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 50%;
  height: 100%;
  background: currentColor;
}

body.scheme-dark .theme-toggle-icon::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: currentColor;
}

/* Transitions for scheme switching */
#header, #sidebar, .diagram-card, #detail-panel, .code-block, .callout {
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

/* ── MOBILE ── */
#mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  font-size: 18px;
}

@media (max-width: 768px) {
  #mobile-toggle { display: flex; align-items: center; }
  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 95;
  }
  #sidebar.open { transform: translateX(0); }
  #content { margin-left: 0; }
  .page-inner { padding: 32px 24px 60px; }
  #detail-panel { width: 100%; }
}
