:root {
  --header-bg: #202124;
  --bg: #f5f1e8;
  --bg-soft: #eee7da;
  --panel: #fffaf0;
  --surface: var(--panel);
  --surface-raised: #fffdf7;
  --surface-soft: #eee7da;
  --text: #252321;
  --text-main: var(--text);
  --muted: #6f675c;
  --text-muted: var(--muted);
  --text-faint: #8b8174;
  --accent: #7a4f24;
  --accent-strong: #3f2f24;
  --accent-hover: var(--accent-strong);
  --accent-soft: #eadfce;
  --link: #7a4f24;
  --border: #d6cabb;
  --border-strong: #bba995;
  --good: #496f58;
  --warn: #8a642d;
  --bad: #8b4540;
  --content-width: 1040px;
  --article-width: 760px;
  --radius: 7px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text-main);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.68;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(63, 47, 36, 0.035) 1px, transparent 1px);
  background-size: 100% 32px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--accent-hover);
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

p {
  margin: 0 0 1.15rem;
}

p:last-child {
  margin-bottom: 0;
}

strong {
  color: var(--text-main);
  font-weight: 650;
}

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

.site-header {
  position: relative;
  z-index: 2;
  background: var(--header-bg);
  border-bottom: 1px solid #34363a;
}

.site-header .container {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}

.site-brand {
  display: inline-flex;
  flex-direction: column;
  color: #f6f1e8;
  text-decoration: none;
  line-height: 1.15;
}

.site-brand:hover {
  color: #ffffff;
}

.site-title {
  font-size: 0.92rem;
  font-weight: 750;
  letter-spacing: 0.14em;
}

.site-kicker {
  margin-top: 5px;
  color: #aaa59d;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 22px;
}

.site-nav a {
  color: #bcb8b1;
  font-size: 0.84rem;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: #ffffff;
}

.site-header a:focus-visible {
  outline-color: #d6b98f;
}

.page-main {
  position: relative;
  z-index: 1;
  padding-block: 64px 80px;
}

.hero {
  max-width: 790px;
  padding: 42px 0 62px;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero h1,
.article-header h1,
.lede h1 {
  margin: 0;
  color: var(--text-main);
  font-size: clamp(2.35rem, 7vw, 4.7rem);
  font-weight: 720;
  line-height: 1.02;
  letter-spacing: 0;
}

.hero-summary {
  max-width: 700px;
  margin: 26px 0 0;
  color: var(--text-muted);
  font-size: clamp(1.03rem, 2vw, 1.2rem);
  line-height: 1.75;
}

.hero-summary strong {
  color: var(--text-main);
}

.hero-link {
  display: inline-block;
  margin-top: 24px;
  font-size: 0.9rem;
}

.content-section {
  padding: 54px 0;
  border-top: 1px solid var(--border);
  scroll-margin-top: 24px;
}

.section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.section-heading {
  margin: 0;
  color: var(--text-main);
  font-size: 1.35rem;
  font-weight: 680;
  letter-spacing: 0;
}

.section-note,
.muted {
  color: var(--text-muted);
}

.section-note {
  margin: 0;
  font-size: 0.86rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.card {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.project-card {
  position: relative;
  display: flex;
  min-height: 210px;
  flex-direction: column;
  padding: 23px;
  color: var(--text-main);
  text-decoration: none;
  transition: border-color 140ms ease, background-color 140ms ease, transform 140ms ease;
}

.project-card:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
  background: var(--surface-raised);
  transform: translateY(-2px);
}

.card-index {
  margin-bottom: 34px;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.73rem;
}

.project-card h3 {
  margin: 0 0 10px;
  color: var(--text-main);
  font-size: 1.07rem;
  line-height: 1.35;
}

.project-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.card-meta {
  margin-top: auto;
  padding-top: 24px;
  color: var(--text-faint);
  font-size: 0.76rem;
}

.experiment-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.experiment-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 76px;
  padding: 18px 20px;
  color: var(--text-main);
  text-decoration: none;
}

.experiment-card:hover {
  color: var(--text-main);
  border-color: var(--border-strong);
  background: var(--surface-raised);
}

.experiment-name {
  font-size: 0.92rem;
  font-weight: 600;
}

.experiment-arrow {
  flex: 0 0 auto;
  color: var(--text-faint);
}

.tag,
.pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.72rem;
  line-height: 1;
}

.site-footer {
  position: relative;
  z-index: 1;
  background: var(--header-bg);
  border-top: 1px solid #34363a;
}

.site-footer .container {
  min-height: 104px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: #bcb8b1;
  font-size: 0.78rem;
}

.footer-mark {
  color: #8e8b85;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Shared article layout */
.article-page,
.panel-page,
.results-page {
  padding: 0;
}

.article-shell {
  width: min(calc(100% - 40px), var(--article-width));
  margin-inline: auto;
}

.panel-page .page-wrapper {
  width: min(calc(100% - 40px), var(--article-width));
}

.article-header {
  padding: 18px 0 42px;
  border-bottom: 1px solid var(--border);
}

.article-header h1,
.lede h1 {
  max-width: 760px;
  font-size: clamp(2rem, 6vw, 3.55rem);
  line-height: 1.08;
}

.article-header .subtitle,
.article-header .sub,
.lede .subtitle {
  margin: 18px 0 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-align: left;
  text-transform: uppercase;
}

.quote {
  margin: 24px 0 0;
  padding-left: 18px;
  border-left: 2px solid var(--accent);
  color: var(--text-muted);
  font-size: 0.96rem;
  font-style: italic;
}

.glass-panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.glass-panel > h1,
.glass-panel > .subtitle {
  text-align: left;
}

.glass-panel > h1 {
  margin: 18px 0 0;
  font-size: clamp(2rem, 6vw, 3.55rem);
  line-height: 1.08;
}

.glass-panel > h1 span,
.lede h1 span {
  color: var(--accent);
}

.glass-panel > .subtitle {
  margin: 18px 0 42px;
  padding-bottom: 38px;
  border-bottom: 1px solid var(--border);
}

.subtitle,
.sub {
  color: var(--text-muted);
}

.section,
.lead,
.prose {
  margin: 0;
  padding: 32px 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  font-size: 0.98rem;
  line-height: 1.78;
}

.lead {
  color: #4c4741;
  font-size: 1.03rem;
}

.section h2,
.prose h2 {
  margin: 0 0 17px;
  color: var(--text-main);
  font-size: 1.35rem;
  line-height: 1.3;
}

.section h2::before,
.prose h2::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 11px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 0.18em;
}

.prose h3 {
  margin: 26px 0 10px;
  color: var(--text-main);
  font-size: 1.05rem;
}

.quote-box,
.callout,
.result-card {
  margin: 22px 0;
  padding: 18px 20px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.quote-box {
  color: #554c43;
  font-style: italic;
  text-align: left;
}

.callout {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.small,
.mini,
.details,
figcaption {
  color: var(--text-muted);
}

.small,
.mini {
  font-size: 0.82rem;
}

.footer-line {
  margin-top: 18px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.back-link,
.back {
  display: inline-flex;
  margin-top: 36px;
  color: var(--text-muted);
  font-size: 0.84rem;
  text-decoration: none;
}

.back-link:hover,
.back:hover {
  color: var(--text-main);
}

code,
pre,
.codebox,
.details .mono,
.meta code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

code {
  color: #6d4320;
  font-size: 0.91em;
}

pre,
.codebox {
  margin: 18px 0 0;
  padding: 17px 18px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #292724;
  border-color: #49443e;
  color: #f1e9dd;
  font-size: 0.82rem;
  line-height: 1.65;
  white-space: pre;
}

pre code,
.codebox code {
  color: #fffaf0;
}

ul {
  margin: 10px 0 1.2rem 20px;
  padding: 0;
}

li {
  margin: 7px 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 9px;
  margin: 24px 0;
}

.stat {
  min-width: 0;
  padding: 15px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat .label {
  margin-bottom: 7px;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.stat .value {
  overflow-wrap: anywhere;
  color: var(--text-main);
  font-size: 1.08rem;
  font-weight: 700;
}

.good {
  color: var(--good) !important;
}

.warn {
  color: var(--warn) !important;
}

table {
  width: 100%;
  margin: 20px 0 6px;
  border: 1px solid var(--border);
  border-collapse: collapse;
  font-size: 0.86rem;
}

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

th {
  background: var(--surface-soft);
  color: var(--text-main);
  font-weight: 650;
}

tr:last-child td {
  border-bottom: 0;
}

figure {
  margin: 26px 0 0;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

figure img,
.post-image {
  display: block;
  width: 100%;
  max-width: 100%;
  border-radius: 3px;
}

figure img {
  background: white;
}

figcaption {
  margin-top: 10px;
  font-size: 0.79rem;
}

.post-image {
  max-height: 520px;
  object-fit: contain;
  border: 1px solid var(--border);
}

.clickable-image {
  cursor: zoom-in;
}

.image-caption {
  margin-top: 10px !important;
  padding: 0 !important;
  border: 0 !important;
  font-size: 0.72rem !important;
}

/* Results page */
.results-page .page {
  width: min(calc(100% - 40px), var(--article-width));
}

.lede {
  padding: 18px 0 38px;
  border-bottom: 1px solid var(--border);
}

.lede p {
  max-width: 700px;
  margin-top: 18px;
  color: var(--text-muted);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  color: var(--text-faint);
  font-size: 0.76rem;
}

.meta code {
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-soft);
  color: var(--accent-strong);
}

.divider {
  display: none;
}

.results-page .section-title {
  margin: 34px 0 12px;
  color: var(--text-main);
  font-size: 1.1rem;
  font-weight: 680;
  text-align: left;
}

.results {
  display: grid;
  gap: 0;
}

.result-row {
  display: grid;
  grid-template-columns: 52px 130px 1fr;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.col-letter {
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 750;
}

.status {
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.status.solution {
  color: var(--accent);
}

.status.hitcap {
  color: var(--warn);
}

.status.nosolution,
.status.exhausted {
  color: var(--bad);
}

.details {
  font-size: 0.8rem;
  line-height: 1.55;
}

.details .mono {
  color: #514a43;
}

.details .sol {
  color: var(--text-main);
  font-style: italic;
}

.results-page .page > footer {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.76rem;
}

.results-grid {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.result-card {
  margin: 0;
}

.result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.badge {
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge.good {
  border-color: #bda98f;
  color: var(--accent-strong);
}

.badge.bad {
  background: transparent;
  color: var(--text-muted);
}

.letters-line {
  font-size: 0.88rem;
  font-weight: 650;
}

@media (max-width: 820px) {
  .card-grid {
    grid-template-columns: 1fr;
  }

  .project-card {
    min-height: 0;
  }

  .card-index {
    margin-bottom: 24px;
  }
}

@media (max-width: 640px) {
  .container,
  .page-wrapper,
  .page,
  .wrap,
  .article-shell,
  .results-page .page {
    width: min(calc(100% - 28px), var(--content-width));
  }

  .site-header .container {
    min-height: 70px;
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding-block: 16px;
  }

  .site-nav {
    width: 100%;
    gap: 17px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .site-nav a {
    flex: 0 0 auto;
  }

  .page-main {
    padding-block: 42px 58px;
  }

  .hero {
    padding: 24px 0 48px;
  }

  .hero h1 {
    font-size: clamp(2.65rem, 15vw, 4rem);
  }

  .section-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .experiment-grid {
    grid-template-columns: 1fr;
  }

  .site-footer .container {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding-block: 24px;
  }

  .glass-panel > h1,
  .article-header h1,
  .lede h1 {
    font-size: clamp(2rem, 11vw, 3rem);
  }

  .section,
  .lead,
  .prose {
    padding-block: 26px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .result-row {
    grid-template-columns: 38px 1fr;
    grid-template-areas:
      "letter status"
      "details details";
    gap: 6px 10px;
  }

  .col-letter {
    grid-area: letter;
  }

  .status {
    grid-area: status;
  }

  .details {
    grid-area: details;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}
