/* ===== GitBook-Style Documentation Theme ===== */

/* ===== CSS Custom Properties ===== */
:root {
  --bg: #ffffff;
  --bg-secondary: #f6f8fa;
  --bg-card: #ffffff;
  --bg-sidebar: #fbfbfc;
  --text: #1f2328;
  --text-secondary: #656d76;
  --text-muted: #8b949e;
  --accent: #1a73e8;
  --accent-light: #e8f0fe;
  --accent-hover: #1557b0;
  --border: #d1d9e0;
  --border-light: #e8ecf0;
  --success: #0f9d58;
  --success-light: #dafbe1;
  --error: #db4437;
  --error-light: #fce8e6;
  --warning: #f9ab00;
  --warning-light: #fef7e0;
  --code-bg: #f6f8fa;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-sm: 6px;
  --font: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Noto Serif KR', Georgia, 'Times New Roman', serif;
  --font-mono: 'Fira Code', 'Consolas', 'Courier New', monospace;
  --font-active: var(--font);
  --font-scale: 1;
  --header-height: 56px;
  --sidebar-width: 280px;
  --toc-width: 220px;
  --content-max: 800px;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-secondary: #161b22;
  --bg-card: #161b22;
  --bg-sidebar: #010409;
  --text: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent: #58a6ff;
  --accent-light: #1a2a4a;
  --accent-hover: #79c0ff;
  --border: #30363d;
  --border-light: #21262d;
  --success: #3fb950;
  --success-light: #1a3a2a;
  --error: #f85149;
  --error-light: #3a1a1a;
  --warning: #d29922;
  --warning-light: #3a3520;
  --code-bg: #161b22;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.4);
}

[data-theme="dark"] .code-keyword { color: #d2a8ff; }
[data-theme="dark"] .code-string { color: #7ee787; }
[data-theme="dark"] .code-prop { color: #79c0ff; }
[data-theme="dark"] .code-comment { color: #8b949e; }
[data-theme="dark"] .badge-yellow { background: #3a3520; color: #d29922; }

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-height) + 24px); }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background 0.2s, color 0.2s;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ===== Skip Navigation ===== */
.skip-nav {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-sm);
  z-index: 1000;
  font-size: 14px;
  text-decoration: none;
}
.skip-nav:focus { top: 8px; }

/* ===== Header ===== */
.gb-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 100;
  transition: background 0.2s, border-color 0.2s;
}

.gb-header__left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.gb-header__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  text-decoration: none;
}
.gb-header__logo:hover { color: var(--text); text-decoration: none; }
.gb-header__logo svg { width: 26px; height: 26px; flex-shrink: 0; }

.gb-header__center {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0 20px;
}

.gb-header__right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

/* Sidebar toggle (mobile) */
.gb-sidebar-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 20px;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.gb-sidebar-toggle:hover { background: var(--bg-secondary); }

/* Search */
.gb-search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 220px;
}
.gb-search-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.gb-search-btn kbd {
  margin-left: auto;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  font-family: var(--font);
  font-size: 11px;
  color: var(--text-muted);
}

/* Theme toggle */
.gb-theme-toggle,
.gb-settings-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 18px;
  transition: background 0.2s;
}
.gb-theme-toggle:hover,
.gb-settings-btn:hover { background: var(--bg-secondary); }
.gb-settings-btn.active { color: var(--accent); background: var(--accent-light); }

/* ===== Settings Panel ===== */
.gb-settings-wrap { position: relative; }
.gb-settings-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  padding: 14px;
  z-index: 1200;
  display: none;
  animation: settingsFadeIn 0.12s ease;
}
.gb-settings-panel.open { display: block; }
@keyframes settingsFadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.gb-settings__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.gb-settings__row:not(:first-child) { margin-top: 12px; }
.gb-settings__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Theme & Font style: shared segmented control */
.gb-seg {
  display: flex;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 1px;
  flex: 1;
}
.gb-seg button {
  flex: 1;
  padding: 4px 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  font-family: var(--font);
  line-height: 1.3;
}
.gb-seg button:hover { color: var(--text); }
.gb-seg button.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* Font size slider */
.gb-settings__size-wrap { flex: 1; display: flex; align-items: center; gap: 6px; }
.gb-settings__size-label { font-size: 10px; color: var(--text-muted); flex-shrink: 0; }
.gb-settings__size-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}
.gb-settings__size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-card);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.gb-settings__size-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-card);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* Divider + Reset */
.gb-settings__footer {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.gb-settings__footer button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font);
  transition: color 0.15s;
}
.gb-settings__footer button:hover { color: var(--accent); }

/* Font-active overrides */
[data-font="serif"] { --font-active: var(--font-serif); }
[data-font="serif"] .gb-article,
[data-font="serif"] .subsection p,
[data-font="serif"] .faq-a,
[data-font="serif"] .faq-answer,
[data-font="serif"] .info-box,
[data-font="serif"] .analogy { font-family: var(--font-serif); }

/* Font scale overrides */
[data-font-size="small"] { --font-scale: 0.9; }
[data-font-size="large"] { --font-scale: 1.12; }
.gb-article { font-size: calc(16px * var(--font-scale)); }
.subsection p, .subsection li { font-size: calc(15px * var(--font-scale)); }
.info-box, .analogy, .faq-a, .faq-answer { font-size: calc(14px * var(--font-scale)); }

/* (reset button styles moved inline to .gb-settings__footer) */

/* GitHub link */
.gb-github-link {
  display: flex;
  align-items: center;
  color: var(--text-secondary);
  transition: color 0.2s;
}
.gb-github-link:hover { color: var(--text); text-decoration: none; }

/* ===== Three-Column Layout ===== */
.gb-wrapper {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--toc-width);
  min-height: 100vh;
  padding-top: var(--header-height);
}

/* ===== Left Sidebar ===== */
.gb-sidebar {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  padding: 16px 0;
  font-size: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.gb-sidebar::-webkit-scrollbar { width: 4px; }
.gb-sidebar::-webkit-scrollbar-track { background: transparent; }
.gb-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.gb-nav-group { margin-bottom: 4px; }

.gb-nav-group__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 8px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}
.gb-nav-group__title:hover { color: var(--text); }
.gb-nav-group__title .gb-arrow {
  font-size: 10px;
  transition: transform 0.2s;
  color: var(--text-muted);
}
.gb-nav-group.collapsed .gb-arrow { transform: rotate(-90deg); }
.gb-nav-group.collapsed .gb-nav-group__items { display: none; }

.gb-nav-item {
  display: block;
  padding: 6px 16px 6px 24px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.5;
  border-left: 2px solid transparent;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.gb-nav-item:hover {
  color: var(--text);
  background: var(--bg-secondary);
  text-decoration: none;
}
.gb-nav-item.active {
  color: var(--accent);
  background: var(--accent-light);
  border-left-color: var(--accent);
  font-weight: 500;
}

.gb-nav-item--page {
  font-weight: 500;
  color: var(--text);
  padding: 8px 16px 8px 20px;
}
.gb-nav-item--page:hover { background: var(--bg-secondary); }
.gb-nav-item--page.active {
  color: var(--accent);
  background: var(--accent-light);
  border-left-color: var(--accent);
}

.gb-nav-item--sub {
  padding-left: 36px;
  font-size: 13px;
}

.gb-nav-divider {
  height: 1px;
  background: var(--border-light);
  margin: 8px 16px;
}

/* ===== Main Content ===== */
.gb-content {
  overflow-x: hidden;
  padding: 32px 48px 80px;
  min-width: 0;
}

.gb-article {
  max-width: var(--content-max);
  margin: 0 auto;
}

/* ===== Right TOC ===== */
.gb-toc {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 24px 16px 24px 0;
  border-left: 1px solid var(--border-light);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.gb-toc::-webkit-scrollbar { width: 4px; }
.gb-toc::-webkit-scrollbar-track { background: transparent; }
.gb-toc::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.gb-toc__title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 0 16px 8px;
  margin-bottom: 4px;
}

.gb-toc__link {
  display: block;
  padding: 4px 16px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.15s;
  line-height: 1.5;
}
.gb-toc__link:hover {
  color: var(--text);
  text-decoration: none;
}
.gb-toc__link.active {
  color: var(--accent);
  border-left-color: var(--accent);
}
.gb-toc__link--h3 {
  padding-left: 28px;
  font-size: 12px;
}

/* ===== First-child margin fix ===== */
.gb-article > *:first-child { margin-top: 0; }

/* ===== Typography ===== */
.gb-article .section-header {
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.gb-article .section-header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  line-height: 1.3;
}
.gb-article .section-header p {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.gb-article .subsection {
  margin-bottom: 48px;
}
.gb-article .subsection h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 16px;
  padding-top: 24px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  scroll-margin-top: calc(var(--header-height) + 16px);
  position: relative;
}
.gb-article .subsection h2 .icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.gb-article .subsection h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 28px 0 12px;
  scroll-margin-top: calc(var(--header-height) + 16px);
}

.gb-article .subsection p {
  margin-bottom: 16px;
  line-height: 1.8;
}

/* ===== Heading Anchors ===== */
.heading-anchor {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 400;
  opacity: 0;
  margin-left: 6px;
  transition: opacity 0.15s;
  font-size: 0.8em;
}
.subsection h2:hover .heading-anchor,
.subsection h3:hover .heading-anchor {
  opacity: 1;
}
.heading-anchor:hover { color: var(--accent); text-decoration: none; }

/* ===== Cards ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
}
.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
}
.card h4 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.card p { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }

/* ===== Analogy / Callout ===== */
.analogy {
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px 20px;
  margin: 20px 0;
  font-size: 14px;
}
.analogy-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

/* ===== Code Blocks ===== */
.code-block {
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  margin: 16px 0;
  overflow-x: auto;
  position: relative;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid var(--border-light);
}
.code-block[data-lang]::before {
  content: attr(data-lang);
  display: block;
  padding: 6px 16px;
  background: var(--border-light);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-family: var(--font);
}
.code-block code { white-space: pre-wrap; display: block; color: var(--text); padding: 16px 20px; }
.code-label {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.code-keyword { color: #8b5cf6; }
.code-string { color: #059669; }
.code-comment { color: var(--text-secondary); font-style: italic; }
.code-prop { color: #2563eb; }

/* Copy button */
.code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
}
.code-block:hover .code-copy { opacity: 1; }
.code-copy:hover { background: var(--bg-secondary); color: var(--text); }
.code-copy.copied { color: var(--success); border-color: var(--success); }

/* ===== Info & Warning Boxes ===== */
.info-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 14px 18px;
  margin: 16px 0;
  font-size: 14px;
}
.info-box strong { color: var(--accent); }

.info-box.warning,
.warning-box {
  background: var(--warning-light);
  border-color: var(--warning);
  border-left-color: var(--warning);
}
.info-box.warning strong,
.warning-box strong { color: #b45309; }

.info-box.error {
  border-color: var(--error);
  border-left-color: var(--error);
  background: var(--error-light);
}
.info-box.error strong { color: var(--error); }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; margin: 16px 0; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-wrap th,
.table-wrap td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border-light); }
.table-wrap th { font-weight: 600; background: var(--bg-secondary); white-space: nowrap; font-size: 13px; }
.table-wrap tr:hover td { background: var(--accent-light); }

/* ===== Step List ===== */
.step-list { list-style: none; counter-reset: step; margin: 20px 0; }
.step-list li {
  counter-increment: step;
  padding: 14px 14px 14px 52px;
  position: relative;
  margin-bottom: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}
.step-list li::before {
  content: counter(step);
  position: absolute;
  left: 14px;
  top: 14px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

/* ===== Feature List ===== */
.feature-list { list-style: none; margin: 16px 0; }
.feature-list li {
  padding: 8px 0 8px 28px;
  position: relative;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
}
.feature-list li:last-child { border-bottom: none; }
.feature-list li::before {
  content: '\2713';
  position: absolute;
  left: 0;
  color: var(--success);
  font-weight: 700;
  font-size: 15px;
}

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-blue { background: var(--accent-light); color: var(--accent); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-yellow { background: var(--warning-light); color: var(--warning); }
.badge-red { background: var(--error-light); color: var(--error); }
.badge-orange { background: var(--warning-light); color: var(--warning); }

/* ===== Mistake Card ===== */
.mistake-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
}
.mistake-card .mistake-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--error);
}
.mistake-card .solution-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  margin-top: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--success);
}
.mistake-card p { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }

/* ===== FAQ ===== */
.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin: 10px 0;
  overflow: hidden;
}
.faq-question {
  padding: 14px 18px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  transition: background 0.2s;
}
.faq-question:hover { background: var(--bg-secondary); }
.faq-question::before {
  content: 'Q';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.faq-answer {
  padding: 0 18px 14px 50px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  display: none;
}
.faq-item.open .faq-answer { display: block; }
.faq-item.open .faq-question { border-bottom: 1px solid var(--border-light); }

/* Skills/Workflows FAQ alternate style */
.faq-q {
  padding: 14px 18px;
  font-weight: 600;
  font-size: 14px;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}
.faq-q:hover { background: var(--border-light); }
.faq-q::before {
  content: 'Q';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.faq-a {
  padding: 14px 18px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
  display: none;
}
.faq-item.open .faq-a { display: block; }
.faq-item.open .faq-q { border-bottom: 1px solid var(--border-light); }

/* FAQ answers - tables inside FAQ */
.faq-a .info-table,
.faq-answer .info-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
}
.info-table thead th {
  background: var(--bg-secondary);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  border-bottom: 2px solid var(--border);
}
.info-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  vertical-align: top;
}
.info-table tbody tr:hover { background: var(--bg-secondary); }

/* ===== Docs Links ===== */
.docs-links {
  margin-top: 40px;
  padding: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  text-align: center;
}
.docs-links h3 { font-size: 17px; font-weight: 600; margin-bottom: 14px; }
.docs-links > a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 14px;
  transition: opacity 0.2s;
}
.docs-links > a:hover { opacity: 0.85; color: white; text-decoration: none; }
.docs-links .secondary-link {
  display: block;
  margin-top: 12px;
  color: var(--accent);
  background: none;
  padding: 0;
  font-size: 13px;
}
.docs-links .secondary-link:hover { text-decoration: underline; }

/* Docs grid (categorized links) */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  text-align: left;
  margin-top: 16px;
}
.docs-grid h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.docs-grid ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.docs-grid ul li {
  padding: 4px 0;
}
.docs-grid ul li a {
  display: inline;
  background: none;
  padding: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
}
.docs-grid ul li a:hover {
  text-decoration: underline;
  opacity: 1;
}

/* ===== Before/After ===== */
.before-after {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 16px 0;
}
.before-after .before,
.before-after .after { padding: 14px; border-radius: var(--radius-sm); font-size: 14px; line-height: 1.7; }
.before-after .before { background: var(--error-light); border: 1px solid var(--error); }
.before-after .after { background: var(--success-light); border: 1px solid var(--success); }
.before-after .ba-label,
.before-after .label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.before-after .before .ba-label,
.before-after .before .label { color: var(--error); }
.before-after .after .ba-label,
.before-after .after .label { color: var(--success); }

/* ===== Scenario Box ===== */
.scenario-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 16px 0;
}
.scenario-box .scenario-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.scenario-box .user-msg {
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  margin: 6px 0;
  font-size: 14px;
  border-left: 3px solid var(--accent);
}
.scenario-box .agent-msg {
  background: var(--success-light);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  margin: 6px 0;
  font-size: 14px;
  border-left: 3px solid var(--success);
}

/* ===== Flowchart Box ===== */
.flowchart-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
  font-size: 14px;
  line-height: 2;
}

/* ===== TOC (inline) ===== */
.toc {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 0 0 28px;
}
.toc h3 { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { padding: 3px 0; }
.toc a { color: var(--accent); text-decoration: none; font-size: 13px; }
.toc a:hover { text-decoration: underline; }

/* ===== Debug Item ===== */
.debug-item {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-left: 4px solid var(--error);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 18px 20px;
  margin: 14px 0;
}
.debug-item h4 { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.debug-item .symptom { font-size: 13px; color: var(--error); margin-bottom: 6px; }
.debug-item .solution { font-size: 14px; color: var(--text-secondary); line-height: 1.7; }

/* ===== Doc Ref Pill ===== */
.doc-ref {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  min-height: 28px;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  border-radius: 12px;
  text-decoration: none;
  transition: all 0.2s;
  margin-left: 4px;
}
.doc-ref:hover { background: var(--accent); color: white; text-decoration: none; }

/* ===== Infographic ===== */
.infographic { margin: 20px 0; text-align: center; }
.infographic svg { max-width: 100%; height: auto; }

/* ===== Pagination ===== */
.gb-pagination {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 0;
  border-top: 1px solid var(--border-light);
  margin-top: 48px;
  max-width: var(--content-max);
  margin-left: auto;
  margin-right: auto;
}
.gb-pagination a {
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 0;
  max-width: 48%;
}
.gb-pagination a:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  text-decoration: none;
}
.gb-pagination__label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.gb-pagination__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gb-pagination__prev { text-align: left; }
.gb-pagination__next { margin-left: auto; text-align: right; }

/* ===== Footer ===== */
.gb-footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border-light);
  margin-top: 32px;
  max-width: var(--content-max);
  margin-left: auto;
  margin-right: auto;
}
.gb-footer a { color: var(--accent); }
.gb-footer p { margin-bottom: 6px; }
.gb-footer p:last-child { margin-bottom: 0; }

/* ===== Search Modal ===== */
.gb-search-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  justify-content: center;
  padding-top: 100px;
  background: rgba(0,0,0,0.4);
}
.gb-search-modal.active { display: flex; }

.gb-search-modal__box {
  width: 560px;
  max-width: 90vw;
  max-height: 460px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.gb-search-modal__input-wrap {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
}
.gb-search-modal__input-wrap svg { flex-shrink: 0; color: var(--text-muted); }

.gb-search-modal__input {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 16px;
  background: transparent;
  color: var(--text);
}
.gb-search-modal__input::placeholder { color: var(--text-muted); }

.gb-search-modal__results {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.gb-search-result {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 0.15s;
}
.gb-search-result:hover { background: var(--bg-secondary); text-decoration: none; }
.gb-search-result__page {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.gb-search-result__title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-top: 2px;
}
.gb-search-result__excerpt {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.gb-search-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ===== Mobile Overlay ===== */
.gb-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 49;
  display: none;
}
.gb-overlay.active { display: block; }

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

/* ===== Utility ===== */
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.text-sm-secondary { font-size: 12px; color: var(--text-secondary); }

/* ===== Scroll Progress ===== */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--success));
  z-index: 999;
  transition: width 0.1s;
}

/* ===== Responsive: Tablet ===== */
@media (max-width: 1100px) {
  .gb-wrapper {
    grid-template-columns: var(--sidebar-width) 1fr;
  }
  .gb-toc { display: none; }
  .gb-content { padding: 28px 32px 60px; }
}

/* ===== Responsive: Mobile ===== */
@media (max-width: 768px) {
  .gb-wrapper {
    grid-template-columns: 1fr;
  }

  .gb-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 300px;
    max-width: 85vw;
    height: calc(100vh - var(--header-height));
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    background: var(--bg);
  }
  .gb-sidebar.open { transform: translateX(0); }

  .gb-sidebar-toggle { display: flex; }

  .gb-content { padding: 20px 16px 60px; }

  .gb-search-btn { min-width: 140px; }
  .gb-search-btn span { display: none; }

  .section-header h1 { font-size: 1.5rem; }
  .card-grid { grid-template-columns: 1fr; }
  .before-after { grid-template-columns: 1fr; }

  .gb-pagination { flex-direction: column; }
  .gb-pagination a { max-width: 100%; }
  .gb-pagination__next { margin-left: 0; }

  .gb-header__logo span { display: none; }

  /* Table responsive */
  .table-wrap { margin: 12px -16px; }
  .table-wrap table { font-size: 13px; }
  .table-wrap th, .table-wrap td { padding: 8px 10px; }

  /* Infographic responsive */
  .infographic svg { max-width: 100%; overflow-x: auto; }
  .infographic { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ===== Dark Mode Card Hover ===== */
[data-theme="dark"] .card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(88, 166, 255, 0.15);
}

/* ===== Page Transition ===== */
.gb-article {
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Info & Warning Box Icons ===== */
.info-box::before {
  content: '\2139';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 700;
  margin-right: 8px;
  flex-shrink: 0;
  float: left;
  margin-top: 2px;
}
.info-box.warning::before {
  content: '!';
  background: var(--warning);
}
.info-box.error::before {
  content: '\2715';
  background: var(--error);
}
.warning-box::before {
  content: '!';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--warning);
  color: white;
  font-size: 12px;
  font-weight: 700;
  margin-right: 8px;
  flex-shrink: 0;
  float: left;
  margin-top: 2px;
}

/* ===== Heading Underline Accent ===== */
.gb-article .subsection h2::after {
  content: '';
  display: block;
  width: 40px;
  height: 2px;
  background: var(--accent);
  margin-top: 0;
  border-radius: 1px;
  flex-basis: 100%;
}

/* ===== Scroll-to-Top Button ===== */
.gb-scroll-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.gb-scroll-top.visible { opacity: 1; visibility: visible; }
.gb-scroll-top:hover { transform: scale(1.1); }

/* ===== Print ===== */
@media print {
  .gb-header, .gb-sidebar, .gb-toc, .gb-pagination, .scroll-progress, .gb-scroll-top { display: none; }
  .gb-wrapper { grid-template-columns: 1fr; }
  .gb-content { padding: 0; }
  body { font-size: 12pt; line-height: 1.6; }
  .code-block { border: 1px solid #ccc; break-inside: avoid; }
  .card { break-inside: avoid; border: 1px solid #ccc; box-shadow: none; }
  .info-box, .warning-box, .analogy { break-inside: avoid; }
  a[href]::after { content: ' (' attr(href) ')'; font-size: 10pt; color: #666; }
  .docs-links a[href]::after { content: none; }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High contrast mode support */
@media (forced-colors: active) {
  .badge, .info-box, .warning-box, .analogy {
    border: 1px solid;
  }
}
