/* spaghetti-code-foundry.com — one stylesheet, no web fonts. Colours follow the app (ui/tokens.css). */
:root {
  color-scheme: light dark;
  --bg: #f6f6f4; --surface: #ffffff; --border: #e2e0db; --text: #1d1c1a; --muted: #6d6a64;
  --accent: #c2410c; --accent-strong: #9a3412; --accent-soft: #fdeee6; --code-bg: #f1efea; --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 8px 24px rgb(0 0 0 / .06);
  --radius: 10px; --wrap: 1180px; --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #141412; --surface: #1c1c1a; --border: #33322e; --text: #ecebe7; --muted: #a29f96; --accent: #f08a50; --accent-strong: #f6a877; --accent-soft: #3a2418; --code-bg: #232320; --shadow: 0 1px 2px rgb(0 0 0 / .4); }
}
:root[data-theme="dark"] { --bg: #141412; --surface: #1c1c1a; --border: #33322e; --text: #ecebe7; --muted: #a29f96; --accent: #f08a50; --accent-strong: #f6a877; --accent-soft: #3a2418; --code-bg: #232320; --shadow: 0 1px 2px rgb(0 0 0 / .4); }

* { box-sizing: border-box; }
html { scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 var(--font); }
img { max-width: 100%; height: auto; }
a { color: var(--accent-strong); text-underline-offset: 2px; }
:root:not([data-theme="light"]) a { color: var(--accent); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) a { color: var(--accent-strong); } }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
code, pre { font-family: var(--mono); font-size: .9em; }
:not(pre) > code { background: var(--code-bg); padding: .1em .35em; border-radius: 5px; overflow-wrap: anywhere; }
pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 72px 14px 16px; overflow-x: auto; line-height: 1.5; position: relative; }
pre .copy { position: absolute; top: 8px; right: 8px; font: 12px var(--font); padding: 3px 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; cursor: pointer; opacity: .85; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 820px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* header */
.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.header-row { display: flex; align-items: center; gap: 18px; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text) !important; text-decoration: none; white-space: nowrap; }
.logo { color: var(--accent); font-size: 1.15em; }
.brand-short { display: none; }
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav a { color: var(--text) !important; text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 15px; }
.site-nav a:hover, .site-nav a[aria-current="page"] { background: var(--accent-soft); }
.search { position: relative; margin-left: auto; }
.search input { width: 220px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
.search-results { position: absolute; right: 0; top: 42px; width: min(440px, 90vw); max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; }
.search-results a { display: block; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--text) !important; }
.search-results a:hover, .search-results a.active { background: var(--accent-soft); }
.search-results small { display: block; color: var(--muted); }
.search-results p { margin: 8px 10px; color: var(--muted); }
.theme-toggle, .menu-toggle { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit; }
.menu-toggle { display: none; }

/* home */
.hero { padding: 56px 0 40px; }
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 40px; align-items: center; }
.hero-grid > *, .split > *, .doc-layout > * { min-width: 0; }
.eyebrow { color: var(--accent-strong); font-weight: 600; font-size: 14px; letter-spacing: .02em; margin: 0 0 10px; }
.hero h1 { font-size: clamp(30px, 4.4vw, 50px); line-height: 1.1; margin: 0 0 16px; letter-spacing: -.02em; }
.hero-lead { font-size: 19px; color: var(--muted); margin: 0 0 24px; }
.cta { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 22px; }
.button { display: inline-block; padding: 10px 16px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text) !important; text-decoration: none; font-weight: 600; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff !important; }
:root[data-theme="dark"] .button.primary { color: #1a0d05 !important; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .button.primary { color: #1a0d05 !important; } }
.button.ghost { background: transparent; }
.button:hover { filter: brightness(1.05); border-color: var(--accent); }
.hero-code { font-size: 14px; }
figure { margin: 0; }
figure img, .doc img { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
figcaption { color: var(--muted); font-size: 14px; margin-top: 8px; }
section { padding: 56px 0; }
section h2 { font-size: clamp(24px, 3vw, 32px); margin: 0 0 24px; letter-spacing: -.01em; }
.band { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.steps { list-style: none; counter-reset: s; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.steps li { counter-increment: s; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.steps li::before { content: counter(s); display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; margin-bottom: 10px; }
.steps strong { display: block; margin-bottom: 6px; }
.steps span { color: var(--muted); font-size: 15px; }
.features { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.features li { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.features h3 { margin: 0 0 8px; font-size: 18px; }
.features p { margin: 0; color: var(--muted); font-size: 15px; }
.more { margin-top: 22px; font-weight: 600; }
.split { display: grid; grid-template-columns: 1fr 1.1fr; gap: 40px; align-items: center; }
.cards { list-style: none; padding: 0; margin: 0 0 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.cards a { display: block; height: 100%; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-decoration: none; color: var(--text) !important; }
.cards a:hover { border-color: var(--accent); }
.cards strong { display: block; margin-bottom: 4px; }
.cards span { color: var(--muted); font-size: 14.5px; }
.faq details { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); margin-bottom: 10px; padding: 0 16px; }
.faq summary { cursor: pointer; padding: 14px 0; font-weight: 600; }
.faq details > div { padding-bottom: 6px; color: var(--muted); }
.final-cta { text-align: center; }
.final-cta .cta { justify-content: center; }

/* docs */
.doc-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr) 220px; gap: 36px; padding-top: 28px; padding-bottom: 56px; }
.doc-layout.no-side { grid-template-columns: minmax(0, 1fr) 220px; }
.side-wrap > summary { display: none; }
.side-wrap { position: sticky; top: 80px; align-self: start; }
.side-wrap .side-nav { position: static; }
.side-nav, .toc { position: sticky; top: 80px; align-self: start; max-height: calc(100vh - 100px); overflow: auto; font-size: 14px; }
.side-nav h2, .toc h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 8px; }
.side-nav ol, .toc ol { list-style: none; margin: 0; padding: 0; }
.side-nav li { margin: 1px 0; }
.side-nav ol ol { padding-left: 12px; border-left: 1px solid var(--border); margin: 2px 0 6px 8px; }
.side-nav a, .toc a { display: block; padding: 4px 8px; border-radius: 6px; color: var(--text) !important; text-decoration: none; }
.side-nav a:hover, .toc a:hover { background: var(--accent-soft); }
.side-nav a[aria-current="page"] { background: var(--accent-soft); font-weight: 600; color: var(--accent-strong) !important; }
.toc .toc-3 a { padding-left: 18px; color: var(--muted) !important; }
.toc a.active { color: var(--accent-strong) !important; font-weight: 600; }
.doc { min-width: 0; }
.doc h1 { font-size: clamp(28px, 3.4vw, 38px); line-height: 1.2; margin: 6px 0 14px; letter-spacing: -.015em; }
.doc .lead { font-size: 19px; color: var(--muted); }
.doc h2 { font-size: 25px; margin: 2.1em 0 .6em; padding-top: .3em; border-top: 1px solid var(--border); }
.doc h3 { font-size: 20px; margin: 1.8em 0 .5em; }
.doc h4 { font-size: 17px; margin: 1.6em 0 .4em; }
.doc h5, .doc h6 { font-size: 15.5px; margin: 1.4em 0 .4em; }
.doc .anchor { margin-left: 8px; color: var(--muted) !important; text-decoration: none; opacity: 0; font-weight: 400; }
.doc :is(h2, h3, h4, h5, h6):hover .anchor, .doc .anchor:focus { opacity: 1; }
.doc blockquote { margin: 1.2em 0; padding: 4px 16px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.table-wrap { overflow-x: auto; margin: 1.2em 0; border: 1px solid var(--border); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; vertical-align: top; padding: 9px 12px; border-bottom: 1px solid var(--border); }
th { background: var(--surface); font-weight: 650; }
tr:last-child td { border-bottom: 0; }
td code, th code { white-space: nowrap; overflow-wrap: normal; }
td:first-child { min-width: 9em; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0; font-size: 14px; color: var(--muted); }
.crumbs li + li::before { content: "›"; margin-right: 6px; }
.crumbs a { color: var(--muted) !important; }
.chapter-list { padding-left: 1.4em; }
.chapter-list li { margin: 10px 0; }
.chapter-list a { font-weight: 600; }
.chapter-list span { display: block; color: var(--muted); font-size: 15px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 40px; }
.pager a { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; background: var(--surface); }
.pager a span { display: block; font-size: 13px; color: var(--muted); }
.pager .next { text-align: right; grid-column: 2; }
.edit { margin-top: 32px; font-size: 14px; }
.howto-cards span { display: block; }

/* footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 40px 0; font-size: 15px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 30px; }
.footer-grid h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 4px 0 10px; }
.footer-grid a:not(.brand) { display: block; color: var(--text) !important; text-decoration: none; margin: 4px 0; }
.footer-grid a:hover { text-decoration: underline; }
.footer-grid p { color: var(--muted); }

/* narrower screens */
@media (max-width: 1100px) {
  .doc-layout { grid-template-columns: 230px minmax(0, 1fr); }
  .doc-layout.no-side { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
  .features { grid-template-columns: repeat(2, 1fr); }
  .steps { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .header-row { flex-wrap: wrap; gap: 10px; padding-top: 8px; padding-bottom: 8px; }
  .menu-toggle { display: inline-block; margin-left: auto; }
  .site-nav { display: none; width: 100%; flex-direction: column; }
  .site-nav.open { display: flex; }
  .search { margin-left: 0; flex: 1; }
  .search input { width: 100%; }
  .hero-grid, .split { grid-template-columns: 1fr; }
  .doc-layout { grid-template-columns: minmax(0, 1fr); }
  .side-wrap { position: static; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
  .side-wrap > summary { display: block; cursor: pointer; padding: 10px 14px; font-weight: 600; }
  .side-nav { max-height: none; padding: 0 10px 8px; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  body { font-size: 15.5px; }
  .brand-full { display: none; }
  .brand-short { display: inline; }
  .features, .steps { grid-template-columns: 1fr; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
  section { padding: 40px 0; }
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
@media print { .site-header, .site-footer, .side-nav, .toc, .pager, .edit { display: none; } .doc-layout { display: block; } }

/* diagrams (mermaid, drawn in the browser) */
.diagram { margin: 1.4em 0; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow-x: auto; text-align: center; }
.diagram svg { max-width: none; height: auto; }
