:root {
  --bg: #101216; --panel: #171a20; --panel-border: #262b33;
  --text: #e7e6e2; --text-dim: #838a97; --accent: #ff8a3d; --teal: #4fd1c5; --select: #ffd23f;
  --field: #1d2128; --field-dark: #0d0f13; --field-hover: #232833; --field-hover-border: #3a4150;
  --overlay-rgb: 23,26,32; --danger: #ff5577;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'IBM Plex Sans', sans-serif; line-height: 1.6; font-size: 15px;
}
code, kbd, .mono { font-family: 'IBM Plex Mono', monospace; }
a { color: var(--teal); }
h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; color: var(--text); }
h1 { font-size: 30px; margin: 0 0 8px; }
h2 { font-size: 21px; margin: 44px 0 12px; padding-top: 10px; border-top: 1px solid var(--panel-border); scroll-margin-top: 76px; }
h2:first-of-type { border-top: none; padding-top: 0; }
h3 { font-size: 16px; margin: 26px 0 8px; scroll-margin-top: 76px; }
p { margin: 0 0 14px; }
ul, ol { padding-left: 22px; }
li { margin-bottom: 6px; }
.dim { color: var(--text-dim); }

/* ---- top nav ---- */
header.site-nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 22px;
  padding: 12px 26px; background: rgba(var(--overlay-rgb), 0.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--panel-border);
}
.wordmark { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 600; font-size: 14px; white-space: nowrap; }
.wordmark .docs-tag { color: var(--text-dim); font-weight: 400; }
.site-nav nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav nav a {
  text-decoration: none; color: var(--text-dim); font-size: 13.5px; font-weight: 500;
  padding: 7px 11px; border-radius: 6px; transition: background 0.15s, color 0.15s;
}
.site-nav nav a:hover { background: var(--field-hover); color: var(--text); }
.site-nav nav a.active { color: var(--bg); background: var(--teal); }
.site-nav .spacer { flex: 1; }
.site-nav .external { color: var(--text-dim); font-size: 13px; text-decoration: none; white-space: nowrap; }
.site-nav .external:hover { color: var(--text); }

/* ---- layout ---- */
main { max-width: 780px; margin: 0 auto; padding: 40px 26px 100px; }
.eyebrow { font-family: 'IBM Plex Mono', monospace; font-size: 11px; letter-spacing: 0.12em; color: var(--teal); text-transform: uppercase; margin-bottom: 10px; }
.dek { font-size: 17px; color: var(--text-dim); max-width: 640px; }

/* ---- buttons / pills ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  font-size: 13.5px; font-weight: 600; padding: 10px 16px; border-radius: 7px;
  border: 1px solid var(--panel-border); background: var(--field); color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--field-hover-border); background: var(--field-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1000; }
.btn.primary:hover { background: #ff9a56; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 22px 0 6px; }

/* ---- on-this-page TOC ---- */
.toc { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 10px; padding: 16px 20px; margin: 28px 0 36px; }
.toc-label { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 8px; }
.toc ol { columns: 2; column-gap: 24px; margin: 0; padding-left: 18px; }
.toc li { font-size: 13.5px; margin-bottom: 5px; break-inside: avoid; }
.toc a { color: var(--text); text-decoration: none; }
.toc a:hover { color: var(--teal); }

/* ---- screen diagram (index page) ---- */
.screen-diagram { margin: 26px 0 36px; }
.screen-diagram svg { width: 100%; height: auto; display: block; }

/* ---- screen cards (index page) ---- */
.card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 22px 0 40px; }
@media (max-width: 700px) { .card-grid { grid-template-columns: 1fr; } }
.screen-card {
  display: block; text-decoration: none; color: var(--text);
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 10px;
  padding: 18px 18px 16px; transition: border-color 0.15s, transform 0.15s;
}
.screen-card:hover { border-color: var(--teal); transform: translateY(-2px); }
.screen-card .tag { font-family: 'IBM Plex Mono', monospace; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--teal); }
.screen-card h3 { margin: 6px 0 8px; font-size: 16px; }
.screen-card ul { padding-left: 16px; margin: 0 0 10px; font-size: 13px; color: var(--text-dim); }
.screen-card li { margin-bottom: 3px; }
.screen-card .go { font-size: 12.5px; font-weight: 600; color: var(--teal); }

/* ---- callouts ---- */
.callout { border-radius: 8px; padding: 12px 16px; margin: 16px 0; font-size: 14px; border-left: 3px solid; }
.callout p:last-child { margin-bottom: 0; }
.callout.note { background: rgba(79,209,197,0.08); border-color: var(--teal); }
.callout.tip { background: rgba(255,138,61,0.08); border-color: var(--accent); }
.callout.limit { background: rgba(131,138,151,0.08); border-color: var(--text-dim); }
.callout .label { display: block; font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 5px; }
.callout.note .label { color: var(--teal); }
.callout.tip .label { color: var(--accent); }
.callout.limit .label { color: var(--text-dim); }

/* ---- collapsible deep-dive sections ---- */
details.dive {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 8px;
  padding: 2px 18px; margin: 14px 0;
}
details.dive[open] { padding-bottom: 16px; }
details.dive summary {
  cursor: pointer; list-style: none; padding: 13px 0; font-weight: 600; font-size: 14.5px;
  display: flex; align-items: center; gap: 8px; user-select: none;
}
details.dive summary::-webkit-details-marker { display: none; }
details.dive summary::before { content: '▸'; color: var(--teal); font-size: 12px; transition: transform 0.15s; }
details.dive[open] summary::before { transform: rotate(90deg); }
details.dive summary .hint { font-weight: 400; color: var(--text-dim); font-size: 12.5px; margin-left: auto; }
details.dive > *:not(summary):first-of-type { margin-top: 0; }

/* nested nice-to-have: nested nav for "full contents" tree */
.contents-tree summary { font-weight: 600; }
.contents-tree ul { margin: 6px 0 2px; }
.contents-tree a { color: var(--text-dim); text-decoration: none; font-size: 13.5px; }
.contents-tree a:hover { color: var(--teal); }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; margin: 14px 0 22px; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--panel-border); vertical-align: top; }
th { color: var(--text-dim); font-weight: 600; font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; }
td .mono { color: var(--teal); }
tr:last-child td { border-bottom: none; }

/* ---- kbd ---- */
kbd {
  font-family: 'IBM Plex Mono', monospace; font-size: 12px; background: var(--field-dark);
  border: 1px solid var(--panel-border); border-bottom-width: 2px; border-radius: 5px;
  padding: 2px 7px; color: var(--text);
}

/* ---- code blocks (ShuffleScript manual) ---- */
pre {
  background: var(--field-dark); border: 1px solid var(--panel-border); border-radius: 8px;
  padding: 14px 18px; overflow-x: auto; margin: 14px 0 22px;
}
pre code {
  font-family: 'IBM Plex Mono', monospace; font-size: 13px; line-height: 1.6; color: var(--text);
  background: none; border: none; padding: 0; white-space: pre;
}
p code, li code, td code { background: var(--field); border: 1px solid var(--panel-border); border-radius: 4px; padding: 1px 6px; font-size: 12.5px; }

/* ---- misc UI-label chip (mirrors an in-app button/label being referenced) ---- */
.ui { font-family: 'IBM Plex Mono', monospace; font-size: 12.5px; background: var(--field); border: 1px solid var(--panel-border); border-radius: 5px; padding: 1px 7px; color: var(--text); white-space: nowrap; }
.dot { display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:6px; }

/* ---- expand/collapse-all control ---- */
.dive-controls { display: flex; gap: 14px; margin: 4px 0 20px; }
.dive-controls button {
  font-family: 'IBM Plex Sans', sans-serif; font-size: 12.5px; font-weight: 600; color: var(--teal);
  background: none; border: none; cursor: pointer; padding: 0;
}
.dive-controls button:hover { text-decoration: underline; }

/* ---- footer ---- */
footer.site-footer {
  border-top: 1px solid var(--panel-border); margin-top: 60px; padding: 26px;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 14px;
  font-size: 12.5px; color: var(--text-dim);
}
footer.site-footer a { color: var(--text-dim); }
footer.site-footer a:hover { color: var(--teal); }
footer.site-footer .links { display: flex; gap: 16px; flex-wrap: wrap; }

/* ---- next-page nav at bottom of content ---- */
.next-page {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  margin-top: 50px; padding: 18px 20px; background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: 10px; text-decoration: none; color: var(--text);
}
.next-page:hover { border-color: var(--teal); }
.next-page .lbl { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.next-page .name { font-size: 16px; font-weight: 600; margin-top: 2px; }
.next-page .arrow { font-size: 20px; color: var(--teal); }
