/* ============================================================
   Fennec-RAG Documentation — Enhanced Stylesheet v2
   Supports: RTL (Arabic), Dark/Light Mode, Responsive
   ============================================================ */

/* === Google Fonts === */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,600;12..96,700;12..96,800&display=swap');

/* === CSS Variables === */
:root {
  --brand-primary:   #f59e0b;
  --brand-secondary: #14b8a6;
  --brand-tertiary:  #6366f1;
  --brand-gradient:  linear-gradient(135deg, #f59e0b 0%, #14b8a6 100%);

  --sidebar-width: 272px;
  --toc-width:     212px;
  --header-height: 62px;
  --content-max:   780px;

  --sp-1:4px; --sp-2:8px; --sp-3:12px; --sp-4:16px; --sp-5:20px;
  --sp-6:24px; --sp-8:32px; --sp-10:40px; --sp-12:48px;

  --r-xs:4px; --r-sm:8px; --r-md:12px; --r-lg:18px; --r-xl:24px;

  --t-fast: 0.15s ease;
  --t-med:  0.25s cubic-bezier(0.4,0,0.2,1);
}

/* === Dark Theme === */
[data-theme="dark"] {
  --bg-base:      #0b0d12;
  --bg-surface:   #111318;
  --bg-elevated:  #181c24;
  --bg-hover:     #1e2230;
  --bg-active:    #242838;
  --bg-code:      #141720;

  --border:        rgba(255,255,255,0.06);
  --border-strong: rgba(255,255,255,0.12);
  --border-accent: rgba(245,158,11,0.28);

  --text-primary:   #edf0f7;
  --text-secondary: #8b95aa;
  --text-muted:     #515b6e;
  --text-link:      #f59e0b;

  --sidebar-bg: #0d1017;
  --header-bg:  rgba(11,13,18,0.88);

  --shadow-sm: 0 1px 4px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.55);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.65);
}

/* === Light Theme === */
[data-theme="light"] {
  --bg-base:      #f6f8fc;
  --bg-surface:   #ffffff;
  --bg-elevated:  #eef1f8;
  --bg-hover:     #e8ecf5;
  --bg-active:    #e0e6f2;
  --bg-code:      #f2f4fa;

  --border:        rgba(0,0,0,0.07);
  --border-strong: rgba(0,0,0,0.13);
  --border-accent: rgba(245,158,11,0.4);

  --text-primary:   #18202e;
  --text-secondary: #48536a;
  --text-muted:     #8b95aa;
  --text-link:      #c47f00;

  --sidebar-bg: #eef1f8;
  --header-bg:  rgba(246,248,252,0.9);

  --shadow-sm: 0 1px 4px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.09);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.13);
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; direction: rtl; }
body {
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background var(--t-med), color var(--t-med);
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === Layout === */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--toc-width);
  grid-template-rows: var(--header-height) 1fr;
  grid-template-areas: "header header header" "sidebar main toc";
  min-height: 100vh;
}

/* ============================================================ HEADER */
.header {
  grid-area: header;
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-6);
  gap: var(--sp-4);
  height: var(--header-height);
}

.header-logo {
  display: flex; align-items: center; gap: var(--sp-3);
  text-decoration: none; flex-shrink: 0;
}

.header-logo img {
  width: 34px; height: 34px; object-fit: contain;
  border-radius: var(--r-sm);
  filter: drop-shadow(0 2px 6px rgba(245,158,11,0.3));
}

.header-logo-text {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em;
  background: var(--brand-gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.header-version {
  font-size: 0.62rem; font-weight: 700;
  background: var(--bg-elevated); color: var(--brand-primary);
  padding: 2px 8px; border-radius: 20px; border: 1px solid var(--border-accent);
}

.header-search { flex: 1; max-width: 500px; position: relative; }

.search-input {
  width: 100%; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-4) var(--sp-2) var(--sp-10);
  font-family: inherit; font-size: 0.875rem; color: var(--text-primary);
  outline: none; direction: rtl;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(245,158,11,0.1);
  background: var(--bg-surface);
}

.search-icon {
  position: absolute; left: var(--sp-3); top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none; font-size: 0.9rem;
}

.search-results {
  position: absolute; top: calc(100% + var(--sp-2)); right: 0; left: 0;
  background: var(--bg-surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  max-height: 440px; overflow-y: auto; z-index: 200; display: none;
  animation: dropIn 0.15s ease;
}
@keyframes dropIn { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }
.search-results.visible { display: block; }

.search-result-item {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); cursor: pointer;
  border-bottom: 1px solid var(--border); transition: background var(--t-fast);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.focused { background: var(--bg-hover); }
.search-result-item .result-icon { font-size: 1rem; flex-shrink: 0; margin-top: 2px; }
.search-result-item .result-title { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.search-result-item .result-section { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.search-result-item .result-excerpt {
  font-size: 0.75rem; color: var(--text-secondary); margin-top: 4px; line-height: 1.5;
  display: -webkit-box; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.search-highlight { color: var(--brand-primary); font-weight: 700; }
.search-no-results { padding: var(--sp-6) var(--sp-4); text-align: center; color: var(--text-muted); font-size: 0.875rem; }

.header-actions { display: flex; align-items: center; gap: var(--sp-2); margin-right: auto; }

.btn-icon {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--bg-elevated);
  color: var(--text-secondary); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; transition: all var(--t-fast);
}
.btn-icon:hover {
  background: var(--bg-hover); color: var(--text-primary);
  border-color: var(--border-strong); transform: translateY(-1px);
}
.mobile-menu-btn { display: none; }

/* ============================================================ SIDEBAR */
.sidebar {
  grid-area: sidebar; position: sticky; top: var(--header-height);
  height: calc(100vh - var(--header-height)); overflow-y: auto;
  background: var(--sidebar-bg); border-left: 1px solid var(--border);
  padding: var(--sp-5) 0 var(--sp-8); transition: transform var(--t-med);
}
.sidebar-section { margin-bottom: var(--sp-2); }
.sidebar-section-header {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4); cursor: pointer; user-select: none;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--text-muted); transition: color var(--t-fast);
  border-radius: var(--r-sm); margin: 0 var(--sp-2);
}
.sidebar-section-header:hover { color: var(--text-secondary); background: var(--bg-hover); }
.sidebar-section-icon { font-size: 0.9rem; }
.sidebar-section-arrow { margin-right: auto; font-size: 0.65rem; transition: transform var(--t-fast); }
.sidebar-section.collapsed .sidebar-section-arrow { transform: rotate(90deg); }
.sidebar-section-items { overflow: hidden; transition: max-height var(--t-med); }
.sidebar-section.collapsed .sidebar-section-items { max-height: 0 !important; }

.sidebar-item {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 7px var(--sp-4) 7px var(--sp-8);
  font-size: 0.84rem; color: var(--text-secondary); cursor: pointer;
  transition: all var(--t-fast); text-decoration: none; position: relative;
  margin: 1px var(--sp-2); border-radius: var(--r-sm); border: 1px solid transparent;
}
.sidebar-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-item.active {
  background: rgba(245,158,11,0.08);
  color: var(--brand-primary); border-color: rgba(245,158,11,0.18); font-weight: 600;
}

.sidebar-badge {
  font-size: 0.58rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 1px 6px; border-radius: 20px; margin-right: auto;
}
.badge-core     { background: rgba(245,158,11,0.12); color: var(--brand-primary); border: 1px solid rgba(245,158,11,0.2); }
.badge-abstract { background: rgba(20,184,166,0.1);  color: var(--brand-secondary); border: 1px solid rgba(20,184,166,0.2); }
.badge-ar       { background: rgba(99,102,241,0.12); color: #818cf8; border: 1px solid rgba(99,102,241,0.2); }

/* ============================================================ MAIN */
.main {
  grid-area: main; min-height: calc(100vh - var(--header-height));
  padding: var(--sp-10) var(--sp-10) var(--sp-12);
  max-width: calc(var(--content-max) + 80px);
}

/* Overview Hero */
.overview-hero {
  padding: var(--sp-12) 0 var(--sp-10);
  border-bottom: 1px solid var(--border); margin-bottom: var(--sp-10);
}
.overview-badge {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  background: rgba(245,158,11,0.09); border: 1px solid rgba(245,158,11,0.3);
  color: var(--brand-primary); padding: var(--sp-1) var(--sp-4);
  border-radius: 20px; font-size: 0.75rem; font-weight: 700;
  margin-bottom: var(--sp-5); letter-spacing: 0.03em;
}
.overview-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 3.2rem; font-weight: 800; line-height: 1.05; letter-spacing: -0.04em;
  background: var(--brand-gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: var(--sp-5);
}
.overview-subtitle {
  font-size: 1.05rem; color: var(--text-secondary); max-width: 560px;
  line-height: 1.85; margin-bottom: var(--sp-8);
}
.overview-cta { display: flex; gap: var(--sp-3); flex-wrap: wrap; }

.btn-primary {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  background: var(--brand-primary); color: #fff;
  padding: var(--sp-3) var(--sp-6); border-radius: var(--r-md);
  font-size: 0.9rem; font-weight: 700; cursor: pointer; border: none;
  transition: all var(--t-fast); font-family: inherit;
  box-shadow: 0 2px 12px rgba(245,158,11,0.3);
}
.btn-primary:hover {
  background: #e8920a; box-shadow: 0 4px 20px rgba(245,158,11,0.4); transform: translateY(-2px);
}
.btn-secondary {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  background: var(--bg-elevated); color: var(--text-primary);
  padding: var(--sp-3) var(--sp-6); border-radius: var(--r-md);
  font-size: 0.9rem; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border-strong); transition: all var(--t-fast); font-family: inherit;
}
.btn-secondary:hover {
  background: var(--bg-hover); border-color: var(--text-muted);
  transform: translateY(-1px); box-shadow: var(--shadow-sm);
}

/* Modules Grid */
.modules-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: var(--sp-4); margin-top: var(--sp-8);
}
.module-card {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--sp-5); cursor: pointer;
  transition: all var(--t-med); position: relative; overflow: hidden;
}
.module-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--brand-gradient); opacity: 0; transition: opacity var(--t-med);
}
.module-card:hover {
  border-color: var(--border-accent); box-shadow: var(--shadow-md);
  transform: translateY(-3px); background: var(--bg-elevated);
}
.module-card:hover::before { opacity: 1; }
.module-card-icon { font-size: 1.7rem; margin-bottom: var(--sp-3); display: block; }
.module-card-title { font-size: 0.88rem; font-weight: 700; color: var(--text-primary); margin-bottom: var(--sp-1); }
.module-card-count { font-size: 0.73rem; color: var(--text-muted); font-weight: 500; }

/* ============================================================ DOC CONTENT */
.doc-content { max-width: var(--content-max); }

.loading-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-4); padding: var(--sp-12); color: var(--text-muted);
}
.loading-spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--brand-primary); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.doc-header { padding-bottom: var(--sp-8); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-8); }

.doc-breadcrumb {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: 0.75rem; color: var(--text-muted); margin-bottom: var(--sp-4);
}
.doc-breadcrumb-sep { color: var(--border-strong); }
.doc-breadcrumb a { color: var(--text-muted); text-decoration: none; transition: color var(--t-fast); }
.doc-breadcrumb a:hover { color: var(--text-primary); }

.doc-body { direction: rtl; }

.doc-body h1 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 2.1rem; font-weight: 800; letter-spacing: -0.03em;
  color: var(--text-primary); margin-bottom: var(--sp-4); line-height: 1.2;
}
.doc-body h2 {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.45rem; font-weight: 700; color: var(--text-primary);
  margin-top: var(--sp-10); margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border);
  scroll-margin-top: calc(var(--header-height) + 20px);
}
.doc-body h3 {
  font-size: 1.1rem; font-weight: 700; color: var(--text-primary);
  margin-top: var(--sp-8); margin-bottom: var(--sp-3);
  scroll-margin-top: calc(var(--header-height) + 20px);
}
.doc-body h4 {
  font-size: 0.95rem; font-weight: 600; color: var(--text-secondary);
  margin-top: var(--sp-5); margin-bottom: var(--sp-2);
}
.doc-body p { color: var(--text-secondary); margin-bottom: var(--sp-4); font-size: 0.95rem; line-height: 1.85; }
.doc-body a {
  color: var(--text-link); text-decoration: underline;
  text-decoration-color: rgba(245,158,11,0.25); text-underline-offset: 3px;
  transition: text-decoration-color var(--t-fast);
}
.doc-body a:hover { text-decoration-color: var(--brand-primary); }
.doc-body strong { color: var(--text-primary); font-weight: 700; }
.doc-body em { font-style: italic; color: var(--text-secondary); }
.doc-body ul, .doc-body ol { padding-right: var(--sp-6); margin-bottom: var(--sp-4); color: var(--text-secondary); font-size: 0.95rem; }
.doc-body li { margin-bottom: var(--sp-2); line-height: 1.75; }
.doc-body blockquote {
  border-right: 3px solid var(--brand-primary);
  padding: var(--sp-4) var(--sp-5);
  background: rgba(245,158,11,0.04);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  margin-bottom: var(--sp-4); color: var(--text-secondary); font-size: 0.95rem;
}

/* Tables */
.doc-body table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  margin-bottom: var(--sp-6); font-size: 0.875rem;
  overflow-x: auto; display: block;
  border: 1px solid var(--border); border-radius: var(--r-md);
}
.doc-body thead th {
  background: var(--bg-elevated); color: var(--text-primary); font-weight: 700;
  padding: var(--sp-3) var(--sp-4); text-align: right;
  border-bottom: 1px solid var(--border-strong); white-space: nowrap;
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em;
}
.doc-body tbody td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); color: var(--text-secondary); vertical-align: top; }
.doc-body tbody tr:last-child td { border-bottom: none; }
.doc-body tbody tr:hover { background: var(--bg-hover); }

/* Inline code */
.doc-body :not(pre) > code {
  font-family: 'JetBrains Mono', monospace; font-size: 0.82em;
  background: var(--bg-code); color: var(--brand-secondary);
  padding: 2px 7px; border-radius: var(--r-xs); border: 1px solid var(--border);
  direction: ltr; display: inline-block;
}

/* ============================================================ CODE BLOCKS */
.code-block-wrapper {
  position: relative; margin: var(--sp-5) 0; border-radius: var(--r-lg);
  overflow: hidden; border: 1px solid var(--border); background: var(--bg-code);
  direction: ltr; transition: border-color var(--t-fast);
}
.code-block-wrapper:hover { border-color: var(--border-strong); }
.code-block-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-2) var(--sp-4); background: var(--bg-elevated); border-bottom: 1px solid var(--border);
}
.code-block-lang { font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; color: var(--brand-secondary); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.code-block-actions { display: flex; gap: var(--sp-1); }
.code-copy-btn, .code-collapse-btn {
  background: none; border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--text-muted); cursor: pointer; font-size: 0.72rem; padding: 3px 8px;
  display: flex; align-items: center; gap: 4px; transition: all var(--t-fast);
  font-family: 'IBM Plex Sans Arabic', sans-serif;
}
.code-copy-btn:hover, .code-collapse-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }
.code-copy-btn.copied { color: var(--brand-secondary); border-color: rgba(20,184,166,0.4); background: rgba(20,184,166,0.08); }
.code-block-wrapper pre {
  margin: 0; padding: var(--sp-5) var(--sp-5) var(--sp-5) var(--sp-10);
  overflow-x: auto; font-size: 0.85rem; line-height: 1.7;
  font-family: 'JetBrains Mono', monospace; position: relative;
}
.code-block-wrapper.collapsed pre { max-height: 120px; overflow: hidden; }
.code-block-wrapper.collapsed::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 60px;
  background: linear-gradient(transparent, var(--bg-code)); pointer-events: none;
}
.code-block-wrapper .line-number {
  position: absolute; right: 0; top: 0; padding: var(--sp-5) var(--sp-3) var(--sp-5) 0;
  text-align: right; font-size: 0.78rem; line-height: 1.7; color: var(--text-muted);
  user-select: none; border-left: 1px solid var(--border); min-width: var(--sp-8);
}

/* ============================================================ TOC */
.toc {
  grid-area: toc; position: sticky; top: var(--header-height);
  height: calc(100vh - var(--header-height)); overflow-y: auto;
  padding: var(--sp-8) var(--sp-4); border-right: 1px solid var(--border);
}
.toc-title { font-size: 0.67rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-muted); margin-bottom: var(--sp-4); padding: 0 var(--sp-2); }
.toc-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.toc-item a { display: block; font-size: 0.78rem; color: var(--text-muted); text-decoration: none; padding: 5px var(--sp-2); border-radius: var(--r-sm); transition: all var(--t-fast); line-height: 1.5; }
.toc-item a:hover { color: var(--text-primary); background: var(--bg-hover); }
.toc-item.active a { color: var(--brand-primary); background: rgba(245,158,11,0.08); font-weight: 600; }
.toc-item.level-3 a { padding-right: var(--sp-5); font-size: 0.74rem; }

/* ============================================================ TAGS */
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 0.7rem; font-weight: 700; padding: 2px 8px; border-radius: 20px; direction: ltr; font-family: 'JetBrains Mono', monospace; letter-spacing: 0.03em; }
.tag-method     { background: rgba(99,102,241,0.1);  color: #818cf8; border: 1px solid rgba(99,102,241,0.2); }
.tag-class      { background: rgba(245,158,11,0.09); color: var(--brand-primary); border: 1px solid rgba(245,158,11,0.2); }
.tag-async      { background: rgba(20,184,166,0.09); color: var(--brand-secondary); border: 1px solid rgba(20,184,166,0.2); }
.tag-deprecated { background: rgba(239,68,68,0.09);  color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.tag-new        { background: rgba(34,197,94,0.09);  color: #4ade80; border: 1px solid rgba(34,197,94,0.2); }

/* ============================================================ CALLOUTS */
.callout { display: flex; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-radius: var(--r-md); margin: var(--sp-5) 0; font-size: 0.875rem; border-width: 1px; border-style: solid; }
.callout-info    { background: rgba(59,130,246,0.07);  border-color: rgba(59,130,246,0.2);  color: #93c5fd; }
.callout-warn    { background: rgba(245,158,11,0.07);  border-color: rgba(245,158,11,0.2);  color: #fbbf24; }
.callout-error   { background: rgba(239,68,68,0.07);   border-color: rgba(239,68,68,0.2);   color: #fca5a5; }
.callout-success { background: rgba(34,197,94,0.07);   border-color: rgba(34,197,94,0.2);   color: #86efac; }
.callout-icon { flex-shrink: 0; font-size: 1.1rem; }
.callout-body { color: var(--text-secondary); }
.callout-body strong { color: var(--text-primary); }

/* ============================================================ FOOTER */
.doc-footer {
  margin-top: var(--sp-12); padding-top: var(--sp-8); border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
}
.doc-nav-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--bg-surface); cursor: pointer; transition: all var(--t-fast);
  text-decoration: none; min-width: 140px;
}
.doc-nav-btn:hover { border-color: var(--border-strong); background: var(--bg-elevated); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.doc-nav-label { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 700; }
.doc-nav-title { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }

/* ============================================================ RESPONSIVE */
@media (max-width: 1200px) {
  .layout { grid-template-columns: var(--sidebar-width) 1fr; grid-template-areas: "header header" "sidebar main"; }
  .toc { display: none; }
  .main { padding: var(--sp-8); }
}

@media (max-width: 768px) {
  .layout { grid-template-columns: 1fr; grid-template-areas: "header" "main"; }
  .sidebar {
    position: fixed; top: 0; right: 0; width: var(--sidebar-width);
    height: 100vh; z-index: 150; transform: translateX(100%); box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 140; display: none; backdrop-filter: blur(4px); }
  .sidebar-overlay.visible { display: block; }
  .mobile-menu-btn { display: flex; }
  .header-search { display: none; }
  .main { padding: var(--sp-5); }
  .overview-title { font-size: 2.1rem; }
  .modules-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .modules-grid { grid-template-columns: 1fr; }
  .overview-title { font-size: 1.8rem; }
  .doc-footer { flex-direction: column; align-items: stretch; }
}

/* ============================================================ HLJS */
[data-theme="dark"] .hljs  { background: transparent; color: #abb2bf; }
[data-theme="light"] .hljs { background: transparent; color: #383a42; }

/* ============================================================ ANIMATIONS */
@keyframes fadeInUp { from { opacity:0; transform:translateY(14px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn   { from { opacity:0; transform:translateY(8px);  } to { opacity:1; transform:translateY(0); } }

.doc-content   { animation: fadeInUp 0.35s cubic-bezier(0.4,0,0.2,1); }
.overview-hero { animation: fadeInUp 0.4s cubic-bezier(0.4,0,0.2,1); }
.modules-grid  { animation: fadeIn 0.5s cubic-bezier(0.4,0,0.2,1) 0.1s both; }

.module-card:nth-child(1) { animation: fadeIn 0.4s ease 0.05s both; }
.module-card:nth-child(2) { animation: fadeIn 0.4s ease 0.10s both; }
.module-card:nth-child(3) { animation: fadeIn 0.4s ease 0.15s both; }
.module-card:nth-child(4) { animation: fadeIn 0.4s ease 0.20s both; }
.module-card:nth-child(5) { animation: fadeIn 0.4s ease 0.25s both; }
.module-card:nth-child(6) { animation: fadeIn 0.4s ease 0.30s both; }
.module-card:nth-child(7) { animation: fadeIn 0.4s ease 0.35s both; }

/* ============================================================ PROGRESS BAR */
.reading-progress {
  position: fixed; top: var(--header-height); right: 0; width: 0%;
  height: 3px; background: var(--brand-gradient); z-index: 200;
  transition: width 0.1s linear; border-radius: 0 2px 2px 0;
}
