:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --bg-card-hover: #144272;
  --bg-systems: #111827;
  --text-primary: #e2e2f0;
  --text-secondary: #b0b0c8;
  --text-muted: #7878a0;
  --accent: #e94560;
  --accent-hover: #ff6b81;
  --accent-dim: rgba(233, 69, 96, 0.15);
  --border: #2a2a4a;
  --border-light: #3a3a5a;
  --radius: 8px;
  --radius-lg: 12px;
  --transition: 0.2s ease;
  --font-mono: "Consolas", "Courier New", monospace;
  --max-width: 1100px;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 70px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

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

img { max-width: 100%; display: block; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

h1, h2, h3 {
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h1 { font-size: 3rem; font-weight: 800; }
h2 { font-size: 2rem; font-weight: 700; color: var(--text-primary); margin-bottom: 0.25em; }
h3 { font-size: 1.1rem; font-weight: 600; }

.section-subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 2rem;
}

/* ========== BUTTONS ========== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-light);
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ========== HERO ========== */

#hero {
  position: relative;
  min-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  padding: 120px 24px 80px;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(233, 69, 96, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 20% 80%, rgba(15, 52, 96, 0.3) 0%, transparent 50%),
    radial-gradient(ellipse 60% 80% at 80% 80%, rgba(15, 52, 96, 0.3) 0%, transparent 50%);
  z-index: 0;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 750px;
}

#hero h1 {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 50%, var(--text-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.3em;
  letter-spacing: -0.02em;
}

#hero .tagline {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto 2rem;
}

.hero-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ========== NAVBAR ========== */

#navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(26, 26, 46, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 10px;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.04rem;
  color: var(--text-primary);
  white-space: nowrap;
}
.nav-brand:hover { color: var(--accent); }

.nav-links {
  display: flex;
  list-style: none;
  gap: 1px;
  flex: 1;
  flex-wrap: nowrap;
}

.nav-links a {
  display: block;
  padding: 6px 7px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.81rem;
  font-weight: 500;
  white-space: nowrap;
  transition: all var(--transition);
}
.nav-links a:hover {
  color: var(--text-primary);
  background: var(--accent-dim);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.lang-switcher {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.lang-btn {
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.lang-btn:hover { color: var(--text-primary); background: var(--accent-dim); }
.lang-btn.active {
  background: var(--accent);
  color: #fff;
}

.nav-github {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 6px;
  transition: all var(--transition);
}
.nav-github:hover { color: var(--text-primary); background: var(--accent-dim); }

.nav-toggle {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  padding: 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
}

.nav-toggle:hover {
  background: var(--accent-dim);
}

.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 1px;
  transition: all 0.25s ease;
}

body.nav-open .nav-toggle span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

body.nav-open .nav-toggle span:nth-child(2) {
  opacity: 0;
}

body.nav-open .nav-toggle span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ========== SECTIONS ========== */

section {
  padding: 80px 0;
}

section:nth-child(even) {
  background: var(--bg-secondary);
}

#about p {
  max-width: 800px;
  margin-bottom: 1rem;
  color: var(--text-secondary);
  font-size: 1.05rem;
}

/* ========== FEATURES ========== */

.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  transition: all var(--transition);
}

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

.feature-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-dim);
  border-radius: var(--radius);
  color: var(--accent);
  margin-bottom: 16px;
}

.feature-card h3 {
  margin-bottom: 8px;
  color: var(--text-primary);
}

.feature-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ========== ARCHITECTURE ========== */

.arch-diagram {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 32px 0;
}

.arch-block {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  transition: all var(--transition);
}

.arch-block:hover {
  border-color: var(--accent);
}

.arch-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  color: var(--accent);
}

.arch-block h3 {
  margin-bottom: 8px;
}

.arch-block p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.6;
}

.arch-arrow {
  display: flex;
  align-items: center;
  padding-top: 40px;
  color: var(--accent);
  opacity: 0.6;
  flex-shrink: 0;
}

.arch-footer {
  text-align: center;
  color: var(--text-muted);
  max-width: 700px;
  margin: 24px auto 0;
  font-size: 0.95rem;
}

/* ========== SCREENSHOTS ========== */

.screenshots-grid {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 12px;
  scroll-snap-type: x mandatory;
}

.screenshot-item {
  min-width: 280px;
  height: 180px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  scroll-snap-align: start;
  transition: border-color var(--transition);
  cursor: pointer;
}

.screenshot-item:hover {
  border-color: var(--accent);
}

.screenshot-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ========== LIGHTBOX ========== */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.lightbox.open {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
}

.lightbox-img {
  position: relative;
  z-index: 1;
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

.lightbox-close {
  position: absolute;
  top: 16px;
  right: 24px;
  z-index: 2;
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  line-height: 1;
}

.lightbox-close:hover {
  opacity: 1;
}

.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  z-index: 2;
  background: none;
  border: none;
  color: #fff;
  font-size: 3rem;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s;
  transform: translateY(-50%);
  line-height: 1;
  padding: 8px 16px;
}

.lightbox-prev:hover,
.lightbox-next:hover {
  opacity: 1;
}

.lightbox-prev {
  left: 8px;
}

.lightbox-next {
  right: 8px;
}

/* ========== VIDEOS ========== */

.videos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
}

.video-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition);
}

.video-card:hover {
  border-color: var(--accent);
}

.video-wrapper {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
}

.video-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.video-caption {
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ========== STORY ========== */

.story-content {
  max-width: 800px;
  margin: 0 auto;
}

.story-content p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  margin-bottom: 1.2rem;
}

.story-content p:last-child {
  font-style: italic;
  color: var(--accent);
}

/* ========== SYSTEMS ACCORDION ========== */

.systems-list {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sys-details {
  background: var(--bg-systems);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
}

.sys-details[open] {
  border-color: var(--border-light);
}

.sys-summary {
  padding: 14px 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition);
}

.sys-summary:hover {
  background: var(--bg-card);
}

.sys-summary::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.sys-summary::marker {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.sys-body {
  padding: 0 20px 18px;
  margin-left: 28px;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.6;
}

/* ========== DOCUMENTATION ========== */

.docs-section {
  background: var(--bg-primary);
}

.docs-content {
  margin: 0 auto;
  color: var(--text-secondary);
  line-height: 1.8;
  font-size: 0.98rem;
}

.docs-content h1 {
  margin-bottom: 0.3em;
  font-size: 2rem;
  color: var(--text-primary);
}

.docs-content h2 {
  font-size: 1.4rem;
  margin-top: 2em;
  margin-bottom: 0.5em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}

.docs-content h3 {
  font-size: 1.1rem;
  margin-top: 1.5em;
  margin-bottom: 0.4em;
  color: var(--text-primary);
}

.docs-content h4 {
  font-size: 1rem;
  margin-top: 1.2em;
  margin-bottom: 0.3em;
  color: var(--text-primary);
}

.docs-content p {
  margin-bottom: 1rem;
}

.docs-content ul,
.docs-content ol {
  margin: 0 0 1rem 1.5rem;
}

.docs-content li {
  margin-bottom: 0.4rem;
}

.docs-content li > ul,
.docs-content li > ol {
  margin-top: 0.4rem;
  margin-bottom: 0;
}

.docs-content a {
  color: var(--accent);
  text-decoration: none;
}

.docs-content a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.docs-content img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 1.2rem 0;
  border: 1px solid var(--border);
}

.docs-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  background: var(--accent-dim);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-secondary);
  font-style: italic;
}

.docs-content blockquote p {
  margin-bottom: 0;
}

.docs-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

.docs-content pre {
  background: var(--bg-systems);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  overflow-x: auto;
  margin: 1rem 0;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.55;
}

.docs-content pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  border-radius: 0;
  color: var(--text-primary);
}

.docs-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--accent-dim);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
}

.docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.93rem;
}

.docs-content th {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--border);
}

.docs-content td {
  padding: 8px 14px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.docs-content tr:nth-child(even) td {
  background: var(--bg-secondary);
}

.docs-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.docs-error {
  text-align: center;
  padding: 40px 0;
  color: var(--text-secondary);
}

.docs-error code {
  color: var(--accent);
}

.docs-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.docs-hint code {
  color: var(--accent);
}

/* ========== CTA ========== */

#cta {
  text-align: center;
}

#cta p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 700px;
  margin: 0 auto 1rem;
}

.cta-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 24px;
}

/* ========== FOOTER ========== */

footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  background: var(--bg-primary);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.88rem;
  flex-wrap: wrap;
}

.footer-sep {
  color: var(--border-light);
}

/* ========== RESPONSIVE ========== */

@media (max-width: 900px) {
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .arch-diagram {
    flex-direction: column;
    align-items: stretch;
  }

  .arch-arrow {
    padding-top: 0;
    justify-content: center;
    transform: rotate(90deg);
  }

  .nav-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 99;
  }

  .nav-links a {
    padding: 10px 14px;
    font-size: 0.9rem;
  }

  body.nav-open .nav-links {
    display: flex;
  }

  .nav-right {
    min-width: 0;
    gap: 8px;
  }

  .lang-switcher {
    flex-wrap: wrap;
  }

  .lang-btn {
    padding: 5px 8px;
  }

  h1 { font-size: 2.2rem; }
  h2 { font-size: 1.6rem; }
}

@media (max-width: 600px) {
  .features-grid {
    grid-template-columns: 1fr;
  }

  .screenshots-grid {
    flex-wrap: nowrap;
  }

  .screenshot-placeholder {
    min-width: 240px;
    height: 150px;
  }

  section {
    padding: 56px 0;
  }

  .hero-buttons, .cta-buttons {
    flex-direction: column;
    align-items: center;
  }

  .footer-inner {
    flex-direction: column;
    gap: 2px;
  }

  .footer-sep { display: none; }
}

/* ========== DOCS MODE (full page) ========== */

body.docs-mode #hero,
body.docs-mode #about,
body.docs-mode #features,
body.docs-mode #architecture,
body.docs-mode #screenshots,
body.docs-mode #videos,
body.docs-mode #story,
body.docs-mode #systems,
body.docs-mode #cta,
body.docs-mode footer {
  display: none;
}

body.docs-mode main {
  display: block;
}

body.docs-mode #docs {
  padding: 0;
  min-height: 100vh;
  background: var(--bg-primary);
}

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

body.docs-mode .docs-main {
  flex: 1;
  min-width: 0;
  padding: 32px 0 80px;
}

body.docs-mode .docs-content {

}

/* ========== SIDEBAR ========== */

.docs-sidebar {
  display: none;
}

body.docs-mode .docs-sidebar {
  display: block;
  width: 250px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 24px 0;
  overflow-y: auto;
  position: sticky;
  top: 0;
  max-height: 100vh;
  background: var(--bg-secondary);
}

.sidebar-resize-handle {
  width: 4px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  transition: background var(--transition);
  z-index: 10;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle.active {
  background: var(--accent);
}

.sidebar-overlay {
  display: none;
}


/* ========== SIDEBAR SEARCH ========== */

.sidebar-search {
  display: none;
  padding: 0 12px 16px;
}

body.docs-mode .sidebar-search {
  display: block;
}

.sidebar-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.sidebar-search-input {
  width: 100%;
  padding: 7px 32px 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}

.sidebar-search-input::placeholder {
  color: var(--text-muted);
}

.sidebar-search-input:focus {
  border-color: var(--accent);
}

.sidebar-search-clear {
  display: none;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  transition: all var(--transition);
}

.sidebar-search-clear:hover {
  color: var(--text-primary);
  background: var(--accent-dim);
}

.sidebar-search-clear.visible {
  display: flex;
}

.sidebar-tree {
  padding: 0 12px;
}

.sidebar-tree ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-tree .sidebar-sub {
  border-left: 1px solid var(--border);
  margin-left: 11px;
}

.sidebar-item {
  position: relative;
  margin: 0;
}

.sidebar-item.collapsed > .sidebar-sub {
  display: none;
}

.sidebar-item.collapsed .tree-toggle {
  transform: rotate(-90deg);
}

/* ----- tree row ----- */

.sidebar-row {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 8px;
}

/* ----- toggle ----- */

.tree-toggle {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.65rem;
  line-height: 1;
  padding: 0;
  border-radius: 3px;
  transition: transform 0.2s ease, color var(--transition);
}

.tree-toggle:hover {
  color: var(--text-primary);
  background: var(--accent-dim);
}

.tree-spacer {
  flex-shrink: 0;
  width: 16px;
  height: 0;
}

/* ----- link & category ----- */

.sidebar-link {
  display: block;
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
  margin-bottom: 1px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-link:hover {
  color: var(--text-primary);
  background: var(--accent-dim);
}

.sidebar-link.active {
  color: var(--accent);
  background: var(--accent-dim);
  font-weight: 600;
}

.sidebar-category {
  display: block;
  flex: 1;
  min-width: 0;
  padding: 7px 8px 6px;
  margin-bottom: 1px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-toggle {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  z-index: 250;
}

.sidebar-toggle:hover {
  background: var(--accent-dim);
}

.sidebar-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 1px;
  transition: all 0.25s ease;
}

body.sidebar-open .sidebar-toggle span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

body.sidebar-open .sidebar-toggle span:nth-child(2) {
  opacity: 0;
}

body.sidebar-open .sidebar-toggle span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 899px) {
  body.docs-mode .docs-layout {
    display: block;
  }

  body.docs-mode .docs-sidebar {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 200;
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    padding: 16px 0;
  }

  body.docs-mode.sidebar-open .docs-sidebar {
    transform: translateX(0);
  }

  body.docs-mode.sidebar-open .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
  }

  body.docs-mode .sidebar-toggle {
    display: flex;
    position: fixed;
    top: 68px;
    right: 12px;
    z-index: 250;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }

  body.docs-mode .sidebar-resize-handle {
    display: none;
  }

  body.docs-mode .docs-main {
    padding: 76px 0 60px;
  }
}

/* ========== BACK LINK ========== */

.docs-back-link {
  display: none;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius);
  transition: all var(--transition);
  text-decoration: none;
  cursor: pointer;
}

.docs-back-link:hover {
  color: var(--text-primary);
  background: var(--accent-dim);
}

body.docs-mode #navbar {
  display: none;
}

body.docs-mode .docs-back-link {
  display: flex;
}

body.docs-mode .nav-links,
body.docs-mode .nav-toggle,
body.docs-mode .nav-github {
  display: none;
}

@media (max-width: 899px) {
  body.docs-mode #navbar {
    display: block;
  }

  body.docs-mode .nav-brand {
    display: none;
  }

  body.docs-mode .nav-right {
    display: flex;
    margin-left: 0;
  }
}

body.docs-mode #docs {
  min-height: 100vh;
}

body.docs-mode .docs-layout {
  min-height: 100vh;
}

body.docs-mode .docs-sidebar {
  top: 0;
  max-height: 100vh;
}

/* ========== QUICKSTART MODE ========== */

#quickstart {
  display: none;
}

body.quickstart-mode #hero,
body.quickstart-mode #about,
body.quickstart-mode #features,
body.quickstart-mode #architecture,
body.quickstart-mode #screenshots,
body.quickstart-mode #videos,
body.quickstart-mode #story,
body.quickstart-mode #systems,
body.quickstart-mode #docs,
body.quickstart-mode #cta,
body.quickstart-mode footer {
  display: none;
}

body.quickstart-mode #quickstart {
  display: block;
  padding: 32px 0 80px;
  min-height: calc(100vh - 56px);
  background: var(--bg-primary);
}

body.quickstart-mode #navbar {
  display: block;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
}

body.quickstart-mode .nav-brand { display: none; }
body.quickstart-mode .nav-links { display: none; }
body.quickstart-mode .nav-toggle { display: none; }
body.quickstart-mode .nav-github { display: none; }
body.quickstart-mode .docs-back-link { display: flex; }
body.quickstart-mode .nav-right { display: flex; margin-left: auto; }
body.quickstart-mode .sidebar-toggle { display: none; }

@media (max-width: 899px) {
  body.quickstart-mode #quickstart {
    padding: 76px 0 60px;
  }

  body.quickstart-mode .nav-right {
    display: flex;
    margin-left: 0;
  }
}

/* Quickstart cards */

.quickstart-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin: 32px 0;
}

.qs-card {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  transition: all var(--transition);
  text-decoration: none;
  color: var(--text-primary);
}

.qs-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.qs-card h3 {
  font-size: 1.2rem;
  margin: 0 0 10px 0;
  color: var(--accent);
}

.qs-card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin: 0 0 12px 0;
  line-height: 1.5;
}

.qs-card .qs-card-meta {
  display: inline-block;
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--accent-dim);
  padding: 4px 10px;
  border-radius: var(--radius);
}

.qs-download {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  transition: all var(--transition);
  margin: 8px 0 6px;
}

.qs-download:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.qs-download svg {
  flex-shrink: 0;
  transition: transform var(--transition);
}

.qs-download:hover svg {
  transform: translateY(2px);
}

.qs-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 28px;
}

.qs-meta span {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 5px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Mermaid diagrams */
.mermaid-wrap {
  position: relative;
  margin: 1.5em 0;
  overflow: hidden;
  min-height: 200px;
  max-height: 75vh;
  background: var(--bg-systems);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: grab;
}
.mermaid-wrap .mermaid {
  display: inline-block;
  padding: 1.5em;
  will-change: transform;
}
.mermaid-wrap .mermaid svg {
  max-width: none;
}
.mermaid-wrap.is-zoomed {
  cursor: grab;
}

.mermaid-zoom-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 5;
}
.mermaid-wrap:hover .mermaid-zoom-controls,
.mermaid-zoom-controls:hover {
  opacity: 1;
}
.mermaid-zoom-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 0.2s, color 0.2s;
  padding: 0;
}
.mermaid-zoom-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.mermaid-wrap.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  margin: 0;
  border-radius: 0;
  border: none;
  max-height: none;
  background: rgba(10, 10, 25, 0.95);
  cursor: grab;
}
.mermaid-wrap.is-fullscreen .mermaid {
  padding: 2em;
}
.mermaid-wrap.is-fullscreen .mermaid-zoom-controls {
  top: 16px;
  right: 16px;
  gap: 6px;
  opacity: 1;
}
.mermaid-wrap.is-fullscreen .mermaid-zoom-btn {
  width: 34px;
  height: 34px;
  font-size: 18px;
}

@media (max-width: 900px) {
  .mermaid-wrap.is-fullscreen .mermaid {
    padding: 1em;
  }
  .mermaid-wrap.is-fullscreen .mermaid-zoom-controls {
    top: 8px;
    right: 8px;
    gap: 4px;
  }
  .mermaid-wrap.is-fullscreen .mermaid-zoom-btn {
    width: 28px;
    height: 28px;
    font-size: 15px;
  }
}
