:root {
  --bg: #f8f5ef;
  --bg-accent: #efe7d8;
  --text: #1d2228;
  --muted: #4f5966;
  --primary: #bf4b27;
  --primary-strong: #982f10;
  --surface: #fffdf8;
  --line: #d7c9af;
  --shadow: 0 14px 40px rgba(46, 33, 16, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -10%, #fff7df, transparent 28%),
    radial-gradient(circle at 95% -15%, #f6d9c4, transparent 33%),
    linear-gradient(170deg, var(--bg), #f3eee5 42%, #f8f5ef);
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  line-height: 1.5;
}

main {
  width: min(1040px, calc(100% - 2.5rem));
  margin: 0 auto 4rem;
}

.site-header {
  width: min(1040px, calc(100% - 2.5rem));
  margin: 1.2rem auto 2rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 251, 242, 0.85);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.top-nav {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.logo {
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--text);
}

.nav-link {
  text-decoration: none;
  color: var(--text);
  padding: 0.35rem 0.7rem;
  border-radius: 10px;
}

.nav-link:hover,
.nav-link[aria-current="page"] {
  background: var(--bg-accent);
}

.dropdown {
  position: relative;
}

.dropdown-toggle {
  padding: 0.38rem 0.74rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff7ec;
  color: var(--text);
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  font-size: 0.95rem;
  cursor: pointer;
}

.dropdown-toggle:hover {
  background: #f6ebda;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  min-width: 180px;
  padding: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdfa;
  box-shadow: 0 10px 25px rgba(29, 34, 40, 0.12);
  display: none;
  z-index: 20;
}

.dropdown-menu a {
  display: block;
  padding: 0.35rem 0.5rem;
  text-decoration: none;
  color: var(--text);
  border-radius: 8px;
}

.dropdown-menu a:hover,
.dropdown-menu a[aria-current="page"] {
  background: var(--bg-accent);
}

.dropdown:hover .dropdown-menu,
.dropdown:focus-within .dropdown-menu {
  display: block;
}

.hero {
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 2.3rem;
  background: linear-gradient(140deg, #fff8ea 0%, #f9efe0 60%, #f6ead5 100%);
  box-shadow: var(--shadow);
  animation: fade-in 420ms ease;
}

.hero-small {
  margin-bottom: 1.3rem;
}

.hero h1 {
  margin: 0.2rem 0 0.6rem;
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1.07;
  font-family: "Source Serif 4", "Georgia", serif;
}

.hero p {
  margin: 0;
  max-width: 68ch;
  color: var(--muted);
}

.eyebrow {
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 0.78rem;
}

.post-date {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 0.8rem 0 0;
}

.post-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.post-list li:last-child {
  border-bottom: none;
}

.post-list a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.post-list a:hover {
  color: var(--primary);
}

.post-list time {
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
  margin-left: 1rem;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.92rem;
}

.results-table th,
.results-table td {
  padding: 0.45rem 0.7rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.results-table th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.results-table tbody tr:hover {
  background: var(--bg-accent);
}

.hero-actions {
  margin-top: 1rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.64rem 0.92rem;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 600;
}

.button-primary {
  background: var(--primary);
  color: #fff;
}

.button-primary:hover {
  background: var(--primary-strong);
}

.grid {
  margin-top: 1.2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(285px, 1fr));
  gap: 1rem;
}

.card,
.pattern-card,
.code-section,
.next-section {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card,
.next-section {
  padding: 1.2rem 1.1rem;
}

.card h2,
.pattern-card h2,
.code-section h2,
.next-section h2 {
  margin: 0;
  font-size: 1.22rem;
  font-family: "Source Serif 4", "Georgia", serif;
}

.card ul,
.next-section ul {
  margin: 0.8rem 0 0;
  padding-left: 1.2rem;
}

.text-link {
  text-decoration: none;
  color: var(--primary-strong);
  font-weight: 600;
}

.patterns-grid {
  margin-top: 1rem;
}

.pattern-card {
  padding: 1rem;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease,
    border-color 160ms ease;
}

.pattern-card:hover {
  transform: translateY(-2px);
  border-color: #cfb385;
}

.pattern-card:focus-visible {
  outline: 2px solid #c96946;
  outline-offset: 2px;
}

.pattern-card:active {
  border-color: #cfb385;
}

.lead {
  margin: 0.45rem 0 0.7rem;
  color: var(--muted);
}

.pattern-open {
  display: inline-block;
  margin-top: 0.4rem;
  text-decoration: none;
  color: var(--primary-strong);
  font-weight: 700;
}

.code-section {
  margin-top: 1rem;
  padding: 1rem;
}

.code-section p {
  margin-top: 0.35rem;
  color: var(--muted);
}

.spectrum-scale {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.spectrum-stage {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  background: linear-gradient(130deg, #fffaf0, #f9eedc);
  padding: 0.8rem;
  position: relative;
  border: 1px solid var(--line);
  border-left: 6px solid var(--primary);
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(29, 34, 40, 0.08);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.spectrum-stage:last-child {
  border-left-color: #44a85f;
}

.spectrum-stage:first-child {
  border-left-color: #cf2d2d;
}

.spectrum-stage:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px rgba(29, 34, 40, 0.16);
}

.spectrum-stage:focus-visible {
  outline: 2px solid #c96946;
  outline-offset: 2px;
}

.spectrum-stage:focus {
  outline: none;
}

.spectrum-stage[aria-pressed="true"] {
  border-color: #c46b45;
  box-shadow: 0 12px 28px rgba(29, 34, 40, 0.16);
}

.spectrum-stage::before {
  content: attr(data-step);
  position: absolute;
  top: 0.55rem;
  right: 0.6rem;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
}

.spectrum-stage strong {
  display: block;
  color: var(--primary-strong);
  font-family: "Source Serif 4", "Georgia", serif;
  margin-bottom: 0.25rem;
}

.spectrum-stage p {
  margin: 0;
  color: var(--muted);
}

.spectrum-title {
  margin: 0.6rem 0 0.75rem;
  font-size: 1.15rem;
  font-family: "Source Serif 4", "Georgia", serif;
}

.spectrum-detail {
  margin: 0.75rem 0 0;
  padding: 0.6rem 0.65rem;
  border-radius: 10px;
  font-size: 0.95rem;
  color: #2a2f36;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid #ecd8b4;
  min-height: 2.4rem;
}

.agentic-spectrum-wrap {
  margin-top: 1.2rem;
  border: 1px solid #ebd9bb;
  border-radius: 18px;
  padding: 0.8rem;
  background: linear-gradient(165deg, rgba(255, 252, 245, 0.75), rgba(255, 247, 226, 0.55));
  box-shadow: 0 12px 30px rgba(29, 34, 40, 0.08);
}

.spectrum-arrow-track {
  position: relative;
  height: 62px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    #dc3e3e 0%,
    #e05f4a 30%,
    #f2c95d 55%,
    #4fb95b 100%
  );
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42),
    0 10px 20px rgba(220, 62, 62, 0.16);
  margin-bottom: 0.85rem;
}

.spectrum-arrow-track::before,
.spectrum-arrow-track::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  border-top: 14px solid transparent;
  border-bottom: 14px solid transparent;
  transform: translateY(-50%);
}

.spectrum-arrow-track::before {
  left: 2px;
  border-right: 16px solid #dc3e3e;
}

.spectrum-arrow-track::after {
  right: 2px;
  border-left: 16px solid #4fb95b;
}

.spectrum-arrow-cap {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  color: #fff9f4;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: rgba(29, 34, 40, 0.58);
  backdrop-filter: blur(3px);
}

.spectrum-arrow-cap.left {
  left: 0.45rem;
}

.spectrum-arrow-cap.center {
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
}

.spectrum-arrow-cap.right {
  right: 0.45rem;
}

.spectrum-indicator {
  position: absolute;
  top: 4px;
  width: 18px;
  height: 54px;
  border-radius: 12px;
  transform: translateX(-50%);
  left: 33%;
  transition: left 180ms ease;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.72),
    0 0 24px rgba(26, 24, 22, 0.2);
}

.spectrum-stage-featured {
  transform: translateY(-2px);
  border-color: #c46b45;
  background: linear-gradient(130deg, #fff8e9, #fde7cf);
  box-shadow: 0 12px 28px rgba(29, 34, 40, 0.13);
}

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

pre {
  margin: 0.8rem 0 0;
  padding: 0.8rem;
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid #d8d2c4;
  background: #18181b;
  color: #f4f4f5;
}

code {
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.9rem;
}

.next-section {
  margin-top: 1rem;
}

.pattern-article {
  padding: 1.1rem 1.15rem;
}

/* Table of contents */
.toc {
  margin-top: 1rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0,0,0,0.02);
  font-size: 0.82rem;
}

.toc strong {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.toc ol {
  margin: 0.4rem 0 0;
  padding-left: 1.3rem;
}

.toc ol > li {
  margin-bottom: 0.3rem;
}

.toc ul {
  margin: 0.15rem 0 0;
  padding-left: 1.2rem;
  list-style: none;
}

.toc ul li {
  font-size: 0.76rem;
  color: var(--muted);
}

.toc ul li::before {
  content: "\2013\00a0";
  color: #ccc;
}

.toc a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.toc a:hover {
  border-bottom-color: var(--primary);
  color: var(--primary);
}

/* Architecture visualization */
.arch-viz {
  margin-top: 0.9rem;
  padding: 1.2rem 1rem 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, #fffaf0 0%, #f8f2e7 100%);
}

.arch-main-node {
  text-align: center;
  border: 2px solid var(--primary);
  border-radius: 14px;
  background: #fffdfa;
  padding: 0.7rem 1rem;
  max-width: 420px;
  margin: 0 auto;
}

.arch-main-node strong {
  font-size: 1rem;
}

.arch-main-contents {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.6rem;
  justify-content: center;
  margin-top: 0.35rem;
}

.arch-main-contents span {
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--bg-accent);
  padding: 0.12rem 0.45rem;
  border-radius: 6px;
  font-family: 'Space Grotesk', monospace;
}

.arch-connectors {
  display: flex;
  justify-content: space-around;
  max-width: 600px;
  margin: 0 auto;
  height: 28px;
}

.arch-connector-line {
  width: 2px;
  height: 100%;
  background: linear-gradient(180deg, var(--primary), #d4bfa0);
  position: relative;
}

.arch-connector-line::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #d4bfa0;
}

.arch-agents-row {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
}

.arch-agent-card {
  flex: 1;
  max-width: 220px;
  border: 1px solid #dccfb7;
  border-radius: 14px;
  background: #fffdfa;
  padding: 0.65rem 0.7rem;
  transition: border-color 200ms ease;
}

.arch-agent-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

.arch-branch-name {
  display: block;
  width: 100%;
  font-size: 0.7rem;
  color: var(--muted);
  font-family: 'Space Grotesk', monospace;
  margin-top: 0.1rem;
}

.arch-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.78rem;
  counter-reset: none;
}

.arch-step {
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
  color: var(--muted);
  transition: background 200ms ease, color 200ms ease;
  line-height: 1.35;
}

.arch-step.active {
  background: #fce8d8;
  color: var(--text);
  font-weight: 500;
}

.arch-step.done {
  color: #8a9a6e;
}

.arch-step.done::before {
  content: "✓ ";
  font-size: 0.7rem;
}

.arch-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 0.8rem;
}

.arch-btn {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff7ec;
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 150ms ease;
}

.arch-btn:hover:not(:disabled) {
  background: #f6ebda;
}

.arch-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.arch-step-label {
  font-size: 0.8rem;
  color: var(--muted);
  min-width: 220px;
  text-align: center;
}

@media (max-width: 640px) {
  .arch-agents-row {
    flex-direction: column;
    align-items: center;
  }
  .arch-agent-card {
    max-width: 100%;
    width: 100%;
  }
  .arch-connectors {
    flex-direction: column;
    align-items: center;
    height: auto;
    gap: 0;
  }
  .arch-connector-line {
    width: 2px;
    height: 20px;
  }
}

/* Swarm architecture diagram */
.swarm-diagram {
  text-align: center;
}

.swarm-top-row {
  text-align: center;
}

.swarm-main {
  display: inline-block;
  border: 2px solid var(--primary);
  border-radius: 14px;
  background: #fffdfa;
  padding: 0.6rem 1.4rem;
  box-shadow: 0 2px 12px rgba(191, 75, 39, 0.08);
}

.swarm-main strong {
  font-size: 1.05rem;
}

.swarm-label {
  color: var(--muted);
  font-size: 0.78rem;
  margin-left: 0.3rem;
}

.swarm-main-tags {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
  margin-top: 0.3rem;
}

.swarm-main-tags span {
  font-size: 0.7rem;
  color: var(--muted);
  background: var(--bg-accent);
  padding: 0.1rem 0.4rem;
  border-radius: 5px;
  font-family: 'Space Grotesk', monospace;
}

.swarm-connector-v {
  position: relative;
  width: 2px;
  height: 36px;
  margin: 0 auto;
  background: linear-gradient(180deg, var(--primary), #d4bfa0);
}

.swarm-connector-v::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #d4bfa0;
}

.swarm-connector-short {
  height: 22px;
}

.swarm-arrow-label-left,
.swarm-arrow-label-right {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
}

.swarm-arrow-label-left {
  right: 12px;
}

.swarm-arrow-label-right {
  left: 12px;
}

.swarm-orch-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.swarm-human {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1.5px dashed #b8a88a;
  border-radius: 12px;
  background: #fef9f0;
  padding: 0.4rem 0.9rem;
  text-align: center;
}

.swarm-human-icon {
  font-size: 1.2rem;
  line-height: 1;
  color: var(--primary);
}

.swarm-human strong {
  font-size: 0.82rem;
}

.swarm-human small {
  color: var(--muted);
  font-size: 0.66rem;
}

.swarm-h-arrow {
  color: #b8a88a;
  font-size: 1.1rem;
  font-weight: 700;
}

.swarm-orch {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1.5px solid #c0a47a;
  border-radius: 12px;
  background: #fff8ee;
  padding: 0.5rem 1.2rem;
}

.swarm-orch .arc-num {
  color: var(--primary);
  font-size: 0.9rem;
}

.swarm-orch small {
  color: var(--muted);
  font-size: 0.72rem;
}

.swarm-fan {
  display: flex;
  justify-content: space-around;
  max-width: 480px;
  margin: 0 auto;
  height: 28px;
}

.swarm-fan-line {
  width: 2px;
  height: 100%;
  background: linear-gradient(180deg, #c0a47a, #dccfb7);
  position: relative;
}

.swarm-fan-line::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #dccfb7;
}

.swarm-fan-labels {
  display: flex;
  justify-content: space-around;
  max-width: 480px;
  margin: 0 auto 0.15rem;
}

.swarm-fan-labels small {
  font-size: 0.65rem;
  color: var(--muted);
}

.swarm-agents {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
}

.swarm-agent {
  flex: 1;
  max-width: 200px;
  border: 1px solid #dccfb7;
  border-radius: 14px;
  background: #fffdfa;
  padding: 0.55rem 0.65rem;
  text-align: left;
}

.swarm-agent strong {
  font-size: 0.88rem;
}

.swarm-branch {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  font-family: 'Space Grotesk', monospace;
  margin: 0.1rem 0 0.25rem;
}

.swarm-lifecycle {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: step;
}

.swarm-lifecycle li {
  font-size: 0.7rem;
  color: var(--muted);
  padding: 0.06rem 0;
  line-height: 1.35;
  counter-increment: step;
}

.swarm-lifecycle li::before {
  content: counter(step) ". ";
  color: #b8945a;
  font-weight: 700;
  font-size: 0.65rem;
}

.swarm-eval-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-top: 0.15rem;
}

.swarm-eval-step {
  text-align: center;
  border: 1px solid #dccfb7;
  border-radius: 10px;
  background: #fffdfa;
  padding: 0.35rem 0.7rem;
}

.swarm-eval-step strong {
  display: block;
  font-size: 0.78rem;
}

.swarm-eval-step small {
  display: block;
  font-size: 0.64rem;
  color: var(--muted);
}

.swarm-eval-merge {
  border-color: var(--primary);
  background: #fff5ed;
}

.swarm-eval-gate .arc-arrow-connector {
  flex: 0 0 28px;
}

@media (max-width: 640px) {
  .swarm-agents {
    flex-direction: column;
    align-items: center;
  }
  .swarm-agent {
    max-width: 100%;
    width: 100%;
  }
  .swarm-fan, .swarm-fan-labels {
    display: none;
  }
  .swarm-arrow-label-left,
  .swarm-arrow-label-right {
    display: none;
  }
  .swarm-orch-row {
    flex-direction: column;
    gap: 0.3rem;
  }
  .swarm-h-arrow {
    transform: rotate(90deg);
  }
  .swarm-eval-gate {
    flex-direction: column;
  }
  .swarm-eval-gate .arc-arrow-connector {
    flex: 0 0 20px;
    width: 2px;
    height: 20px;
    background: linear-gradient(180deg, #d4bfa0, #c0a47a);
  }
  .swarm-eval-gate .arc-arrow-connector::after {
    right: auto;
    left: 50%;
    top: auto;
    bottom: -1px;
    transform: translateX(-50%);
    border-top: 6px solid #c0a47a;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: none;
  }
}

/* Intro arc graph */
.arc-graph {
  margin-top: 0.9rem;
  padding: 0.95rem 1rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(160deg, #fffaf0 0%, #f8f2e7 100%);
}

.arc-graph-title {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}

.arc-flow-row {
  display: flex;
  align-items: center;
}

.arc-node {
  flex: 1;
  min-width: 0;
  border: 1px solid #dccfb7;
  border-radius: 14px;
  background: #fffdfa;
  box-shadow: 0 6px 16px rgba(46, 33, 16, 0.08);
  padding: 0.5rem 0.6rem;
}

.arc-num {
  display: inline-grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #f0dfc4, #e4cdaa);
  color: #6b4d28;
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.arc-node strong {
  display: block;
  line-height: 1.2;
  font-size: 0.85rem;
}

.arc-node small {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.73rem;
}

.arc-arrow-connector {
  flex: 0 0 36px;
  height: 2px;
  position: relative;
  background: linear-gradient(90deg, #d4bfa0, #c0a47a);
}

.arc-arrow-connector::after {
  content: "";
  position: absolute;
  right: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid #c0a47a;
}

.arc-caption {
  margin: 0.55rem 0 0;
  text-align: center;
  color: #6f5835;
  font-size: 0.74rem;
  font-weight: 600;
  font-style: italic;
}

@media (max-width: 900px) {
  .arc-flow-row {
    flex-direction: column;
  }

  .arc-node {
    width: 100%;
  }

  .arc-arrow-connector {
    flex: 0 0 28px;
    width: 2px;
    height: 28px;
    background: linear-gradient(180deg, #d4bfa0, #c0a47a);
  }

  .arc-arrow-connector::after {
    right: auto;
    left: 50%;
    top: auto;
    bottom: -1px;
    transform: translateX(-50%);
    border-top: 8px solid #c0a47a;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: none;
  }
}

.pattern-article h2 {
  font-size: 1.45rem;
  margin: 0.95rem 0 0.45rem;
}

.pattern-article h3 {
  font-size: 1.1rem;
}

.pattern-article p,
.pattern-article ul {
  margin: 0.35rem 0;
}

.pattern-article ul {
  padding-left: 1.8rem;
}

.pattern-article h2,
.pattern-article h3 {
  margin: 0.85rem 0 0.35rem;
}

.infra-component {
  margin: 0.7rem 0;
  padding: 0.7rem 0.85rem;
  border-left: 3px solid #d4bfa0;
  background: rgba(255, 250, 240, 0.5);
  border-radius: 0 10px 10px 0;
}

.infra-component h4 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
  font-family: "Source Serif 4", "Georgia", serif;
  color: var(--text);
}

.infra-component p {
  margin: 0;
}

.pattern-article pre {
  overflow-x: auto;
  margin-top: 0.8rem;
}

.pattern-article code {
  font-size: 0.9rem;
}

.next-section pre {
  overflow-x: auto;
}

/* ── Agent Type Cards ── */

.agent-type-card {
  margin-top: 1rem;
  padding: 1.3rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  position: relative;
}

/* ── Collapsible agent type sections ── */

.agent-type-details {
  margin-top: 1.2rem;
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

.agent-type-details summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.agent-type-details summary::-webkit-details-marker {
  display: none;
}

.agent-type-details summary::before {
  content: "\25B6";
  font-size: 0.7rem;
  color: var(--primary);
  transition: transform 200ms ease;
  flex-shrink: 0;
}

.agent-type-details[open] > summary::before {
  transform: rotate(90deg);
}

.agent-type-details summary h3 {
  margin: 0;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.2rem;
  color: var(--primary-strong);
}

.agent-type-details summary:hover h3 {
  color: var(--primary);
}

.agent-type-details > p,
.agent-type-details > .agent-type-note,
.agent-type-details > .viz-container {
  margin-top: 0.5rem;
}

.agent-type-card h2,
.agent-type-card h3 {
  margin: 0 0 0.4rem;
  font-size: 1.3rem;
  font-family: "Source Serif 4", Georgia, serif;
}

.agent-type-card > p {
  margin: 0.3rem 0 0.6rem;
  color: var(--muted);
  line-height: 1.55;
}

.agent-type-badge {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
}

.agent-type-note {
  font-size: 0.82rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  background: #faf5ec;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

.viz-label {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
}

/* ── Interactive Visualizations ── */

.viz-area {
  margin-top: 1.2rem;
}

.viz-container {
  animation: viz-enter 350ms ease;
}

@keyframes viz-enter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.viz-title {
  margin: 0 0 0.8rem;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.05rem;
  color: var(--primary-strong);
}

/* Pipeline layout */
.viz-pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 1rem 0.8rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid #ece3d0;
  overflow-x: auto;
  flex-wrap: nowrap;
}

/* Nodes */
.viz-node {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  border: 2px solid #d7c9af;
  background: #fffcf5;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 250ms ease;
  position: relative;
  min-width: 60px;
  text-align: center;
}

.viz-node-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.viz-node.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, #fff4e6, #fde7cf);
  color: var(--text);
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(191, 75, 39, 0.18);
}

.viz-node.done {
  border-color: #6abf6a;
  background: #edf8ed;
  color: #2d6a2d;
}

.viz-node.dimmed {
  opacity: 0.35;
}

/* Decision node */
.viz-node-decision {
  border-style: dashed;
  border-width: 2px;
}

.viz-badge-llm {
  position: absolute;
  top: -10px;
  right: -8px;
  padding: 0.1rem 0.4rem;
  border-radius: 20px;
  font-size: 0.6rem;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  white-space: nowrap;
}

/* Edges */
.viz-edge {
  flex-shrink: 0;
  width: 32px;
  height: 2px;
  background: #d7c9af;
  position: relative;
}

.viz-edge::after {
  content: "";
  position: absolute;
  right: 0;
  top: -3px;
  border: 3.5px solid transparent;
  border-left: 5px solid #d7c9af;
}

.viz-edge.active {
  background: var(--primary);
}

.viz-edge.active::after {
  border-left-color: var(--primary);
}

/* Conditional edges (LLM decision) */
.viz-edge-conditional {
  background: repeating-linear-gradient(
    90deg,
    var(--primary) 0,
    var(--primary) 4px,
    transparent 4px,
    transparent 7px
  );
  height: 2px;
}

.viz-edge-conditional::after {
  border-left-color: var(--primary);
}

.viz-edge-conditional.active {
  height: 3px;
  background: repeating-linear-gradient(
    90deg,
    var(--primary) 0,
    var(--primary) 4px,
    transparent 4px,
    transparent 7px
  );
  animation: edge-glow 1s ease-in-out infinite;
}

@keyframes edge-glow {
  0%, 100% { box-shadow: 0 0 4px rgba(191, 75, 39, 0.3); }
  50%      { box-shadow: 0 0 10px rgba(191, 75, 39, 0.6); }
}

/* Animated data packet */
.viz-packet {
  position: absolute;
  top: -4px;
  left: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px rgba(191, 75, 39, 0.5);
}

.viz-packet.animate {
  animation: packet-move 400ms ease forwards;
}

@keyframes packet-move {
  from { left: 0; opacity: 1; }
  to   { left: calc(100% - 10px); opacity: 0.6; }
}

/* Branch layout (Corrective RAG) */
.viz-branch {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-left: 0.2rem;
}

.viz-branch-path {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0.4rem 0.5rem;
  border-radius: 10px;
  border: 1px dashed #ddd3be;
  background: rgba(255, 252, 245, 0.4);
  transition: all 250ms ease;
}

.viz-branch-path.active-path {
  border-color: var(--primary);
  background: rgba(253, 231, 207, 0.3);
}

.viz-branch-path.dimmed-path {
  opacity: 0.25;
}

.viz-path-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  margin-right: 0.4rem;
  white-space: nowrap;
  min-width: 65px;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  transition: all 250ms ease;
}

.active-path .viz-path-label {
  background: var(--primary);
  color: #fff;
}

/* ReAct loop */
.viz-react-loop {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0.6rem;
  border-radius: 12px;
  border: 2px dashed #d4b0d4;
  background: rgba(244, 232, 244, 0.2);
  position: relative;
}

.viz-loop-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0.3rem;
}

.viz-loop-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--primary);
  background: #fff4e6;
  padding: 0.15rem 0.45rem;
  border-radius: 20px;
  border: 1px solid #e4ceb0;
  white-space: nowrap;
  animation: pulse-slow 2.5s ease-in-out infinite;
}

/* ── Circular ReAct visualization ── */

.react-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}

.react-circle-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}

/* User question node */
.react-question {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
  border: 2px solid #d7c9af;
  background: #fffcf5;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 250ms ease;
}

.react-question.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, #fff4e6, #fde7cf);
  color: var(--text);
  box-shadow: 0 4px 16px rgba(191, 75, 39, 0.2);
}

.react-question.done {
  border-color: #6abf6a;
  background: #edf8ed;
  color: #2d6a2d;
}

.react-question-text {
  font-style: italic;
  font-weight: 500;
}

.react-question-arrow {
  font-size: 1.1rem;
  color: #d7c9af;
  line-height: 1;
  transition: color 250ms ease;
}

.react-question-arrow.active {
  color: var(--primary);
}

/* Diagram layout (flex column, no absolute positioning) */
.react-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.react-diagram-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
}

.react-connectors {
  display: flex;
  justify-content: space-between;
  width: 72%;
  padding: 0 0.5rem;
}

/* Arrow connectors */
.react-arrow {
  font-size: 1.5rem;
  color: #d7c9af;
  transition: color 250ms ease;
  line-height: 1;
  user-select: none;
}

.react-arrow.active {
  color: var(--primary);
}

/* Agent nodes */
.react-cnode {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.4rem 0.55rem;
  border-radius: 10px;
  border: 2px solid #d7c9af;
  background: #fffcf5;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 250ms ease;
  min-width: 58px;
  text-align: center;
}

.react-cnode .viz-node-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.react-cnode.active {
  border-color: var(--primary);
  background: linear-gradient(135deg, #fff4e6, #fde7cf);
  color: var(--text);
  box-shadow: 0 4px 16px rgba(191, 75, 39, 0.2);
  transform: scale(1.06);
  z-index: 3;
}

.react-cnode.done {
  border-color: #6abf6a;
  background: #edf8ed;
  color: #2d6a2d;
}

.react-cnode.dimmed {
  opacity: 0.35;
}

/* Center label */
.react-center-label {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.3;
  pointer-events: none;
  padding: 0 0.3rem;
  white-space: nowrap;
}

/* Environment box */
.react-env {
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  border: 1px dashed #afbfd9;
  background: #e6ecf7;
  text-align: center;
  min-width: 180px;
  max-width: 260px;
  transition: all 250ms ease;
}

.react-env.active {
  border-color: #2b4a7f;
  box-shadow: 0 4px 12px rgba(43, 74, 127, 0.18);
}

.react-env-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #2b4a7f;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.react-env-tools {
  display: flex;
  gap: 0.3rem;
  justify-content: center;
  margin-top: 0.3rem;
  flex-wrap: wrap;
}

.react-env-tool {
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.65rem;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  background: rgba(255,255,255,0.7);
  color: #2b4a7f;
  border: 1px solid #afbfd9;
  transition: all 200ms ease;
}

.react-env-tool.tool-active {
  background: #2b4a7f;
  color: #fff;
  border-color: #2b4a7f;
}

/* Final answer */
.react-final {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  border-radius: 10px;
  border: 2px solid #d7c9af;
  background: #fffcf5;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 250ms ease;
}

.react-final.active {
  border-color: #6abf6a;
  background: #edf8ed;
  color: #2d6a2d;
  box-shadow: 0 4px 12px rgba(106, 191, 106, 0.2);
}

.react-final.dimmed {
  opacity: 0.35;
}

/* ── Trace panel ── */

.react-trace-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #1a1a1d;
  padding: 0.7rem;
  min-height: 280px;
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.react-trace-title {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #888;
}

.react-trace-entries {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.react-trace-empty {
  margin: 0;
  font-size: 0.75rem;
  color: #666;
  font-style: italic;
}

.react-trace-entry {
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  line-height: 1.4;
  animation: trace-in 300ms ease;
  border-left: 3px solid;
}

@keyframes trace-in {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.trace-question {
  background: rgba(191, 160, 100, 0.12);
  border-left-color: #c4a35a;
  color: #d4c08a;
}

.trace-think {
  background: rgba(244, 232, 244, 0.15);
  border-left-color: #b06ab0;
  color: #d4a0d4;
}

.trace-act {
  background: rgba(191, 75, 39, 0.12);
  border-left-color: var(--primary);
  color: #e8a070;
}

.trace-observe {
  background: rgba(43, 74, 127, 0.12);
  border-left-color: #5a8fd4;
  color: #8ab4e8;
}

.trace-final {
  background: rgba(106, 191, 106, 0.12);
  border-left-color: #6abf6a;
  color: #8fd88f;
}

.trace-iteration-label {
  padding: 0.15rem 0.4rem;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #666;
  border-top: 1px solid #333;
  margin-top: 0.2rem;
  padding-top: 0.4rem;
}

/* Reflexion trace colors */
.trace-eval {
  background: rgba(192, 57, 43, 0.12);
  border-left-color: #c0392b;
  color: #e88;
}

.trace-reflect {
  background: rgba(142, 68, 173, 0.12);
  border-left-color: #9b59b6;
  color: #c49bd4;
}

.trace-memory {
  background: rgba(43, 74, 127, 0.12);
  border-left-color: #5a8fd4;
  color: #8ab4e8;
}

/* ── Reflexion visualization ── */

.reflexion-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.reflexion-arrow {
  font-size: 1.2rem;
}

.reflexion-node.eval-fail {
  border-color: #c0392b;
  background: linear-gradient(135deg, #fde8e8, #f8d0d0);
  color: #922;
}

.reflexion-node.eval-pass {
  border-color: #6abf6a;
  background: #edf8ed;
  color: #2d6a2d;
}

.reflexion-memory-box {
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  border: 1px dashed #afbfd9;
  background: #e6ecf7;
  text-align: center;
  min-width: 160px;
  max-width: 220px;
  transition: all 250ms ease;
}

.reflexion-memory-box.active {
  border-color: #2b4a7f;
  box-shadow: 0 4px 12px rgba(43, 74, 127, 0.18);
}

.reflexion-memory-box.dimmed {
  opacity: 0.35;
}

.reflexion-memory-entries {
  margin-top: 0.3rem;
}

.reflexion-memory-empty {
  color: #7a8faa;
  font-style: italic;
  font-size: 0.62rem;
  margin: 0;
}

.reflexion-memory-entry {
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  background: rgba(255,255,255,0.7);
  color: #2b4a7f;
  font-size: 0.62rem;
  margin-top: 0.2rem;
  border: 1px solid #afbfd9;
  text-align: left;
}

.reflexion-call {
  font-size: 0.55rem;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  color: #888;
  opacity: 0.7;
  margin-top: 0.1rem;
  transition: opacity 250ms ease;
}

.react-cnode.active .reflexion-call {
  opacity: 1;
  color: var(--primary);
}

.reflexion-loop-label {
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 600;
  margin-top: 0.15rem;
  opacity: 0.4;
  transition: opacity 250ms ease;
}

.reflexion-loop-label.active {
  opacity: 1;
  color: var(--primary);
}

.reflexion-side-panels {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.reflexion-side-panels .react-trace-panel {
  max-height: 200px;
}

.reflexion-stm-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #1a1a1d;
  padding: 0.7rem;
  min-height: 100px;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.reflexion-stm-panel .react-trace-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #aaa;
  margin: 0 0 0.4rem 0;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #333;
}

.reflexion-stm-panel .react-trace-title small {
  font-weight: 400;
  color: #666;
}

.reflexion-stm-entries {
  flex: 1;
  overflow-y: auto;
}

.reflexion-stm-entry {
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.68rem;
  line-height: 1.4;
  border-left: 3px solid #555;
  margin-bottom: 0.25rem;
  color: #ccc;
}

.reflexion-stm-entry.stm-action {
  border-left-color: var(--primary);
  background: rgba(191, 75, 39, 0.08);
  color: #e8a070;
}

.reflexion-stm-entry.stm-result {
  border-left-color: #5a8fd4;
  background: rgba(43, 74, 127, 0.08);
  color: #8ab4e8;
}

.reflexion-stm-entry.stm-inject {
  border-left-color: #9b59b6;
  background: rgba(142, 68, 173, 0.1);
  color: #c49bd4;
  font-style: italic;
}

.reflexion-stm-cleared {
  text-align: center;
  font-size: 0.6rem;
  color: #666;
  font-style: italic;
  padding: 0.2rem;
}

/* ── Tree of Thoughts visualization ── */

.tot-task {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 0.3rem 0;
}

.tot-canvas {
  position: relative;
  width: 100%;
  max-width: 540px;
  height: 330px;
  margin: 0 auto;
}

.tot-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tot-edge {
  stroke: #d7c9af;
  stroke-width: 2;
  transition: stroke 300ms ease, opacity 300ms ease;
}

.tot-edge.tot-edge-active {
  stroke: var(--primary);
  stroke-width: 2.5;
}

.tot-edge.tot-edge-solved {
  stroke: #6abf6a;
  stroke-width: 2.5;
}

.tot-edge.tot-edge-dimmed {
  opacity: 0.25;
}

.tot-hidden {
  display: none !important;
}

.tot-node {
  position: absolute;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
  border: 2px solid #d7c9af;
  background: #fffcf5;
  text-align: center;
  transition: all 300ms ease;
  z-index: 1;
  white-space: nowrap;
}

.tot-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.tot-label-solution {
  color: #2d6a2d;
}

.tot-remaining {
  font-size: 0.54rem;
  color: #888;
}

.tot-eval-badge {
  padding: 0.06rem 0.35rem;
  border-radius: 4px;
  font-size: 0.52rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tot-eval-sure {
  background: #27ae60;
  color: #fff;
}

.tot-eval-likely {
  background: #f39c12;
  color: #fff;
}

.tot-eval-impossible {
  background: #c0392b;
  color: #fff;
}

.tot-node.tot-active {
  border-color: var(--primary);
  background: linear-gradient(135deg, #fff4e6, #fde7cf);
  box-shadow: 0 3px 12px rgba(191, 75, 39, 0.25);
  z-index: 2;
}

.tot-node.tot-pruned {
  border-color: #c0392b;
  border-style: dashed;
  opacity: 0.4;
}

.tot-node.tot-pruned .tot-label {
  text-decoration: line-through;
}

.tot-node.tot-dimmed {
  opacity: 0.25;
}

.tot-node.tot-on-path {
  border-color: #6abf6a;
  background: #f0faf0;
}

.tot-node.tot-solved {
  border-color: #6abf6a;
  background: #edf8ed;
  box-shadow: 0 3px 12px rgba(106, 191, 106, 0.3);
}

/* Bottom row: trace + detail side by side */
.tot-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin-top: 0.5rem;
}

@media (max-width: 720px) {
  .tot-bottom-row {
    grid-template-columns: 1fr;
  }
}

/* Trace colors for ToT */
.trace-generate {
  background: rgba(191, 75, 39, 0.12);
  border-left-color: var(--primary);
  color: #e8a070;
}

.trace-evaluate {
  background: rgba(243, 156, 18, 0.12);
  border-left-color: #f39c12;
  color: #f0c060;
}

.trace-backtrack {
  background: rgba(192, 57, 43, 0.12);
  border-left-color: #c0392b;
  color: #e88;
}

.trace-solve {
  background: rgba(106, 191, 106, 0.12);
  border-left-color: #6abf6a;
  color: #8fd88f;
}

/* ── STaR visualization ── */

.star-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}

.star-flow {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.star-examples {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.star-example {
  border: 2px solid #d7c9af;
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  background: #fffcf5;
  font-size: 0.72rem;
  line-height: 1.5;
  transition: all 300ms ease;
}

.star-example.star-ex-active {
  border-color: var(--primary);
  box-shadow: 0 3px 12px rgba(191, 75, 39, 0.15);
}

.star-example.star-ex-done-correct {
  border-color: #6abf6a;
  background: #f6fdf6;
}

.star-example.star-ex-done-wrong {
  border-color: #c0392b;
  background: #fdf6f6;
}

.star-example.star-ex-rationalized {
  border-color: #9b59b6;
  background: #faf6fd;
}

.star-example-header {
  font-weight: 700;
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.star-example-rationale {
  margin-top: 0.3rem;
  padding: 0.3rem 0.4rem;
  background: rgba(0,0,0,0.03);
  border-radius: 5px;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.66rem;
  color: #555;
}

.star-example-answer {
  margin-top: 0.25rem;
  font-weight: 600;
}

.star-verdict {
  font-size: 0.64rem;
  padding: 0.08rem 0.35rem;
  border-radius: 4px;
  font-weight: 700;
}

.star-correct {
  background: #27ae60;
  color: #fff;
}

.star-wrong {
  background: #c0392b;
  color: #fff;
}

.star-rationalize {
  margin-top: 0.3rem;
  padding: 0.35rem 0.4rem;
  background: rgba(142, 68, 173, 0.08);
  border-left: 3px solid #9b59b6;
  border-radius: 5px;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.66rem;
  color: #555;
}

.star-prompt {
  margin-top: 0.25rem;
  padding: 0.2rem 0.4rem;
  background: rgba(43, 74, 127, 0.06);
  border-left: 3px solid #5a8fd4;
  border-radius: 4px;
  font-size: 0.64rem;
  color: #555;
}

.star-prompt code {
  background: rgba(0,0,0,0.05);
  padding: 0.1rem 0.25rem;
  border-radius: 3px;
  font-size: 0.62rem;
}

.star-rat-header {
  margin-top: 0.35rem;
  padding-top: 0.3rem;
  border-top: 1px dashed #d7c9af;
}

.star-rat-check {
  margin-top: 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
}

.star-hidden {
  display: none !important;
}

.star-pipeline {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.star-pipe-arrow {
  font-size: 1.2rem;
  color: #d7c9af;
}

.star-pipe-filter,
.star-pipe-train,
.star-pipe-repeat {
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  font-size: 0.7rem;
  text-align: center;
  transition: all 300ms ease;
}

.star-pipe-filter {
  border: 2px solid #d7c9af;
  background: #fffcf5;
}

.star-pipe-filter.star-pipe-active {
  border-color: var(--primary);
  background: linear-gradient(135deg, #fff4e6, #fde7cf);
}

.star-filter-items {
  margin-top: 0.3rem;
  font-size: 0.62rem;
  color: #555;
}

.star-filter-item {
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
  margin: 0.15rem 0;
}

.star-filter-kept {
  background: rgba(39, 174, 96, 0.1);
  border-left: 3px solid #27ae60;
}

.star-filter-rationalized {
  background: rgba(142, 68, 173, 0.1);
  border-left: 3px solid #9b59b6;
}

.star-pipe-train {
  border: 2px solid #6abf6a;
  background: #edf8ed;
  color: #2d6a2d;
  font-weight: 600;
}

.star-pipe-train.star-pipe-dimmed {
  opacity: 0.35;
}

.star-pipe-train.star-pipe-active {
  box-shadow: 0 3px 12px rgba(106, 191, 106, 0.25);
}

.star-pipe-repeat {
  border: 2px dashed #d7c9af;
  background: #fffcf5;
  color: var(--muted);
  font-weight: 600;
}

.star-pipe-repeat.star-pipe-active {
  border-color: var(--primary);
  color: var(--primary);
}

/* STaR trace colors */
.trace-star-generate {
  background: rgba(191, 75, 39, 0.12);
  border-left-color: var(--primary);
  color: #e8a070;
}

.trace-star-correct {
  background: rgba(106, 191, 106, 0.12);
  border-left-color: #6abf6a;
  color: #8fd88f;
}

.trace-star-wrong {
  background: rgba(192, 57, 43, 0.12);
  border-left-color: #c0392b;
  color: #e88;
}

.trace-star-rationalize {
  background: rgba(142, 68, 173, 0.12);
  border-left-color: #9b59b6;
  color: #c49bd4;
}

.trace-star-train {
  background: rgba(106, 191, 106, 0.12);
  border-left-color: #6abf6a;
  color: #8fd88f;
}

/* ── ReST-EM visualization ── */

.restem-canvas {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.3rem 0;
}

.restem-iteration {
  border: 2px solid #d7c9af;
  border-radius: 12px;
  padding: 0.5rem;
  background: #fffcf5;
  min-width: 220px;
  flex: 1;
  transition: all 300ms ease;
}

.restem-iteration.restem-dimmed {
  opacity: 0.3;
}

.restem-iteration.restem-active {
  border-color: var(--primary);
  box-shadow: 0 3px 12px rgba(191, 75, 39, 0.15);
}

.restem-iteration.restem-done {
  border-color: #6abf6a;
}

.restem-iter-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.4rem;
  text-align: center;
}

.restem-steps {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.restem-step {
  width: 100%;
  padding: 0.35rem 0.4rem;
  border-radius: 8px;
  border: 1.5px solid #d7c9af;
  background: #fafaf5;
  transition: all 300ms ease;
}

.restem-step.restem-step-active {
  border-color: var(--primary);
  background: linear-gradient(135deg, #fff4e6, #fde7cf);
}

.restem-step.restem-step-done {
  border-color: #6abf6a;
  background: #f6fdf6;
}

.restem-step-header {
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.restem-samples {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.restem-sample {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
  font-size: 0.6rem;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  background: rgba(0,0,0,0.02);
  transition: all 300ms ease;
}

.restem-sample.restem-sample-hidden {
  display: none;
}

.restem-sample.restem-sample-kept {
  background: rgba(39, 174, 96, 0.1);
  border-left: 3px solid #27ae60;
}

.restem-sample.restem-sample-discarded {
  opacity: 0.3;
  text-decoration: line-through;
}

.restem-eq {
  flex: 1;
}

.restem-tag {
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
  font-size: 0.55rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-left: 0.3rem;
}

.restem-tag-correct {
  background: #27ae60;
  color: #fff;
}

.restem-tag-wrong {
  background: #c0392b;
  color: #fff;
}

.restem-arrow {
  font-size: 1rem;
  color: #d7c9af;
  text-align: center;
  transition: color 300ms ease;
}

.restem-arrow.restem-arrow-active {
  color: var(--primary);
}

.restem-iter-arrow {
  font-size: 1.8rem;
  color: #d7c9af;
  align-self: center;
  transition: color 300ms ease;
  flex-shrink: 0;
}

.restem-iter-arrow.restem-iter-arrow-active {
  color: var(--primary);
}

.restem-iter-arrow.restem-iter-arrow-hidden {
  opacity: 0.2;
}

.restem-kept {
  font-size: 0.6rem;
  color: #2d6a2d;
  margin-top: 0.2rem;
}

.restem-metric {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 0.5rem;
  min-height: 1.2em;
}

@media (max-width: 720px) {
  .react-layout,
  .star-layout {
    grid-template-columns: 1fr;
  }

  .ra-layout {
    flex-direction: column;
  }

  .ra-code-panel {
    flex: 0 0 auto;
  }

  .restem-canvas {
    flex-direction: column;
  }

  .restem-iter-arrow {
    transform: rotate(90deg);
    align-self: center;
  }

  .react-trace-panel {
    max-height: 250px;
  }
}


/* ── Scaffolding → Internalized spectrum ── */

.scaffold-spectrum {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: stretch;
  margin: 1.5rem 0;
}

.scaffold-col {
  padding: 1rem 1.2rem;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.scaffold-external {
  background: #f5f0e8;
}

.scaffold-internal {
  background: linear-gradient(135deg, #eef4fb, #e6ecf7);
}

.scaffold-heading {
  margin: 0 0 0.6rem;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.scaffold-col ul {
  margin: 0;
  padding-left: 1.1rem;
  list-style: disc;
}

.scaffold-col li {
  font-size: 0.88rem;
  line-height: 1.55;
  margin-bottom: 0.3rem;
  color: var(--text);
}

.scaffold-examples {
  margin: 0.7rem 0 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  font-style: italic;
}

.scaffold-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: var(--primary);
  padding: 0 0.2rem;
}

@media (max-width: 720px) {
  .scaffold-spectrum {
    grid-template-columns: 1fr;
  }

  .scaffold-arrow {
    transform: rotate(90deg);
    font-size: 1.4rem;
    padding: 0.3rem 0;
  }
}

@keyframes pulse-slow {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.viz-react-loop.loop-active {
  border-color: var(--primary);
  background: rgba(253, 231, 207, 0.15);
}

/* Detail card below pipeline */
.viz-detail-card {
  margin-top: 0.8rem;
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid #ece3d0;
  background: #fffdf8;
  min-height: 48px;
  transition: all 200ms ease;
}

.viz-detail-text {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

/* Controls */
.viz-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 0.7rem;
}

.viz-btn {
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff7ec;
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 150ms ease;
}

.viz-btn:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.viz-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.viz-progress {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  min-width: 80px;
  text-align: center;
}

@media (max-width: 820px) {
  .viz-pipeline {
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
  }

  .viz-branch {
    margin-left: 0;
  }
}

/* ── Math post blocks (exercises, proofs, results) ── */

.exercise-block,
.proof-block,
.result-block {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-radius: 0 10px 10px 0;
}

.exercise-block {
  border-left: 4px solid var(--primary);
  background: rgba(191, 75, 39, 0.06);
}

.proof-block {
  border-left: 4px solid #b8a88a;
  background: rgba(184, 168, 138, 0.08);
}

.result-block {
  border-left: 4px solid #2b7a4b;
  background: rgba(43, 122, 75, 0.06);
}

.exercise-block > strong,
.proof-block > strong,
.result-block > strong {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 0.3rem;
}

.exercise-block > strong { color: var(--primary-strong); }
.proof-block > strong { color: #6f5835; }
.result-block > strong { color: #2b7a4b; }

.exercise-block p,
.proof-block p,
.result-block p {
  margin: 0.3rem 0;
}

.pattern-article .exercise-block p,
.pattern-article .proof-block p,
.pattern-article .result-block p {
  margin: 0.3rem 0;
}

.proof-end {
  text-align: right;
  font-size: 0.9rem;
  color: #b8a88a;
}

.subsection-details {
  border-top: 1px solid var(--line);
  padding-top: 0.6rem;
  margin-top: 0.8rem;
}

.subsection-details summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.subsection-details summary::-webkit-details-marker {
  display: none;
}

.subsection-details summary::before {
  content: "\25B6";
  font-size: 0.65rem;
  color: var(--primary);
  transition: transform 200ms ease;
  flex-shrink: 0;
}

.subsection-details[open] > summary::before {
  transform: rotate(90deg);
}

.subsection-details summary h3 {
  margin: 0;
  font-size: 1.1rem;
}

.subsection-details summary:hover h3 {
  color: var(--primary);
}

.subsection-details > *:not(summary) {
  margin-top: 0.4rem;
}

.math-roadmap {
  list-style: none;
  padding: 0;
  counter-reset: roadmap;
}

.math-roadmap li {
  counter-increment: roadmap;
  padding: 0.25rem 0;
  padding-left: 1.6rem;
  position: relative;
}

.math-roadmap li::before {
  content: counter(roadmap);
  position: absolute;
  left: 0;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: linear-gradient(135deg, #f0dfc4, #e4cdaa);
  color: #6b4d28;
  font-size: 0.68rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  top: 0.35rem;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Footnotes ── */

.footnotes {
  max-width: 720px;
  margin: 2rem auto 0;
  padding: 0 1rem;
}

.footnotes hr {
  border: none;
  border-top: 1px solid var(--line);
  margin-bottom: 1rem;
}

.footnotes ol {
  padding-left: 1.4rem;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.55;
}

.footnotes li {
  margin-bottom: 0.5rem;
}

.footnotes a {
  color: var(--primary);
  text-decoration: none;
}

sup a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

/* ── Reasoning + Acting trace visualization ── */

.ra-layout {
  display: flex;
  gap: 0.8rem;
  align-items: stretch;
}

.ra-code-panel {
  flex: 0 0 46%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ra-code-details {
  border: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.ra-code-details > summary {
  cursor: pointer;
  list-style: none;
  margin-bottom: 0.4rem;
}

.ra-code-details > summary::-webkit-details-marker { display: none; }

.ra-code-details > summary::before {
  content: "\25B6";
  font-size: 0.65rem;
  color: var(--primary);
  margin-right: 0.4rem;
  display: inline-block;
  transition: transform 200ms ease;
}

.ra-code-details[open] > summary::before {
  transform: rotate(90deg);
}

.ra-code-panel .react-trace-title {
  margin-bottom: 0;
}

.ra-code {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.76rem;
  line-height: 1.55;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  margin: 0;
  overflow-y: auto;
  overflow-x: auto;
  color: var(--muted);
  flex: 1;
  min-height: 0;
}

/* ── Code fold toggles ── */

.ra-fold[data-expanded="false"] > .ra-fold-body { display: none; }
.ra-fold[data-expanded="true"] > .ra-fold-dots { display: none; }

.ra-fold-dots {
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 150ms;
}

.ra-fold-dots:hover {
  opacity: 1;
  color: var(--primary);
}

.ra-fold-body {
  cursor: pointer;
}

.ra-c-dim { opacity: 0.4; }

.ra-c-hl {
  border-left: 2px solid transparent;
  padding-left: 4px;
  margin-left: -6px;
  border-radius: 3px;
  transition: border-color 250ms ease, background 250ms ease;
}

.ra-c-blue   { border-left-color: #3b82f6; background: rgba(59, 130, 246, 0.08); color: var(--fg); }
.ra-c-amber  { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.08); color: var(--fg); }
.ra-c-green  { border-left-color: #10b981; background: rgba(16, 185, 129, 0.08); color: var(--fg); }
.ra-c-purple { border-left-color: #8b5cf6; background: rgba(139, 92, 246, 0.08); color: var(--fg); }

.ra-trace-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.8rem;
  overflow-y: auto;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.ra-trace-entry {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  margin-bottom: 0.35rem;
  border-left: 3px solid var(--line);
  background: var(--card);
  animation: raFadeIn 250ms ease;
}

@keyframes raFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ra-badge {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.ra-content {
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--fg);
}

.ra-boundary {
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  padding: 0.3rem 0;
  margin: 0.15rem 0 0.35rem;
  border-top: 1px dashed var(--line);
  border-bottom: 1px dashed var(--line);
  letter-spacing: 0.03em;
  animation: raFadeIn 250ms ease;
}

.ra-user                 { border-left-color: #64748b; }
.ra-user .ra-badge       { background: #64748b22; color: #94a3b8; }

.ra-analysis             { border-left-color: #3b82f6; }
.ra-analysis .ra-badge   { background: #3b82f622; color: #60a5fa; }
.ra-analysis .ra-content { font-style: italic; color: var(--muted); }

.ra-toolcall             { border-left-color: #f59e0b; }
.ra-toolcall .ra-badge   { background: #f59e0b22; color: #fbbf24; }
.ra-toolcall .ra-content { font-family: "SF Mono", "Fira Code", monospace; font-size: 0.8rem; }

.ra-toolresponse             { border-left-color: #10b981; }
.ra-toolresponse .ra-badge   { background: #10b98122; color: #34d399; }
.ra-toolresponse .ra-content { font-family: "SF Mono", "Fira Code", monospace; font-size: 0.8rem; }

.ra-final                { border-left-color: #8b5cf6; }
.ra-final .ra-badge      { background: #8b5cf622; color: #a78bfa; }
.ra-final .ra-content    { font-weight: 500; }

@media (max-width: 720px) {
  main,
  .site-header {
    width: calc(100% - 1.2rem);
  }

  .site-header {
    align-items: flex-start;
    gap: 0.6rem;
    flex-direction: column;
  }

  .top-nav {
    width: 100%;
    flex-wrap: wrap;
  }

  .dropdown-menu {
    position: static;
    margin-top: 0.35rem;
  }

  .hero {
    padding: 1.35rem;
  }
}
