/* ==========================================================================
   Skill-Up — styles
   ========================================================================== */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1a1e24;
  --text-2: #4f5965;
  --muted: #7d8793;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --accent-text: #3730a3;
  --success: #15803d;
  --success-soft: #e7f6ec;
  --code-bg: #f7f8fa;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);

  /* syntax highlighting */
  --hl-keyword: #cf222e;
  --hl-string: #0a3069;
  --hl-number: #0550ae;
  --hl-title: #8250df;
  --hl-type: #953800;
  --hl-comment: #6e7781;
  --hl-attr: #0550ae;

  --radius: 10px;
  --topbar-h: 56px;
  --sidebar-w: 288px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0e1014;
  --surface: #161a20;
  --surface-2: #1e232b;
  --border: #2a313b;
  --text: #e6e9ee;
  --text-2: #a9b2bd;
  --muted: #727d8a;
  --accent: #8b8cf8;
  --accent-soft: #23244a;
  --accent-text: #c9caff;
  --success: #4ade80;
  --success-soft: #142a1d;
  --code-bg: #12161c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);

  --hl-keyword: #ff7b72;
  --hl-string: #a5d6ff;
  --hl-number: #79c0ff;
  --hl-title: #d2a8ff;
  --hl-type: #ffa657;
  --hl-comment: #8b949e;
  --hl-attr: #79c0ff;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 15px/1.65 var(--font);
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); }
code, kbd, pre { font-family: var(--mono); }
img { max-width: 100%; height: auto; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Buttons ---------- */

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--text-2);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.text-btn {
  border: 0;
  background: none;
  padding: 2px 6px;
  font: inherit;
  font-size: 12.5px;
  color: var(--accent);
  cursor: pointer;
  border-radius: 6px;
}
.text-btn:hover { background: var(--accent-soft); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.is-on { background: var(--success-soft); border-color: var(--success); color: var(--success); }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}

#menu-btn { display: none; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  width: calc(var(--sidebar-w) - 28px);
  flex: none;
}
.brand-mark { display: block; border-radius: 9px; box-shadow: 0 2px 8px color-mix(in srgb, #6366f1 35%, transparent); }

.search {
  position: relative;
  flex: 1;
  max-width: 520px;
}
.search-icon { position: absolute; left: 11px; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%;
  height: 36px;
  padding: 0 36px 0 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
.search input::-webkit-search-cancel-button { display: none; }
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface); }
.search kbd {
  position: absolute;
  right: 9px;
  top: 50%;
  translate: 0 -50%;
  padding: 0 6px;
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  pointer-events: none;
}
.search input:focus ~ kbd { display: none; }

#search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  max-height: 65vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
}
#search-results a { display: block; padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--text); }
#search-results li.selected a, #search-results a:hover { background: var(--accent-soft); }
.sr-title { display: block; font-size: 14px; font-weight: 500; }
.sr-path { display: block; font-size: 12px; color: var(--muted); }
.sr-empty { padding: 10px; color: var(--muted); font-size: 14px; }
.sr-group {
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.sr-snippet { display: block; margin-top: 2px; font-size: 12.5px; line-height: 1.45; color: var(--text-2); }
.sr-snippet mark, .sr-title mark { background: color-mix(in srgb, #facc15 45%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }

/* Briefly highlights the section a search result jumped to */
.flash { animation: flash 2s ease-out; }
@keyframes flash {
  0%, 30% { background: color-mix(in srgb, #facc15 30%, transparent); }
  100% { background: transparent; }
}

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.offline-badge { background: #fff4e0; border-color: transparent; color: #b45309; font-weight: 600; }
[data-theme="dark"] .offline-badge { background: #2d2210; color: #fbbf24; }
.install-btn { padding: 4px 12px 4px 10px; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

.ask-btn {
  padding: 4px 12px;
  border: 0;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff;
  font-weight: 600;
}
.ask-btn:hover { color: #fff; filter: brightness(1.08); }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; padding: 6px 16px; }
.btn-primary:hover { color: #fff; filter: brightness(1.08); }
[data-theme="dark"] .btn-primary { color: #11121c; }

/* ---------- Ask Claude panel ---------- */

.ask-panel {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  z-index: 38;
  width: min(440px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.ask-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 10px 18px;
  border-bottom: 1px solid var(--border);
}
.ask-head h2 { margin: 0; font-size: 1rem; }
.ask-body { flex: 1; overflow-y: auto; padding: 16px 18px 24px; font-size: 14px; }

.ask-setup ol { padding-left: 1.2rem; }
.ask-setup li + li { margin-top: 6px; }
.ask-token-form { display: flex; gap: 8px; margin-top: 12px; }
.ask-token-form input, .ask-form textarea {
  flex: 1;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.ask-token-form input:focus, .ask-form textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--surface); }
.ask-form textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.ask-error { color: #dc2626; }

.ask-context { display: block; margin: 8px 0; font-size: 13px; color: var(--text-2); }
.ask-context input { margin: 0 4px 0 0; vertical-align: -2px; }
.ask-context span { font-weight: 500; color: var(--text); }
.ask-examples { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: none;
  font: inherit;
  font-size: 12.5px;
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.ask-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.ask-body .section-title { margin-top: 28px; }
.ask-requests { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ask-request { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.ask-request-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ask-request-title { margin: 4px 0; font-weight: 500; }
.ask-status { font-size: 12px; font-weight: 600; color: var(--muted); }
.ask-request[data-status="working"] .ask-status, .ask-request[data-status="sent"] .ask-status { color: var(--accent); }
.ask-request[data-status="working"] .ask-status::before { content: "● "; animation: pulse 1.2s infinite; }
.ask-request[data-status="done"] .ask-status { color: var(--success); }
.ask-request[data-status="failed"] .ask-status { color: #dc2626; }
@keyframes pulse { 50% { opacity: 0.3; } }
.ask-reply { margin: 6px 0; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-size: 13.5px; }
.ask-reply > :first-child { margin-top: 0; }
.ask-reply > :last-child { margin-bottom: 0; }
.ask-reply hr { margin: 8px 0; }
.ask-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--border); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 50;
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px);
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
}
.toast-close { width: 28px; height: 28px; font-size: 13px; }

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 8px 32px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 6px 8px 10px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.sidebar-head .text-btn { text-transform: none; letter-spacing: 0; font-weight: 500; }

.overlay { display: none; }

main {
  min-width: 0;
  padding: 0 40px 72px;
  outline: none;
}

/* ---------- Sidebar tree ---------- */

.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { margin-left: 13px; padding-left: 8px; border-left: 1px solid var(--border); }
.tree li:not(.expanded) > .tree { display: none; }

.tree-row { display: flex; align-items: center; gap: 2px; }

.twisty, .twisty-spacer { width: 22px; height: 22px; flex: none; }
.twisty {
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.twisty:hover { background: var(--surface-2); color: var(--text); }
.twisty svg { transition: transform 0.15s ease; }
li.expanded > .tree-row > .twisty svg { transform: rotate(90deg); }

.tree-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-2);
  text-decoration: none;
}
.tree-link:hover { background: var(--surface-2); color: var(--text); }
.has-children > .tree-row > .tree-link { color: var(--text); font-weight: 500; }
.tree-link.active, .has-children > .tree-row > .tree-link.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}
.tree-icon { flex: none; width: 18px; text-align: center; }
.tree-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.revised-dot { flex: none; width: 7px; height: 7px; margin-left: auto; border-radius: 50%; }
li.revised > .tree-row .revised-dot { background: var(--success); }

/* ---------- Breadcrumb (sticky under the top bar) ---------- */

#breadcrumb {
  position: sticky;
  top: var(--topbar-h);
  z-index: 20;
  margin: 0 -40px 20px;
  padding: 10px 40px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
#breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--muted);
}
#breadcrumb li + li::before { content: "›"; margin-right: 6px; color: var(--muted); }
#breadcrumb a { color: var(--text-2); text-decoration: none; }
#breadcrumb a:hover { color: var(--accent); text-decoration: underline; }
#breadcrumb [aria-current] { color: var(--text); font-weight: 600; }

/* ---------- Generic page bits ---------- */

.loading { padding: 48px 0; color: var(--muted); }

.page-header { margin-bottom: 20px; }
.page-header h1 {
  margin: 4px 0 6px;
  font-size: clamp(1.6rem, 2.6vw, 2.1rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.lede { margin: 0 0 12px; font-size: 1.05rem; color: var(--text-2); }

.empty {
  padding: 28px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-2);
}

.section-title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-2);
}
.pill-done { background: var(--success-soft); border-color: transparent; color: var(--success); }
.pill-tag { background: transparent; }
.pill-level { font-weight: 600; border-color: transparent; }
.pill-level[data-level="beginner"] { background: #e7f6ec; color: #15803d; }
.pill-level[data-level="intermediate"] { background: #fff4e0; color: #b45309; }
.pill-level[data-level="advanced"] { background: #fde8e8; color: #b91c1c; }
[data-theme="dark"] .pill-level[data-level="beginner"] { background: #142a1d; color: #4ade80; }
[data-theme="dark"] .pill-level[data-level="intermediate"] { background: #2d2210; color: #fbbf24; }
[data-theme="dark"] .pill-level[data-level="advanced"] { background: #2e1515; color: #f87171; }

.meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.meta-row .revise-btn { margin-left: auto; }

/* ---------- Cards ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}

.card {
  display: flex;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card-icon { font-size: 24px; line-height: 1.2; }
.card-body { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.card-title { font-weight: 600; }
.card-desc { font-size: 13.5px; line-height: 1.5; color: var(--text-2); margin-bottom: 6px; }

/* ---------- Home ---------- */

.hero {
  margin-bottom: 28px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background:
    radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 55%),
    var(--surface);
}
.hero h1 { margin: 0; font-size: clamp(1.8rem, 3.5vw, 2.4rem); letter-spacing: -0.03em; }
.hero p { margin: 6px 0 0; font-size: 1.05rem; color: var(--text-2); }

.stats { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 22px; align-items: flex-end; }
.stat { display: flex; flex-direction: column; }
.stat strong { font-size: 1.6rem; line-height: 1.1; }
.stat span { font-size: 12.5px; color: var(--muted); }
.stat-progress { flex: 1; min-width: 200px; max-width: 360px; gap: 6px; }
.progress { display: block; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--success); border-radius: inherit; transition: width 0.3s; }

.home-section { margin-bottom: 32px; }

.recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.recent a {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.recent a:hover { border-color: var(--accent); }
.recent .muted { font-size: 12px; font-weight: 400; }

/* ---------- Concept page ---------- */

.concept-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 48px; }
.concept { max-width: 860px; min-width: 0; }

.tabs {
  display: flex;
  gap: 4px;
  margin: 24px 0 4px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tab {
  margin-bottom: -1px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  font: inherit;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

.toc { display: none; }

.qa-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 16px 0 4px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 13px;
}

.sub-topics { margin-top: 40px; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 56px; }
.pager a {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.pager a:hover { border-color: var(--accent); }
.pager .next { grid-column: 2; text-align: right; }

/* ---------- Prose (rendered Markdown) ---------- */

.prose { overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose h2, .prose h3, .prose h4, .prose details { scroll-margin-top: calc(var(--topbar-h) + 60px); }
.prose h2 {
  margin: 2.2rem 0 0.8rem;
  padding-bottom: 0.35rem;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
}
.prose h3 { margin: 1.6rem 0 0.5rem; font-size: 1.1rem; }
.prose h4 { margin: 1.2rem 0 0.4rem; font-size: 1rem; }
.prose p, .prose ul, .prose ol { margin: 0.65rem 0; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: 0.25rem; }
.prose li > ul, .prose li > ol { margin: 0.25rem 0; }
.prose hr { margin: 2rem 0; border: 0; border-top: 1px solid var(--border); }
.prose strong { font-weight: 650; }

.prose :not(pre) > code {
  padding: 0.12em 0.38em;
  font-size: 0.87em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
}

.prose blockquote {
  margin: 1rem 0;
  padding: 0.6rem 1rem;
  border-left: 3px solid var(--border);
  color: var(--text-2);
}

/* Callouts:  > [!TIP] … */
.prose .callout { --c: #3b82f6; border-left-color: var(--c); background: color-mix(in srgb, var(--c) 8%, transparent); border-radius: 0 8px 8px 0; color: var(--text); }
.prose .callout p { margin: 0.3rem 0; }
.callout-title { font-weight: 600; color: var(--c); margin-bottom: 2px; }
.callout-tip { --c: #16a34a; }
.callout-important { --c: #8b5cf6; }
.callout-warning { --c: #d97706; }
.callout-caution { --c: #dc2626; }

/* Tables */
.table-wrap { margin: 1rem 0; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; }
.prose th, .prose td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.prose th + th, .prose td + td { border-left: 1px solid var(--border); }
.prose tr:last-child td { border-bottom: 0; }
.prose th { background: var(--surface-2); font-weight: 600; }

/* Q&A cards:  ### Q: … */
details.qa {
  margin: 0.6rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
details.qa > summary {
  position: relative;
  padding: 12px 40px 12px 46px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
details.qa > summary::-webkit-details-marker { display: none; }
details.qa > summary::before {
  content: "Q";
  position: absolute;
  left: 14px;
  top: 12px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
}
details.qa > summary::after {
  content: "+";
  position: absolute;
  right: 16px;
  top: 10px;
  font-size: 18px;
  color: var(--muted);
}
details.qa[open] > summary::after { content: "−"; }
details.qa[open] > summary { border-bottom: 1px solid var(--border); }
details.qa > summary:hover { color: var(--accent); }
.qa-body { padding: 4px 18px 10px 46px; }

/* Code blocks */
.code-block {
  margin: 1rem 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--code-bg);
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 6px 3px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font: 12px var(--mono);
  color: var(--muted);
}
.copy-btn {
  padding: 2px 8px;
  border: 0;
  border-radius: 5px;
  background: none;
  font: 12px var(--font);
  color: var(--text-2);
  cursor: pointer;
}
.copy-btn:hover { background: var(--border); color: var(--text); }
.code-block pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-size: 13.5px; line-height: 1.55; }
.code-block code { background: none; }

.hljs-keyword, .hljs-selector-tag, .hljs-doctag, .hljs-meta .hljs-keyword { color: var(--hl-keyword); }
.hljs-string, .hljs-regexp, .hljs-meta .hljs-string { color: var(--hl-string); }
.hljs-number, .hljs-literal, .hljs-symbol, .hljs-bullet { color: var(--hl-number); }
.hljs-title, .hljs-title.function_, .hljs-section { color: var(--hl-title); }
.hljs-type, .hljs-built_in, .hljs-title.class_, .hljs-variable, .hljs-template-variable { color: var(--hl-type); }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-params, .hljs-selector-class, .hljs-name { color: var(--hl-attr); }
.hljs-comment, .hljs-quote, .hljs-meta { color: var(--hl-comment); font-style: italic; }
.hljs-addition { color: var(--success); }
.hljs-deletion { color: var(--hl-keyword); }

/* Mermaid diagrams */
.diagram {
  margin: 1.25rem 0;
  padding: 16px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}
.diagram pre.mermaid { margin: 0; background: none; font-family: var(--font); }
.diagram pre.mermaid:not([data-processed]) { min-height: 80px; color: transparent; }
.diagram-error { text-align: left; }
.diagram-error::before { content: "⚠️ Diagram couldn't be rendered — source shown below"; display: block; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.diagram-error pre.mermaid { color: var(--text-2) !important; font: 13px/1.5 var(--mono); white-space: pre-wrap; }

/* ---------- Responsive ---------- */

@media (min-width: 1280px) {
  .concept-layout { grid-template-columns: minmax(0, 860px) 220px; }
  .toc {
    display: block;
    position: sticky;
    top: calc(var(--topbar-h) + 64px);
    align-self: start;
    max-height: calc(100vh - var(--topbar-h) - 88px);
    overflow-y: auto;
    padding-top: 6px;
    font-size: 13px;
  }
  .toc-title { margin-bottom: 8px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
  .toc ul { margin: 0; padding: 0; list-style: none; border-left: 1px solid var(--border); }
  .toc a { display: block; padding: 3px 0 3px 12px; margin-left: -1px; border-left: 2px solid transparent; color: var(--text-2); text-decoration: none; line-height: 1.4; }
  .toc a:hover { color: var(--accent); border-left-color: var(--accent); }
  .toc .toc-h3 a { padding-left: 24px; font-size: 12.5px; }
}

@media (max-width: 900px) {
  #menu-btn { display: grid; }
  .brand { width: auto; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    left: 0;
    z-index: 35;
    width: min(85vw, 320px);
    height: auto;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: none; }
  .overlay { position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 30; background: rgba(0, 0, 0, 0.35); }
  body.nav-open .overlay { display: block; }
  main { padding: 0 16px 56px; }
  #breadcrumb { margin: 0 -16px 16px; padding: 8px 16px; }
}

@media (max-width: 560px) {
  .topbar { gap: 8px; padding: 0 10px; }
  #brand-name { display: none; }
  .search kbd { display: none; }
  .install-btn { padding: 6px; }
  .install-btn span, .ask-btn-label { display: none; }
  .ask-btn { padding: 4px 9px; }
  .hero { padding: 20px; }
  .meta-row .revise-btn { margin-left: 0; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
  .qa-body { padding-left: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
