:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --fg: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --accent-bg: #1f6feb22;
  --ok: #3fb950;
  --err: #f85149;
  --code-bg: #0b0f14;
  font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
}

header, main, footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.5rem;
}

header {
  max-width: 1200px;
}
header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.6rem;
}
.subtitle {
  color: var(--muted);
  font-weight: normal;
  font-size: 1rem;
}
.intro {
  color: var(--muted);
  max-width: 72ch;
  margin-bottom: 1.25rem;
}
.links a {
  color: var(--accent);
}

.overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem 1.5rem;
  margin: 0 0 1rem;
}
.overview section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}
.overview h2 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.diagram {
  margin: 0;
  padding: 0.5rem 0.75rem;
  background: var(--code-bg);
  border-radius: 4px;
  font-family: ui-monospace, "Menlo", monospace;
  font-size: 0.8rem;
  overflow-x: auto;
  color: var(--fg);
  line-height: 1.55;
}
.principles ul {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}
.principles li {
  margin: 0.25rem 0;
}
.principles strong {
  color: var(--fg);
}

main {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card h2 {
  margin: 0;
  font-size: 1.05rem;
  font-family: ui-monospace, "Menlo", monospace;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}
.card .milestone {
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  background: var(--accent-bg);
  color: var(--accent);
  border-radius: 999px;
  white-space: nowrap;
}
.card p.desc {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.inputs {
  display: grid;
  gap: 0.5rem;
}
.field label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.15rem;
}
.field input, .field textarea {
  width: 100%;
  background: var(--code-bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.5rem;
  font-family: ui-monospace, "Menlo", monospace;
  font-size: 0.9rem;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.presets button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
}
.presets button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.run {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  font-weight: 600;
  cursor: pointer;
  align-self: flex-start;
}
.run:hover { filter: brightness(1.1); }

.output {
  background: var(--code-bg);
  border-left: 3px solid var(--border);
  padding: 0.5rem 0.75rem;
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 1.5rem;
}
.output.ok { border-color: var(--ok); }
.output.err { border-color: var(--err); color: var(--err); }

main {
  display: block;
}

#plugin-showcase-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.5rem 1.5rem 2rem;
}
#plugin-showcase-wrap h2 {
  margin: 0 0 0.75rem;
}

#run-demos-wrap {
  max-width: 1200px;
  margin: 0 auto 2rem;
  padding: 0.5rem 1.5rem;
  border-top: 1px solid var(--border);
}
#run-demos-wrap details summary {
  cursor: pointer;
  list-style: none;
}
#run-demos-wrap details summary::-webkit-details-marker {
  display: none;
}
#run-demos-wrap summary h2 {
  display: inline;
  margin: 0;
}
#run-demos-wrap summary .hint {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: normal;
  margin-left: 0.5rem;
}
#run-demos-wrap details[open] summary .hint::after {
  content: " — click to collapse";
}
#run-demos-wrap #demos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.func-controls {
  margin: 0.75rem 0 1rem;
  overflow-x: auto;
}
.funcs-table {
  border-collapse: collapse;
  font-size: 0.85rem;
  width: 100%;
}
.funcs-table th {
  text-align: left;
  font-weight: 500;
  color: var(--muted);
  font-size: 0.75rem;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
.funcs-table td {
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  vertical-align: middle;
}
.funcs-table td.uid {
  font-family: ui-monospace, monospace;
  color: var(--muted);
  min-width: 120px;
}
.funcs-table input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}
.funcs-table input[type="checkbox"]:disabled {
  cursor: not-allowed;
}
.funcs-table input[type="text"] {
  width: 100%;
  min-width: 180px;
  background: var(--code-bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
}
.source-tag {
  display: inline-block;
  font-family: ui-monospace, monospace;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.source-tag.source-exported {
  color: var(--ok);
  border-color: var(--ok);
}
.source-tag.source-internal {
  color: var(--muted);
}
.source-tag.source-imported {
  color: var(--accent);
  border-color: var(--accent);
}

.plugin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1rem;
}
.plugin-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.plugin-box h3 {
  margin: 0;
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  color: var(--accent);
}
.plugin-box .pane-text {
  margin: 0;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  background: var(--code-bg);
  color: var(--fg);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 100%;
  resize: vertical;
  line-height: 1.45;
}
.plugin-box .pane-text:focus {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}
.plugin-box.err .pane-text {
  color: var(--err);
}
.plugin-box .pane-toolbar {
  display: flex;
  justify-content: flex-end;
}
.plugin-box .pane-sync {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.plugin-box .pane-sync:hover:not([disabled]) {
  filter: brightness(1.1);
}
.plugin-box .pane-sync[disabled] {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}
.plugin-box .pane-errors {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}
.plugin-box .pane-errors.err {
  color: var(--err);
  background: rgba(248, 81, 73, 0.08);
  border: 1px solid var(--err);
  border-radius: 4px;
  padding: 0.5rem 0.65rem;
  margin-top: 0.4rem;
}
.plugin-box .pane-errors ul {
  margin: 0.25rem 0 0;
  padding-left: 1.2rem;
}
.plugin-box .pane-cap {
  margin: 0;
  font-size: 0.7rem;
  color: var(--muted);
  font-style: italic;
}

footer {
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}
footer a {
  color: var(--accent);
}

/* ---------------------------------------------------------------------------
   Playground — compile in the browser, run what was compiled
   --------------------------------------------------------------------------- */

#playground-wrap {
  margin-bottom: 2.5rem;
}

.pg-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.pg-bar label {
  font-weight: 600;
  font-size: 0.9rem;
}

.pg-bar select {
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
}

button.pg-primary {
  padding: 0.4rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
}

.pg-hint {
  font-size: 0.78rem;
  opacity: 0.55;
}

.pg-status {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.pg-status.good { color: #1a7f37; }
.pg-status.bad { color: #b42318; }

.pg-blurb {
  margin: 0 0 0.9rem;
  font-size: 0.9rem;
  opacity: 0.8;
  max-width: 68ch;
}

.pg-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

@media (max-width: 900px) {
  .pg-grid { grid-template-columns: minmax(0, 1fr); }
}

.pg-pane h3 {
  margin: 0 0 0.4rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.6;
}

textarea.pg-editor {
  width: 100%;
  min-height: 22rem;
  padding: 0.7rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  tab-size: 2;
  border: 1px solid rgba(128, 128, 128, 0.35);
  border-radius: 6px;
  resize: vertical;
}

.pg-run-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pg-run-row {
  border: 1px solid rgba(128, 128, 128, 0.28);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
}

.pg-run-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

code.pg-fn { font-weight: 600; }

.pg-sig {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  opacity: 0.65;
}

.pg-run-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

input.pg-args {
  flex: 1 1 8rem;
  min-width: 6rem;
  padding: 0.3rem 0.45rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
}

.pg-result {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  font-weight: 600;
}

.pg-result.good { color: #1a7f37; }
.pg-result.bad { color: #b42318; font-weight: 400; font-size: 0.78rem; }

.pg-download { margin-top: 0.7rem; }

a.pg-dl { font-size: 0.85rem; }

.pg-details { margin-top: 0.7rem; }

.pg-details summary {
  cursor: pointer;
  font-size: 0.85rem;
  opacity: 0.75;
}

pre.pg-wat {
  margin-top: 0.5rem;
  max-height: 22rem;
  overflow: auto;
  padding: 0.6rem;
  font-size: 0.74rem;
  line-height: 1.45;
  background: rgba(128, 128, 128, 0.08);
  border-radius: 6px;
}

pre.pg-error {
  white-space: pre-wrap;
  padding: 0.6rem;
  font-size: 0.8rem;
  color: #b42318;
  background: rgba(180, 35, 24, 0.07);
  border-radius: 6px;
}

.pg-note {
  font-size: 0.85rem;
  opacity: 0.7;
}

/* Collapsed sections below the playground: keep their headings inline so the
   disclosure triangle reads as part of the same line. */
#plugin-showcase-wrap summary h2,
#run-demos-wrap summary h2 {
  display: inline;
  font-size: 1.05rem;
}

#plugin-showcase-wrap,
#run-demos-wrap {
  margin-top: 1.6rem;
}

header { margin-bottom: 1.2rem; }

/* Why a call takes more arguments than its signature shows. */
.pg-abi-note {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: 0.3rem;
}
