/* =========================================================
   ZealPHP — Design System
   "Terminal Luxury" — precision of a well-configured terminal
   + confidence of a high-end engineering brand.
   Dark-first, monospace-forward, electric amber/gold accent.
   ========================================================= */

:root {
  --accent:       #f59e0b;
  --accent-dark:  #d97706;
  --accent-light: #fbbf24;
  --bg:           #ffffff;
  --bg-alt:       #faf9f7;
  --bg-dark:      #0c0a09;
  --text:         #1c1917;
  --text-muted:   #78716c;
  --border:       #e7e5e4;
  --nav-bg:       #0c0a09;
  --nav-text:     #e7e5e4;
  --code-bg:      #1a1412;
  --code-text:    #e7e5e4;
  --success:      #10b981;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --border-dark:  rgba(255,255,255,.08);
  --text-light:   #cbd5e1;
  --radius:       8px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --font:         'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:    'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
  --nav-w:        240px;
  --content-max:  1100px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scrollbar-gutter: stable; }
body {
  font-family: var(--font); color: var(--text); background: var(--bg);
  line-height: 1.65;
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--accent); }
img { max-width: 100%; display: block; }

/* ── Typography ── */
h1 { font-size: 2.5rem; font-weight: 800; line-height: 1.15; letter-spacing: -.04em; }
h2 { font-size: 1.5rem; font-weight: 700; line-height: 1.3; letter-spacing: -.02em; }
h3 { font-size: 1.15rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }
p  { max-width: 70ch; }

/* ── Layout: Shell ── */
.shell { display: flex; min-height: 100vh; }

/* ── Top Nav (horizontal) ── */
.topnav {
  position: sticky; top: 0; z-index: 100;
  background: var(--nav-bg);
  border-bottom: 1px solid rgba(245,158,11,.08);
  display: flex; align-items: center; gap: 0;
  padding: .5rem 1.5rem; min-height: 48px;
}
.topnav .logo {
  font-size: 1.1rem; font-weight: 800; color: #fff;
  display: flex; align-items: center; gap: 0;
  margin-right: 2rem; text-decoration: none;
  white-space: nowrap;
}
.topnav .logo span { color: var(--accent); }
.nav-links { display: flex; flex-direction: column; flex: 1; gap: 0; }
.nav-row { display: flex; gap: .1rem; align-items: center; flex-wrap: wrap; }
.nav-row-features { border-top: 1px solid rgba(245,158,11,.06); padding: .15rem 0; margin-top: .15rem; }
.nav-row a {
  color: #a8a29e; font-size: .75rem; font-weight: 500;
  padding: .35rem .55rem; border-radius: 5px;
  transition: color .15s, background .15s;
  white-space: nowrap;
}
.nav-row a:hover {
  color: var(--accent); text-decoration: none;
  background: rgba(245,158,11,.08);
}
.nav-row a.active {
  color: var(--accent); text-decoration: none;
  background: rgba(245,158,11,.1);
}
/* ── Mobile hamburger toggle ── */
.nav-toggle-input { display: none; }
.nav-toggle-btn { display: none; }
.topnav .actions { display: flex; gap: .5rem; margin-left: auto; }
.topnav .actions a {
  color: #a8a29e; font-size: .82rem; padding: .35rem .8rem;
  border: 1px solid rgba(245,158,11,.15); border-radius: 5px;
}
.topnav .actions a:hover { background: rgba(245,158,11,.06); text-decoration: none; color: var(--accent); }

/* GitHub star badge in the nav (extracted from inline styles in _nav.php). */
.gh-star-link { display: inline-flex; align-items: center; gap: .35rem; }
.gh-star-icon { color: #fbbf24; }
.gh-star-count { color: #fbbf24; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ── Alpha banner (sitewide maturity strip) ── */
.alpha-banner {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1.5rem; font-size: .85rem; font-weight: 600;
  background: #fbbf24;
  color: #422006;
  border-bottom: 1px solid #78350f;
}
.alpha-banner-tag {
  background: #422006; color: #fbbf24;
  padding: .15rem .55rem; border-radius: 4px;
  font-weight: 800; font-size: .72rem; letter-spacing: .05em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.alpha-banner-text { flex: 1; }
.alpha-banner a { color: #422006; text-decoration: underline; font-weight: 800; }
.alpha-banner a:hover { color: #1a1a1a; }
@media (max-width: 720px) {
  .alpha-banner { font-size: .76rem; padding: .5rem .75rem; gap: .5rem; }
}

/* ── Benchmark methodology line ── */
.bench-method {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: .72rem; color: #cbd5e1;
  background: rgba(15,23,42,.55);
  border: 1px solid rgba(245,158,11,.22);
  border-radius: 6px;
  padding: .55rem .85rem;
  margin: 2.5rem auto 1.75rem;
  max-width: 700px;
}
.bench-method strong { color: var(--accent); font-family: inherit; }
.bench-method a { color: var(--accent); text-decoration: none; }
.bench-method a:hover { text-decoration: underline; }

/* ── Page body ── */
.page-body { flex: 1; display: flex; flex-direction: column; }

/* ── Container ── */
.container { max-width: var(--content-max); margin: 0 auto; padding: 0 1.5rem; width: 100%; }

/* ── Section ── */
.section { padding: 3rem 0; }
.section + .section { border-top: 1px solid var(--border); }
.section-title { font-size: 1.6rem; font-weight: 800; margin-bottom: .4rem; }
.section-desc  { color: var(--text-muted); max-width: 60ch; margin-bottom: 2rem; }

/* ── Dark-themed section (matches the home hero aesthetic, used by /performance) ── */
.section.section-dark {
  background: linear-gradient(180deg, #0c0a09 0%, #1c1917 100%);
  color: #e7e5e4;
}
.section.section-dark .section-title { color: #fff; }
.section.section-dark .section-desc { color: #a8a29e; }
.section.section-dark h2 { color: #fff; }
.section.section-dark h3 { color: #fafaf9; }
.section.section-dark p,
.section.section-dark li { color: #d6d3d1; }
.section.section-dark a:not(.btn) { color: var(--accent); }
.section.section-dark a:not(.btn):hover { text-decoration: underline; }
.section.section-dark code {
  background: rgba(245,158,11,.08);
  color: #fde68a;
  padding: .1rem .3rem;
  border-radius: 3px;
}
.section.section-dark .ztable {
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(245,158,11,.12);
}
.section.section-dark .ztable th {
  background: rgba(245,158,11,.06);
  color: #fafaf9;
  border-bottom: 1px solid rgba(245,158,11,.18);
}
.section.section-dark .ztable td {
  color: #e7e5e4;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.section.section-dark .qs-block {
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(245,158,11,.14);
}
.section.section-dark .qs-block h3 { color: var(--accent); }
.section.section-dark .code-label {
  background: rgba(245,158,11,.12);
  color: #fde68a;
}

/* ── Problem section (home page, between hero and AI demo) ── */
.section.section-problem {
  background: var(--bg-alt);
  padding-top: 3.5rem;
  padding-bottom: 3.5rem;
  text-align: center;
}
.section.section-problem .section-title {
  font-size: 1.85rem;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 1.25rem;
}
.section.section-problem .section-desc {
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 1rem;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
}
.section.section-problem .section-problem-payoff {
  margin-top: 1.75rem;
  margin-bottom: 0;
  font-size: 1.05rem;
}
.section.section-problem .section-problem-payoff strong {
  color: var(--accent-dark);
}

/* ── Dark-background section (bg + own title/desc only; children keep their own styling) ── */
.section.section-darkbg {
  background: linear-gradient(180deg, #0c0a09 0%, #1c1917 100%);
}
.section.section-darkbg > .container > .section-title {
  color: #fff;
}
.section.section-darkbg > .container > .section-desc {
  color: #a8a29e;
}
.section.section-darkbg > .container > .section-desc strong {
  color: #fde68a;
}

/* ── Hero ── */
.hero {
  background: linear-gradient(135deg, #0c0a09 0%, #1c1917 50%, #292524 100%);
  color: #fff; padding: 5rem 1.5rem 4rem;
  text-align: center; position: relative; overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(245,158,11,.15) 0%, transparent 65%);
}
.hero::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-conic-gradient(#a8a29e11 0% 25%, transparent 0% 50%) 0 0 / 3px 3px;
  opacity: .4;
  pointer-events: none;
}
.hero h1 {
  font-size: clamp(2.5rem, 6.5vw, 4.5rem);
  color: #fff; position: relative; letter-spacing: -.04em;
  filter: drop-shadow(0 0 14px rgba(245, 158, 11, 0.22));
}
.hero h1 span { color: var(--accent); }
.hero p { font-size: 1.15rem; color: #a8a29e; margin: 1rem auto 2rem; position: relative; }
.hero p.home-hero-stamp { font-size: .8rem; color: #a8a29e; margin: 1rem auto .5rem; font-weight: 400; letter-spacing: .06em; text-transform: none; opacity: .8; }
.hero .cta { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; position: relative; }

/* ── Hero wordmark (electric) ── */
.zeal-mark {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}
.zeal-bolt {
  font-size: 1.25rem;
  color: var(--accent);
  filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.45));
  margin-bottom: 0.35rem;
  opacity: 0;
  transform: translateY(-4px) scale(0.92);
  animation: zeal-bolt-in 0.5s ease-out 0.15s 1 forwards;
}
@keyframes zeal-bolt-in {
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.hero h1::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  background: linear-gradient(
    100deg,
    transparent 30%,
    rgba(255, 255, 255, 0.85) 47%,
    rgba(251, 191, 36, 0.95) 50%,
    rgba(255, 255, 255, 0.85) 53%,
    transparent 70%
  );
  background-size: 250% 100%;
  background-position: 150% 0;
  -webkit-background-clip: text;
          background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  letter-spacing: -.04em;
  font-weight: 800;
  pointer-events: none;
  animation: zeal-sweep 1.6s cubic-bezier(.4, 0, .2, 1) 0.4s 1 forwards;
}
@keyframes zeal-sweep {
  0%   { background-position: 150% 0; }
  100% { background-position: -50% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .hero h1::after { display: none; }
  .zeal-bolt {
    opacity: 1;
    transform: none;
    animation: none;
  }
}
.oss-badges {
  display: flex;
  justify-content: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  position: relative;
}
.oss-badges a {
  display: inline-flex;
  line-height: 0;
}
.oss-badges img {
  display: block;
  height: 20px;
  width: auto;
}

/* ── Buttons ── */
/* Baseline: every <button> and <summary> is a click target → pointer. Kept at
   low specificity (element selector) so the intentional overrides still win:
   .btn:disabled / button:disabled → not-allowed, .htmx-request → progress.
   Without this, bare buttons that don't carry .btn (chat Send, notes Add note,
   the login/register submits, the copy buttons) fell back to the UA arrow. */
button, summary { cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .6rem 1.4rem; border-radius: 7px; font-size: .9rem; font-weight: 600;
  cursor: pointer; border: none; transition: all .15s; text-decoration: none !important;
}
.btn-primary { background: var(--accent); color: #0c0a09; }
.btn-primary:hover { background: var(--accent-dark); color: #0c0a09; }
.btn-outline { border: 1px solid rgba(245,158,11,.4); color: #fff; background: transparent; }
.btn-outline:hover { background: rgba(245,158,11,.1); border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: .35rem .9rem; font-size: .8rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
/* Leading icon inside a .btn — sized to the text, inherits button colour
 * via stroke:currentColor. The .btn flex gap handles spacing. */
.btn-icon { width: 1.05em; height: 1.05em; flex-shrink: 0; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-alt); }

/* ── Benchmark bar ── */
.bench-note {
  text-align: center;
  color: #a8a29e;
  font-size: .82rem;
  margin: 1.75rem auto .75rem;
  position: relative;
}
.bench {
  display: flex; gap: 2rem; justify-content: center; flex-wrap: wrap;
  padding: 1.5rem; background: rgba(245,158,11,.04); border-radius: var(--radius);
  margin: 0 auto 0; max-width: 700px; position: relative;
  border: 1px solid rgba(245,158,11,.08);
}
.bench-stat { text-align: center; }
.bench-stat .num { font-size: 1.8rem; font-weight: 800; color: var(--accent); line-height: 1; }
.bench-stat .label { font-size: .78rem; color: #78716c; margin-top: .15rem; }
.bench-stat .sub { font-size: .66rem; color: #64748b; margin-top: .25rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ── Feature grid ── */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-top: 2rem;
}

/* ── Cards ── */
.card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  box-shadow: var(--shadow); transition: box-shadow .25s, border-color .25s;
}
.card:hover {
  box-shadow: 0 0 0 1px rgba(245,158,11,.3), 0 4px 12px rgba(245,158,11,.08);
  border-color: rgba(245,158,11,.3);
}
.card-icon { font-size: 1.8rem; margin-bottom: .75rem; }
/* Anchor-card reset (was inline on <a class="card">) + badge spacing. */
.card-link-reset { display: block; color: inherit; text-decoration: none; }
.card-badge { margin-bottom: .5rem; }
.card h3 { margin-bottom: .4rem; }
.card p { font-size: .875rem; color: var(--text-muted); }
.card .card-link {
  display: inline-block; margin-top: 1rem; font-size: .82rem;
  font-weight: 600; color: var(--accent-dark);
}
.card .card-link:hover { color: var(--accent); }

/* ── Demo panel (code + live output split) ── */
.demo-panel {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin: 1.5rem 0; box-shadow: var(--shadow);
}
.demo-panel.full { grid-template-columns: 1fr; }
.demo-code {
  background: var(--code-bg); padding: 1.25rem;
  overflow-x: auto; border-right: 1px solid rgba(245,158,11,.06);
}
.demo-code pre { margin: 0; }
.demo-code code { font-family: var(--font-mono); font-size: .82rem; line-height: 1.6; }
.demo-output {
  background: var(--bg-alt); padding: 1.25rem;
  font-family: var(--font-mono); font-size: .82rem;
  /* Was 360px — too tight for widget demos (chatroom, notes, tictactoe).
     Bumped so full widgets fit without a nested scrollbar. JSON-payload
     callers still scroll past this point naturally. */
  min-height: 120px; max-height: min(720px, 80vh); overflow: auto;
  position: relative;
}
.demo-output .label {
  position: sticky; top: 0; float: right; margin-left: auto;
  font-size: .7rem; color: var(--text-muted); font-family: var(--font); text-transform: uppercase;
  background: var(--bg-alt); padding: .25rem .5rem; border-radius: 3px;
  z-index: 2;
}
.demo-output pre { white-space: pre-wrap; word-break: break-all; color: #1c1917; margin: 0; }
.demo-loading { color: var(--text-muted); font-style: italic; font-family: var(--font); }
.demo-run-btn {
  position: sticky; bottom: .25rem; float: right; margin: .5rem 0 0 .5rem;
  background: var(--accent); color: #0c0a09; border: none; cursor: pointer;
  padding: .3rem .8rem; border-radius: 5px; font-size: .78rem; font-weight: 600;
  z-index: 2;
}
.demo-run-btn:hover { background: var(--accent-dark); }

/* ── Code block (display only) ── */
.code-block {
  background: var(--code-bg); border-radius: var(--radius);
  padding: 1.25rem; overflow-x: auto; margin: 1rem 0;
}
.code-block pre { margin: 0; }
.code-block code { font-family: var(--font-mono); font-size: .82rem; line-height: 1.6; color: var(--code-text); }
.code-label {
  background: rgba(245,158,11,.08); color: #44403c; font-size: .76rem;
  padding: .25rem .7rem; border-radius: 4px 4px 0 0; font-family: var(--font-mono);
  display: inline-block; margin-bottom: -.1rem; font-weight: 500;
}

/* ── HTTP method badges ── */
.badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 4px;
  font-size: .72rem; font-weight: 700; letter-spacing: .04em; font-family: var(--font-mono);
}
.badge-get     { background: #d1fae5; color: #065f46; }
.badge-post    { background: #dbeafe; color: #1e40af; }
.badge-put     { background: #fef3c7; color: #92400e; }
.badge-patch   { background: #ede9fe; color: #5b21b6; }
.badge-delete  { background: #fee2e2; color: #991b1b; }
.badge-ws      { background: #ecfdf5; color: #047857; border: 1px solid #6ee7b7; }
.badge-sse     { background: #fdf4ff; color: #7e22ce; }
.badge-feature { background: #fef3c7; color: #92400e; }

/* ── Table ── */
.ztable { display: block; width: max-content; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: .875rem; margin: 1rem 0; }
.ztable th { background: var(--bg-alt); font-weight: 600; padding: .6rem 1rem; text-align: left; border-bottom: 2px solid var(--border); }
.ztable td { padding: .6rem 1rem; border-bottom: 1px solid var(--border); }
.ztable tr:last-child td { border-bottom: none; }
.ztable code { font-size: .8rem; background: var(--bg-alt); padding: .1rem .35rem; border-radius: 3px; font-family: var(--font-mono); }

/* ── Injection table (routing page) ── */
.inject-grid { display: grid; gap: 1.25rem; }
.inject-case { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.inject-case-header {
  background: var(--bg-alt); padding: .6rem 1rem;
  font-size: .82rem; font-weight: 600; display: flex; gap: .5rem; align-items: center;
  border-bottom: 1px solid var(--border);
}
.inject-case-body { display: grid; grid-template-columns: 1fr 1fr; }
.inject-case-body .demo-code { border-radius: 0; border-top: none; border-right: 1px solid var(--border); }
.inject-case-body .demo-output { border-radius: 0; }

/* ── Quick start ── */
.quickstart {
  background: var(--bg-dark); color: var(--code-text);
  border-radius: var(--radius); padding: 2rem;
  font-family: var(--font-mono); font-size: .875rem; line-height: 1.8;
  margin: 2rem 0;
}
.quickstart .comment { color: #78716c; }
.quickstart .cmd     { color: #50fa7b; }
.quickstart .php     { color: #ff79c6; }

/* ── Alert / callout ── */
.callout {
  padding: 1rem 1.25rem; border-radius: var(--radius);
  border-left: 4px solid var(--accent);
  background: #fffbeb; margin: 1rem 0;
  font-size: .875rem;
}
.callout.warn  { border-color: var(--warning); background: #fffbeb; }
.callout.info  { border-color: var(--accent);  background: #fffbeb; }

/* ── Footer ── */
footer {
  background: #1c1917; border-top: 1px solid #292524;
  padding: 2rem 1.5rem; margin-top: auto;
}
.footer-inner {
  max-width: var(--content-max); margin: 0 auto;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem;
}
.footer-brand { font-weight: 700; color: #e7e5e4; }
.footer-brand span { color: var(--accent); }
.footer-links { display: flex; gap: 1.5rem; }
.footer-links a { font-size: .85rem; color: #a8a29e; }
.footer-links a:hover { color: var(--accent); }
.footer-copy { font-size: .82rem; color: #78716c; }

/* ── WebSocket demo ── */
.ws-shell {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin: 1.5rem 0;
}
.ws-topbar {
  background: var(--bg); border-bottom: 1px solid var(--border);
  padding: .7rem 1rem; display: flex; align-items: center;
  justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.ws-status { display: inline-flex; align-items: center; gap: .45rem; font-size: .82rem; font-weight: 700; }
.ws-dot { width: .6rem; height: .6rem; border-radius: 50%; background: #a8a29e; display: inline-block; }
.ws-status[data-state="connecting"] .ws-dot { background: #f59e0b; }
.ws-status[data-state="open"] .ws-dot { background: #16a34a; }
.ws-status[data-state="error"] .ws-dot { background: #dc2626; }
.ws-meta { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; color: var(--text-muted); font-size: .78rem; }
.ws-meta code { background: var(--bg-alt); padding: .16rem .42rem; border-radius: 4px; color: var(--text); }
.ws-log {
  background: var(--code-bg); color: var(--code-text);
  font-family: var(--font-mono); font-size: .78rem;
  min-height: 200px; max-height: 300px; overflow-y: auto;
  padding: 1rem;
}
.ws-msg { padding: 2px 0; border-bottom: 1px solid rgba(245,158,11,.04); }
.ws-msg.sent { color: #58a6ff; }
.ws-msg.recv { color: #3fb950; }
.ws-msg.sys  { color: #78716c; font-style: italic; }
.ws-msg.err  { color: #f85149; }
.ws-quick {
  background: #faf9f7; border-top: 1px solid var(--border);
  padding: .6rem 1rem; display: flex; gap: .45rem; flex-wrap: wrap;
}
.ws-chip {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 5px; padding: .25rem .6rem; font-size: .78rem;
  cursor: pointer; font-weight: 600;
}
.ws-chip:hover { border-color: var(--accent); color: var(--accent); }
.ws-controls {
  background: var(--bg-alt); border-top: 1px solid var(--border);
  padding: .75rem 1rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
}
.ws-select {
  padding: .4rem .7rem; border: 1px solid var(--border);
  border-radius: 5px; font-size: .85rem; background: var(--bg);
  min-width: 14rem;
}
.ws-input {
  flex: 1; background: var(--bg); border: 1px solid var(--border);
  border-radius: 5px; padding: .4rem .7rem; font-size: .85rem; outline: none;
  min-width: 13rem;
}
.ws-input:focus { border-color: var(--accent); }
button:disabled { opacity: .55; cursor: not-allowed; }

/* ── Demo controls (button row above a demo output) ── */
.demo-controls {
  display: flex; gap: .5rem; flex-wrap: wrap;
  padding-top: 1rem; margin-bottom: .75rem;
}

/* ── Subsection heading inside a page section ── */
.subsection-title { margin: 2rem 0 .5rem; }

/* Standalone demo block — extra top margin when not inside .inject-grid */
.inject-case.is-standalone { margin-top: 1.5rem; }

/* ── SSE log ── */
.sse-log {
  background: var(--code-bg); color: var(--code-text);
  font-family: var(--font-mono); font-size: .78rem;
  min-height: 120px; max-height: 200px; overflow-y: auto;
  padding: 1rem; border-radius: var(--radius); border: 1px solid rgba(245,158,11,.06);
}
.sse-event { padding: 2px 0; border-bottom: 1px solid rgba(245,158,11,.04); }
.sse-event.open { color: #3fb950; }
.sse-event.tick { color: #58a6ff; }
.sse-event.done { color: #f78166; }

/* ── Tabs ── */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; gap: 0; }
.tab-btn {
  padding: .55rem 1.1rem; font-size: .85rem; font-weight: 500; cursor: pointer;
  border: none; background: none; border-bottom: 2px solid transparent;
  margin-bottom: -2px; color: var(--text-muted); transition: color .15s, border-color .15s;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .demo-panel { grid-template-columns: 1fr; }
  .demo-code { border-right: none; border-bottom: 1px solid var(--border); }
  .inject-case-body { grid-template-columns: 1fr; }
  h1 { font-size: 1.75rem; }
  .hero { padding: 3rem 1rem 2.5rem; }
  .bench { gap: 1rem; }
  .topnav { flex-wrap: wrap; height: auto; min-height: 56px; }
  .nav-toggle-btn {
    display: flex; flex-direction: column; gap: 4px; cursor: pointer;
    padding: .5rem; margin-left: auto; order: 2;
  }
  .nav-toggle-btn span {
    display: block; width: 20px; height: 2px; background: #a8a29e;
    transition: transform .2s, opacity .2s;
  }
  .nav-toggle-input:checked ~ .nav-toggle-btn span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
  .nav-toggle-input:checked ~ .nav-toggle-btn span:nth-child(2) { opacity: 0; }
  .nav-toggle-input:checked ~ .nav-toggle-btn span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }
  .nav-links {
    display: none; flex-direction: column; width: 100%;
    padding: .5rem 0; order: 3;
  }
  .nav-toggle-input:checked ~ .nav-links { display: flex !important; }
  .nav-row { flex-direction: column; gap: 0; }
  .nav-row-features { border-top: none; padding-top: 0; margin-top: 0; }
  .nav-links a { padding: .6rem 1rem; font-size: .85rem; }
  .topnav .actions { order: 1; margin-left: auto; }
}

/* ── Code copy button ── */
pre { position: relative; }
.code-copy {
  position: absolute; top: .4rem; right: .4rem;
  background: rgba(0,0,0,.4); color: #a8a29e;
  border: 1px solid rgba(255,255,255,.12); border-radius: 4px;
  padding: .15rem .5rem; font-size: .62rem; font-family: var(--font);
  cursor: pointer; transition: all .15s; opacity: 0;
  z-index: 5; line-height: 1.4;
}
pre:hover > .code-copy { opacity: 1; }
.code-copy:hover { color: #e7e5e4; border-color: rgba(255,255,255,.25); background: rgba(0,0,0,.6); }
.code-copy.copied { color: var(--success); border-color: var(--success); }
.code-compare-panel .code-copy {
  background: rgba(0,0,0,.06); color: #78716c;
  border-color: rgba(0,0,0,.12);
}
.code-compare-panel .code-copy:hover { background: rgba(0,0,0,.12); color: #1c1917; border-color: rgba(0,0,0,.2); }

/* ── Highlight.js overrides ── */
.hljs { background: transparent !important; padding: 0 !important; }

/* ── Hero Streaming Demo ── */
.hero-demo {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  max-width: 820px; margin: 2.5rem auto 0;
  border-radius: 10px; overflow: hidden;
  border: 1px solid rgba(245,158,11,.12);
  box-shadow: 0 8px 32px rgba(0,0,0,.4), 0 0 0 1px rgba(245,158,11,.06);
  position: relative; text-align: left;
}
.hero-demo-code {
  background: #0c0a09; padding: 1.5rem;
  font-family: var(--font-mono); font-size: .82rem;
  line-height: 1.7; color: #e7e5e4;
  border-right: 1px solid rgba(245,158,11,.08);
}
.hero-demo-code .code-label {
  display: block; margin-bottom: .75rem;
  font-family: var(--font-mono); font-size: .76rem;
  color: #a8a29e; font-weight: 500;
  background: transparent; padding: 0;
}
.hero-demo-output {
  background: #1c1917; padding: 1.5rem;
  font-family: var(--font); font-size: .88rem;
  color: #e7e5e4; display: flex; flex-direction: column;
  justify-content: flex-start;
  height: 220px; overflow-y: auto;
}
.hero-demo-output .code-label {
  display: block; margin-bottom: .75rem;
  font-family: var(--font-mono); font-size: .76rem;
  color: #a8a29e; font-weight: 500;
  background: transparent; padding: 0;
}
.hero-demo-output .stream-line {
  opacity: 0; animation: streamIn .3s forwards;
  line-height: 1.6;
}
@keyframes streamIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.hero-tagline {
  font-size: .88rem; color: #a8a29e; margin-top: 1.5rem;
  font-style: italic; position: relative;
}
@media (max-width: 768px) {
  .hero-demo { grid-template-columns: 1fr; max-width: 100%; }
  .hero-demo-code { border-right: none; border-bottom: 1px solid rgba(245,158,11,.08); }
}

/* ── Architecture Comparison ── */
.arch-compare {
  display: grid; grid-template-columns: 1fr auto 1fr;
  gap: 2rem; align-items: start; margin: 2rem 0;
}
.arch-box {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.5rem; background: var(--bg);
}
.arch-box.complex { border-color: #fca5a5; background: #fef2f2; }
.arch-box.simple { border-color: #86efac; background: #f0fdf4; }
.arch-box h3 { font-size: 1rem; margin-bottom: 1rem; }
.arch-node {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .75rem; margin: .35rem 0;
  border-radius: 6px; font-size: .82rem; font-weight: 500;
}
.arch-box.complex .arch-node {
  background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b;
}
.arch-box.simple .arch-node {
  background: #dcfce7; border: 1px solid #86efac; color: #166534;
}
.arch-vs {
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 800; color: var(--text-muted);
  align-self: center;
}
@media (max-width: 768px) {
  .arch-compare { grid-template-columns: 1fr; }
  .arch-vs { padding: .5rem 0; }
}

/* ── Code Comparison ── */
.code-compare {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; margin: 1.5rem 0;
}
.code-compare-panel {
  padding: 1.25rem; overflow-x: auto;
  background: var(--bg-alt);
}
.code-compare-panel:first-child {
  border-right: 1px solid var(--border);
}
.code-compare-panel .compare-label {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; margin-bottom: .75rem;
  display: flex; align-items: center; gap: .5rem;
  color: var(--text-muted);
}
/* <pre> inside the light-bg panel needs its OWN dark bg so the global
   hljs theme (monokai — palette designed for dark bg) lands on a dark
   canvas. Without this, .hljs's transparent bg bleeds the panel's
   light bg through and monokai's saturated tokens wash out. */
.code-compare-panel pre {
  margin: 0; font-size: .78rem; line-height: 1.6;
  background: var(--code-bg); border-radius: 6px;
  padding: .9rem 1rem;
}
.code-compare-panel code { font-family: var(--font-mono); }
.compare-verdict {
  font-size: .88rem; font-weight: 600; margin-top: 1rem;
  padding: .75rem 1rem; border-radius: 6px;
  background: #fef3c7; color: #92400e;
}
@media (max-width: 768px) {
  .code-compare { grid-template-columns: 1fr; }
  .code-compare-panel:first-child { border-right: none; border-bottom: 1px solid var(--border); }
}

/* ── Chat Widget ── */
.chat-widget {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; max-width: 700px; margin: 2rem auto;
  box-shadow: var(--shadow-md);
}
.chat-header {
  background: var(--bg-dark); color: #fff;
  padding: .75rem 1rem; font-size: .85rem; font-weight: 600;
  display: flex; justify-content: space-between; align-items: center;
}
.chat-header .chat-status {
  font-size: .72rem; font-weight: 400; color: #a8a29e;
}
.chat-messages {
  background: var(--bg); padding: 1rem;
  min-height: 220px; max-height: 360px; overflow-y: auto;
}
.chat-msg {
  margin-bottom: .75rem; display: flex; gap: .5rem;
}
.chat-msg.user { justify-content: flex-end; }
.chat-msg-bubble {
  max-width: 80%; padding: .6rem .9rem; border-radius: 12px;
  font-size: .85rem; line-height: 1.5;
}
.chat-msg.user .chat-msg-bubble {
  background: var(--accent); color: #0c0a09;
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant .chat-msg-bubble {
  background: var(--bg-alt); color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-msg.assistant .chat-msg-bubble code {
  background: rgba(0,0,0,.06); padding: .1rem .3rem;
  border-radius: 3px; font-size: .8rem;
}
.chat-msg.assistant .chat-msg-bubble p {
  margin: 0 0 .5rem 0;
}
.chat-msg.assistant .chat-msg-bubble p:last-child {
  margin-bottom: 0;
}
.chat-msg.assistant .chat-msg-bubble pre {
  background: var(--code-bg); color: var(--code-text);
  padding: .6rem .8rem; border-radius: 6px; overflow-x: auto;
  margin: .5rem 0; font-size: .78rem; line-height: 1.5;
}
.chat-msg.assistant .chat-msg-bubble pre:last-child {
  margin-bottom: 0;
}
.chat-msg.assistant .chat-msg-bubble pre code {
  background: none; padding: 0; border-radius: 0;
  font-size: inherit; color: inherit;
}
.chat-msg.assistant .chat-msg-bubble ul,
.chat-msg.assistant .chat-msg-bubble ol {
  margin: .4rem 0; padding-left: 1.3rem;
}
.chat-msg.assistant .chat-msg-bubble li {
  margin-bottom: .2rem;
}
.chat-msg.assistant .chat-msg-bubble li:last-child {
  margin-bottom: 0;
}
.chat-input-row {
  border-top: 1px solid var(--border);
  display: flex; padding: .5rem; gap: .5rem;
  background: var(--bg-alt);
}
.chat-input {
  flex: 1; border: 1px solid var(--border); border-radius: 8px;
  padding: .5rem .75rem; font-size: .85rem; outline: none;
  font-family: var(--font); resize: none;
}
.chat-input:focus { border-color: var(--accent); }
.chat-send {
  background: var(--accent); color: #0c0a09; border: none;
  border-radius: 8px; padding: .5rem 1rem; cursor: pointer;
  font-weight: 600; font-size: .85rem;
}
.chat-send:hover { background: var(--accent-dark); }
.chat-send:disabled { opacity: .5; cursor: not-allowed; }
.chat-source-toggle {
  padding: .5rem 1rem; background: var(--bg-alt);
  border-top: 1px solid var(--border);
  font-size: .78rem; color: var(--text-muted);
}
.chat-source-toggle a {
  cursor: pointer; font-weight: 600;
}
.chat-source {
  display: none; background: var(--code-bg); color: var(--code-text);
  padding: 1rem; font-family: var(--font-mono); font-size: .78rem;
  max-height: 300px; overflow: auto; line-height: 1.6;
}
.chat-source.open { display: block; }
.chat-source-tabs {
  display: flex; gap: 0; border-bottom: 1px solid rgba(245,158,11,.1);
  background: var(--code-bg);
}
.chat-source-tab {
  padding: .5rem 1rem; font-size: .75rem; font-weight: 600;
  background: none; border: none; color: #a8a29e; cursor: pointer;
  border-bottom: 2px solid transparent; font-family: var(--font);
}
.chat-source-tab:hover { color: #e7e5e4; }
.chat-source-tab.active {
  color: #fff; border-bottom-color: var(--accent);
}
.chat-src-panel {
  margin: 0 !important; border-radius: 0 !important;
}
.chat-typing {
  display: inline-flex; gap: 8px; align-items: center;
  padding: 8px 2px;
}
.chat-typing span {
  display: inline-block; width: 10px; height: 10px;
  background: var(--accent-light); border-radius: 50%;
  box-shadow: 0 0 8px rgba(251, 191, 36, .55);
  animation: chat-dot 1s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: .18s; }
.chat-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes chat-dot {
  0%, 80%, 100% { transform: translateY(0); opacity: .55; }
  40%          { transform: translateY(-6px); opacity: 1; }
}

/* ── Bold Claims ── */
.bold-claim {
  margin: 2.5rem 0; padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}
.bold-claim:last-child { border-bottom: none; }
.bold-claim h3 {
  font-size: 1.3rem; font-weight: 800; margin-bottom: .5rem;
}
.bold-claim > p {
  color: var(--text-muted); margin-bottom: 1.25rem;
}

/* ============================================================
 * Top-of-page htmx progress bar (NProgress / GitHub-docs pattern)
 * Animated via CSS transform; JS in _master.php toggles the class.
 * States: idle (default) → start → mid → done → idle
 * ============================================================ */
.htmx-progress {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 2px;
  background: linear-gradient(90deg, var(--accent, #f59e0b), #fbbf24);
  box-shadow: 0 0 8px rgba(245, 158, 11, .55);
  transform-origin: left center;
  transform: scaleX(0);
  opacity: 0;
  z-index: 9999;
  pointer-events: none;
  transition: transform .25s ease, opacity .15s ease;
}
.htmx-progress.start { opacity: 1; transform: scaleX(.30); transition-duration: .18s; }
.htmx-progress.mid   { opacity: 1; transform: scaleX(.75); transition: transform 1.4s cubic-bezier(.1,.6,.3,.95), opacity .15s; }
.htmx-progress.done  { opacity: 0; transform: scaleX(1.00); transition: transform .22s ease, opacity .25s .15s ease; }

/* htmx auto-adds the .htmx-request class to the triggering element while a
 * request is in flight. Subtle dim + progress cursor so the click target
 * acknowledges itself even before the response arrives. */
.htmx-request { opacity: .6; cursor: progress; transition: opacity .15s ease; }

/* Apache + mod_php parity reference section (template/pages/http.php#parity) */
.section-subtitle { font-size: 1.35rem; font-weight: 800; margin: 2.5rem 0 .5rem; padding-top: 1.5rem; border-top: 1px solid rgba(245,158,11,.18); }
.parity-group { font-size: 1.05rem; font-weight: 700; color: var(--accent-dark); margin: 1.5rem 0 .5rem; }
.parity-table td:nth-child(2) { white-space: nowrap; font-weight: 600; }

/* ==================================================================== */
/* /docs/ — narrative guides + auto-generated API reference              */
/* Layout reuses the learn-theme classes (learn-layout / learn-sidebar / */
/* lesson-content / lesson-header) — only the markdown-specific prose    */
/* styles + breadcrumb refinement live here.                             */
/* ==================================================================== */

/* Guide article — max-width caps line length for readability inside the
 * lesson-content shell that the learn theme already provides. */
.docs-guide { max-width: 760px; }
.docs-breadcrumbs {
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.docs-breadcrumbs a { color: var(--text-muted); }
.docs-breadcrumbs a:hover { color: var(--accent-dark); text-decoration: none; }
.docs-breadcrumbs .sep { margin: 0 .35rem; opacity: .5; }
.docs-breadcrumbs .current { color: var(--text); font-weight: 600; }

/* Markdown prose */
.docs-markdown {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
}
.docs-markdown h1 {
  font-size: 2.1rem;
  letter-spacing: -.02em;
  margin: 0 0 1rem;
  padding-bottom: .4rem;
  border-bottom: 2px solid var(--border);
}
.docs-markdown h2 {
  font-size: 1.5rem;
  margin: 2.2rem 0 .6rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  letter-spacing: -.01em;
}
/* Drop the h2's own top border (a redundant divider) when it directly
 * follows another rule: an <hr> (markdown `---`) OR the page <h1>, whose
 * border-bottom already draws a line. Without this, a guide that opens
 * "# Title" then "## Section" — i.e. most of them — shows two stacked
 * rules at the top that read as a double <hr>. */
.docs-markdown hr + h2,
.docs-markdown h1 + h2 { border-top: 0; padding-top: 0; margin-top: .6rem; }
.docs-markdown h3 { font-size: 1.15rem; margin: 1.6rem 0 .4rem; }
.docs-markdown h4 { font-size: 1rem; margin: 1.2rem 0 .3rem; color: var(--text-muted); }
.docs-markdown p { margin: 0 0 1rem; }
.docs-markdown a { color: var(--accent-dark); text-decoration: underline; text-decoration-color: rgba(245,158,11,.35); text-underline-offset: 2px; }
.docs-markdown a:hover { text-decoration-color: var(--accent); }
.docs-markdown ul, .docs-markdown ol { margin: 0 0 1.1rem; padding-left: 1.5rem; }
.docs-markdown li { margin: .25rem 0; }
.docs-markdown li > p { margin-bottom: .35rem; }
.docs-markdown strong { font-weight: 700; color: var(--text); }

/* Inline code */
.docs-markdown code {
  font-family: var(--font-mono);
  font-size: .88em;
  background: rgba(245,158,11,.08);
  border: 1px solid rgba(245,158,11,.18);
  padding: .08em .35em;
  border-radius: 4px;
  color: var(--accent-dark);
}

/* Code blocks */
.docs-markdown pre {
  background: var(--code-bg);
  color: #e7e5e4;
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: 1rem 0 1.5rem;
  overflow-x: auto;
  font-size: .88rem;
  line-height: 1.55;
  border: 1px solid #2a201d;
}
.docs-markdown pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Tables */
.docs-markdown table {
  /* Responsive: size to content but cap at the container width and scroll
   * horizontally instead of overflowing the page (esp. on mobile). The
   * display:block + width:max-content + overflow-x:auto trio is the
   * standard GitHub-markdown approach — the row/cell display values keep
   * the table layout intact inside the scrollable block. */
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: .93rem;
}
.docs-markdown th, .docs-markdown td {
  text-align: left;
  padding: .55rem .8rem;
  border-bottom: 1px solid var(--border);
}
.docs-markdown th {
  background: var(--bg-alt);
  font-weight: 700;
  border-bottom-width: 2px;
}
.docs-markdown tr:hover td { background: rgba(245,158,11,.02); }

/* Blockquotes */
.docs-markdown blockquote {
  border-left: 3px solid var(--accent);
  background: rgba(245,158,11,.04);
  padding: .8rem 1.1rem;
  margin: 1rem 0;
  color: var(--text);
  border-radius: 0 4px 4px 0;
}
.docs-markdown blockquote p:last-child { margin-bottom: 0; }

/* HR */
.docs-markdown hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

/* Footer (under guide). Override the global dark `footer {}` rule —
 * this is an in-content footer, not the site chrome footer. */
.docs-foot {
  background: transparent;
  border-top: 1px solid var(--border);
  margin: 3rem 0 0;
  padding: 1rem 0 0;
  font-size: .85rem;
  color: var(--text-muted);
}
.docs-foot p { color: var(--text-muted); margin: 0; }
.docs-foot a { color: var(--accent-dark); }
.docs-foot a:hover { color: var(--accent); }

/* api-missing fallback — same prose treatment but no sidebar */
.docs-landing pre {
  background: var(--code-bg);
  color: #e7e5e4;
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin: 1rem 0 1.5rem;
  overflow-x: auto;
  font-size: .88rem;
  line-height: 1.55;
}
.docs-landing code {
  font-family: var(--font-mono);
  font-size: .88em;
  background: rgba(245,158,11,.08);
  border: 1px solid rgba(245,158,11,.18);
  padding: .08em .35em;
  border-radius: 4px;
  color: var(--accent-dark);
}
.docs-landing pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
}

/* Curated API index — grouped class grid (template/pages/docs/api-index.php) */
.api-index { margin-top: 1.5rem; }
.api-index-group { margin-bottom: 2rem; }
.api-index-group-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 .75rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: -.01em;
}
.api-index-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: .4rem;
}
.api-index-link {
  display: block;
  padding: .5rem .7rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  text-decoration: none;
  background: var(--bg);
  transition: border-color .15s, background .15s;
}
.api-index-link:hover {
  border-color: rgba(245,158,11,.45);
  background: rgba(245,158,11,.05);
  text-decoration: none;
}
.api-index-link code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: .82rem;
  color: var(--accent-dark);
}
.api-index-link:hover code { color: var(--accent-dark); }

/* ====================================================================
 * API SEARCH — htmx-powered inline suggestions at the top of every
 * /docs/api/ page. The <input> debounces input events and GETs
 * /api/docs/search?q=…, which returns an HTML fragment that htmx swaps
 * into #api-search-results. The empty :empty selector hides the
 * dropdown when there's nothing to show.
 * ==================================================================== */

.api-search,
.lesson-content > .api-search,
.lesson-content .api-search {
  position: relative !important;
  display: block;
  margin: .5rem 0 1.75rem;
  isolation: isolate;
}
.api-search-icon {
  position: absolute;
  top: 50%;
  left: .85rem;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
  z-index: 2;
}
input.api-search-input,
.api-search input.api-search-input {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: .7rem 5rem .7rem 2.6rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: .95rem;
  line-height: 1.3;
  transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-appearance: none;
  appearance: none;
}
input.api-search-input::placeholder {
  color: var(--text-muted);
}
input.api-search-input:focus {
  outline: 0;
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0 0 4px rgba(245,158,11,.12);
}
input.api-search-input::-webkit-search-cancel-button { -webkit-appearance: none; }

.api-search-hint {
  position: absolute;
  top: 50%;
  right: .85rem;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: .68rem;
  color: var(--text-muted);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .1rem .4rem .15rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
}
.api-search:focus-within .api-search-hint { opacity: 1; }

/* Spinner — htmx adds .htmx-request to the input while a request is
 * in flight; show the spinner then. */
.api-search-spinner {
  position: absolute;
  top: 50%;
  right: 3.6rem;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border: 2px solid rgba(245,158,11,.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
}
.api-search-spinner.htmx-request { opacity: 1; animation: api-search-spin .8s linear infinite; }
@keyframes api-search-spin { to { transform: translateY(-50%) rotate(360deg); } }

/* Dropdown results panel. Sits absolutely under the input; CSS `:empty`
 * hides it when there are no results, so the dropdown only appears
 * after the user has typed something. */
.api-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.04);
  max-height: 60vh;
  overflow-y: auto;
  /* Keep wheel/touch scrolling inside the dropdown — without this the
   * scroll chains to the page once the list hits its top/bottom edge
   * (or whenever the cursor is over it), so the whole page moves
   * instead of the results. */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  z-index: 50;
  scrollbar-width: thin;
}
.api-search-results:empty { display: none; }

.api-search-empty {
  padding: 1rem 1.25rem;
  font-size: .92rem;
  color: var(--text-muted);
}
.api-search-empty code {
  font-family: var(--font-mono);
  color: var(--accent-dark);
  background: rgba(245,158,11,.08);
  border: 1px solid rgba(245,158,11,.18);
  padding: .08em .35em;
  border-radius: 4px;
}

.api-search-list { list-style: none; padding: .3rem 0 .4rem; margin: 0; }

.api-search-group .api-search-kind {
  display: block;
  margin: 0;
  padding: .7rem .9rem .25rem;
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-muted);
  font-weight: 700;
  font-family: var(--font);
}
.api-search-group:first-child .api-search-kind { padding-top: .35rem; }

.api-search-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "name parent" "summary parent";
  gap: 0 .75rem;
  padding: .5rem .9rem;
  color: var(--text);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background .1s, border-color .1s;
}
.api-search-item:hover,
.api-search-item:focus {
  background: rgba(245,158,11,.06);
  border-left-color: var(--accent);
  outline: 0;
  text-decoration: none;
}
.api-search-item .api-search-name {
  grid-area: name;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: .88rem;
  color: var(--accent-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.api-search-item .api-search-parent {
  grid-area: parent;
  align-self: center;
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--text-muted);
  background: var(--bg-alt);
  padding: .12rem .45rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.api-search-item .api-search-summary {
  grid-area: summary;
  font-size: .78rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: .12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

/* ==========================================================================
   Contacts-list fragment demo (template/demos/contacts-list.php)
   Extracted from the inline <style> block that lived in that demo partial
   (separation-of-concerns refactor). Lives here because the fragment renders
   inside a full page rather than a standalone document; all rules are scoped
   under .contacts-fragment-demo so they can't leak into other components.
   ========================================================================== */
.contacts-fragment-demo .contact-list { list-style: none; padding: 0; margin: 0;
    border: 1px solid var(--border, #e7e5e4); border-radius: 8px; overflow: hidden; background: #fff; }
.contacts-fragment-demo .contact-row { display: flex; align-items: center; justify-content: space-between;
    padding: .75rem 1rem; border-bottom: 1px solid var(--border, #e7e5e4); gap: 1rem; }
.contacts-fragment-demo .contact-row:last-child { border-bottom: 0; }
.contacts-fragment-demo .contact-row.expanded { background: #fffbeb; }
.contacts-fragment-demo .contact-info { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.contacts-fragment-demo .contact-name { font-weight: 600; color: #1c1917; }
.contacts-fragment-demo .contact-role { color: #78716c; font-size: .8rem; }
.contacts-fragment-demo .contact-email { font-family: ui-monospace, monospace; font-size: .78rem; color: #57534e; margin-top: .3rem; }
.contacts-fragment-demo .toggle-btn { background: #fff; color: #b45309; border: 1px solid #fcd34d; padding: .3rem .7rem;
    border-radius: 4px; cursor: pointer; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.contacts-fragment-demo .toggle-btn:hover { background: #fef3c7; }
.contacts-fragment-demo .htmx-indicator { display: none; color: #78716c; font-size: .75rem; margin-left: .35rem; }
.contacts-fragment-demo .htmx-request .htmx-indicator { display: inline; }
