:root {
  --bg: #0f1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #1c2128;
  --border: #30363d;
  --border-light: #21262d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #656d76;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --accent-dim: rgba(88, 166, 255, 0.1);
  --accent-border: rgba(88, 166, 255, 0.3);
  --green: #3fb950;
  --green-dim: rgba(63, 185, 80, 0.1);
  --purple: #bc8cff;
  --purple-dim: rgba(188, 140, 255, 0.1);
  --yellow: #e3b341;
  --red: #f85149;
  --sidebar-width: 260px;
  --header-height: 60px;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.3);
}

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

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ─── Disclaimer Bar ─── */
.disclaimer-bar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 8px 24px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
}

.disclaimer-bar strong { color: var(--yellow); }
.disclaimer-bar a { color: var(--text-secondary); text-decoration: underline; }
.disclaimer-bar a:hover { color: var(--yellow); }

/* When disclaimer bar is present, push header down */
body.has-disclaimer .site-header { top: 36px; }
body.has-disclaimer .layout { padding-top: calc(var(--header-height) + 36px); }
body.has-disclaimer .homepage { padding-top: calc(var(--header-height) + 36px); }
body.has-disclaimer .sidebar { top: calc(var(--header-height) + 36px); }

/* ─── Site Header ─── */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-height);
  background: rgba(15, 17, 23, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 32px;
}

.site-header .logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.05rem; color: var(--text-primary);
  text-decoration: none; white-space: nowrap;
}

.site-header .logo:hover { text-decoration: none; color: var(--accent); }

.logo-icon {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, #58a6ff 0%, #bc8cff 100%);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}

.header-nav {
  display: flex; gap: 4px; align-items: center;
}

.header-nav a {
  color: var(--text-secondary); font-size: 0.875rem; font-weight: 500;
  padding: 6px 12px; border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}

.header-nav a:hover { color: var(--text-primary); background: var(--bg-secondary); text-decoration: none; }
.header-nav a.active { color: var(--accent); background: var(--accent-dim); }

.header-actions {
  margin-left: auto;
  display: flex; gap: 8px; align-items: center;
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius);
  font-size: 0.875rem; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: all 0.15s;
}

.btn-ghost {
  color: var(--text-secondary);
  border-color: var(--border);
  background: transparent;
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-secondary); background: var(--bg-secondary); text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); text-decoration: none; color: #000; }

/* ─── Layout with Sidebar ─── */
.layout {
  display: flex;
  padding-top: var(--header-height);
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  padding: 24px 0 48px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

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

.sidebar-section {
  padding: 0 16px;
  margin-bottom: 24px;
}

.sidebar-label {
  font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); padding: 8px 8px 4px;
}

.sidebar-item {
  display: flex; align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: color 0.15s, background 0.15s;
}

.sidebar-item:hover { color: var(--text-primary); background: var(--bg-secondary); text-decoration: none; }
.sidebar-item.active { color: var(--accent); background: var(--accent-dim); }

.sidebar-item .dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; opacity: 0.5; flex-shrink: 0;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
}

.content-area {
  max-width: 860px;
  margin: 0 auto;
  padding: 48px 48px 96px;
}

/* ─── Hero ─── */
.hero {
  text-align: center;
  padding: 120px 24px 80px;
  max-width: 720px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 100px;
  background: var(--accent-dim); border: 1px solid var(--accent-border);
  color: var(--accent); font-size: 0.8rem; font-weight: 600;
  margin-bottom: 24px;
}

.hero h1 {
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  font-weight: 800; line-height: 1.1;
  letter-spacing: -0.03em;
  background: linear-gradient(160deg, #e6edf3 30%, #8b949e 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 20px;
}

.hero p {
  font-size: 1.125rem; color: var(--text-secondary);
  line-height: 1.7; max-width: 560px; margin: 0 auto 36px;
}

.hero-actions {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
  margin-bottom: 64px;
}

.hero-code {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  max-width: 560px;
  margin: 0 auto;
  text-align: left;
}

.hero-code-header {
  background: var(--bg-tertiary);
  padding: 10px 16px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border);
}

.hero-code-header .dots { display: flex; gap: 6px; }
.hero-code-header .dot { width: 11px; height: 11px; border-radius: 50%; }
.hero-code-header .dot-red { background: #ff5f56; }
.hero-code-header .dot-yellow { background: #ffbd2e; }
.hero-code-header .dot-green { background: #27c93f; }
.hero-code-header .filename {
  margin-left: 8px;
  font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-muted);
}

.hero-code pre {
  padding: 20px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.7;
  overflow-x: auto;
  margin: 0;
}

/* ─── Feature Grid ─── */
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px 96px;
}

.feature-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.feature-card:hover { border-color: var(--accent-border); box-shadow: 0 0 0 1px var(--accent-border), var(--shadow); }

.feature-icon {
  width: 40px; height: 40px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; margin-bottom: 14px;
}

.feature-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.feature-card p { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.6; }

/* ─── Headings ─── */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.3; color: var(--text-primary); }

.content-area h1 { font-size: 2rem; margin-bottom: 12px; letter-spacing: -0.02em; }
.content-area .lead { font-size: 1.05rem; color: var(--text-secondary); line-height: 1.7; margin-bottom: 40px; border-bottom: 1px solid var(--border); padding-bottom: 32px; }
.content-area h2 { font-size: 1.35rem; margin: 48px 0 16px; padding-top: 48px; border-top: 1px solid var(--border-light); }
.content-area h2:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.content-area h3 { font-size: 1.05rem; margin: 32px 0 12px; }
.content-area h4 { font-size: 0.9rem; margin: 24px 0 8px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.06em; }

.content-area p { margin-bottom: 16px; color: var(--text-secondary); line-height: 1.75; }
.content-area p strong { color: var(--text-primary); }
.content-area ul, .content-area ol { margin: 0 0 16px 20px; color: var(--text-secondary); }
.content-area li { margin-bottom: 6px; line-height: 1.7; }
.content-area li strong { color: var(--text-primary); }

/* ─── Code ─── */
code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--purple);
}

pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  overflow-x: auto;
  margin: 16px 0 24px;
  position: relative;
}

pre code {
  background: none; border: none; padding: 0;
  font-size: 0.875rem; line-height: 1.75;
  color: var(--text-primary);
}

.code-lang {
  position: absolute; top: 12px; right: 16px;
  font-size: 0.7rem; color: var(--text-muted);
  font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: 0.06em;
}

/* Syntax highlighting */
.kw { color: #ff7b72; }    /* keywords: set, run, if, else, transition, available, when */
.kw2 { color: #f78166; }   /* secondary keywords */
.ref { color: #79c0ff; }   /* @references */
.str { color: #a5d6ff; }   /* strings */
.num { color: #f2cc60; }   /* numbers */
.bool { color: #79c0ff; }  /* True/False */
.cmt { color: #8b949e; font-style: italic; }  /* comments */
.blk { color: #7ee787; }   /* block names: system, config, topic, etc */
.blk2 { color: #d2a8ff; }  /* subagent/topic instance names */
.op { color: #ff7b72; }    /* operators */
.tmpl { color: #a5d6ff; }  /* template content */
.interp { color: #ffa657; } /* {! interpolation delimiters */
.field { color: #e6edf3; }  /* field names */
.type { color: #d2a8ff; }   /* types: string, number, boolean */
.mod { color: #79c0ff; }    /* modifiers: mutable, linked */
.tgt { color: #a5d6ff; }    /* target URIs */

/* ─── Tables ─── */
.content-area table { width: 100%; border-collapse: collapse; margin: 16px 0 24px; font-size: 0.875rem; }
.content-area th { background: var(--bg-secondary); padding: 10px 16px; text-align: left; font-weight: 600; border: 1px solid var(--border); color: var(--text-primary); }
.content-area td { padding: 10px 16px; border: 1px solid var(--border); color: var(--text-secondary); vertical-align: top; }
.content-area td code { font-size: 0.8rem; }
.content-area tr:hover td { background: var(--bg-secondary); }

/* ─── Callouts ─── */
.callout {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid;
  margin: 20px 0;
  font-size: 0.875rem;
}

.callout-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.callout p { margin: 0; line-height: 1.6; }

.callout-info { background: var(--accent-dim); border-color: var(--accent-border); color: var(--text-secondary); }
.callout-info .callout-icon { color: var(--accent); }

.callout-tip { background: var(--green-dim); border-color: rgba(63, 185, 80, 0.3); color: var(--text-secondary); }
.callout-tip .callout-icon { color: var(--green); }

.callout-warn { background: rgba(227, 179, 65, 0.1); border-color: rgba(227, 179, 65, 0.3); color: var(--text-secondary); }
.callout-warn .callout-icon { color: var(--yellow); }

/* ─── Step list ─── */
.steps { counter-reset: step; list-style: none; margin: 0 0 24px; padding: 0; }
.steps li { counter-increment: step; display: flex; gap: 16px; margin-bottom: 24px; }
.steps li::before {
  content: counter(step);
  min-width: 28px; height: 28px;
  background: var(--accent-dim); border: 1px solid var(--accent-border);
  border-radius: 50%; color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; flex-shrink: 0; margin-top: 2px;
}

/* ─── Packages grid ─── */
.pkg-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px; margin: 16px 0 32px;
}

.pkg-card {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px;
  transition: border-color 0.15s;
}

.pkg-card:hover { border-color: var(--accent-border); }

.pkg-card .pkg-name {
  font-family: var(--font-mono); font-size: 0.8rem;
  color: var(--purple); margin-bottom: 6px;
}

.pkg-card .pkg-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 8px; }
.pkg-card .pkg-desc { font-size: 0.825rem; color: var(--text-secondary); line-height: 1.5; }

.pkg-tag {
  display: inline-block; padding: 2px 8px;
  border-radius: 100px; font-size: 0.7rem; font-weight: 600;
  margin-top: 10px;
}

.tag-core { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent-border); }
.tag-dialect { background: var(--purple-dim); color: var(--purple); border: 1px solid rgba(188, 140, 255, 0.3); }
.tag-editor { background: var(--green-dim); color: var(--green); border: 1px solid rgba(63, 185, 80, 0.3); }
.tag-app { background: rgba(227, 179, 65, 0.1); color: var(--yellow); border: 1px solid rgba(227, 179, 65, 0.3); }

/* ─── Example cards ─── */
.example-header {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 14px 20px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
  margin-top: 32px;
}

.example-header .dots { display: flex; gap: 6px; }
.example-header .dot { width: 11px; height: 11px; border-radius: 50%; }
.example-header .dot-r { background: #ff5f56; }
.example-header .dot-y { background: #ffbd2e; }
.example-header .dot-g { background: #27c93f; }
.example-header .filename {
  font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-muted); margin-left: 6px;
}

.example-header + pre {
  margin-top: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  border-top: none;
}

/* ─── Page hero ─── */
.page-hero {
  padding: 48px 0 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}

.page-hero .breadcrumb {
  display: flex; gap: 6px; align-items: center;
  font-size: 0.8rem; color: var(--text-muted); margin-bottom: 12px;
}

.page-hero .breadcrumb a { color: var(--text-muted); }
.page-hero .breadcrumb a:hover { color: var(--accent); }
.page-hero .breadcrumb span { color: var(--text-muted); }

.page-hero h1 { font-size: 1.8rem; letter-spacing: -0.02em; }

/* ─── Inline badges ─── */
.badge {
  display: inline-block; padding: 1px 8px;
  border-radius: 100px; font-size: 0.72rem; font-weight: 600; font-family: var(--font-mono);
  vertical-align: middle; margin-left: 6px;
}

.badge-req { background: rgba(248, 81, 73, 0.15); color: var(--red); border: 1px solid rgba(248, 81, 73, 0.3); }
.badge-opt { background: var(--bg-tertiary); color: var(--text-muted); border: 1px solid var(--border); }

/* ─── Footer ─── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 40px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.825rem;
}

.site-footer a { color: var(--text-secondary); }
.site-footer a:hover { color: var(--accent); }

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .content-area { padding: 32px 20px 64px; }
  .header-nav { display: none; }
}

@media (max-width: 600px) {
  .hero h1 { font-size: 2rem; }
  .features { grid-template-columns: 1fr; }
  .hero-actions { flex-direction: column; align-items: center; }
  .pkg-grid { grid-template-columns: 1fr; }
}

/* ─── Homepage full-width ─── */
.homepage { padding-top: var(--header-height); }
.homepage .main-content { margin-left: 0; }

/* ─── Syntax reference small ─── */
.spec-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 16px 0 24px;
}

.spec-block-header {
  background: var(--bg-secondary); padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.spec-block-title { font-size: 0.8rem; font-weight: 700; color: var(--text-primary); font-family: var(--font-mono); }
.spec-block-type { font-size: 0.72rem; color: var(--text-muted); }
.spec-block-body { padding: 16px 20px; background: var(--bg); }
.spec-block-body p { font-size: 0.875rem; margin-bottom: 12px; }
.spec-block-body p:last-child { margin-bottom: 0; }
.spec-block-body code { font-size: 0.8rem; }

/* ─── Search ─── */
.search-container {
  position: relative;
  flex: 0 0 auto;
}

.search-input {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: var(--font-sans);
  padding: 6px 12px;
  width: 190px;
  outline: none;
  transition: border-color 0.15s, width 0.2s;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  border-color: var(--accent-border);
  width: 250px;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 380px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 200;
  overflow: hidden;
}

.search-result-item {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: background 0.1s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-tertiary); text-decoration: none; }

.search-result-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.search-result-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-empty {
  padding: 16px 14px;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

@media (max-width: 900px) {
  .search-container { display: none; }
}
