/* tokens from src/viewer/styles.css */
:root {
  --font: "Inter", "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --accent: #6d8bff;
  --accent-2: #9b7bff;
  --accent-soft: rgba(109, 139, 255, 0.16);
  --amber: #ffb020;
  --ok: #3ecf8e;
  --err: #ff5d6c;
  --warn: #f5a524;
  --axis-x: #f0545c;
  --axis-y: #5cc86c;
  --axis-z: #5b8cff;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0c11;
  --bg-grad-1: #131826;
  --bg-grad-2: #07080c;
  --panel: rgba(18, 21, 30, 0.78);
  --panel-solid: #12151e;
  --panel-2: rgba(255, 255, 255, 0.035);
  --line: rgba(255, 255, 255, 0.075);
  --line-2: rgba(255, 255, 255, 0.13);
  --text: #e7eaf2;
  --text-2: #a3abbd;
  --text-3: #6b7489;
  --hover: rgba(255, 255, 255, 0.06);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --code-bg: rgba(0, 0, 0, 0.35);
  --tk-s: #a5e1a1;
  --tk-k: #c792ea;
  --tk-t: #7fb4ff;
  --tk-n: #f7b267;
  --tk-c: #6b7489;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f6;
  --bg-grad-1: #ffffff;
  --bg-grad-2: #e2e7f0;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #ffffff;
  --panel-2: rgba(10, 20, 50, 0.035);
  --line: rgba(15, 23, 42, 0.08);
  --line-2: rgba(15, 23, 42, 0.14);
  --text: #141822;
  --text-2: #4b5569;
  --text-3: #8790a3;
  --hover: rgba(15, 23, 42, 0.05);
  --shadow: 0 10px 30px rgba(30, 40, 70, 0.12), 0 1px 0 rgba(255, 255, 255, 0.6) inset;
  --code-bg: rgba(15, 23, 42, 0.05);
  --accent-soft: rgba(80, 110, 250, 0.12);
  --tk-s: #1b7f3b;
  --tk-k: #8b3fd1;
  --tk-t: #2557d6;
  --tk-n: #b45f06;
  --tk-c: #8790a3;
}

:root[data-theme="light"] .dim-label {
  background: rgba(255, 255, 255, 0.9);
  color: #2747b8;
  border-color: rgba(70, 100, 220, 0.4);
}

/* tscad docs site. Colour tokens come from the viewer (prepended at build time). */

* { box-sizing: border-box; }
html { scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15.5px/1.65 var(--font);
  color: var(--text);
  background: radial-gradient(1200px 700px at 70% -10%, var(--bg-grad-1), transparent 70%), var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; height: auto; }
::selection { background: var(--accent-soft); }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  height: 60px; display: flex; align-items: center; gap: 22px;
  padding: 0 clamp(16px, 3vw, 32px);
  background: var(--panel); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.brand svg { width: 26px; height: 26px; }
.brand small { font-weight: 500; color: var(--text-3); font-size: 12px; border: 1px solid var(--line-2); border-radius: 99px; padding: 1px 8px; }
.top nav { display: flex; gap: 4px; margin-left: 8px; }
.top nav a { color: var(--text-2); padding: 6px 11px; border-radius: 8px; font-size: 14.5px; font-weight: 500; }
.top nav a:hover { color: var(--text); background: var(--hover); text-decoration: none; }
.top nav a.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); }
.top .spacer { flex: 1; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 15px;
  border-radius: 10px; font-weight: 600; font-size: 14px; border: 1px solid var(--line-2);
  color: var(--text); background: var(--panel-2); cursor: pointer; white-space: nowrap;
  transition: transform .15s var(--ease), background .15s, border-color .15s;
}
.btn:hover { text-decoration: none; background: var(--hover); border-color: var(--text-3); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; box-shadow: 0 6px 24px rgba(109, 139, 255, .35); }
.btn.primary:hover { transform: translateY(-1px); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn.lg { height: 46px; padding: 0 22px; font-size: 15.5px; border-radius: 12px; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--hover); }
.icon-btn svg { width: 18px; height: 18px; }
:root[data-theme="light"] .i-sun, :root:not([data-theme="light"]) .i-moon { display: none; }
.menu-btn { display: none; }

/* ---------- docs layout ---------- */
.layout {
  display: grid; grid-template-columns: 250px minmax(0, 1fr) 220px; gap: 40px;
  max-width: 1400px; margin: 0 auto; padding: 0 clamp(16px, 3vw, 32px);
}
.layout.no-toc { grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 60px; align-self: start; height: calc(100vh - 60px); overflow: auto; padding: 28px 4px 40px 0; }
.sidebar h4 { margin: 22px 0 6px; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); font-weight: 700; }
.sidebar h4:first-child { margin-top: 0; }
.sidebar a { display: block; padding: 5px 10px; margin: 1px 0; border-radius: 8px; color: var(--text-2); font-size: 14.5px; }
.sidebar a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.sidebar a.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.sidebar a.sub { padding-left: 22px; font-size: 13.5px; font-family: var(--mono); }
.toc { position: sticky; top: 60px; align-self: start; max-height: calc(100vh - 60px); overflow: auto; padding: 32px 0; font-size: 13px; }
.toc h4 { margin: 0 0 8px; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.toc a { display: block; color: var(--text-3); padding: 3px 0 3px 12px; border-left: 2px solid var(--line); }
.toc a.l3 { padding-left: 24px; }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }

/* ---------- prose ---------- */
.prose { min-width: 0; padding: 28px 0 80px; }
.prose > :first-child { margin-top: 0; }
.prose h1 { font-size: clamp(30px, 4vw, 40px); line-height: 1.15; letter-spacing: -0.025em; margin: 8px 0 18px; }
.prose h2 { font-size: 25px; letter-spacing: -0.015em; margin: 48px 0 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.prose h3 { font-size: 19px; margin: 32px 0 8px; }
.prose h4 { font-size: 16px; margin: 24px 0 6px; }
.prose h1, .prose h2, .prose h3, .prose h4 { position: relative; }
.prose .anchor { position: absolute; left: -0.9em; color: var(--text-3); opacity: 0; font-weight: 400; padding-right: 6px; }
.prose :hover > .anchor { opacity: 1; text-decoration: none; }
.prose p, .prose li { color: var(--text-2); }
.prose strong { color: var(--text); }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: 4px 0; }
.prose li::marker { color: var(--text-3); }
.prose blockquote { margin: 18px 0; padding: 10px 18px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; }
.prose blockquote p { margin: 6px 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 36px 0; }
.prose img { border-radius: var(--radius); border: 1px solid var(--line); }
.lead { font-size: 18px; color: var(--text-2); max-width: 680px; }
:not(pre) > code {
  font: 0.86em/1.4 var(--mono); padding: 2px 6px; border-radius: 6px;
  background: var(--code-bg); border: 1px solid var(--line); color: var(--text); white-space: break-spaces;
}
a > code { color: var(--accent); }
pre.code {
  position: relative; margin: 18px 0; padding: 16px 18px; overflow: auto;
  background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: 13.5px/1.6 var(--mono); tab-size: 2;
}
pre.code[data-lang]:not([data-lang=""])::before {
  content: attr(data-lang); position: absolute; top: 6px; right: 10px; font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em;
}
pre.code .copy {
  position: absolute; top: 6px; right: 6px; opacity: 0; transition: opacity .15s;
  font: 600 11.5px var(--font); padding: 4px 9px; border-radius: 7px; border: 1px solid var(--line-2);
  background: var(--panel-solid); color: var(--text-2); cursor: pointer;
}
pre.code:hover .copy { opacity: 1; }
pre.code:hover::before { opacity: 0; }
.table-wrap { overflow-x: auto; margin: 18px 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 13px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--text); font-weight: 600; background: var(--panel-2); }
td { color: var(--text-2); }
td code { white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

/* tokens (lezer classHighlighter) */
.tok-keyword, .tok-modifier, .tok-operatorKeyword, .tok-controlKeyword { color: var(--tk-k); }
.tok-string, .tok-string2, .tok-regexp { color: var(--tk-s); }
.tok-typeName, .tok-className, .tok-tagName { color: var(--tk-t); }
.tok-number, .tok-bool, .tok-atom, .tok-literal { color: var(--tk-n); }
.tok-comment, .tok-meta { color: var(--tk-c); font-style: italic; }
.tok-propertyName, .tok-attributeName { color: var(--text-2); }
.tok-variableName.tok-definition, .tok-function { color: var(--text); }
.tok-punctuation, .tok-operator { color: var(--text-3); }

/* ---------- reference ---------- */
.ref-group { margin-top: 44px; }
.ref-group > h2 { margin-bottom: 4px; }
.ref-group > p { margin-top: 0; }
.el {
  margin: 18px 0; padding: 18px 20px 6px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel-2);
}
.el h3 { margin: 0 0 4px; font: 600 17px var(--mono); }
.el h3 .tag { color: var(--tk-t); }
.el .summary { margin: 0 0 6px; color: var(--text); }
.el .doc { margin: 0 0 10px; font-size: 14.5px; }
.el .table-wrap { margin: 10px 0 14px; }
.el td:first-child { white-space: nowrap; font-family: var(--mono); font-size: 13px; color: var(--text); }
.el td:nth-child(2) { font-family: var(--mono); font-size: 12.5px; color: var(--tk-t); min-width: 120px; }
.el .req { color: var(--err); margin-left: 2px; }
.el .also { font-size: 13.5px; color: var(--text-3); margin: 6px 0 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 6px; }
.chips a { font: 12.5px var(--mono); padding: 3px 9px; border-radius: 7px; border: 1px solid var(--line); color: var(--text-2); }
.chips a:hover { color: var(--text); border-color: var(--line-2); text-decoration: none; }

/* ---------- landing ---------- */
.hero {
  max-width: 1240px; margin: 0 auto; padding: clamp(40px, 7vw, 90px) clamp(16px, 3vw, 32px) 40px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: clamp(28px, 4vw, 60px); align-items: center;
}
.eyebrow { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; font-weight: 600; color: var(--text-2); border: 1px solid var(--line-2); border-radius: 99px; padding: 4px 12px 4px 6px; background: var(--panel-2); }
.eyebrow b { background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: 1px 8px; font-size: 12px; }
.hero h1 { font-size: clamp(38px, 5.6vw, 66px); line-height: 1.03; letter-spacing: -0.035em; margin: 18px 0 18px; }
.grad { background: linear-gradient(120deg, var(--accent) 10%, var(--accent-2) 60%, #ff8ad8 110%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { font-size: clamp(16px, 1.6vw, 19px); }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin: 28px 0 22px; }
.install { display: inline-flex; align-items: center; gap: 10px; font: 13.5px var(--mono); color: var(--text-2); padding: 9px 14px; border-radius: 10px; border: 1px dashed var(--line-2); }
.install span { color: var(--text-3); }
.hero-art { position: relative; }
.hero-art::before { content: ""; position: absolute; inset: 8% 6%; background: radial-gradient(closest-side, rgba(109, 139, 255, .35), transparent); filter: blur(30px); z-index: -1; }
.frame { border-radius: 18px; border: 1px solid var(--line-2); background: var(--panel); box-shadow: var(--shadow); overflow: hidden; }
.frame .bar { display: flex; gap: 7px; padding: 11px 14px; border-bottom: 1px solid var(--line); align-items: center; font: 12px var(--mono); color: var(--text-3); }
.frame .bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); display: inline-block; }
.frame .bar span { margin-left: 8px; }
.frame img { display: block; width: 100%; border: 0; border-radius: 0; }
.section { max-width: 1240px; margin: 0 auto; padding: 56px clamp(16px, 3vw, 32px); }
.section h2 { font-size: clamp(26px, 3vw, 36px); letter-spacing: -0.02em; margin: 0 0 10px; }
.section > p.lead { margin: 0 0 30px; }
.split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 28px; align-items: stretch; }
.split pre.code { margin: 0; height: 100%; font-size: 12.8px; background: var(--panel-solid); }
.split .frame { display: flex; flex-direction: column; }
.split .frame img { flex: 1; min-height: 0; object-fit: contain; padding: 12px; }
.split .caption { padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--text-2); }
.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.feature { padding: 22px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-2); }
.feature .ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 12px; }
.feature .ico svg { width: 20px; height: 20px; }
.feature h3 { margin: 0 0 6px; font-size: 16.5px; }
.feature p { margin: 0; color: var(--text-2); font-size: 14.5px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.card { display: flex; flex-direction: column; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-2); overflow: hidden; color: var(--text); transition: transform .2s var(--ease), border-color .2s; }
.card:hover { transform: translateY(-2px); border-color: var(--line-2); text-decoration: none; }
.card img { display: block; aspect-ratio: 3 / 2; object-fit: cover; width: 100%; border: 0; border-radius: 0; background: var(--panel-solid); }
.card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card h3 { margin: 0; font-size: 15.5px; }
.card p { margin: 0; color: var(--text-2); font-size: 13.5px; line-height: 1.5; flex: 1; }
.card .links { display: flex; gap: 14px; font-size: 13.5px; font-weight: 600; margin-top: 6px; }
.index-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin: 12px 0 28px; }
.index-card { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-2); color: var(--text); transition: transform .2s var(--ease), border-color .2s; }
.index-card:hover { transform: translateY(-2px); border-color: var(--line-2); text-decoration: none; }
.index-card span { color: var(--text-2); font-size: 13.5px; line-height: 1.5; }
.mcp { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: center; padding: 34px; border-radius: 20px; border: 1px solid var(--line-2); background: linear-gradient(135deg, var(--accent-soft), transparent 60%), var(--panel-2); }
.mcp pre.code { margin: 0; }
footer { border-top: 1px solid var(--line); color: var(--text-3); font-size: 13.5px; padding: 28px clamp(16px, 3vw, 32px); display: flex; gap: 18px; flex-wrap: wrap; justify-content: space-between; max-width: 1400px; margin: 0 auto; }
footer a { color: var(--text-2); }

/* example page */
.example-head { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 24px; align-items: start; margin-bottom: 18px; }
.example-head img { border-radius: var(--radius); border: 1px solid var(--line); }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .layout { grid-template-columns: 230px minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 900px) {
  .top nav { display: none; }
  .top.open nav { display: flex; flex-direction: column; position: absolute; top: 60px; left: 0; right: 0; padding: 10px 16px 16px; background: var(--panel-solid); border-bottom: 1px solid var(--line); margin: 0; }
  .menu-btn { display: grid; }
  .layout, .layout.no-toc { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .sidebar { position: static; height: auto; padding: 14px 0 0; border-bottom: 1px solid var(--line); }
  .sidebar details > summary { cursor: pointer; font-weight: 600; color: var(--text-2); padding: 6px 0 12px; list-style: none; }
  .sidebar details:not([open]) > :not(summary) { display: none; }
  .hero, .split, .mcp, .example-head { grid-template-columns: minmax(0, 1fr); }
  .features { grid-template-columns: minmax(0, 1fr); }
  .top .gh-label, .top .play-label { display: none; }
  .prose .anchor { display: none; }
}
@media (min-width: 901px) {
  .sidebar details > summary { display: none; }
}
@media (min-width: 901px) and (max-width: 1100px) {
  .features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
