/* ==========================================================================
   NG-CDF Integrated Digital Platform — Master Documentation Theme
   Vanilla CSS Design System with High-End Mobile & Desktop Responsiveness
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  /* Kenya National NG-CDF Brand Palette */
  --brand-green-900: #073822;
  --brand-green-800: #0a4d2e;
  --brand-green-700: #0d633c;
  --brand-green-600: #107a4a;
  --brand-green-500: #169b62;
  --brand-green-400: #34d399;
  --brand-green-100: #d1fae5;
  --brand-green-50:  #ecfdf5;

  --brand-gold-500:  #eab308;
  --brand-gold-400:  #facc15;
  --brand-gold-100:  #fef9c3;

  /* Light Theme Palette */
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --bg-glass: rgba(255, 255, 255, 0.88);
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --text-inverse: #ffffff;

  --primary: var(--brand-green-700);
  --primary-hover: var(--brand-green-800);
  --primary-light: var(--brand-green-50);
  --primary-border: var(--brand-green-500);

  --accent-gold: #d97706;
  --accent-gold-bg: #fffbeb;

  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --inline-code-bg: #e2e8f0;
  --inline-code-text: #0f172a;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', var(--font-sans);
  --font-mono: 'JetBrains Mono', monospace;

  --sidebar-width: 320px;
  --header-height: 68px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
}

[data-theme="dark"] {
  --bg-primary: #080c14;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #1e293b;
  --bg-surface-subtle: #141e33;
  --bg-glass: rgba(15, 23, 42, 0.9);
  --border-subtle: #1e293b;
  --border-strong: #334155;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --text-inverse: #0f172a;

  --primary: var(--brand-green-500);
  --primary-hover: var(--brand-green-400);
  --primary-light: rgba(22, 155, 98, 0.15);
  --primary-border: var(--brand-green-400);

  --accent-gold: #fbbf24;
  --accent-gold-bg: rgba(245, 158, 11, 0.15);

  --code-bg: #090d16;
  --code-text: #f1f5f9;
  --inline-code-bg: #1e293b;
  --inline-code-text: #38bdf8;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.7);
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

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

/* Scroll reading progress bar */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-green-500), var(--brand-gold-500));
  width: 0%;
  z-index: 9999;
  transition: width 0.1s linear;
}

/* ==========================================================================
   Top Navigation Header
   ========================================================================== */
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 1000;
  transition: all 0.2s ease;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  padding: 2px;
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.brand-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.brand-tag {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--brand-gold-500);
  color: #073822;
  padding: 2px 6px;
  border-radius: 999px;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* Document Switcher Tabs (Desktop) */
.doc-tabs-container {
  display: flex;
  align-items: center;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 3px;
  gap: 3px;
}

.doc-tab-btn {
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.doc-tab-btn:hover {
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .doc-tab-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.doc-tab-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.icon-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.icon-btn:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
  background: var(--bg-surface-subtle);
}

.search-trigger-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  height: 36px;
  padding: 0 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.search-trigger-btn:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.search-key-badge {
  font-size: 0.68rem;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.mobile-menu-toggle {
  display: none;
}

/* ==========================================================================
   App Container & Sidebar Layout
   ========================================================================== */
.app-container {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  position: relative;
}

/* Mobile Sidebar Backdrop Overlay */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1040;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Sidebar Navigation */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  padding: 1rem 1.15rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-doc-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
  background: var(--primary-light);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  display: inline-block;
  border: 1px solid rgba(22, 155, 98, 0.25);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-sidebar-close {
  display: none;
  width: 30px;
  height: 30px;
}

.sidebar-doc-title {
  font-family: var(--font-heading);
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-main);
}

/* Mobile Document Switcher in Sidebar */
.sidebar-doc-selector {
  display: none; /* Only visible on mobile/tablet */
  padding: 0.75rem 1rem;
  background: var(--bg-surface-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-doc-selector-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.sidebar-doc-pills {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-doc-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  width: 100%;
}

.sidebar-doc-pill:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
}

.sidebar-doc-pill.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(22, 155, 98, 0.35);
  font-weight: 700;
}

/* TOC Search Box */
.toc-search-container {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.toc-search-box {
  position: relative;
}

.toc-search-input {
  width: 100%;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.75rem 0.4rem 1.9rem;
  font-size: 0.8rem;
  font-family: var(--font-sans);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s ease;
}

.toc-search-input:focus {
  border-color: var(--primary);
}

.toc-search-icon {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
}

/* Sidebar Nav Scroll */
.sidebar-nav-container {
  flex: 1;
  overflow-y: auto;
  padding: 0.65rem;
  -webkit-overflow-scrolling: touch;
}

.sidebar-nav-container::-webkit-scrollbar {
  width: 4px;
}
.sidebar-nav-container::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 4px;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-item {
  display: flex;
  flex-direction: column;
}

.toc-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.35;
  transition: all 0.12s ease;
}

.toc-link:hover {
  background: var(--bg-surface-subtle);
  color: var(--text-main);
}

.toc-link.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
  border-left: 3px solid var(--primary);
  padding-left: calc(0.6rem - 3px);
}

.toc-level-2 {
  padding-left: 0.65rem;
  font-weight: 600;
}

.toc-level-3 {
  padding-left: 1.25rem;
  font-size: 0.76rem;
}

.toc-level-4 {
  padding-left: 1.85rem;
  font-size: 0.72rem;
  color: var(--text-subtle);
}

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-subtle);
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
.main-content {
  flex: 1;
  max-width: 1040px;
  margin: 0 auto;
  padding: 2.25rem 2.5rem 6rem;
  min-width: 0;
  width: 100%;
}

/* Document Hero Banner */
.doc-hero-banner {
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-surface-subtle));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 2rem;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.doc-hero-banner::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background: linear-gradient(180deg, var(--brand-green-600), var(--brand-gold-500));
}

.doc-hero-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.doc-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg-surface-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.doc-chip.primary {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(22, 155, 98, 0.25);
}

.doc-hero-title {
  font-family: var(--font-heading);
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin-bottom: 0.65rem;
  word-break: break-word;
}

.doc-hero-desc {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.55;
  max-width: 820px;
}

/* Document Quick Toolbar */
.doc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-muted);
  gap: 1rem;
}

.doc-stats-group {
  display: flex;
  align-items: center;
  gap: 1.15rem;
}

.doc-stat-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* ==========================================================================
   Rendered Markdown Content Styling
   ========================================================================== */
.markdown-body {
  font-size: 1rem;
  color: var(--text-main);
  line-height: 1.75;
  word-break: break-word;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  font-family: var(--font-heading);
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.3;
  margin-top: 2.5rem;
  margin-bottom: 0.85rem;
  position: relative;
  scroll-margin-top: calc(var(--header-height) + 1.25rem);
  word-break: break-word;
}

.markdown-body h1 {
  font-size: 1.85rem;
  border-bottom: 2px solid var(--border-subtle);
  padding-bottom: 0.5rem;
  margin-top: 2.85rem;
  color: var(--brand-green-700);
}

[data-theme="dark"] .markdown-body h1 {
  color: var(--brand-green-400);
}

.markdown-body h2 {
  font-size: 1.45rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.35rem;
  margin-top: 2.25rem;
}

.markdown-body h3 {
  font-size: 1.2rem;
  margin-top: 1.85rem;
}

.markdown-body h4 {
  font-size: 1.05rem;
  margin-top: 1.35rem;
}

.markdown-body p {
  margin-bottom: 1.2rem;
}

.markdown-body a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: all 0.15s ease;
}

.markdown-body a:hover {
  border-bottom-color: var(--primary);
}

.markdown-body ul,
.markdown-body ol {
  margin-bottom: 1.2rem;
  padding-left: 1.6rem;
}

.markdown-body li {
  margin-bottom: 0.4rem;
}

.markdown-body hr {
  height: 1px;
  background: var(--border-subtle);
  border: none;
  margin: 2.5rem 0;
}

/* Blockquotes & Callouts */
.markdown-body blockquote {
  border-left: 4px solid var(--primary);
  padding: 0.75rem 1.15rem;
  margin: 1.35rem 0;
  background: var(--primary-light);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-main);
  font-style: normal;
}

.alert-box {
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  margin: 1.35rem 0;
  border-left: 4px solid;
}

.alert-box.alert-note {
  background: var(--bg-surface-subtle);
  border-color: #3b82f6;
}

.alert-box.alert-tip {
  background: var(--brand-green-50);
  border-color: var(--brand-green-500);
}

[data-theme="dark"] .alert-box.alert-tip {
  background: rgba(22, 155, 98, 0.12);
}

.alert-box.alert-warning {
  background: #fffbeb;
  border-color: var(--brand-gold-500);
}

[data-theme="dark"] .alert-box.alert-warning {
  background: rgba(234, 179, 8, 0.12);
}

/* Responsive Tables */
.markdown-body table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.5rem 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: 0.88rem;
}

.markdown-body th {
  background: var(--bg-surface-subtle);
  color: var(--text-main);
  font-weight: 700;
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border-subtle);
  font-family: var(--font-heading);
}

.markdown-body td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: top;
}

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

.markdown-body tr:hover td {
  background: var(--bg-surface-subtle);
}

/* Code & ASCII Diagrams */
.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--inline-code-bg);
  color: var(--inline-code-text);
  padding: 0.2em 0.4em;
  border-radius: var(--radius-sm);
}

.code-card {
  position: relative;
  background: var(--code-bg);
  border-radius: var(--radius-md);
  margin: 1.5rem 0;
  border: 1px solid var(--border-strong);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.code-card-header {
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.5rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.code-card-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.code-card-dots {
  display: flex;
  gap: 4px;
}

.code-card-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #475569;
}

.copy-code-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  font-size: 0.7rem;
  font-family: var(--font-sans);
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
}

.copy-code-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.markdown-body pre {
  margin: 0 !important;
  background: transparent !important;
  padding: 1.15rem !important;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--code-text);
  -webkit-overflow-scrolling: touch;
}

.markdown-body pre code {
  background: transparent !important;
  color: inherit !important;
  padding: 0 !important;
  font-size: inherit;
}

/* ASCII Box Art */
.ascii-diagram {
  font-family: var(--font-mono);
  line-height: 1.35 !important;
  font-size: 0.8rem !important;
  color: #38bdf8 !important;
  white-space: pre !important;
}

/* Mermaid Container */
.mermaid-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin: 1.5rem 0;
  display: flex;
  justify-content: center;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-sm);
}

/* Anchor Link on Headings */
.heading-anchor {
  color: var(--text-subtle);
  text-decoration: none !important;
  margin-left: 0.45rem;
  opacity: 0;
  font-size: 0.8em;
  transition: opacity 0.15s ease;
}

.markdown-body h1:hover .heading-anchor,
.markdown-body h2:hover .heading-anchor,
.markdown-body h3:hover .heading-anchor {
  opacity: 1;
}

/* ==========================================================================
   Page Footer Navigation
   ========================================================================== */
.doc-footer-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 3.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border-subtle);
}

.doc-nav-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}

.doc-nav-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.doc-nav-card.next {
  text-align: right;
  align-items: flex-end;
}

.doc-nav-direction {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  letter-spacing: 0.05em;
}

.doc-nav-title {
  font-family: var(--font-heading);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
  word-break: break-word;
}

/* ==========================================================================
   Global Search Modal
   ========================================================================== */
.search-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8vh;
}

.search-modal-backdrop.active {
  display: flex;
}

.search-modal {
  width: 90%;
  max-width: 660px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalSlide 0.2s ease-out;
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.search-modal-header {
  padding: 0.85rem 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-subtle);
}

.search-modal-input {
  flex: 1;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text-main);
  outline: none;
}

.search-modal-results {
  max-height: 440px;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  -webkit-overflow-scrolling: touch;
}

.search-result-item {
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  transition: all 0.12s ease;
  cursor: pointer;
}

.search-result-item:hover,
.search-result-item.selected {
  background: var(--bg-surface-subtle);
  border-color: var(--border-subtle);
}

.search-result-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.search-result-doc-tag {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
}

.search-result-snippet {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.search-modal-footer {
  padding: 0.6rem 1.15rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-subtle);
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

/* ==========================================================================
   Responsive Adaptations (Tablet & Mobile)
   ========================================================================== */

/* Tablet (1024px and below) */
@media (max-width: 1024px) {
  .doc-tabs-container {
    display: none; /* Collapses to mobile document selector in sidebar */
  }

  .mobile-menu-toggle {
    display: flex;
  }

  .sidebar-doc-selector {
    display: block; /* Show document selector inside sidebar drawer */
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100dvh;
    width: min(340px, 86vw);
    min-width: unset;
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
    z-index: 1050;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-sidebar-close {
    display: flex;
  }

  .main-content {
    padding: 1.75rem 1.5rem 5rem;
  }
}

/* Small Tablet & Mobile Landscape (768px and below) */
@media (max-width: 768px) {
  :root {
    --header-height: 60px;
  }

  .top-header {
    padding: 0 0.85rem;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
  }

  .brand-title {
    font-size: 0.95rem;
  }

  .brand-sub {
    display: none; /* Hide subtitle to keep header compact */
  }

  .doc-hero-banner {
    padding: 1.5rem 1.25rem;
    border-radius: var(--radius-lg);
    margin-bottom: 1.75rem;
  }

  .doc-hero-title {
    font-size: 1.65rem;
  }

  .doc-hero-desc {
    font-size: 0.92rem;
  }

  .doc-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .doc-stats-group {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .copy-code-btn {
    justify-content: center;
    width: 100%;
    padding: 6px 12px;
  }

  .doc-footer-nav {
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 2.5rem;
  }

  .doc-nav-card.next {
    text-align: left;
    align-items: flex-start;
  }
}

/* Mobile Phone (540px and below) */
@media (max-width: 540px) {
  .search-btn-label,
  .search-key-badge {
    display: none; /* Search button collapses to icon-only */
  }

  .search-trigger-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-md);
  }

  .print-action-btn {
    display: none; /* Hide print on phone screens */
  }

  .brand-title span:first-child {
    font-size: 0.9rem;
  }

  .brand-tag {
    font-size: 0.58rem;
    padding: 1px 5px;
  }

  .main-content {
    padding: 1.15rem 0.85rem 4rem;
  }

  .doc-hero-banner {
    padding: 1.25rem 0.9rem;
  }

  .doc-hero-title {
    font-size: 1.4rem;
  }

  .markdown-body h1 {
    font-size: 1.5rem;
    margin-top: 2rem;
  }

  .markdown-body h2 {
    font-size: 1.25rem;
    margin-top: 1.65rem;
  }

  .markdown-body h3 {
    font-size: 1.1rem;
    margin-top: 1.35rem;
  }

  .markdown-body p,
  .markdown-body li {
    font-size: 0.94rem;
    line-height: 1.65;
  }

  .search-modal-backdrop {
    padding-top: 4vh;
  }

  .search-modal {
    width: 95%;
    max-height: 88vh;
    border-radius: var(--radius-lg);
  }

  .search-modal-input {
    font-size: 16px; /* Prevents auto-zoom in iOS Safari */
  }

  .code-card {
    border-radius: var(--radius-sm);
  }

  .markdown-body pre {
    padding: 0.75rem !important;
    font-size: 0.78rem;
  }
}

/* Print Styles */
@media print {
  .top-header,
  .sidebar,
  .sidebar-backdrop,
  #reading-progress,
  .doc-footer-nav,
  .doc-toolbar,
  .copy-code-btn {
    display: none !important;
  }

  .app-container {
    margin-top: 0;
  }

  .main-content {
    max-width: 100%;
    padding: 0;
  }

  body {
    background: #ffffff;
    color: #000000;
  }
}
