:root {
  --paper: #efe7d7;
  --paper-light: #faf6ec;
  --ink: #0d1117;
  --muted: #66655f;
  --cinnabar: #aa3f32;
  --cobalt: #2d4fd7;
  --acid: #dcefb2;
  --surface: #faf6ec;
  --surface-glass: rgba(250, 246, 236, 0.88);
  --surface-hover: #fffaf0;
  --surface-selected: #f8f0dc;
  --copy: #333630;
  --edge: rgba(13, 17, 23, 0.62);
  --edge-soft: rgba(13, 17, 23, 0.24);
  --header-glass: rgba(239, 231, 215, 0.9);
  --grid-line: rgba(13, 17, 23, 0.035);
  --soft-shadow: rgba(62, 47, 31, 0.14);
  --ink-fixed: #0d1117;
  --paper-fixed: #faf6ec;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="moon"] {
  --paper: #090d14;
  --paper-light: #151d2a;
  --ink: #f4efe6;
  --muted: #aab4c3;
  --cinnabar: #e06a56;
  --cobalt: #8297ff;
  --acid: #cfe49b;
  --surface: #111925;
  --surface-glass: rgba(17, 25, 37, 0.9);
  --surface-hover: #1a2636;
  --surface-selected: #223149;
  --copy: #c5ceda;
  --edge: rgba(209, 220, 236, 0.42);
  --edge-soft: rgba(192, 205, 224, 0.22);
  --header-glass: rgba(9, 13, 20, 0.86);
  --grid-line: rgba(221, 229, 241, 0.032);
  --soft-shadow: rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background:
    radial-gradient(circle at 8% 5%, rgba(170, 63, 50, 0.1), transparent 26rem),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    var(--paper);
  background-size: auto, 34px 34px, 34px 34px, auto;
  color: var(--ink);
  margin: 0;
  min-height: 100vh;
  min-width: 320px;
}
html[data-theme="moon"] body {
  background:
    radial-gradient(circle at 12% 2%, rgba(130, 151, 255, 0.16), transparent 32rem),
    radial-gradient(circle at 88% 22%, rgba(224, 106, 86, 0.09), transparent 30rem),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    var(--paper);
  background-size: auto, auto, 34px 34px, 34px 34px, auto;
}

html[data-theme="moon"] .community-header { border-bottom-color: rgba(211, 179, 110, 0.25); }
html[data-theme="moon"] .community-brand > span { background: #f4efe6; color: #090d14; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a, button, input, pre { outline: none; }
a:focus-visible, button:focus-visible, input:focus-visible, pre:focus-visible {
  box-shadow: 0 0 0 3px var(--paper-light), 0 0 0 6px var(--cobalt) !important;
}
[hidden] { display: none !important; }

.community-header {
  align-items: center;
  backdrop-filter: blur(18px);
  background: var(--header-glass);
  border-bottom: 1px solid var(--edge-soft);
  display: flex;
  justify-content: space-between;
  min-height: 78px;
  padding: 0 clamp(18px, 4vw, 64px);
  position: sticky;
  top: 0;
  z-index: 30;
}
.community-brand { align-items: center; color: inherit; display: flex; gap: 12px; text-decoration: none; }
.community-brand > span {
  align-items: center;
  background: var(--ink);
  box-shadow: 3px 3px 0 var(--cinnabar);
  color: var(--paper-light);
  display: flex;
  font: 800 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  height: 39px;
  justify-content: center;
  transform: rotate(-2deg);
  width: 42px;
}
.community-brand strong { font-size: 13px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.community-header-actions, .community-header nav { align-items: center; display: flex; }
.community-header-actions { gap: clamp(16px, 3vw, 34px); }
.community-header nav { gap: clamp(14px, 3vw, 34px); }
.community-header nav a {
  color: var(--ink);
  font: 750 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .08em;
  position: relative;
  text-decoration: none;
  text-transform: uppercase;
}
.community-header nav a::after {
  background: var(--cinnabar);
  bottom: -9px;
  content: "";
  height: 2px;
  left: 0;
  position: absolute;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 180ms ease;
  width: 100%;
}
.community-header nav a:hover::after { transform: scaleX(1); }
.theme-toggle {
  align-items: center;
  background: transparent;
  border: 1px solid var(--edge-soft);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font: 750 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  gap: 8px;
  letter-spacing: .08em;
  min-height: 38px;
  padding: 0 13px;
  text-transform: uppercase;
}
.theme-toggle:hover { background: var(--ink); color: var(--paper-light); }

.eyebrow {
  align-items: center;
  display: flex;
  font: 750 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  gap: 10px;
  letter-spacing: .13em;
  margin: 0 0 22px;
  text-transform: uppercase;
}
.eyebrow::before { background: var(--cinnabar); content: ""; height: 2px; width: 26px; }
.community-hero {
  display: grid;
  gap: clamp(34px, 7vw, 100px);
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr);
  margin: 0 auto;
  max-width: 1600px;
  padding: clamp(70px, 10vw, 142px) clamp(20px, 5vw, 78px) clamp(60px, 9vw, 112px);
}
.community-hero h1 {
  font-family: "Iowan Old Style", "Bodoni 72", Didot, Georgia, serif;
  font-size: clamp(5rem, 9vw, 10.5rem);
  font-weight: 600;
  letter-spacing: -.075em;
  line-height: .8;
  margin: 0;
}
.community-hero h1::first-line { color: var(--cinnabar); font-style: italic; }
.community-hero-copy { align-self: end; }
.community-hero-copy > p { color: var(--copy); font-size: clamp(17px, 2vw, 21px); line-height: 1.65; margin: 0; max-width: 620px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.hero-actions button, .viewer-actions a, .viewer-actions button, .load-more {
  align-items: center;
  background: var(--ink);
  border: 1px solid var(--ink);
  color: var(--paper-light);
  cursor: pointer;
  display: inline-flex;
  font-size: 11px;
  font-weight: 850;
  gap: 22px;
  justify-content: center;
  min-height: 46px;
  padding: 0 17px;
  text-decoration: none;
  text-transform: uppercase;
}
.hero-actions button { box-shadow: 4px 4px 0 var(--cinnabar); }
.hero-actions .secondary-button { background: transparent; border-color: var(--edge); box-shadow: none; color: var(--ink); }
.hero-actions button:hover, .load-more:hover { transform: translateY(-2px); }

.community-stats { background: var(--ink-fixed); color: var(--paper-fixed); display: grid; grid-template-columns: repeat(4, 1fr); }
.community-stats article { border-right: 1px solid #343b46; min-height: 142px; padding: 30px clamp(18px, 3vw, 46px); }
.community-stats article:last-child { border-right: 0; }
.community-stats strong { display: block; font: 500 clamp(42px, 5vw, 72px)/.9 "Iowan Old Style", Georgia, serif; letter-spacing: -.055em; }
.community-stats span { color: #aeb7c5; display: block; font: 800 10px/1 ui-monospace, monospace; letter-spacing: .1em; margin-top: 16px; text-transform: uppercase; }

.archive-workspace { background: var(--surface-glass); border-bottom: 1px solid var(--edge-soft); display: grid; grid-template-columns: minmax(360px, .72fr) minmax(0, 1.28fr); min-height: 900px; }
.archive-sidebar { border-right: 1px solid var(--edge-soft); min-width: 0; padding: clamp(32px, 4vw, 62px); }
.archive-heading h2, .study-disclaimer h2 { font: 500 clamp(38px, 5vw, 70px)/.92 "Iowan Old Style", Georgia, serif; letter-spacing: -.055em; margin: 0 0 18px; }
.archive-heading > p:last-child { color: var(--copy); font-size: 14px; line-height: 1.65; max-width: 550px; }
.archive-search { display: block; margin-top: 34px; position: relative; }
.archive-search > span { color: var(--muted); display: block; font: 800 9px/1 ui-monospace, monospace; letter-spacing: .1em; margin-bottom: 9px; text-transform: uppercase; }
.archive-search input { background: var(--surface); border: 1px solid var(--edge); border-radius: 0; color: var(--ink); min-height: 52px; padding: 0 54px 0 15px; width: 100%; }
.archive-search kbd { border: 1px solid var(--edge-soft); color: var(--muted); font: 800 11px/1 ui-monospace, monospace; padding: 6px 9px; position: absolute; right: 12px; top: 32px; }
.language-filters { display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); margin-top: 13px; }
.language-filters button { background: transparent; border: 1px solid var(--edge-soft); color: var(--muted); cursor: pointer; min-height: 42px; padding: 0 10px; }
.language-filters button span { color: inherit; display: block; font: 800 9px/1 ui-monospace, monospace; margin-top: 2px; }
.language-filters button.active, .language-filters button:hover { background: var(--ink); border-color: var(--ink); color: var(--paper-light); }
.source-filter { display: block; margin-top: 15px; }
.source-filter > span { color: var(--muted); display: block; font: 800 9px/1 ui-monospace, monospace; letter-spacing: .1em; margin-bottom: 9px; text-transform: uppercase; }
.source-filter select { background: var(--surface); border: 1px solid var(--edge-soft); border-radius: 0; color: var(--ink); min-height: 44px; padding: 0 12px; width: 100%; }
.result-summary { color: var(--muted); font: 800 10px/1.4 ui-monospace, monospace; letter-spacing: .06em; padding: 22px 0 12px; text-transform: uppercase; }
.result-summary.error { color: #aa3f32; }
.implementation-list { border-top: 1px solid var(--edge-soft); }
.implementation-card { align-items: center; background: transparent; border: 0; border-bottom: 1px solid var(--edge-soft); color: inherit; cursor: pointer; display: grid; gap: 13px; grid-template-columns: 46px minmax(0, 1fr) auto; min-height: 78px; padding: 12px 10px; text-align: left; width: 100%; }
.implementation-card:hover, .implementation-card.selected { background: var(--surface-selected); }
.implementation-card.selected { box-shadow: inset 3px 0 var(--cinnabar); }
.implementation-number { color: var(--muted); font: 800 9px/1 ui-monospace, monospace; }
.implementation-copy { min-width: 0; }
.implementation-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.implementation-copy small { color: var(--muted); display: block; font: 700 10px/1 ui-monospace, monospace; margin-top: 7px; }
.implementation-arrow { color: var(--cinnabar); }
.load-more { margin-top: 16px; width: 100%; }

.community-viewer { background: var(--paper-light); min-width: 0; padding: clamp(30px, 4vw, 64px); position: relative; }
.viewer-empty { align-items: center; display: flex; flex-direction: column; justify-content: center; min-height: 680px; text-align: center; }
.viewer-empty > span { color: var(--cinnabar); font: 500 90px/1 Georgia, serif; opacity: .35; }
.viewer-empty h2 { font: 500 clamp(38px, 5vw, 64px)/1 "Iowan Old Style", Georgia, serif; letter-spacing: -.05em; margin: 15px 0; }
.viewer-empty p { color: var(--muted); }
.viewer-content { margin: 0 auto; max-width: 980px; }
.viewer-header { align-items: flex-start; display: flex; gap: 30px; justify-content: space-between; }
.viewer-kicker { color: var(--cinnabar); font: 900 10px/1 ui-monospace, monospace; letter-spacing: .1em; margin: 0 0 12px; text-transform: uppercase; }
.viewer-header h2 { font: 500 clamp(34px, 5vw, 68px)/.92 "Iowan Old Style", Georgia, serif; letter-spacing: -.055em; margin: 0; }
.viewer-header p:last-child { color: var(--muted); font: 700 11px/1 ui-monospace, monospace; margin: 15px 0 0; }
.viewer-actions { display: flex; flex-wrap: wrap; gap: 7px; margin: 28px 0 13px; }
.viewer-actions a, .viewer-actions button { background: transparent; border-color: var(--edge-soft); color: var(--ink); font-size: 10px; gap: 0; min-height: 39px; }
.viewer-actions a:hover, .viewer-actions button:hover { border-color: var(--cinnabar); color: var(--cinnabar); }
.source-notice { align-items: flex-start; background: rgba(45, 79, 215, .1); border-left: 3px solid var(--cobalt); display: flex; flex-direction: column; gap: 5px; padding: 15px 17px; }
.source-notice strong { font: 900 10px/1 ui-monospace, monospace; letter-spacing: .08em; text-transform: uppercase; }
.source-notice span { color: var(--copy); font-size: 12px; line-height: 1.5; }
.source-notice a { color: var(--cobalt); }
.viewer-code-heading { align-items: center; background: #111a27; border: 1px solid #303b4a; border-bottom: 0; color: #eef3f8; display: flex; justify-content: space-between; gap: 20px; margin-top: 14px; padding: 17px 20px; }
.viewer-code-heading > div { display: grid; gap: 5px; }
.viewer-code-heading > div > span { color: #8291a5; font: 800 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .1em; text-transform: uppercase; }
.viewer-code-heading strong { font-size: 13px; }
#viewer-code-language { border: 1px solid #8dd8ff; color: #8dd8ff; font: 800 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 7px 9px; text-transform: uppercase; }
.community-viewer pre { background: linear-gradient(145deg, #050a12 0%, #0a1522 55%, #07101a 100%); border: 1px solid #303b4a; color: #dbe5f3; font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; max-height: calc(100vh - 330px); min-height: 430px; overflow: auto; padding: 22px 0 28px; tab-size: 2; white-space: pre; }
#source-code { display: block; }
.code-line { display: grid; grid-template-columns: 56px minmax(max-content, 1fr); min-height: 1.65em; padding-right: 22px; white-space: pre; }
.code-line:hover { background: rgba(220, 239, 178, .055); }
.line-number { border-right: 1px solid #263244; color: #64748b; margin-right: 17px; padding-right: 12px; text-align: right; user-select: none; }
.token-keyword, .token-preprocessor { color: #c586c0; }
.token-string { color: #ce9178; }
.token-number { color: #b5cea8; }
.token-comment { color: #6a9955; font-style: italic; }
.token-type { color: #4ec9b0; }
.token-function { color: #dcdcaa; }
.token-constant { color: #4fc1ff; }
.token-operator { color: #d4d4d4; }

.study-disclaimer { background: var(--paper); color: var(--ink); display: grid; gap: clamp(26px, 6vw, 90px); grid-template-columns: minmax(280px, .8fr) minmax(320px, 1.2fr); padding: clamp(64px, 9vw, 124px) clamp(20px, 5vw, 78px); }
.study-disclaimer .eyebrow { grid-column: 1 / -1; margin-bottom: -30px; }
.study-disclaimer h2 { max-width: 680px; }
.study-disclaimer > p:last-child { border-left: 3px solid var(--cinnabar); color: var(--copy); font-size: clamp(16px, 1.6vw, 20px); line-height: 1.75; margin: 0; max-width: 780px; padding-left: clamp(22px, 4vw, 44px); }

footer { align-items: center; background: var(--ink-fixed); color: var(--paper-fixed); display: flex; gap: 24px; justify-content: space-between; min-height: 110px; padding: 22px clamp(20px, 5vw, 78px); }
footer a { color: var(--paper-fixed); font-weight: 800; text-decoration: none; }
footer span { color: #aeb7c5; font-size: 12px; text-align: center; }

@media (max-width: 980px) {
  .community-header nav a:nth-child(2), .community-header nav a:nth-child(3) { display: none; }
  .community-hero, .archive-workspace { grid-template-columns: 1fr; }
  .study-disclaimer { grid-template-columns: 1fr; }
  .study-disclaimer .eyebrow { margin-bottom: 0; }
  .archive-sidebar { border-bottom: 1px solid var(--edge-soft); border-right: 0; }
  .viewer-content { position: static; }
  .community-viewer pre { max-height: 70vh; }
}

@media (max-width: 680px) {
  .community-header { padding: 0 14px; }
  .community-brand strong, .community-header nav { display: none; }
  .theme-toggle { padding: 0 10px; }
  .community-stats { grid-template-columns: repeat(2, 1fr); }
  .community-stats article:nth-child(2) { border-right: 0; }
  .community-stats article:nth-child(-n + 2) { border-bottom: 1px solid #343b46; }
  .community-stats article { min-height: 112px; padding: 22px 18px; }
  .community-hero { padding-top: 64px; }
  .community-hero h1 { font-size: clamp(4rem, 19vw, 6.2rem); }
  .language-filters { grid-template-columns: 1fr; }
  .viewer-header { flex-direction: column; }
  .viewer-code-heading { align-items: flex-start; }
  .community-viewer pre { background: linear-gradient(145deg, #050a12 0%, #0a1522 55%, #07101a 100%); }
  .code-line { grid-template-columns: 48px minmax(max-content, 1fr); padding-right: 16px; }
  footer { align-items: flex-start; flex-direction: column; }
  footer span { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
