/*
 * Maat Documentation — Stylesheet
 * Monochrome sketch/paper aesthetic matching the Flutter mobile app.
 * ──────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Fira+Code:wght@400&display=swap');

/* ══════════════════════════════════════════════════════════════
   Design Tokens
   ══════════════════════════════════════════════════════════════ */
:root {
  /* Colors — directly from Flutter AppColors */
  --primary: #2D2D2D;
  --background: #F5F2ED;
  --card-background: #FFFFFF;
  --text-primary: #2D2D2D;
  --text-secondary: #6B6B6B;
  --text-tertiary: #9E9E9E;
  --border: #D9D9D9;
  --divider: #E8E8E8;
  --connected-green: #4CAF50;
  --input-background: #F0EDE8;
  --card-shadow: rgba(0, 0, 0, 0.1);
  --code-bg: #1E1E1E;
  --code-header-bg: #2D2D2D;

  /* Spacing & Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);

  /* Transitions */
  --transition-fast: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-smooth: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ══════════════════════════════════════════════════════════════
   Base & Reset
   ══════════════════════════════════════════════════════════════ */
html {
  box-sizing: border-box;
  scroll-behavior: smooth;
}

*, *::before, *::after {
  box-sizing: inherit;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--background);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--primary);
  color: var(--card-background);
}

/* ══════════════════════════════════════════════════════════════
   Typography
   ══════════════════════════════════════════════════════════════ */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  margin-top: 2rem;
  margin-bottom: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-top: 0;
}

h2 {
  font-size: 1.5rem;
  letter-spacing: -0.015em;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

h3 {
  font-size: 1.25rem;
}

h4 {
  font-size: 1.05rem;
  margin-top: 1.25rem;
}

p, ul, ol {
  margin-top: 0;
  margin-bottom: 1.25rem;
  max-width: 68ch;
}

.lead {
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

a {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 4px;
  transition: var(--transition-fast);
}

a:hover {
  text-decoration-color: var(--primary);
}

code {
  font-family: 'Fira Code', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.875em;
  padding: 0.15em 0.4em;
  background: rgba(45, 45, 45, 0.06);
  border-radius: 4px;
}

ul, ol {
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.4rem;
}

/* ══════════════════════════════════════════════════════════════
   Header
   ══════════════════════════════════════════════════════════════ */
.header {
  position: sticky;
  top: 0;
  height: 64px;
  z-index: 50;
  background: rgba(245, 242, 237, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 400px;
  margin: 0 auto;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Logo (serif italic — mirrors Flutter splash title) */
.logo {
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: 0.5px;
}

.logo:hover {
  text-decoration: none;
  opacity: 0.8;
}

/* Version badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  background: var(--input-background);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  letter-spacing: 0.02em;
}

/* Search bar */
.search-wrapper {
  position: relative;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-background);
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition-fast);
}

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

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 45, 45, 0.08);
}

.search-shortcut {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: inherit;
  font-size: 0.7rem;
  padding: 2px 6px;
  background: var(--input-background);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-tertiary);
  pointer-events: none;
}

/* GitHub link button */
.github-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition-fast);
}

.github-link:hover {
  background: var(--input-background);
  color: var(--text-primary);
  text-decoration: none;
}

/* ══════════════════════════════════════════════════════════════
   3-Column Docs Layout
   ══════════════════════════════════════════════════════════════ */
.docs-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 220px;
  max-width: 1440px;
  margin: 0 auto;
  min-height: calc(100vh - 64px);
}

/* ══════════════════════════════════════════════════════════════
   Left Sidebar
   ══════════════════════════════════════════════════════════════ */
.sidebar {
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--card-background);
  padding: 24px 16px;
}

/* Scrollbar styling */
.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

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

/* ── Collapsible Menu Groups ── */
.menu-group {
  margin-bottom: 4px;
}

.menu-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 8px 12px;
  text-align: left;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.menu-trigger:hover {
  color: var(--text-secondary);
  background: var(--input-background);
}

.menu-trigger .chevron {
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.menu-group.open .menu-trigger .chevron {
  transform: rotate(90deg);
}

/* Smooth accordion via grid-template-rows trick */
.menu-content {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s ease-out;
}

.menu-group.open .menu-content {
  grid-template-rows: 1fr;
}

.menu-content-inner {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-left: 4px;
}

/* ── Navigation Links ── */
.nav-link {
  display: block;
  padding: 7px 12px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 450;
  transition: var(--transition-fast);
  position: relative;
}

.nav-link:hover {
  background: var(--input-background);
  color: var(--text-primary);
  transform: translateX(3px);
  text-decoration: none;
}

.nav-link.active {
  background: rgba(45, 45, 45, 0.07);
  color: var(--text-primary);
  font-weight: 600;
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background-color: var(--primary);
  border-radius: 0 3px 3px 0;
}

/* ══════════════════════════════════════════════════════════════
   Main Content Area
   ══════════════════════════════════════════════════════════════ */
.content {
  padding: 40px 48px;
  max-width: 840px;
  width: 100%;
  margin: 0 auto;
}

.doc-section {
  margin-bottom: 4rem;
  scroll-margin-top: 80px;
}

/* ══════════════════════════════════════════════════════════════
   Right Sidebar — Table of Contents
   ══════════════════════════════════════════════════════════════ */
.toc {
  position: sticky;
  top: 80px;
  height: calc(100vh - 80px);
  overflow-y: auto;
  padding: 24px 16px;
  font-size: 0.82rem;
}

.toc::-webkit-scrollbar {
  width: 3px;
}

.toc::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.toc-header {
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  padding-left: 12px;
}

.toc-link {
  display: block;
  padding: 4px 0 4px 12px;
  color: var(--text-tertiary);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: var(--transition-fast);
  margin-bottom: 2px;
  line-height: 1.4;
}

.toc-link:hover {
  color: var(--text-secondary);
  border-left-color: var(--border);
  text-decoration: none;
}

.toc-link.active {
  color: var(--text-primary);
  border-left-color: var(--primary);
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════
   Code Blocks
   ══════════════════════════════════════════════════════════════ */
.code-wrapper {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 20px 0;
  box-shadow: var(--shadow-sm);
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--code-header-bg);
  color: #94a3b8;
  font-size: 0.78rem;
  font-family: 'Fira Code', monospace;
}

.code-block {
  background: var(--code-bg);
  overflow-x: auto;
}

.code-block pre {
  margin: 0;
  padding: 20px;
}

.code-block code {
  color: #e2e8f0;
  font-size: 0.85rem;
  line-height: 1.65;
  background: none;
  padding: 0;
  border-radius: 0;
}

.copy-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  padding: 4px 12px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #f1f5f9;
}

.copy-btn:active {
  transform: scale(0.95);
}

.copy-btn.copied {
  background: var(--connected-green);
  border-color: var(--connected-green);
  color: #fff;
}

/* ══════════════════════════════════════════════════════════════
   OS Tab Switcher
   ══════════════════════════════════════════════════════════════ */
.os-tabs-container {
  margin: 1.5rem 0;
}

.os-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
}

.os-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: var(--transition-fast);
}

.os-tab:hover {
  color: var(--text-secondary);
}

.os-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--primary);
}

.os-tab-content {
  display: none;
  padding-top: 8px;
}

.os-tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════════
   Callout / Alert Boxes
   ══════════════════════════════════════════════════════════════ */
.callout {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  border-left: 4px solid;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 1.5rem 0;
}

.callout-icon {
  flex-shrink: 0;
  margin-top: 2px;
}

.callout-body p:last-child {
  margin-bottom: 0;
}

.callout-title {
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 0.95rem;
}

.callout-note {
  background: rgba(25, 118, 210, 0.06);
  border-left-color: #1976D2;
}

.callout-note .callout-icon { color: #1976D2; }

.callout-tip {
  background: rgba(56, 142, 60, 0.06);
  border-left-color: #388E3C;
}

.callout-tip .callout-icon { color: #388E3C; }

.callout-warning {
  background: rgba(251, 192, 45, 0.08);
  border-left-color: #F9A825;
}

.callout-warning .callout-icon { color: #F57F17; }

/* ══════════════════════════════════════════════════════════════
   Feature Grid
   ══════════════════════════════════════════════════════════════ */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 2rem 0;
}

.feature-card {
  background: var(--card-background);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: var(--transition-smooth);
}

.feature-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.feature-icon {
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.feature-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 0;
  margin-bottom: 6px;
}

.feature-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0;
  line-height: 1.6;
}

/* ══════════════════════════════════════════════════════════════
   Architecture Diagram
   ══════════════════════════════════════════════════════════════ */
.architecture-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 2rem;
  background: var(--card-background);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin: 2rem 0;
  gap: 0;
}

.arch-box {
  background: var(--background);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 14px 28px;
  text-align: center;
  min-width: 180px;
  transition: var(--transition-fast);
}

.arch-box:hover {
  box-shadow: var(--shadow-md);
  transform: scale(1.02);
}

.arch-box-icon {
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.arch-box-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.arch-box-tech {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  font-family: 'Fira Code', monospace;
  margin-top: 2px;
}

.arch-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
}

.arch-connector-line {
  width: 2px;
  height: 24px;
  background: var(--primary);
  position: relative;
}

.arch-connector-line::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px 4px 0;
  border-style: solid;
  border-color: var(--primary) transparent transparent transparent;
}

.arch-connector-label {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  font-weight: 500;
  letter-spacing: 0.03em;
}

/* ══════════════════════════════════════════════════════════════
   Prerequisites
   ══════════════════════════════════════════════════════════════ */
.prereq-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 1.5rem 0;
}

.prereq-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  background: var(--card-background);
  border: 1px solid var(--divider);
  border-radius: var(--radius-sm);
}

.prereq-check {
  flex-shrink: 0;
  margin-top: 2px;
}

.prereq-body {
  font-size: 0.95rem;
  line-height: 1.6;
}

.prereq-body p {
  margin: 0;
}

/* ══════════════════════════════════════════════════════════════
   Interactive Stepper
   ══════════════════════════════════════════════════════════════ */
.stepper {
  display: flex;
  flex-direction: column;
  margin: 2rem 0;
}

.step {
  display: flex;
  gap: 16px;
}

.step-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--card-background);
  border: 2px solid var(--border);
  color: var(--text-tertiary);
  z-index: 2;
  transition: var(--transition-smooth);
}

.step.active .step-number {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.step.completed .step-number {
  background: var(--connected-green);
  border-color: var(--connected-green);
  color: #fff;
}

.step-line {
  width: 2px;
  flex: 1;
  min-height: 20px;
  background: var(--divider);
  margin: 4px 0;
}

.step:last-child .step-line {
  display: none;
}

.step-content {
  padding-bottom: 24px;
}

.step-title {
  margin-top: 4px;
  margin-bottom: 6px;
  font-size: 1.05rem;
}

.step-content p {
  font-size: 0.925rem;
  color: var(--text-secondary);
  margin-bottom: 0;
}

.stepper-compact .step-content {
  padding-bottom: 16px;
}

/* ══════════════════════════════════════════════════════════════
   API Reference Cards
   ══════════════════════════════════════════════════════════════ */
.api-card {
  background: var(--card-background);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.api-card h4 {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.api-card p {
  margin-bottom: 0.75rem;
}

.api-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.method-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: 'Fira Code', monospace;
  letter-spacing: 0.04em;
}

.method-get    { background: #E8F5E9; color: #2E7D32; }
.method-post   { background: #E3F2FD; color: #1565C0; }
.method-put    { background: #FFF3E0; color: #EF6C00; }
.method-delete { background: #FFEBEE; color: #C62828; }

.endpoint {
  font-family: 'Fira Code', monospace;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  background: none;
  padding: 0;
}

/* ══════════════════════════════════════════════════════════════
   Configuration Table
   ══════════════════════════════════════════════════════════════ */
.config-table-wrapper {
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.config-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  background: var(--card-background);
}

.config-table thead {
  background: var(--input-background);
}

.config-table th {
  padding: 10px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.config-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--divider);
  vertical-align: top;
  line-height: 1.5;
}

.config-table tr:last-child td {
  border-bottom: none;
}

.config-table code {
  font-size: 0.82rem;
}

/* ══════════════════════════════════════════════════════════════
   FAQ / Troubleshooting
   ══════════════════════════════════════════════════════════════ */
.faq-item {
  padding: 20px 24px;
  background: var(--card-background);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.faq-item h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.05rem;
}

.faq-item ul {
  margin-bottom: 0;
}

/* ══════════════════════════════════════════════════════════════
   Roadmap
   ══════════════════════════════════════════════════════════════ */
.roadmap-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 2rem 0;
  padding-left: 16px;
  border-left: 2px solid var(--divider);
}

.roadmap-item {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  position: relative;
}

.roadmap-marker {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--card-background);
  flex-shrink: 0;
  margin-left: -23px;
  margin-top: 4px;
  z-index: 1;
}

.roadmap-done .roadmap-marker {
  background: var(--connected-green);
}

.roadmap-body strong {
  display: block;
  margin-bottom: 4px;
}

.roadmap-body p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0;
}

/* ══════════════════════════════════════════════════════════════
   Footer
   ══════════════════════════════════════════════════════════════ */
.footer {
  background: var(--card-background);
  border-top: 1px solid var(--border);
  padding: 24px 0;
  margin-top: 0;
}

.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.footer-tagline {
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.footer-right a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition-fast);
}

.footer-right a:hover {
  color: var(--text-primary);
}

.footer-license {
  font-size: 0.82rem;
  color: var(--text-tertiary);
}

/* ══════════════════════════════════════════════════════════════
   Scroll-to-Top Button
   ══════════════════════════════════════════════════════════════ */
.scroll-top-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--card-background);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.15s ease;
  z-index: 30;
}

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

/* ══════════════════════════════════════════════════════════════
   Mobile Navigation Overlay
   ══════════════════════════════════════════════════════════════ */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.mobile-nav-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-nav-overlay.open {
  display: flex;
  opacity: 1;
}

.mobile-nav-drawer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--card-background);
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 0;
}

.mobile-nav-overlay.open .mobile-nav-drawer {
  transform: translateX(0);
}

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

.mobile-nav-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.mobile-nav-close:hover {
  color: var(--text-primary);
}

.mobile-nav-content {
  padding: 16px;
}

.mobile-nav-content .nav-link {
  padding: 10px 12px;
  font-size: 0.95rem;
}

/* ══════════════════════════════════════════════════════════════
   Utilities
   ══════════════════════════════════════════════════════════════ */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ══════════════════════════════════════════════════════════════
   Responsive Breakpoints
   ══════════════════════════════════════════════════════════════ */

/* Tablet — hide right TOC */
@media (max-width: 1280px) {
  .docs-layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

/* Mobile — single column */
@media (max-width: 768px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .hamburger-btn {
    display: block;
  }

  .content {
    padding: 28px 20px;
  }

  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.3rem;
  }

  .feature-grid {
    grid-template-columns: 1fr;
  }

  .header-center {
    display: none;
  }

  .github-link span {
    display: none;
  }

  .api-card {
    padding: 16px;
  }

  .architecture-diagram {
    padding: 1.5rem 1rem;
  }

  .arch-box {
    min-width: 140px;
    padding: 10px 16px;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .footer-right {
    flex-wrap: wrap;
    gap: 12px;
  }

  .config-table {
    font-size: 0.82rem;
  }

  .config-table th,
  .config-table td {
    padding: 8px 10px;
  }

  .search-shortcut {
    display: none;
  }
}

/* Mid-tablet — 2-column feature grid */
@media (min-width: 769px) and (max-width: 1024px) {
  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ══════════════════════════════════════════════════════════════
   Print Styles
   ══════════════════════════════════════════════════════════════ */
@media print {
  .header,
  .sidebar,
  .toc,
  .hamburger-btn,
  .scroll-top-btn,
  .mobile-nav-overlay,
  .copy-btn {
    display: none !important;
  }

  .docs-layout {
    grid-template-columns: 1fr;
  }

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

  body {
    background: #fff;
  }
}
