:root {
  --text: #222;
  --muted: #666;
  --background: #fff;
  --soft: #f6f6f4;
  --border: #d9d9d4;
  --link: #245b45;
  --heading: #1e1e1e;
  --node-border: #8ea99d;
  --node-bg: #fff;
  --frame-bg: #fbf6ec;
  --glow: none;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --text: #e4e4df;
  --muted: #a0a099;
  --background: #16181a;
  --soft: #202325;
  --border: #34383a;
  --link: #7fd1a8;
  --heading: #f2f2ee;
  --node-border: #4d6a5d;
  --node-bg: #202325;
  --frame-bg: #202325;
  color-scheme: dark;
}

:root[data-theme="neon"] {
  --text: #dff6ff;
  --muted: #9a8fd0;
  --background: #070a1f;
  --soft: #110b2e;
  --border: #4a1d96;
  --link: #19e6e6;
  --heading: #a855f7;
  --accent-pink: #ff2bd6;
  --accent-lime: #c6ff3d;
  --accent-red: #ff2a3d;
  --node-border: #19e6e6;
  --node-bg: #110b2e;
  --frame-bg: #110b2e;
  --glow: 0 0 8px rgba(168, 85, 247, 0.8), 0 0 24px rgba(168, 85, 247, 0.45);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  padding-bottom: 64px;
  background: var(--background);
  color: var(--text);
  font: 17px/1.7 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--link);
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

h1,
h2,
h3,
h4 {
  margin-top: 0;
  color: var(--heading);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 400;
  line-height: 1.25;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.1rem, 6vw, 3.6rem);
}

h2 {
  font-size: clamp(1.7rem, 4vw, 2.4rem);
}

h3 {
  margin-bottom: 12px;
  font-size: 1.55rem;
}

h4 {
  margin-bottom: 4px;
  font-size: 1.08rem;
}

p {
  margin: 0 0 1.15em;
}

code {
  font-size: 0.9em;
}

.page,
.wrap {
  width: min(820px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header,
.concept-header {
  padding: 54px 0 38px;
  border-bottom: 1px solid var(--border);
}

.site-header p,
.lede {
  max-width: 650px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

main {
  padding: 48px 0 90px;
}

.toc {
  margin-bottom: 76px;
  border: 1px solid var(--border);
  padding: 26px 30px;
  background: var(--soft);
}

.toc h2 {
  margin-bottom: 12px;
  font-size: 1.35rem;
}

.toc ol {
  margin: 0;
  padding-left: 24px;
}

.toc li + li {
  margin-top: 6px;
}

.concept {
  scroll-margin-top: 24px;
}

.concept-title {
  margin-bottom: 54px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 30px;
}

.concept-title h2 {
  margin-bottom: 12px;
}

.concept-title > p:last-child {
  max-width: 700px;
  color: var(--muted);
  font-size: 1.05rem;
}

.category,
.eyebrow {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.concept section,
.prose section {
  margin: 0 0 56px;
}

.concept section + section {
  border-top: 1px solid var(--border);
  padding-top: 48px;
}

.concept h4:not(:first-of-type) {
  margin-top: 30px;
}

.diagram {
  margin: 24px 0 16px;
  overflow-x: auto;
  border: 1px solid var(--border);
  padding: 26px 18px;
  background: var(--soft);
}

.flow {
  display: flex;
  min-width: 650px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 24px 0;
}

.node {
  min-width: 105px;
  border: 1px solid var(--node-border);
  padding: 11px 13px;
  background: var(--node-bg);
  text-align: center;
}

.arrow {
  color: var(--muted);
  font-size: 1.2rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--soft);
  font-weight: 400;
}

ul,
ol {
  padding-left: 24px;
}

li + li {
  margin-top: 8px;
}

.back-link {
  margin-top: 72px;
  border-top: 1px solid var(--border);
  padding-top: 24px;
}

footer {
  border-top: 1px solid var(--border);
  padding: 30px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

footer p {
  margin-bottom: 4px;
}

/* Compatibility for the standalone concept template and example page. */
.breadcrumb {
  margin-bottom: 22px;
  font-size: 0.9rem;
}

.concept-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 30px;
}

.prose {
  max-width: 760px;
}

.prose h2 {
  margin: 2em 0 0.6em;
  font-size: 1.7rem;
}

.meta {
  border-left: 3px solid var(--border);
  padding: 20px;
  background: var(--soft);
}

.meta dl {
  margin: 0;
}

.meta dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
  text-transform: uppercase;
}

.meta dd {
  margin: 2px 0 15px;
}

.callout {
  margin: 26px 0;
  padding: 18px 20px;
  background: var(--soft);
}

@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  .site-header,
  .concept-header {
    padding-top: 40px;
  }

  main {
    padding-top: 34px;
  }

  .toc {
    margin-bottom: 56px;
    padding: 20px;
  }

  .concept-title {
    margin-bottom: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}


.concept + .concept {
  margin-top: 96px;
  border-top: 2px solid var(--border);
  padding-top: 72px;
}

.site-nav {
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  font-size: 0.9rem;
}

.site-nav .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
}

.site-nav a {
  text-decoration: none;
  color: var(--muted);
}

.site-nav a:hover { color: var(--text); }
.site-nav .home { color: var(--text); font-weight: 500; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 72px;
}

.card {
  border: 1px solid var(--border);
  padding: 24px 28px;
  background: var(--soft);
  text-decoration: none;
  color: inherit;
  display: block;
}

.card:hover { border-color: var(--link); }
.card h3 { margin: 0 0 6px; font-size: 1.15rem; font-family: Georgia, serif; font-weight: 400; }
.card p { margin: 0; color: var(--muted); font-size: 0.92rem; }

.concept-frame {
  display: block;
  width: 100%;
  min-height: 1200px;
  border: 0;
  background: var(--frame-bg);
}

.source-links {
  margin-top: 24px;
  text-align: center;
}

@media (max-width: 600px) {
  .concept + .concept {
    margin-top: 72px;
    padding-top: 54px;
  }

  .concept-frame {
    min-height: 1800px;
  }

  .source-links span {
    display: none;
  }

  .source-links a {
    display: block;
    margin-top: 8px;
  }
}

/* Theme switcher: fixed bottom right */
.theme-switch {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10;
  display: flex;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  background: var(--background);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.theme-switch button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 4px 12px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.theme-switch button:hover { color: var(--text); }

.theme-switch button[aria-pressed="true"] {
  border-color: var(--link);
  color: var(--link);
}

/* Cyberphunk neon: HUD look (fonts are loaded by theme.js) */
:root[data-theme="neon"] {
  --accent-pink: #ff3fb4;
  --soft: #0d0f26;
  --border: #2a2160;
  --display: "Orbitron", "Segoe UI", system-ui, sans-serif;
}

:root[data-theme="neon"] body {
  font-family: "Exo 2", system-ui, sans-serif;
  font-size: 15.5px;
}

:root[data-theme="neon"] h1,
:root[data-theme="neon"] h2,
:root[data-theme="neon"] h3,
:root[data-theme="neon"] h4 {
  font-family: var(--display);
  font-weight: 500;
}

:root[data-theme="neon"] h1,
:root[data-theme="neon"] h2 {
  text-shadow: var(--glow);
}

:root[data-theme="neon"] h1 { letter-spacing: 0.04em; }

/* section titles: cyan, uppercase */
:root[data-theme="neon"] .concept h3 {
  color: var(--link);
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

:root[data-theme="neon"] a {
  font-weight: 600;
  text-shadow: 0 0 6px rgba(25, 230, 230, 0.4);
}

:root[data-theme="neon"] a:hover {
  color: var(--accent-pink);
  text-shadow: 0 0 8px rgba(255, 63, 180, 0.8);
}

:root[data-theme="neon"] .category,
:root[data-theme="neon"] .eyebrow {
  color: var(--accent-pink);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
}

/* header: nav as boxed buttons, cyan line then purple line */
:root[data-theme="neon"] .site-header {
  border-bottom: 1px solid var(--heading);
  padding-bottom: 28px;
  box-shadow: 0 8px 12px -8px rgba(168, 85, 247, 0.7);
}

:root[data-theme="neon"] .site-nav {
  border-bottom: 1px solid var(--link);
  margin-top: 22px;
  padding: 0 0 22px;
  box-shadow: 0 8px 12px -8px rgba(25, 230, 230, 0.6);
}

:root[data-theme="neon"] .site-nav .wrap { gap: 10px; }

:root[data-theme="neon"] .site-nav a {
  border: 1px solid var(--border);
  padding: 7px 14px;
  background: var(--soft);
  color: var(--text);
  font-family: var(--display);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-shadow: none;
}

:root[data-theme="neon"] .site-nav a:hover,
:root[data-theme="neon"] .site-nav a[aria-current="page"] {
  border-color: var(--link);
  color: var(--link);
}

/* panels with cyan / purple corner brackets */
:root[data-theme="neon"] .concept-title,
:root[data-theme="neon"] .concept section,
:root[data-theme="neon"] .card {
  position: relative;
  margin: 0 0 24px;
  border: 1px solid var(--border);
  padding: 22px 28px;
  background: var(--soft);
  box-shadow: 0 0 14px rgba(168, 85, 247, 0.12);
}

:root[data-theme="neon"] .concept-title::before,
:root[data-theme="neon"] .concept section::before,
:root[data-theme="neon"] .card::before,
:root[data-theme="neon"] .concept-title::after,
:root[data-theme="neon"] .concept section::after,
:root[data-theme="neon"] .card::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  pointer-events: none;
}

:root[data-theme="neon"] .concept-title::before,
:root[data-theme="neon"] .concept section::before,
:root[data-theme="neon"] .card::before {
  top: -1px;
  left: -1px;
  border-top: 2px solid var(--link);
  border-left: 2px solid var(--link);
}

:root[data-theme="neon"] .concept-title::after,
:root[data-theme="neon"] .concept section::after,
:root[data-theme="neon"] .card::after {
  right: -1px;
  bottom: -1px;
  border-right: 2px solid var(--heading);
  border-bottom: 2px solid var(--heading);
}

/* a title followed by a section reads as one panel */
:root[data-theme="neon"] .concept-title:has(+ section) {
  margin-bottom: 0;
  border-bottom: 0;
  padding-bottom: 4px;
}

:root[data-theme="neon"] .concept-title:has(+ section)::after,
:root[data-theme="neon"] .concept-title + section::before {
  display: none;
}

:root[data-theme="neon"] .concept-title + section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

:root[data-theme="neon"] .concept + .concept {
  margin-top: 0;
  border-top: 0;
  padding-top: 0;
}

:root[data-theme="neon"] .concept-title > p:last-child { font-size: 1rem; }

:root[data-theme="neon"] .card:hover {
  border-color: var(--accent-pink);
  box-shadow: 0 0 16px rgba(255, 63, 180, 0.5);
}

:root[data-theme="neon"] .card h3 {
  color: var(--heading);
  font-size: 1rem;
  text-transform: none;
  letter-spacing: 0.03em;
}

:root[data-theme="neon"] .card-grid { margin-top: 24px; }

/* square pink / purple bullets */
:root[data-theme="neon"] .concept ul { list-style: none; padding-left: 4px; }

:root[data-theme="neon"] .concept li {
  position: relative;
  padding-left: 22px;
}

:root[data-theme="neon"] .concept li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 7px;
  height: 7px;
  background: var(--heading);
  box-shadow: 0 0 6px var(--heading);
}

:root[data-theme="neon"] .concept li:last-child::before {
  background: var(--accent-pink);
  box-shadow: 0 0 6px var(--accent-pink);
}

/* tables */
:root[data-theme="neon"] table { border: 1px solid var(--border); font-size: 0.88rem; }

:root[data-theme="neon"] th {
  background: #0f1c33;
  color: var(--link);
  font-family: var(--display);
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

:root[data-theme="neon"] td,
:root[data-theme="neon"] th { border-bottom-color: var(--border); }

:root[data-theme="neon"] td:first-child { font-weight: 600; }

:root[data-theme="neon"] .node {
  box-shadow: 0 0 10px rgba(25, 230, 230, 0.25);
}

:root[data-theme="neon"] img {
  border: 1px solid var(--accent-pink);
  box-shadow: 0 0 18px rgba(255, 63, 180, 0.4);
}

:root[data-theme="neon"] footer { border-top-color: var(--border); }

:root[data-theme="neon"] .theme-switch {
  border-color: var(--link);
  box-shadow: 0 0 12px rgba(25, 230, 230, 0.4);
}

:root[data-theme="neon"] .theme-switch button {
  font-family: var(--display);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

:root[data-theme="neon"] .theme-switch button[aria-pressed="true"] {
  border-color: var(--accent-pink);
  color: var(--accent-pink);
  text-shadow: 0 0 6px rgba(255, 63, 180, 0.7);
}

:root[data-theme="neon"] ::selection {
  background: var(--accent-pink);
  color: #070a1f;
}

:root[data-theme="neon"] :focus-visible {
  outline: 2px solid var(--accent-pink);
}
