/* ======================================================================
   Site Variables
   ====================================================================== */
:root {
  /* ── Site design tokens (source of truth) ─────────────────────────── */
  --color-bg: #ffffff;
  --color-bg-secondary: #f8fafc;
  --color-text: #1a1a2e;
  --color-text-muted: #64748b;
  --color-text-light: #94a3b8;
  --color-primary: #2563eb;
  --color-primary-light: #dbeafe;
  --color-border: #e2e8f0;
  --color-code-bg: #f1f5f9;
  --color-panel-info: #dbeafe;
  --color-panel-note: #fef3c7;
  --color-panel-warning: #fed7aa;
  --color-panel-error: #fecaca;
  --color-panel-success: #d1fae5;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --sidebar-width: 280px;
  --toc-width: 220px;
  --header-height: 56px;
  --space-tabs-height: 0px;
  --content-max-width: 820px;

  /* ── Basecoat / shadcn-ui token bridge ────────────────────────────── */
  /* Maps Basecoat's full semantic token set to our design tokens so     */
  /* that all Basecoat components (sidebar, alert, badge, etc.) inherit  */
  /* the active site theme automatically.                                 */
  --background: var(--color-bg);
  --foreground: var(--color-text);
  --card: var(--color-bg);
  --card-foreground: var(--color-text);
  --popover: var(--color-bg);
  --popover-foreground: var(--color-text);
  --primary: var(--color-primary);
  --primary-foreground: #ffffff;
  --secondary: var(--color-bg-secondary);
  --secondary-foreground: var(--color-text);
  --muted: var(--color-bg-secondary);
  --muted-foreground: var(--color-text-muted);
  --accent: var(--color-primary-light);
  --accent-foreground: var(--color-primary);
  --destructive: var(--color-panel-error);
  --destructive-foreground: #ffffff;
  --border: var(--color-border);
  --input: var(--color-border);
  --ring: var(--color-primary);
  --radius: 8px;
  /* Sidebar */
  --sidebar: var(--color-bg-secondary);
  --sidebar-foreground: var(--color-text);
  --sidebar-primary: var(--color-primary);
  --sidebar-primary-foreground: #ffffff;
  --sidebar-accent: var(--color-primary-light);
  --sidebar-accent-foreground: var(--color-primary);
  --sidebar-border: var(--color-border);
  /* Chart palette (sensible defaults) */
  --chart-1: #3b82f6;
  --chart-2: #10b981;
  --chart-3: #f59e0b;
  --chart-4: #8b5cf6;
  --chart-5: #ec4899;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* ======================================================================
   Dark mode — design tokens + Basecoat token bridge
   Both @media and .dark class so both system preference and explicit
   toggle (via Basecoat theme switcher) work.
   ====================================================================== */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0f172a;
    --color-bg-secondary: #1e293b;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-text-light: #64748b;
    --color-primary: #60a5fa;
    --color-primary-light: #1e3a5f;
    --color-border: #334155;
    --color-code-bg: #1e293b;
    --color-panel-info: #1e3a5f;
    --color-panel-note: #3d2b00;
    --color-panel-warning: #3d1f00;
    --color-panel-error: #3d0f0f;
    --color-panel-success: #0f2d1a;
    /* Basecoat dark tokens */
    --primary-foreground: #0f172a;
    --destructive: #7f1d1d;
    --destructive-foreground: #fca5a5;
    --chart-1: #60a5fa;
    --chart-2: #34d399;
    --chart-3: #fbbf24;
    --chart-4: #a78bfa;
    --chart-5: #f472b6;
  }
}

:root.dark, .dark {
  --color-bg: #0f172a;
  --color-bg-secondary: #1e293b;
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-text-light: #64748b;
  --color-primary: #60a5fa;
  --color-primary-light: #1e3a5f;
  --color-border: #334155;
  --color-code-bg: #1e293b;
  --color-panel-info: #1e3a5f;
  --color-panel-note: #3d2b00;
  --color-panel-warning: #3d1f00;
  --color-panel-error: #3d0f0f;
  --color-panel-success: #0f2d1a;
  /* Basecoat dark tokens */
  --primary-foreground: #0f172a;
  --destructive: #7f1d1d;
  --destructive-foreground: #fca5a5;
  --chart-1: #60a5fa;
  --chart-2: #34d399;
  --chart-3: #fbbf24;
  --chart-4: #a78bfa;
  --chart-5: #f472b6;
}

/* Force light — overrides @media (prefers-color-scheme: dark) when user picks light explicitly */
:root.light {
  --color-bg: #ffffff;
  --color-bg-secondary: #f8fafc;
  --color-text: #1a1a2e;
  --color-text-muted: #64748b;
  --color-text-light: #94a3b8;
  --color-primary: #2563eb;
  --color-primary-light: #dbeafe;
  --color-border: #e2e8f0;
  --color-code-bg: #f1f5f9;
  --color-panel-info: #dbeafe;
  --color-panel-note: #fef3c7;
  --color-panel-warning: #fed7aa;
  --color-panel-error: #fecaca;
  --color-panel-success: #d1fae5;
  /* Basecoat light tokens */
  --primary-foreground: #ffffff;
  --destructive: var(--color-panel-error);
  --destructive-foreground: #ffffff;
  --chart-1: #3b82f6;
  --chart-2: #10b981;
  --chart-3: #f59e0b;
  --chart-4: #8b5cf6;
  --chart-5: #ec4899;
}

/* ======================================================================
   Header / Top Nav
   ====================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  min-width: 0;
}

.site-header-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
}
.site-header-title:hover { color: var(--color-primary); text-decoration: none; }
.site-header-title--with-logo { font-size: 0; }
@media (min-width: 781px) {
  .site-header-title--with-logo { font-size: 1rem; }
}

.site-header-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.site-header-logo-img {
  height: 28px;
  max-width: 160px;
  object-fit: contain;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--color-text);
  border-radius: 6px;
}
.sidebar-toggle:hover { background: var(--color-bg-secondary); }

.site-header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  margin-left: 6px;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 0.375rem;
  cursor: pointer;
  color: inherit;
  flex-shrink: 0;
  line-height: 1;
}
.theme-toggle:hover { background: var(--color-bg-secondary); color: var(--color-text); }
/* Default: show moon (action = switch to dark) */
.theme-icon-light { display: none; }
/* Dark class active: show sun (action = switch to light) */
:root.dark .theme-icon-light, .dark .theme-icon-light { display: block; }
:root.dark .theme-icon-dark, .dark .theme-icon-dark { display: none; }
/* System dark, no explicit class: show sun */
@media (prefers-color-scheme: dark) {
  :root:not(.dark):not(.light) .theme-icon-light { display: block; }
  :root:not(.dark):not(.light) .theme-icon-dark { display: none; }
}
/* Light class explicitly set: always show moon, even in system dark */
:root.light .theme-icon-light { display: none !important; }
:root.light .theme-icon-dark { display: block !important; }

/* Space Tabs Bar */
.space-tabs-bar {
  position: sticky;
  top: var(--header-height);
  z-index: 99;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  overflow: hidden;
}
.space-tabs-scroll {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 0 1.5rem;
  gap: 0;
}
.space-tabs-scroll::-webkit-scrollbar { display: none; }
.space-tab {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.space-tab:hover {
  color: var(--color-text);
  text-decoration: none;
}
.space-tab--active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

/* Header Center (Search) */
.site-header-center {
  display: flex;
  justify-content: center;
  flex-shrink: 0;
  width: 100%;
  max-width: 400px;
}

/* Search */
.site-search {
  position: relative;
  width: 100%;
}
.home-search {
  max-width: 480px;
  margin: 1.5rem auto 0;
}
.site-search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  color: var(--color-text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.home-search .site-search-input {
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  border-radius: 10px;
}
.site-search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
.site-search-input::placeholder { color: var(--color-text-light); }
.site-search-results {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 360px;
  overflow-y: auto;
  z-index: 200;
}
.site-search-results.open { display: block; }
.site-search-result {
  display: block;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  color: var(--color-text);
  text-decoration: none;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.1s;
}
.site-search-result:last-child { border-bottom: none; }
.site-search-result:hover {
  background: var(--color-primary-light);
  text-decoration: none;
}
.site-search-result-title { font-weight: 500; }
.site-search-result-space {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  margin-top: 0.125rem;
}
.site-search-empty {
  padding: 1rem 0.75rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-align: center;
}

/* Header Links */
.header-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.header-link {
  font-size: 0.875rem;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.header-link:hover {
  opacity: 0.7;
  text-decoration: none;
}

/* Space Switcher */
.space-switcher {
  position: relative;
}

.space-switcher-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
}
.space-switcher-btn:hover { background: var(--color-bg-secondary); }

.space-switcher-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 200px;
  z-index: 110;
  overflow: hidden;
}

.space-switcher.open .space-switcher-dropdown { display: block; }

.space-switcher-dropdown a {
  display: block;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--color-text);
  text-decoration: none;
  transition: background 0.1s;
}
.space-switcher-dropdown a:hover { background: var(--color-bg-secondary); text-decoration: none; }
.space-switcher-dropdown a.space-switcher-item--active { font-weight: 600; color: var(--color-primary); }

/* ======================================================================
   Homepage
   ====================================================================== */
.home-content {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 2rem;
  flex: 1;
  box-sizing: border-box;
}

.home-hero {
  text-align: center;
  margin-bottom: 3rem;
}

.home-hero h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.home-description {
  font-size: 1.125rem;
  color: var(--color-text-muted);
  max-width: 500px;
  margin: 0 auto;
}

.space-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 340px));
  justify-content: center;
  gap: 1rem;
  max-width: 100%;
}

.space-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.space-card:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(37,99,235,0.08);
  text-decoration: none;
}

.space-card-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  background: var(--color-primary-light);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.space-card-body { min-width: 0; }
.space-card-title { font-size: 0.9375rem; font-weight: 600; margin: 0; }
.space-card-meta { font-size: 0.875rem; color: var(--color-text-muted); margin-top: 0.25rem; }

/* ======================================================================
   Page Layout: Sidebar | Content | TOC
   ====================================================================== */
.site-layout {
  display: grid;
  grid-template-columns: clamp(var(--sidebar-width), 18vw, 380px) minmax(0, 1fr) clamp(var(--toc-width), 14vw, 300px);
  flex: 1;
}

.site-sidebar {
  border-right: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  position: sticky;
  top: calc(var(--header-height) + var(--space-tabs-height));
  height: calc(100vh - var(--header-height) - var(--space-tabs-height));
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-inner {
  padding: 1rem 0;
}



.site-main {
  padding: 2rem 2.5rem 4rem;
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

.site-toc {
  position: sticky;
  top: calc(var(--header-height) + var(--space-tabs-height));
  height: calc(100vh - var(--header-height) - var(--space-tabs-height));
  overflow-y: auto;
  border-left: 1px solid var(--color-border);
}

.toc-inner {
  padding: 1.5rem 1rem;
}

.toc-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.toc-item {
  display: block;
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.toc-item:hover { color: var(--color-text); text-decoration: none; }
.toc-item--active { color: var(--color-primary); border-left-color: var(--color-primary); }
.toc-item--h3 { padding-left: 1rem; }
.toc-item--h4 { padding-left: 2rem; }

/* ======================================================================
   Page Tree (Sidebar)
   ====================================================================== */
.page-tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.page-tree .page-tree {
  /* nested */
}

.page-tree-item {
  list-style: none;
}

.page-tree-item-row {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  padding: 0.25rem 0.75rem;
}

.page-tree-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  color: var(--color-text-muted);
  transition: transform 0.15s, background 0.1s;
}
.page-tree-toggle:hover { background: var(--color-border); }

.page-tree-item--parent > .page-tree-item-row > .page-tree-toggle.expanded {
  transform: rotate(90deg);
}

.page-tree-toggle-spacer {
  width: 20px;
  flex-shrink: 0;
}

.page-tree-link {
  font-size: 0.875rem;
  color: var(--color-text);
  text-decoration: none;
  padding: 0.125rem 0.25rem;
  border-radius: 4px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-tree-link:hover { color: var(--color-primary); text-decoration: none; }
.page-tree-link--active {
  color: var(--color-primary);
  font-weight: 600;
  background: var(--color-primary-light);
}
.page-tree-link--folder {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-text-muted);
}

.page-tree-children {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1rem;
  display: none;
}
.page-tree-children--expanded {
  display: block;
}

/* ======================================================================
   Content Typography
   ====================================================================== */
.article-body h1 { font-size: 2rem; margin-top: 0; margin-bottom: 1rem; line-height: 1.3; }
.article-body h2 { font-size: 1.5rem; margin-top: 2rem; margin-bottom: 0.5em; line-height: 1.3; }
.article-body h3 { font-size: 1.25rem; margin-top: 1.5em; margin-bottom: 0.5em; line-height: 1.3; }
.article-body h4 { font-size: 1.125rem; margin-top: 1.5em; margin-bottom: 0.5em; line-height: 1.3; }
.article-body h5 { font-size: 1rem; margin-top: 1.5em; margin-bottom: 0.5em; line-height: 1.3; }
.article-body h6 { font-size: 0.875rem; margin-top: 1.5em; margin-bottom: 0.5em; line-height: 1.3; }

.article-body p { margin-bottom: 1em; }
.article-body td p,
.article-body th p,
.article-body li > p,
.article-body .site-panel p { margin-bottom: 0.25em; }
.article-body td p:last-child,
.article-body th p:last-child,
.article-body li > p:last-child,
.article-body .site-panel p:last-child { margin-bottom: 0; }

.article-body a { color: var(--color-primary); text-decoration: none; transition: color 0.15s; }
.article-body a:hover { color: color-mix(in srgb, var(--color-primary) 80%, black); text-decoration: underline; }

.article-body ul { margin: 0.5em 0 1em 1.5em; list-style-type: disc; }
.article-body ol { margin: 0.5em 0 1em 1.5em; list-style-type: decimal; }
.article-body ul ul { list-style-type: circle; }
.article-body ul ul ul { list-style-type: square; }
.article-body li { margin-bottom: 0.25em; }

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25em 0;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

.article-body th, .article-body td {
  border: 1px solid var(--color-border);
  padding: 0.625rem 0.875rem;
  text-align: left;
  font-size: 0.9375rem;
}

.article-body th {
  background: var(--color-bg-secondary);
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--color-text-muted);
}

.article-body tr:hover td { background: rgba(0,0,0,0.015); }

.article-body code {
  font-family: var(--font-mono);
  background: var(--color-code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.875em;
  color: #e11d48;
}

.article-body pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1.25em 0;
  border: 1px solid rgba(0,0,0,0.1);
}

.article-body pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  color: inherit;
}

.article-body blockquote {
  border-left: 3px solid var(--color-primary);
  padding: 0.75em 1.25em;
  margin: 1.25em 0;
  color: var(--color-text-muted);
  background: var(--color-bg-secondary);
  border-radius: 0 6px 6px 0;
}
.article-body blockquote p:last-child { margin-bottom: 0; }

.article-body hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2.5em 0;
}

.article-body img { max-width: 100%; height: auto; border-radius: 4px; }

/* Panels — Atlassian-style with icon area */
.site-panel {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin: 1em 0;
  border-left: 4px solid;
  font-size: 0.9375rem;
  line-height: 1.6;
}
.site-panel__icon {
  flex-shrink: 0;
  font-size: 1.1rem;
  line-height: 1.6;
}
.site-panel__body {
  flex: 1;
  min-width: 0;
}
.site-panel__body > *:last-child { margin-bottom: 0; }

.site-panel--info    { background: var(--color-panel-info); border-color: #3b82f6; }
.site-panel--note    { background: var(--color-panel-note); border-color: #f59e0b; }
.site-panel--warning { background: var(--color-panel-warning); border-color: #f97316; }
.site-panel--error   { background: var(--color-panel-error); border-color: #ef4444; }
.site-panel--success { background: var(--color-panel-success); border-color: #10b981; }

/* Lists inside panels */
.site-panel ol,
.site-panel ul {
  padding-left: 1.75em;
  margin: 0.5em 0 1em 0;
  list-style-position: outside;
}
.site-panel ol { padding-left: 2em; }
.site-panel li { margin-bottom: 0.25em; }
.site-panel p { margin-bottom: 0.25em; }
.site-panel p:last-child { margin-bottom: 0; }

/* Inline elements */
.mention {
  background: #dbeafe;
  color: #1d4ed8;
  padding: 0.1em 0.4em;
  border-radius: 20px;
  font-weight: 500;
  font-size: 0.9em;
  white-space: nowrap;
}

.task-list, .decision-list { list-style: none; margin-left: 0; padding-left: 0; }
.task-item, .decision-item { padding: 0.375em 0; display: flex; align-items: flex-start; gap: 0.5em; }
.task-item input[type="checkbox"] {
  margin-top: 0.3em;
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}
.decision-item::before { content: "→"; color: var(--color-primary); font-weight: 600; margin-right: 0.25em; }

.media-single { margin: 1em 0; max-width: 100%; }
.media-single--center { text-align: center; margin-left: auto; margin-right: auto; }
.media-single--left { text-align: left; }
.media-single--right { text-align: right; margin-left: auto; }
.media-single[data-border] .media-image { border-style: solid; }
figure.media-single figcaption { font-size: 0.875rem; color: var(--color-text-muted); margin-top: 0.5rem; }
.media { padding: 1rem; background: var(--color-code-bg); border-radius: 4px; text-align: center; color: var(--color-text-muted); }
.media-image { max-width: 100%; height: auto; border-radius: 4px; display: inline-block; }
.extension { padding: 0.75rem 1rem; background: var(--color-code-bg); border-radius: 4px; margin: 1em 0; color: var(--color-text-muted); font-style: italic; }
.bodied-extension .extension-title { font-weight: 600; margin-bottom: 0.5rem; font-style: italic; }
.inline-extension { display: inline; margin: 0; padding: 0.15em 0.35em; font-size: 0.9em; }

/* Children macro */
.children-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 0.75rem; margin: 1em 0; }
.children-card { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; border: 1px solid var(--color-border); border-radius: 8px; text-decoration: none; color: var(--color-text); transition: border-color 0.15s, background 0.15s; }
.children-card:hover { border-color: var(--color-primary); background: var(--color-primary-light); text-decoration: none; }
.children-card-title { font-size: 0.9375rem; font-weight: 500; }

.inline-card {
  word-break: break-all;
  color: var(--color-primary);
  text-decoration: none;
  padding: 0.1em 0.35em;
  background: var(--color-primary-light);
  border-radius: 4px;
  font-size: 0.9em;
  transition: background 0.15s;
}
.inline-card:hover { background: color-mix(in srgb, var(--color-primary-light) 80%, var(--color-primary)); text-decoration: none; }

/* Status badges */
.status {
  display: inline-block;
  padding: 0.1em 0.4em;
  border-radius: 3px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.status-neutral { background: #e2e8f0; color: #475569; }
.status-purple { background: #ede9fe; color: #7c3aed; }
.status-blue { background: #dbeafe; color: #2563eb; }
.status-red { background: #fecaca; color: #dc2626; }
.status-yellow { background: #fef3c7; color: #d97706; }
.status-green { background: #d1fae5; color: #059669; }

/* Date */
.date {
  background: var(--color-code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-size: 0.9em;
}

/* Block card */
.block-card {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.875rem 1rem;
  margin: 1.25em 0;
  transition: border-color 0.15s, box-shadow 0.15s;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.block-card:hover { border-color: var(--color-primary); box-shadow: 0 1px 4px rgba(37,99,235,0.08); }
.block-card a { word-break: break-all; color: var(--color-primary); text-decoration: none; }
.block-card a:hover { text-decoration: underline; }

/* Expand / Details */
.expand {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin: 1.25em 0;
  overflow: hidden;
}
.expand summary {
  padding: 0.875rem 1rem;
  cursor: pointer;
  font-weight: 500;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.expand summary::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid var(--color-text-muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.expand[open] summary::before { transform: rotate(90deg); }
.expand summary::-webkit-details-marker { display: none; }
.expand summary:hover { background: var(--color-bg-secondary); }
.expand > :not(summary) { padding: 0 1rem 1rem; }
.nested-expand { margin: 0.5em 0; border-color: var(--color-border); }

/* Macro expand (Refined / Kolekti third-party expands) */
.c-macro.c-macro--expand {
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 6px;
  margin: 1.25em 0;
  overflow: hidden;
}
.c-macro-expand__title {
  padding: 0.875rem 1rem;
  cursor: pointer;
  font-weight: 500;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.c-macro-expand__title::before {
  content: "";
  display: inline-block;
  width: 0; height: 0;
  border-left: 5px solid var(--color-text-muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.c-macro--expand[open] .c-macro-expand__title::before { transform: rotate(90deg); }
.c-macro-expand__title::-webkit-details-marker { display: none; }
.c-macro-expand__title:hover { background: var(--color-bg-secondary, #f8fafc); }
.c-macro-expand__content { padding: 0 1rem 1rem; }

/* Layout sections */
.layout-section {
  display: flex;
  gap: 2rem;
  margin: 1.5em 0;
}
.layout-column {
  flex: 1;
  min-width: 0;
}

/* Embeds (YouTube etc.) */
.embed-container {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
  margin: 1.25em 0;
  border-radius: 8px;
  background: #000;
}
.embed-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ======================================================================
   Macro Exports
   ====================================================================== */
.macro-image {
  margin: 1.25em 0;
  text-align: center;
}
.macro-image--left { text-align: left; }
.macro-image--center { text-align: center; }
.macro-image--right { text-align: right; }
.macro-image img { max-width: 100%; height: auto; border-radius: 4px; }
.macro-image-caption {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
  text-align: center;
}

.macro-diagram {
  margin: 1.25em 0;
  text-align: center;
}
.macro-diagram img { max-width: 100%; height: auto; }
.macro-diagram--bordered {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem;
}

.macro-placeholder {
  padding: 1rem 1rem;
  background: var(--color-code-bg);
  border-radius: 8px;
  color: var(--color-text-muted);
  font-style: italic;
  margin: 1em 0;
  text-align: center;
}

.export-note {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-left: 4px solid #f59e0b;
  border-radius: 6px;
  color: #78350f;
  font-size: 0.875rem;
  margin: 1em 0;
}
.export-note::before {
  content: '⚠';
  flex-shrink: 0;
  font-style: normal;
}
@media (prefers-color-scheme: dark) {
  .export-note {
    background: #2d1f00;
    border-color: #d97706;
    color: #fcd34d;
  }
}
:root.dark .export-note, .dark .export-note {
  background: #2d1f00;
  border-color: #d97706;
  color: #fcd34d;
}


/* Tier 1: Progress bar */
.c-macro.c-macro--progress { margin: 1em 0; }
.c-macro-progress__bar { display: block; }
.c-macro-progress__fill { display: block; }

/* Tier 1: Buttons */
.c-macro.c-macro--buttons { margin: 1em 0; display: flex; flex-wrap: wrap; gap: 8px; }
.c-macro.c-macro--buttons[style*="center"] { justify-content: center; }
.c-macro.c-macro--buttons[style*="right"] { justify-content: flex-end; }
.c-macro-button {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  text-decoration: none;
  transition: opacity 0.15s;
}
/* Hardcode button brand colors — use .article-body prefix to beat the .article-body a link color rule */
.article-body a.c-macro-button--default, .article-body a.c-macro-button--blue { background: #2563eb; color: #ffffff; border: 1px solid #2563eb; }
.article-body a.c-macro-button--default:hover, .article-body a.c-macro-button--blue:hover { opacity: 0.85; color: #ffffff; }
.article-body a.c-macro-button--success { background: #10b981; color: #ffffff; border: 1px solid #10b981; }
.article-body a.c-macro-button--success:hover { opacity: 0.85; color: #ffffff; }
.article-body a.c-macro-button--warning { background: #f59e0b; color: #ffffff; border: 1px solid #f59e0b; }
.article-body a.c-macro-button--warning:hover { opacity: 0.85; color: #ffffff; }
.article-body a.c-macro-button--destructive { background: #ef4444; color: #ffffff; border: 1px solid #ef4444; }
.article-body a.c-macro-button--destructive:hover { opacity: 0.85; color: #ffffff; }
.article-body a.c-macro-button--outline { background: transparent; color: #2563eb; border: 1px solid #2563eb; }
.article-body a.c-macro-button--outline:hover { background: #eff6ff; }
.article-body a.c-macro-button--secondary { background: var(--color-bg-secondary); color: var(--color-text); border: 1px solid var(--color-border); }
.article-body a.c-macro-button--secondary:hover { opacity: 0.85; }
.article-body a.c-macro-button--ghost { background: transparent; color: var(--color-text); border: 1px solid transparent; }
.article-body a.c-macro-button--ghost:hover { background: var(--color-bg-secondary); }
.article-body a.c-macro-button--link { background: none; color: #2563eb; border: none; text-decoration: underline; }

/* Third-party: Refined Steps */
.c-macro.c-macro--steps {
  list-style: none; padding: 0; margin: 1.25em 0; counter-reset: step-counter;
}
.c-macro-steps__item {
  display: flex; gap: 1rem; padding: 1rem 0;
  border-bottom: 1px solid var(--color-border, #e2e8f0);
}
.c-macro-steps__item:last-child { border-bottom: none; }
.c-macro-steps__number {
  flex-shrink: 0; width: 2rem; height: 2rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--color-primary, #2563eb); color: #fff;
  font-size: 0.875rem; font-weight: 600;
}
.c-macro-steps__content { flex: 1; min-width: 0; }
.c-macro-steps__content > *:first-child { margin-top: 0; }
.c-macro-steps__content > *:last-child { margin-bottom: 0; }

/* Inline TOC macro */
.c-macro.c-macro--toc {
  margin: 1.25em 0; padding: 1rem 1.25rem;
  border: 1px solid var(--color-border, #e2e8f0); border-radius: 8px;
  background: var(--color-bg-secondary, #f8fafc);
}
.c-macro--toc .toc-item {
  display: block; padding: 0.25rem 0;
  font-size: 0.875rem; color: var(--color-text-muted, #64748b);
  text-decoration: none;
}
.c-macro--toc .toc-item:hover { color: var(--color-primary, #2563eb); }

/* Tier 1: Banner (static first slide) */
/* Banner carousel */
.c-macro.c-macro--banner {
  margin: 1.25em 0; border-radius: 8px; overflow: hidden;
  position: relative; background: #1e293b;
}
.c-macro-banner__slides {
  display: flex; flex-direction: row;
  overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory;
  scroll-behavior: smooth; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; width: 100%; cursor: grab;
}
.c-macro-banner__slides::-webkit-scrollbar { display: none; }
.c-macro-banner__slide {
  flex: 0 0 100%; scroll-snap-align: start;
  position: relative; min-height: 280px;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.c-macro-banner__slide-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
}
.c-macro-banner__slide-content {
  position: relative; z-index: 1; padding: 2rem 1.5rem 1.5rem;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 100%);
  color: #fff;
}
.c-macro-banner__title { font-size: 1.5rem; font-weight: 700; margin: 0 0 0.4em; line-height: 1.2; }
.c-macro-banner__body { margin: 0 0 0.75em; font-size: 0.95rem; opacity: 0.9; }
.c-macro-banner__cta {
  display: inline-block; background: #fff; color: #1e293b;
  padding: 0.45em 1.1em; border-radius: 6px; font-weight: 600;
  text-decoration: none; font-size: 0.875rem;
}
.c-macro-banner__cta:hover { opacity: 0.9; }
/* Nav buttons */
.c-macro-banner__prev, .c-macro-banner__next {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 10; background: rgba(255,255,255,0.85); border: none;
  border-radius: 50%; width: 2rem; height: 2rem; font-size: 1rem;
  line-height: 1; cursor: pointer; display: flex; align-items: center;
  justify-content: center; opacity: 0; transition: opacity 0.15s;
}
.c-macro-banner__prev:focus, .c-macro-banner__next:focus { opacity: 1; }
.c-macro.c-macro--banner:hover .c-macro-banner__prev,
.c-macro.c-macro--banner:hover .c-macro-banner__next { opacity: 1; }
.c-macro-banner__prev { left: 0.75rem; }
.c-macro-banner__next { right: 0.75rem; }
/* Dots */
.c-macro-banner__dots {
  position: absolute; bottom: 0.625rem; left: 50%; transform: translateX(-50%);
  display: flex; gap: 0.375rem; z-index: 10;
}
.c-macro-banner__dot {
  width: 8px; height: 8px; border-radius: 50%; border: none;
  background: rgba(255,255,255,0.5); cursor: pointer; padding: 0; transition: background 0.15s;
}
.c-macro-banner__dot.active { background: #fff; }

/* Tier 1: Colors */
.c-macro.c-macro--colors { margin: 1em 0; }
/* Box mode: full-height segmented bar matching the macro UI */
.c-macro-colors--box .c-macro-colors__bar { display: flex; height: 75px; border-radius: 8px; overflow: hidden; }
.c-macro-colors__segment { flex: 1; display: flex; align-items: center; justify-content: center; transition: flex 0.1s ease; cursor: default; }
.c-macro-colors__segment:hover { flex: 3; }
.c-macro-colors__segment-label { font-size: 0.75rem; font-weight: 600; color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 0.5rem; mix-blend-mode: difference; filter: invert(1) grayscale(1) contrast(9); }
/* Table mode: Name | Swatch | Hex */
.c-macro-colors__table { width: auto; border-collapse: collapse; font-size: 0.875rem; }
.c-macro-colors__table th { padding: 0.375rem 0.75rem; border: 1px solid var(--color-border); background: var(--color-bg-secondary); font-weight: 600; text-align: left; }
.c-macro-colors__table td { padding: 0.5rem 0.75rem; border: 1px solid var(--color-border); }
.c-macro-colors__swatch { width: 48px; height: 28px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.1); }
.c-macro-colors__td-name { font-weight: 500; white-space: nowrap; }
.c-macro-colors__td-hex code { font-family: var(--font-mono); font-size: 0.875rem; user-select: all; }

/* Tier 1: Lorem */
.c-macro.c-macro--lorem { margin: 1em 0; }
.c-macro-lorem__cols { }
.c-macro-lorem__col p { margin-bottom: 0.75em; }
.c-macro-lorem__col p:last-child { margin-bottom: 0; }

/* Tier 1: Tooltip */
.c-macro.c-macro--tooltip { cursor: help; font-size: 0.9em; }

/* Tier 3: RSS Feed */
.c-macro.c-macro--rss { margin: 1em 0; }
.c-macro-rss__loading { display: flex; align-items: center; gap: 0.5rem; color: var(--color-text-muted); font-size: 0.875rem; padding: 0.75rem 0; }
.c-macro-rss__empty { color: var(--color-text-muted); font-size: 0.875rem; padding: 0.5rem 0; }
/* articles and articles-with-images modes */
.c-macro-rss__articles { display: flex; flex-direction: column; gap: 0; }
.c-macro-rss__article {
  display: flex; align-items: flex-start; gap: 0.875rem; padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border); text-decoration: none; color: inherit;
}
.c-macro-rss__article:last-child { border-bottom: none; }
.c-macro-rss__article:hover .c-macro-rss__article-title { color: var(--color-primary); text-decoration: underline; }
.c-macro-rss__article-img { width: 72px; height: 52px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.c-macro-rss__article-body { flex: 1; min-width: 0; }
.c-macro-rss__article-title { font-weight: 500; font-size: 0.9375rem; line-height: 1.35; margin-bottom: 0.2em; }
.c-macro-rss__article-date { font-size: 0.875rem; color: var(--color-text-muted); }
/* table mode */
.c-macro-rss__table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.c-macro-rss__table th { padding: 0.5rem 0.75rem; border-bottom: 2px solid var(--color-border); text-align: left; font-weight: 600; }
.c-macro-rss__table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--color-border); }
.c-macro-rss__table a { color: var(--color-primary); text-decoration: none; }
.c-macro-rss__table a:hover { text-decoration: underline; }
.c-macro-rss__table-date { white-space: nowrap; color: var(--color-text-muted); }
/* gallery mode */
.c-macro-rss__gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.75rem; }
.c-macro-rss__gallery-card {
  display: flex; flex-direction: column; justify-content: flex-end;
  min-height: 140px; border-radius: 8px; overflow: hidden;
  background: var(--color-bg-secondary) center/cover no-repeat;
  text-decoration: none; color: #fff; position: relative;
}
.c-macro-rss__gallery-overlay {
  padding: 0.75rem; background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, transparent 100%);
}
.c-macro-rss__gallery-title { font-weight: 600; font-size: 0.85rem; line-height: 1.3; }
.c-macro-rss__gallery-date { font-size: 0.75rem; opacity: 0.8; margin-top: 0.2rem; }

/* Tier 3: Swagger */
.c-macro.c-macro--swagger { margin: 1.25em 0; border: 1px solid var(--color-border); border-radius: 8px; overflow: hidden; }
.c-macro-swagger__loading { padding: 1rem; color: var(--color-text-muted); font-size: 0.875rem; margin: 0; }
/* Override Swagger UI defaults for site theme integration */
.c-macro.c-macro--swagger .swagger-ui .topbar { display: none !important; }
.c-macro.c-macro--swagger .swagger-ui { font-family: var(--font-sans); }
.c-macro.c-macro--swagger .swagger-ui .info { margin: 1rem 0; }

/* Tier 3: Animation (Lottie) */
.c-macro.c-macro--animation { margin: 1.25em 0; }
.c-macro-animation--left { display: flex; justify-content: flex-start; }
.c-macro-animation--center { display: flex; justify-content: center; }
.c-macro-animation--right { display: flex; justify-content: flex-end; }
.c-macro.c-macro--animation lottie-player { display: block; }

/* Tier 1: Diff */
.c-macro.c-macro--diff { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.25em 0; }
.c-macro-diff__side pre { margin: 0; padding: 1rem; border-radius: 6px; overflow-x: auto; font-size: 0.875rem; }
.c-macro-diff__side:first-child { background: var(--diff-removed-bg, #ffeef0); color: var(--diff-removed-text, #86181d); }
.c-macro-diff__side:first-child pre { background: transparent; }
.c-macro-diff__side:last-child { background: var(--diff-added-bg, #e6ffed); color: var(--diff-added-text, #22863a); }
.c-macro-diff__side:last-child pre { background: transparent; }
@media (max-width: 768px) { .c-macro.c-macro--diff { grid-template-columns: 1fr; } }

/* Tier 1: Code viewer */
.c-macro.c-macro--code { margin: 1.25em 0; }
.c-macro-code { margin: 0; padding: 1rem 1rem; background: #1e293b; color: #e2e8f0; border-radius: 8px; overflow-x: auto; font-size: 0.85rem; }
.c-macro-code--line-numbers { counter-reset: line; }
.c-macro-code--line-numbers code { display: block; }
.c-macro-code--line-numbers code::before { counter-increment: line; content: counter(line) " "; margin-right: 1em; color: var(--color-text-muted); }

/* Tier 1: Background */
.c-macro.c-macro--background { margin: 1.25em 0; padding: 1.5rem; }
.c-macro-background__inner { }

/* Cards macro (Capable / Mosaic export) */
.c-macro.c-macro--cards {
  margin: 1.25em 0;
}
.c-macro-cards__grid {
  display: grid;
  gap: 1rem;
}
.c-macro-cards__grid--cols-1 { grid-template-columns: 1fr; }
.c-macro-cards__grid--cols-2 { grid-template-columns: repeat(2, 1fr); }
.c-macro-cards__grid--cols-3 { grid-template-columns: repeat(3, 1fr); }
.c-macro-cards__grid--cols-4 { grid-template-columns: repeat(4, 1fr); }
.c-macro-cards__grid--cols-5 { grid-template-columns: repeat(5, 1fr); }
.c-macro-cards__grid--cols-6 { grid-template-columns: repeat(6, 1fr); }
.c-macro-cards__card {
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s, transform 0.2s;
}
.c-macro-cards__card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

/* Isolate cards macro from article-body link/heading styles — card text uses card's textColor only */
.article-body .c-macro.c-macro--cards .c-macro-cards__link,
.article-body .c-macro.c-macro--cards .c-macro-cards__link:hover,
.article-body .c-macro.c-macro--cards .c-macro-cards__link:focus {
  color: inherit;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.article-body .c-macro.c-macro--cards .c-macro-cards__link .c-macro-cards__title,
.article-body .c-macro.c-macro--cards .c-macro-cards__link .c-macro-cards__description {
  color: inherit;
}
.article-body .c-macro.c-macro--cards .c-macro-cards__link .c-macro-cards__title:hover,
.article-body .c-macro.c-macro--cards .c-macro-cards__link .c-macro-cards__description:hover {
  color: inherit;
}

.c-macro-cards__image {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--color-code-bg);
}
.c-macro-cards__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 8px;
}
/* When card has body below image, round only top corners of image to meet body */
.c-macro-cards__card:has(.c-macro-cards__body) .c-macro-cards__image img {
  border-radius: 8px 8px 0 0;
}
.c-macro-cards__body {
  padding: 1rem;
  flex: 1;
}
.c-macro-cards__title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.25em;
  line-height: 1.3;
}
.c-macro-cards__description {
  font-size: 0.875rem;
  margin: 0;
  line-height: 1.5;
  opacity: 0.9;
}
@media (max-width: 768px) {
  .c-macro-cards__grid--cols-2,
  .c-macro-cards__grid--cols-3,
  .c-macro-cards__grid--cols-4,
  .c-macro-cards__grid--cols-5,
  .c-macro-cards__grid--cols-6 {
    grid-template-columns: 1fr;
  }
}

/* Tabs macro (basecoat-inspired) */
.c-macro.c-macro--tabs {
  margin: 1.25em 0;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}
.c-macro-tabs__list {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-secondary);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.c-macro-tabs__list::-webkit-scrollbar { display: none; }
.c-macro-tabs__tab {
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.c-macro-tabs__tab:hover { color: var(--color-text); }
.c-macro-tabs__tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.c-macro-tabs__panels { padding: 1rem; }
.c-macro-tabs__panel { display: none; }
.c-macro-tabs__panel.active { display: block; }

/* Vertical tabs */
.c-macro-tabs--vertical { display: flex; }
.c-macro-tabs--vertical .c-macro-tabs__list {
  flex-direction: column;
  border-bottom: none;
  border-right: 1px solid var(--color-border);
  min-width: 160px;
  overflow-x: visible;
  overflow-y: auto;
}
.c-macro-tabs--vertical .c-macro-tabs__tab {
  border-bottom: none;
  border-right: 2px solid transparent;
  text-align: left;
}
.c-macro-tabs--vertical .c-macro-tabs__tab.active {
  border-right-color: var(--color-primary);
}
.c-macro-tabs--vertical .c-macro-tabs__panels { flex: 1; }

/* ======================================================================
   Responsive
   ====================================================================== */
@media (max-width: 1200px) {
  .site-layout {
    grid-template-columns: clamp(var(--sidebar-width), 18vw, 380px) minmax(0, 1fr);
  }
  .site-toc { display: none; }
}

@media (max-width: 780px) {
  .sidebar-toggle { display: block; }

  .site-header {
    padding: 0 1rem;
  }

  .site-header-center { display: none; }
  .header-links { display: none; }
  .space-switcher { display: none; }

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

  .site-sidebar {
    position: fixed;
    top: calc(var(--header-height) + var(--space-tabs-height));
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    background: var(--color-bg-secondary);
  }
  .site-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 12px rgba(0,0,0,0.1);
  }

  .site-main {
    padding: 1.5rem 1rem 3rem;
    min-width: 0;
    overflow-x: hidden;
  }

  .home-content {
    padding: 2rem 1rem;
  }

  .space-cards {
    grid-template-columns: 1fr;
  }

  .layout-section {
    flex-direction: column;
  }
}

/* ======================================================================
   Page Navigation (Prev / Next)
   ====================================================================== */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}
.page-nav-link {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--color-text);
  transition: border-color 0.15s, background 0.15s;
  max-width: 50%;
  min-width: 0;
}
.page-nav-link:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}
.page-nav-arrow {
  font-size: 1.125rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
  line-height: 1;
}
.page-nav-prev { align-items: center; }
.page-nav-next { align-items: center; margin-left: auto; }
.page-nav-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}
.page-nav-prev .page-nav-text { align-items: flex-start; }
.page-nav-next .page-nav-text { align-items: flex-end; }
.page-nav-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}
.page-nav-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* ======================================================================
   Heading Anchor Links
   ====================================================================== */
.article-body h1, .article-body h2, .article-body h3,
.article-body h4, .article-body h5, .article-body h6 {
  position: relative;
}
.heading-anchor {
  position: absolute;
  left: -1.5em;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.15s;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.75em;
  line-height: 1;
  padding: 0.25em;
}
.heading-anchor:hover { color: var(--color-primary); }
.article-body h1:hover .heading-anchor,
.article-body h2:hover .heading-anchor,
.article-body h3:hover .heading-anchor,
.article-body h4:hover .heading-anchor,
.article-body h5:hover .heading-anchor,
.article-body h6:hover .heading-anchor { opacity: 1; }

/* ======================================================================
   Space Card Avatars
   ====================================================================== */
.space-card-avatar {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

/* ======================================================================
   Footer
   ====================================================================== */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  line-height: 1.6;
}
.site-footer-text {
  margin: 0 0 0.5rem;
  color: var(--color-text);
  font-size: 0.875rem;
}
.site-footer-branding {
  margin: 0;
}
.site-footer-branding a {
  color: var(--color-primary);
  text-decoration: none;
}
.site-footer-branding a:hover {
  text-decoration: underline;
}

/* Blocked attachment notice */
.attachment-blocked {
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: 8px;
  padding: 16px 20px;
  background: var(--color-bg-secondary, #f8fafc);
  color: var(--color-text-muted, #64748b);
  text-align: center;
  margin: 12px 0;
}
.attachment-blocked span {
  font-weight: 600;
  display: block;
  margin-bottom: 4px;
}
.attachment-blocked p {
  margin: 0;
  font-size: 0.875rem;
}

.macro-diagram__svg-wrap { width: 100%; overflow: hidden; cursor: grab; }
.macro-diagram__svg-wrap svg { width: 100%; height: auto; display: block; touch-action: none; }

/* Theme overrides */
:root {
  --font-sans: "Inter", system-ui, sans-serif;
  --color-bg: #edf6ff;
}
.site-header {
  background: #3d3efe;
  color: #ffffff;
}
.site-header-title { color: #ffffff; }
.site-header-title:hover { color: #ffffff; opacity: 0.8; }