/*
 *= require_tree .
 *= require_self
 */

/* ---- Design tokens -----------------------------------------------------
   "Lumen" = a unit of light. The palette is dark (a server console at
   night) with a single warm glow as the accent, literally the lumen
   cutting through the dark, rather than Discord's own blurple or a
   generic acid-green/terracotta AI-default palette.
------------------------------------------------------------------------- */
:root {
  --bg:            #121319;
  --surface:       #1b1d26;
  --surface-raised: #22242f;
  --border:        #2c2f3d;
  --text:          #e7e8ec;
  --text-muted:    #9297a8;
  --text-faint:    #676c7d;

  --glow:          #f2c14e;   /* the "lumen" itself */
  --glow-dim:      #b9923a;
  --glow-bg:       rgba(242, 193, 78, 0.10);

  --danger:        #ff6b6b;
  --danger-bg:     rgba(255, 107, 107, 0.10);
  --success:       #6ee7b7;

  --discord-blurple: #5865f2;

  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --radius: 10px;
  --container-width: 760px;
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

.container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

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

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
}

h1 { font-size: 1.9rem; }
h2 { font-size: 1.2rem; }

p { color: var(--text-muted); }

code {
  font-family: var(--font-display);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  font-size: 0.9em;
  color: var(--text);
}

/* ---- Header ------------------------------------------------------------ */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

/* ---- Footer ------------------------------------------------------------ */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 3rem;
  padding: 1.5rem 0;
}
.site-footer a {
  color: var(--text-faint);
  font-size: 0.85rem;
  margin-right: 1.5rem;
}
.site-footer a:hover { color: var(--text); }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.wordmark {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.wordmark:hover { text-decoration: none; }
.wordmark-dot { color: var(--glow); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.nav-link {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}
.nav-link:hover { color: var(--glow); text-decoration: none; }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
}

/* ---- Flash messages ------------------------------------------------------ */
.flash {
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  margin-top: 1.25rem;
  font-size: 0.9rem;
}
.flash.notice { background: var(--glow-bg); color: var(--glow); border: 1px solid var(--glow-dim); }
.flash.alert  { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }

main { padding: 2.5rem 0 4rem; }

/* ---- Hero (landing page) ------------------------------------------------ */
.eyebrow {
  display: block;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-bottom: 1rem;
}

.hero {
  padding: 4.5rem 0 2rem;
  max-width: 520px;
}
.hero h1 {
  font-size: 2.3rem;
  line-height: 1.15;
  color: var(--text);
}
.glow-text {
  color: var(--glow);
  text-shadow: 0 0 24px var(--glow-bg);
}
.hero-sub {
  margin: 1rem 0 2rem;
  font-size: 1.02rem;
}

/* ---- Buttons ------------------------------------------------------------ */
.btn-discord, .btn-primary, .btn-ghost, input[type="submit"] {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0.6rem 1.1rem;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn-discord {
  background: var(--discord-blurple);
  color: white;
}
.btn-discord:hover { text-decoration: none; box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.25); }

.btn-primary, input[type="submit"] {
  background: var(--glow);
  color: #1a1305;
}
.btn-primary:hover, input[type="submit"]:hover {
  box-shadow: 0 0 0 4px var(--glow-bg);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}
.btn-ghost:hover { border-color: var(--text-faint); color: var(--text); }

@media (prefers-reduced-motion: reduce) {
  .btn-discord, .btn-primary, .btn-ghost, input[type="submit"] { transition: none; }
}

/* ---- Guild list (/guilds) ------------------------------------------------ */
.guild-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.guild-list li {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
}
.guild-list img {
  border-radius: 8px;
  flex-shrink: 0;
}
.guild-list strong {
  flex: 1;
  font-weight: 600;
  color: var(--text);
}

/* ---- Dashboard cards (/guilds/:id) --------------------------------------- */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.dashboard-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.dashboard-card:hover {
  text-decoration: none;
  border-color: var(--glow-dim);
  box-shadow: 0 0 0 1px var(--glow-dim);
}
.dashboard-card h2 { color: var(--text); margin-bottom: 0.25rem; }
.dashboard-card p { margin: 0; font-size: 0.9rem; }

/* ---- First-time setup checklist (/guilds/:id) ---------------------------- */
.checklist-card {
  border: 1px solid var(--glow-dim);
  background: var(--glow-bg);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
}
.checklist-card h2 { color: var(--text); font-size: 1.05rem; margin-bottom: 0.9rem; }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.9rem; }
.checklist li { display: flex; gap: 0.75rem; align-items: flex-start; }
.checklist-mark {
  flex-shrink: 0;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--glow);
  margin-top: 0.1rem;
}
.checklist-done .checklist-mark { background: var(--glow); border-color: var(--glow); color: #0e0f14; }
.checklist-done strong, .checklist-done p { color: var(--text-faint); }
.checklist-body strong { color: var(--text); display: block; margin-bottom: 0.2rem; }
.checklist-body p { margin: 0 0 0.4rem; font-size: 0.88rem; color: var(--text-muted); }

/* ---- Command list (/guilds/:id/lum_scripts) ------------------------------ */
.command-list-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.command-search {
  flex: 1 1 220px;
  max-width: 320px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.5rem 0.8rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
}
.command-search:focus { outline: none; border-color: var(--glow-dim); box-shadow: 0 0 0 3px var(--glow-bg); }
.reference-search { display: block; max-width: 420px; margin: 0.5rem 0 1.5rem; }
.bulk-actions { display: flex; gap: 0.5rem; margin-left: auto; }
.bulk-actions form { display: inline; }

.script-category-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 2rem 0 0.5rem;
}
.script-category-header:first-of-type { margin-top: 1.5rem; }
.script-category-header[hidden] { display: none; } /* same [hidden] override issue as .script-list above */
.script-category {
  margin: 0;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}
.script-category-actions { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; }
.script-category-actions-sep { color: var(--text-faint); }
.btn-link {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
  text-decoration-color: transparent;
}
.btn-link:hover { color: var(--text); text-decoration-color: currentColor; }
.btn-link--danger:hover { color: var(--danger); }

.script-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.script-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1.1rem;
}
.script-list li.disabled { opacity: 0.55; }
/* Search filtering (lum_scripts/index.ejs) sets [hidden] on individual
   rows and on the whole <ul>. Without this, `display: flex` above wins
   over the browser's default [hidden] -> display:none, so a "hidden"
   row stays fully visible -- same gotcha already handled for
   .node-editor/.node-template elsewhere in this file. */
.script-list[hidden], .script-list li[hidden] { display: none; }
.script-list-info { min-width: 0; }
.script-list strong {
  font-family: var(--font-display);
  color: var(--glow);
  margin-right: 0.6rem;
}
.script-actions { display: flex; gap: 0.75rem; align-items: center; flex-shrink: 0; }
.script-actions form { display: inline; }
.script-actions button {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
}
.script-actions button:hover { color: var(--danger); }
.inline-toggle-form { display: inline-flex !important; }

.empty-state {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  margin-top: 1.5rem;
}

/* ---- Forms (script editor) ----------------------------------------------- */
.script-form { margin-top: 1.5rem; }
.field { margin-bottom: 1.25rem; }
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.field input[type="text"],
.field select,
.field textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.6rem 0.8rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
}
.field input[type="text"]:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--glow-dim);
  box-shadow: 0 0 0 3px var(--glow-bg);
}

.code-editor {
  font-family: var(--font-display) !important;
  font-size: 0.9rem !important;
  line-height: 1.6;
  background: #0e0f14 !important;
  color: #d7dae0;
  white-space: pre;
  tab-size: 4;
}

/* ---- Command editor: mode toggle + CodeMirror theme + node canvas ------- */

.editor-mode-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.editor-mode-header label { margin: 0; }

.mode-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem;
  background: var(--surface);
}
.mode-toggle-btn {
  border: none;
  background: transparent;
  color: var(--text-faint);
  font-family: var(--font-display);
  font-size: 0.8rem;
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
}
.mode-toggle-btn.is-active { background: var(--glow-bg); color: var(--glow); }

.guide-tabs { margin: 1.25rem 0 2rem; }
.guide-tabs a.mode-toggle-btn { text-decoration: none; display: inline-block; }

.validation-hint--error { color: var(--danger); }

/* CodeMirror theme, matching .code-editor's look so switching to it from
   a plain textarea (no-JS / CDN blocked fallback) doesn't jump. */
.CodeMirror {
  font-family: var(--font-display) !important;
  font-size: 0.9rem !important;
  line-height: 1.6;
  background: #0e0f14;
  color: #d7dae0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: auto;
}
.cm-s-lumen .CodeMirror-gutters { background: #0e0f14; border-right: 1px solid var(--border); }
.cm-s-lumen .CodeMirror-linenumber { color: var(--text-faint); }
.cm-s-lumen .CodeMirror-cursor { border-left: 1px solid var(--glow); }
.cm-s-lumen .cm-keyword { color: var(--glow); font-weight: 600; }
.cm-s-lumen .cm-builtin { color: #7ec8e3; }
.cm-s-lumen .cm-atom { color: var(--discord-blurple); }
.cm-s-lumen .cm-string { color: var(--success); }
.cm-s-lumen .cm-number { color: #d9a86c; }
.cm-s-lumen .cm-comment { color: var(--text-faint); font-style: italic; }
.cm-s-lumen .cm-variable { color: #d7dae0; }
.cm-s-lumen .cm-operator { color: #c9a0ff; }
.cm-error-line { background: var(--danger-bg); }

/* Node editor ("easy mode") */
.node-editor { display: flex; gap: 1rem; align-items: flex-start; }
.node-editor[hidden] { display: none; }
.node-palette {
  flex: 0 0 180px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  background: var(--surface);
}
.blocks-palette-label { font-size: 0.8rem; color: var(--text-faint); margin: 0 0 0.6rem; }
.node-palette-list { list-style: none; margin: 0 0 0.75rem; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.node-template {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}
.node-template:hover { border-color: var(--glow-dim); }
.node-template[hidden] { display: none; }
.node-palette .hint { margin: 0; }

.node-canvas-wrap {
  flex: 1 1 auto;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px) 0 0 / 24px 24px,
    #0e0f14;
  overflow: auto;
  max-height: 520px;
  /* NOT touch-action: none here -- that would also block touch-scrolling
     the canvas itself. Only the drag handles below (node headers, ports)
     opt out of default touch handling, via their own touch-action. */
}
.node-canvas { position: relative; min-width: 100%; min-height: 480px; }
.node-wires { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; }
.node-wire { fill: none; stroke: var(--glow-dim); stroke-width: 2; pointer-events: stroke; cursor: pointer; }
.node-wire:hover { stroke: var(--danger); }
.node-wire--pending { stroke: var(--text-faint); stroke-dasharray: 4 4; pointer-events: none; }

.node-box {
  position: absolute;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  font-size: 0.82rem;
}
.node-box--start { border-color: var(--glow-dim); }
.node-box-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  cursor: grab;
  background: var(--surface-raised);
  border-radius: var(--radius) var(--radius) 0 0;
  touch-action: none; /* dragging the node shouldn't also scroll the canvas */
}
.node-box-title { color: var(--text); font-size: 0.82rem; }
.node-remove { background: none; border: none; color: var(--text-faint); cursor: pointer; font-size: 0.85rem; padding: 0; }
.node-remove:hover { color: var(--danger); }
.node-box-body { padding: 0.6rem 0.65rem; display: flex; flex-direction: column; gap: 0.5rem; }
.node-box-body .hint { margin: 0; }

.block-field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.78rem; color: var(--text-muted); }
.block-field input,
.block-field textarea {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.35rem 0.5rem;
  font-family: var(--font-body);
  font-size: 0.82rem;
  resize: vertical;
}
.block-hint { font-size: 0.72rem; }

.node-port {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--glow);
  border: 2px solid #0e0f14;
  transform: translateY(-50%);
  cursor: crosshair;
  touch-action: none; /* dragging a wire shouldn't also scroll the canvas */
}
.node-port--in { left: -10px; background: var(--discord-blurple); }
.node-port--out { right: -10px; }

@media (max-width: 700px) {
  .node-editor { flex-direction: column; }
  .node-palette { flex: 0 0 auto; width: 100%; max-height: 220px; overflow-y: auto; }
  .node-canvas-wrap { width: 100%; max-height: 60vh; }
}

.checkbox-field { display: flex; align-items: center; gap: 0.5rem; }
.checkbox-field label { margin: 0; }

.hint { font-size: 0.82rem; color: var(--text-faint); margin-top: 0.4rem; }
.muted { color: var(--text-faint); }

/* ---- Settings page (/guilds/:id/settings) -------------------------------- */
.back-link { margin: 0 0 1rem; }
.back-link a { font-size: 0.9rem; }

.page-header { margin-bottom: 2rem; }
.page-header .eyebrow { margin-bottom: 0.35rem; }
.page-header h1 { color: var(--text); }

.settings-form { display: flex; flex-direction: column; gap: 1.5rem; }

.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.5rem 1.75rem;
}
.settings-section-header { margin-bottom: 1.1rem; }
.settings-section-header h2 {
  color: var(--text);
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}
.settings-section-header .hint { margin-top: 0; max-width: 56ch; }

.toggle-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-height: 320px;
  overflow-y: auto;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.25rem;
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row-label {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  font-size: 0.92rem;
  cursor: pointer;
  min-width: 0;
}
.toggle-row-text { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.toggle-row-text code { align-self: flex-start; }
.toggle-row-desc { font-size: 0.8rem; color: var(--text-faint); }

.role-swatch {
  display: inline-block;
  flex-shrink: 0;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  border: 1px solid var(--border);
}
.role-swatch--none { background: transparent; border-style: dashed; }

/* Custom toggle switch, built on a real (accessible) checkbox that's
   visually hidden but still keyboard/screen-reader operable. */
.switch { position: relative; display: inline-block; flex-shrink: 0; width: 2.4rem; height: 1.4rem; }
.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}
.switch-track {
  position: absolute;
  inset: 0;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.switch-track::before {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch input:checked ~ .switch-track { background: var(--glow-bg); border-color: var(--glow-dim); }
.switch input:checked ~ .switch-track::before { background: var(--glow); transform: translateX(1rem); }
.switch input:focus-visible ~ .switch-track { box-shadow: 0 0 0 3px var(--glow-bg); }

.prefix-row { display: flex; flex-direction: column; align-items: flex-start; gap: 0.4rem; }
.prefix-input {
  width: 5rem;
  text-align: center;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.5rem 0.6rem;
  font-family: var(--font-display);
  font-size: 1rem;
}
.prefix-input:focus {
  outline: none;
  border-color: var(--glow-dim);
  box-shadow: 0 0 0 3px var(--glow-bg);
}
.prefix-example { margin-top: 0; }
.prefix-example code { color: var(--glow); }

.channel-select {
  width: 100%;
  max-width: 320px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.6rem 0.8rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
}
.channel-select:focus {
  outline: none;
  border-color: var(--glow-dim);
  box-shadow: 0 0 0 3px var(--glow-bg);
}

.form-errors {
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.25rem;
  color: var(--danger);
  font-size: 0.9rem;
}
.form-errors ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* ---- Guide page (/guide) -------------------------------------------------- */
.guide { max-width: 720px; }
.guide h2 {
  color: var(--text);
  margin-top: 2.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.guide h2:first-of-type { border-top: none; margin-top: 1.5rem; }
.guide h3 { color: var(--text); margin-top: 1.5rem; }
.guide ul { color: var(--text-muted); padding-left: 1.3rem; }
.guide li { margin-bottom: 0.4rem; }
.guide p { color: var(--text-muted); }

/* Reference page wraps each section in its own <section> so search
   filtering can hide a whole section at once (see reference.ejs).
   That breaks .guide h2:first-of-type above, since every section's h2
   becomes the first (and only) h2 within its own parent; restore the
   same visual rule using the section boundary instead. */
.reference-section h2 { margin-top: 2.5rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.reference-section:first-child h2 { border-top: none; margin-top: 1.5rem; }

.guide-toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0 2.5rem;
}
.guide-toc strong {
  display: block;
  font-family: var(--font-display);
  color: var(--glow);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.6rem;
}
.guide-toc ol {
  margin: 0;
  padding-left: 1.2rem;
  columns: 2;
  column-gap: 2rem;
}
.guide-toc li { margin-bottom: 0.3rem; }
.guide-toc a { color: var(--text-muted); font-size: 0.92rem; }
.guide-toc a:hover { color: var(--glow); text-decoration: none; }

.guide-code {
  font-family: var(--font-display);
  font-size: 0.85rem;
  line-height: 1.6;
  background: #0e0f14;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  color: #d7dae0;
  margin: 0.75rem 0 1.25rem;
  white-space: pre;
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0 1.5rem;
  font-size: 0.9rem;
}
.guide-table th, .guide-table td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.8rem;
  text-align: left;
  vertical-align: top;
}
.guide-table th {
  background: var(--surface-raised);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.guide-table td { color: var(--text-muted); }
.guide-table td code, .guide li code, .guide p code { color: var(--glow); background: var(--surface-raised); }

@media (max-width: 600px) {
  .guide-toc ol { columns: 1; }
}
