/* ============================================================
   WORKING WELL WITH AI — Futuristic Dark UI
   ============================================================ */

/* ── Custom properties ─────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-base:        #05050f;
  --bg-sidebar:     #07071a;
  --bg-elevated:    #0c0c20;
  --bg-card:        #0e0e25;
  --bg-code:        #0a0a1e;
  --bg-hover:       rgba(0, 200, 255, 0.05);
  --bg-active:      rgba(0, 200, 255, 0.08);

  /* Borders */
  --border-subtle:  rgba(255, 255, 255, 0.04);
  --border-mid:     rgba(255, 255, 255, 0.08);
  --border-accent:  rgba(0, 200, 255, 0.25);

  /* Text */
  --text-primary:   #d8e0f0;
  --text-secondary: #8898bb;
  --text-muted:     #4a5572;
  --text-inverse:   #05050f;

  /* Accents */
  --accent-cyan:    #00c8ff;
  --accent-purple:  #7b2fff;
  --accent-green:   #00e896;
  --accent-amber:   #ffb830;

  /* Glows */
  --glow-cyan:      0 0 20px rgba(0, 200, 255, 0.35);
  --glow-cyan-sm:   0 0 8px  rgba(0, 200, 255, 0.2);
  --glow-purple:    0 0 20px rgba(123, 47, 255, 0.4);

  /* Fonts */
  --font-display:   'Space Grotesk', system-ui, sans-serif;
  --font-body:      'Inter', system-ui, sans-serif;
  --font-mono:      'JetBrains Mono', 'Fira Code', monospace;

  /* Dimensions */
  --sidebar-w:      280px;
  --topbar-h:       56px;
  --content-max:    780px;

  /* Transitions */
  --ease:           cubic-bezier(0.4, 0, 0.2, 1);
  --speed:          160ms;
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Starfield canvas ───────────────────────────────────────── */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.45;
}

/* ── Layout ─────────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border-mid) transparent;
  transition: transform var(--speed) var(--ease);
  box-shadow: 1px 0 40px rgba(0, 0, 0, 0.6);
}

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

/* Brand */
.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-glyph {
  font-size: 26px;
  color: var(--accent-cyan);
  text-shadow: var(--glow-cyan);
  line-height: 1;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.brand-sub {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 400;
  color: var(--accent-cyan);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 0 20px;
}

.nav-section {
  border-bottom: 1px solid var(--border-subtle);
}

.nav-section-toggle {
  width: 100%;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  padding: 0;
  transition: background var(--speed) var(--ease);
}

.nav-section-toggle:hover {
  background: var(--bg-hover);
}

.nav-section-link {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  padding: 11px 0 11px 20px;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  line-height: 1.3;
  transition: color var(--speed) var(--ease);
  cursor: pointer;
}

.nav-section-link:hover {
  color: var(--text-primary);
}

.is-active-section .nav-section-link {
  color: var(--accent-cyan);
}

.nav-chevron-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 11px 16px 11px 8px;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0.5;
  transition: transform var(--speed) var(--ease), opacity var(--speed) var(--ease), color var(--speed) var(--ease);
}

.nav-chevron-btn:hover {
  opacity: 1;
  color: var(--text-primary);
}

.nav-section-toggle[aria-expanded="true"] .nav-chevron-btn,
.is-active-section .nav-chevron-btn {
  transform: rotate(90deg);
  opacity: 1;
}

.nav-section-icon {
  font-size: 13px;
  opacity: 0.7;
  flex-shrink: 0;
  width: 16px;
  text-align: center;
}

.nav-section-label {
  flex: 1;
  line-height: 1.3;
}

.nav-items {
  list-style: none;
  padding: 2px 0 8px;
  display: none;
}

.nav-items.is-open,
.is-active-section .nav-items {
  display: block;
}

.nav-item {
  display: block;
  padding: 7px 20px 7px 46px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color var(--speed) var(--ease),
              background var(--speed) var(--ease),
              border-color var(--speed) var(--ease);
  line-height: 1.4;
}

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

.nav-item.is-active {
  color: var(--accent-cyan);
  background: var(--bg-active);
  border-left-color: var(--accent-cyan);
  text-shadow: var(--glow-cyan-sm);
}

/* Sidebar footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-footer-text {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

/* ── Main area ───────────────────────────────────────────────── */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: rgba(5, 5, 15, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.sidebar-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.sidebar-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 1px;
  transition: background var(--speed);
}

.sidebar-toggle:hover span { background: var(--text-primary); }

.topbar-breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  min-width: 0;
}

.breadcrumb-home {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--speed);
  white-space: nowrap;
}

.breadcrumb-home:hover { color: var(--accent-cyan); }

.breadcrumb-sep { opacity: 0.4; }

.breadcrumb-current {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green), 0 0 16px rgba(0, 232, 150, 0.3);
  animation: pulse-dot 3s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Content wrap ────────────────────────────────────────────── */
.content-wrap {
  flex: 1;
  padding: 40px 48px 60px;
  max-width: calc(var(--content-max) + 96px);
  width: 100%;
}

/* ── Hero ────────────────────────────────────────────────────── */
.hero {
  margin-bottom: 48px;
  padding: 40px 0 0;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  margin-bottom: 14px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: #ffffff;
  text-shadow: 0 0 40px rgba(0, 200, 255, 0.2);
  margin-bottom: 18px;
}

.hero-sub {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 560px;
  margin-bottom: 32px;
}

.hero-stats {
  display: flex;
  gap: 32px;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-num {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-cyan);
  text-shadow: var(--glow-cyan-sm);
  line-height: 1;
}

.stat-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.cta-btn {
  display: inline-flex;
  align-items: center;
  padding: 13px 28px;
  background: transparent;
  border: 1px solid var(--accent-cyan);
  color: var(--accent-cyan);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  border-radius: 3px;
  transition: background var(--speed) var(--ease),
              box-shadow var(--speed) var(--ease),
              color var(--speed) var(--ease);
}

.cta-btn:hover {
  background: var(--bg-active);
  box-shadow: var(--glow-cyan), inset 0 0 20px rgba(0, 200, 255, 0.06);
}

.divider {
  height: 1px;
  background: linear-gradient(90deg, var(--border-accent), transparent);
  margin-bottom: 40px;
}

/* ── Markdown body ───────────────────────────────────────────── */
.md-body {
  max-width: var(--content-max);
}

/* Headings */
.md-body h1 {
  font-family: var(--font-display);
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: #ffffff;
  margin: 0 0 24px;
  padding-top: 8px;
}

.md-body h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin: 40px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  position: relative;
}

.md-body h2::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 48px;
  height: 1px;
  background: var(--accent-cyan);
  box-shadow: var(--glow-cyan-sm);
}

.md-body h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-cyan);
  letter-spacing: 0.01em;
  margin: 28px 0 10px;
}

.md-body h4 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 22px 0 8px;
}

/* Paragraphs */
.md-body p {
  color: var(--text-primary);
  margin-bottom: 16px;
  font-size: 15px;
  line-height: 1.8;
}

/* Links */
.md-body a {
  color: var(--accent-cyan);
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 200, 255, 0.25);
  transition: border-color var(--speed), color var(--speed), text-shadow var(--speed);
}

.md-body a:hover {
  color: #ffffff;
  border-bottom-color: var(--accent-cyan);
  text-shadow: var(--glow-cyan-sm);
}

/* Strong / em */
.md-body strong {
  color: #ffffff;
  font-weight: 600;
}

.md-body em {
  color: var(--text-secondary);
  font-style: italic;
}

/* Lists */
.md-body ul,
.md-body ol {
  margin: 0 0 16px 0;
  padding-left: 0;
  list-style: none;
}

.md-body ul > li,
.md-body ol > li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 8px;
  color: var(--text-primary);
  line-height: 1.75;
}

.md-body ul > li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--accent-cyan);
  font-size: 16px;
  line-height: 1.6;
}

.md-body ol {
  counter-reset: ol-counter;
}

.md-body ol > li {
  counter-increment: ol-counter;
}

.md-body ol > li::before {
  content: counter(ol-counter) '.';
  position: absolute;
  left: 0;
  color: var(--accent-cyan);
  font-size: 13px;
  font-family: var(--font-mono);
  font-weight: 500;
  line-height: 1.85;
}

/* Nested lists */
.md-body li > ul,
.md-body li > ol {
  margin-top: 6px;
  margin-bottom: 4px;
}

/* Blockquotes */
.md-body blockquote {
  margin: 20px 0;
  padding: 16px 20px;
  background: var(--bg-card);
  border-left: 3px solid var(--accent-cyan);
  box-shadow: var(--glow-cyan-sm), inset 0 0 30px rgba(0, 200, 255, 0.03);
  border-radius: 0 4px 4px 0;
}

.md-body blockquote p {
  color: var(--text-secondary);
  font-size: 14.5px;
  margin-bottom: 0;
  font-style: italic;
}

.md-body blockquote p + p {
  margin-top: 8px;
}

/* Horizontal rules */
.md-body hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, var(--border-accent), var(--border-subtle), transparent);
  margin: 36px 0;
}

/* Code — inline */
.md-body code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-elevated);
  color: var(--accent-cyan);
  padding: 2px 7px;
  border-radius: 3px;
  border: 1px solid var(--border-mid);
  white-space: nowrap;
}

/* Code — block (from fenced/codehilite) */
.md-body .highlight,
.md-body pre {
  background: var(--bg-code) !important;
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  padding: 20px 22px;
  overflow-x: auto;
  margin: 20px 0;
  position: relative;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4), inset 0 0 40px rgba(0, 200, 255, 0.02);
}

.md-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-mono);
  white-space: pre;
}

/* Syntax highlighting colours – Pygments-compatible overrides */
.md-body .highlight .k,
.md-body .highlight .kd,
.md-body .highlight .kn { color: #c084fc; }        /* keyword: purple */
.md-body .highlight .s,
.md-body .highlight .s1,
.md-body .highlight .s2 { color: #86efac; }        /* string: green */
.md-body .highlight .c,
.md-body .highlight .c1,
.md-body .highlight .cm { color: #4a5572; font-style: italic; } /* comment */
.md-body .highlight .n  { color: #d8e0f0; }        /* name */
.md-body .highlight .mi { color: #fbbf24; }        /* number: amber */
.md-body .highlight .o  { color: var(--accent-cyan); }  /* operator */
.md-body .highlight .nf { color: #60a5fa; }        /* function: blue */
.md-body .highlight .nb { color: #c084fc; }        /* builtin */
.md-body .highlight .bp { color: var(--text-secondary); }

/* Tables */
.md-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 13.5px;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid var(--border-mid);
}

.md-body thead {
  background: var(--bg-elevated);
}

.md-body th {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-accent);
}

.md-body td {
  padding: 10px 16px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  line-height: 1.6;
  vertical-align: top;
}

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

.md-body tbody tr {
  background: var(--bg-base);
  transition: background var(--speed);
}

.md-body tbody tr:hover { background: var(--bg-hover); }

/* Checkboxes from task lists */
.md-body input[type="checkbox"] {
  accent-color: var(--accent-cyan);
  margin-right: 6px;
}

/* ── Page footer ─────────────────────────────────────────────── */
.page-footer {
  padding: 20px 48px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.footer-sep { opacity: 0.4; }

/* ── Backdrop overlay (mobile) ───────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 15, 0.75);
  backdrop-filter: blur(4px);
  z-index: 90;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 4px 0 60px rgba(0, 0, 0, 0.8);
  }

  .sidebar-backdrop.is-open { display: block; }

  .sidebar-toggle { display: flex; }

  .main { margin-left: 0; }

  .content-wrap { padding: 28px 24px 48px; }

  .topbar { padding: 0 20px; }

  .page-footer { padding: 18px 24px; }
}

@media (max-width: 540px) {
  .hero-stats { gap: 20px; }
  .content-wrap { padding: 20px 16px 40px; }
  .md-body h1 { font-size: 24px; }
}

/* ── Scrollbar (main content) ────────────────────────────────── */
.main {
  scrollbar-width: thin;
  scrollbar-color: var(--border-mid) transparent;
}

.main::-webkit-scrollbar { width: 6px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb {
  background: var(--border-mid);
  border-radius: 3px;
}

/* ── Selection ───────────────────────────────────────────────── */
::selection {
  background: rgba(0, 200, 255, 0.2);
  color: #ffffff;
}

/* ── Focus visible ───────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}
