@import url('https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,400&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
  --bg:         #f2f5fb;
  --sidebar-bg: #141820;
  --sidebar-w:  256px;
  --panel:      #ffffff;
  --text:       #1b2434;
  --muted:      #5a6880;
  --line:       #e1e8f2;
  --accent:     #4f6dff;
  --code-bg:    #0e1420;
  --code-fg:    #dde6f8;

  --c-motion:   #38a8ff;
  --c-pen:      #22c97a;
  --c-control:  #7d58ff;
  --c-logic:    #f0609a;
  --c-variable: #f0a800;
  --c-events:   #f95858;
  --c-array:    #ff8c00;
  --c-proc:     #9428ff;

  --pt-number:  #fde68a;
  --pt-string:  #bbf7d0;
  --pt-color:   #fbcfe8;
  --pt-name:    #bfdbfe;
  --pt-bool:    #ddd6fe;
  --pt-var:     #fed7aa;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #c0cee6;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding-bottom: 24px;
}
.sidebar-brand {
  padding: 20px 18px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 8px;
}
.sidebar-brand .brand-name { font-size: 1.25rem; font-weight: 700; color: #fff; }
.sidebar-brand .brand-sub  { font-size: 0.72rem; opacity: 0.45; margin-top: 1px; }
.nav-group-label {
  font-size: 0.63rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: #485570;
  padding: 10px 18px 3px; display: block;
}
.nav-group a {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 18px; font-size: 0.86rem; color: #8899bb;
  text-decoration: none; border-left: 2px solid transparent;
  transition: color 0.1s, background 0.1s;
}
.nav-group a:hover { color: #fff; background: rgba(255,255,255,0.035); }
.nav-group a.active { color: #fff; border-left-color: var(--accent); background: rgba(79,109,255,0.1); }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* ── Main ── */
.main-wrap { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }

/* ── Hero ── */
.hero {
  background: linear-gradient(135deg, #141820 0%, #1c2540 60%, #1a2d5a 100%);
  color: white; padding: 52px 52px 44px; position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(circle at 75% 25%, rgba(79,109,255,0.22) 0%, transparent 45%),
    radial-gradient(circle at 15% 80%, rgba(148,40,255,0.15) 0%, transparent 40%);
}
.hero-inner { position: relative; max-width: 820px; }
.hero-eyebrow { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.45; margin: 0 0 10px; }
.hero h1 { margin: 0 0 8px; font-size: clamp(2.6rem, 5vw, 4rem); font-weight: 700; line-height: 1.0; letter-spacing: -0.02em; }
.hero-version { font-size: 0.8rem; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.14); border-radius: 999px; padding: 3px 10px; margin-left: 10px; vertical-align: middle; font-weight: 400; opacity: 0.7; }
.hero-lede { max-width: 660px; font-size: 1.02rem; opacity: 0.82; margin: 12px 0 20px; line-height: 1.55; }
.hero-pills { display: flex; gap: 7px; flex-wrap: wrap; }
.hero-pill { font-size: 0.77rem; background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12); border-radius: 999px; padding: 5px 11px; color: rgba(255,255,255,0.75); }

/* ── Content ── */
.content { padding: 36px 52px 72px; max-width: 960px; }
section { margin-bottom: 52px; }
.section-header { display: flex; align-items: baseline; gap: 12px; margin: 0 0 6px; }
.section-num { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); opacity: 0.6; }
section > h2 { font-size: 1.7rem; font-weight: 700; margin: 0 0 5px; border-bottom: 2px solid var(--line); padding-bottom: 10px; }
.section-intro { color: var(--muted); font-size: 0.94rem; margin: 0 0 20px; max-width: 68ch; }
h3 { font-size: 1.0rem; font-weight: 600; margin: 22px 0 7px; }
p { margin: 0 0 9px; max-width: 74ch; }
ul, ol { margin: 7px 0 11px; padding-left: 1.4em; max-width: 70ch; }
li { margin-bottom: 3px; }
a { color: var(--accent); }

/* ── inline code ── */
code { font-family: 'DM Mono', Consolas, monospace; font-size: 0.875em; background: #edf1fb; color: #3a4e6e; padding: 0.1em 0.35em; border-radius: 4px; }

/* ── code blocks ── */
pre {
  font-family: 'DM Mono', Consolas, monospace;
  font-size: 0.84rem; background: var(--code-bg); color: var(--code-fg);
  border-radius: 11px; padding: 16px 20px; overflow-x: auto;
  margin: 9px 0 14px; line-height: 1.62;
  border: 1px solid rgba(255,255,255,0.04);
  box-shadow: 0 4px 22px rgba(0,0,0,0.20);
}
pre code { background: transparent; padding: 0; color: inherit; font-size: inherit; }

/* syntax tokens */
.t-kw  { color: #7eb8ff; }
.t-num { color: #fbbf24; }
.t-str { color: #86efac; }
.t-var { color: #c4b5fd; }
.t-cmt { color: #3d5070; font-style: italic; }
.t-proc{ color: #fda4af; }
.t-hex { color: #fb923c; }

/* ── Command entry ── */
.cmd-entry { background: var(--panel); border: 1px solid var(--line); border-radius: 13px; margin-bottom: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(30,50,100,0.05); }
.cmd-header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #f8faff; }
.cmd-cat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cmd-name { font-family: 'DM Mono', monospace; font-size: 0.91rem; font-weight: 500; color: #1a2a42; flex: 1; }
.cmd-name .param-pill { margin-left: 5px; }
.cmd-tag { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; color: #fff; opacity: 0.9; }
.cmd-body { padding: 12px 16px; }
.cmd-body p { margin: 0 0 7px; font-size: 0.92rem; }
.cmd-body p:last-child { margin-bottom: 0; }
.cmd-body pre { margin: 7px 0 0; }

/* param pills */
.param-pill { display: inline-block; font-family: 'DM Mono', monospace; font-size: 0.76em; font-style: italic; padding: 1px 6px; border-radius: 999px; font-weight: 400; }
.param-pill.p-number { background: var(--pt-number);  color: #713f12; }
.param-pill.p-string { background: var(--pt-string);  color: #14532d; }
.param-pill.p-color  { background: var(--pt-color);   color: #701a75; }
.param-pill.p-name   { background: var(--pt-name);    color: #1e3a5f; }
.param-pill.p-bool   { background: var(--pt-bool);    color: #3730a3; }
.param-pill.p-var    { background: var(--pt-var);     color: #7c2d12; }

/* tag colours */
.tag-motion   { background: var(--c-motion); }
.tag-pen      { background: var(--c-pen);      color: #0a1a10 !important; }
.tag-control  { background: var(--c-control); }
.tag-logic    { background: var(--c-logic); }
.tag-variable { background: var(--c-variable); color: #1e1600 !important; }
.tag-events   { background: var(--c-events); }
.tag-array    { background: var(--c-array);    color: #1a0e00 !important; }
.tag-proc     { background: var(--c-proc); }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; margin: 10px 0 16px; font-size: 0.89rem; }
thead th { background: #f0f4fb; font-weight: 600; font-size: 0.74rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); padding: 8px 12px; border-bottom: 2px solid var(--line); text-align: left; }
td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.builtin-table td:first-child code { background: #fef3c7; color: #78350f; }

/* ── Callouts ── */
.callout { display: flex; gap: 11px; border-radius: 10px; padding: 12px 15px; margin: 12px 0; font-size: 0.89rem; }
.callout-icon { font-size: 1.05rem; flex-shrink: 0; line-height: 1.5; }
.callout-body { flex: 1; }
.callout-body strong { display: block; margin-bottom: 2px; }
.callout.info   { background: #eff6ff; border: 1px solid #bfdbfe; }
.callout.warn   { background: #fffbeb; border: 1px solid #fde68a; }
.callout.tip    { background: #f0fdf4; border: 1px solid #bbf7d0; }
.callout.danger { background: #fff1f2; border: 1px solid #fecdd3; }

/* ── Two-col cards ── */
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 0 0 14px; }
.col-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.col-card h4 { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 0 0 6px; }

/* ── Examples ── */
.examples-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(410px, 1fr)); gap: 18px; margin-top: 18px; }
.example-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: 0 3px 16px rgba(30,50,100,0.06); display: flex; flex-direction: column; }
.example-card.wide { grid-column: 1 / -1; }
.example-head { padding: 13px 17px 8px; border-bottom: 1px solid var(--line); }
.example-num  { font-size: 0.67rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); opacity: 0.6; margin-bottom: 1px; }
.example-head h3 { margin: 0; font-size: 0.98rem; font-weight: 600; }
.example-desc { padding: 9px 17px 5px; font-size: 0.84rem; color: var(--muted); line-height: 1.5; }
.example-card pre { margin: 0; border-radius: 0; border: 0; box-shadow: none; flex: 1; font-size: 0.78rem; padding: 12px 17px; }
.example-actions { display: flex; gap: 7px; flex-wrap: wrap; padding: 10px 17px; border-top: 1px solid var(--line); background: #f8faff; }
.example-action-link, .example-action-button {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; color: #1f3f78; font-family: 'DM Sans', sans-serif;
  font-weight: 600; font-size: 0.8rem; text-decoration: none; cursor: pointer;
  box-shadow: 0 1px 4px rgba(40,70,150,0.07);
  transition: background 0.1s;
}
.example-action-link:hover, .example-action-button:hover { background: #eef2ff; }
.example-action-link.run { background: var(--accent); color: #fff; border-color: var(--accent); }
.example-action-link.run:hover { background: #3d5aff; }

/* ── responsive ── */
@media (max-width: 820px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .hero { padding: 30px 20px 26px; }
  .content { padding: 22px 18px 48px; }
  .examples-grid { grid-template-columns: 1fr; }
  .cols-2 { grid-template-columns: 1fr; }
}
@media print {
  .sidebar { display: none; }
  .main-wrap { margin-left: 0; }
  .hero { background: #141820 !important; }
  .cmd-entry, .example-card { break-inside: avoid; box-shadow: none; }
}

#advanced-toolkit table td code,
#advanced-toolkit table th code {
  white-space: nowrap;
}
.example-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.example-action-button.primary {
  background: linear-gradient(180deg, #5d78ff, #4866ff);
  color: #fff;
}
.manual-runner-shell {
  margin-top: 14px;
  border: 1px solid rgba(112, 133, 255, 0.18);
  border-radius: 18px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(249, 251, 255, 0.96), rgba(242, 246, 255, 0.98));
  box-shadow: 0 14px 34px rgba(78, 98, 176, 0.10);
}
.manual-runner-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(112, 133, 255, 0.14);
  background: linear-gradient(180deg, rgba(255,255,255,0.84), rgba(246,249,255,0.92));
}
.manual-runner-status {
  font-size: 12px;
  font-weight: 700;
  color: #4e5f9a;
}
.manual-runner-status[data-kind="running"] { color: #275f36; }
.manual-runner-status[data-kind="error"] { color: #a33d4f; }
.manual-runner-stage {
  aspect-ratio: 4 / 3;
  min-height: 240px;
  background: linear-gradient(180deg, #edf3ff, #f8fbff);
}
.manual-runner-placeholder {
  min-height: 240px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  color: #5d6d96;
}
.manual-runner-frame {
  width: 100%;
  height: 100%;
  min-height: 360px;
  border: 0;
  display: block;
  background: #edf3ff;
}
@media (max-width: 900px) {
  .manual-runner-frame {
    min-height: 300px;
  }
}

.manual-runner-stage { overflow: hidden; }
.manual-runner-frame { min-height: 0; height: 100%; }
