:root {
  --bg: #fbf6e8;
  --bg-2: #f6eed8;
  --card: rgba(255, 253, 247, .82);
  --line: #ece2c8;
  --line-2: #e2d4b2;
  --ink: #3a3129;
  --muted: #8a7d6b;
  --accent: #e3a04f;
  --accent-ink: #9a5a17;
  --sage: #d8ecd0;
  --sage-ink: #4f8a5e;
  --rose: #f6d5cf;
  --rose-ink: #c0604b;
  --lavender: #e6dcf2;
  --lavender-ink: #8069b0;
  --vermilion: #d1573c;
  --radius: 22px;
  --shadow: 0 1px 2px rgba(80, 60, 30, .05), 0 12px 32px rgba(120, 90, 40, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15.5px;
  line-height: 1.55;
  padding: 0 16px 28px;
  overflow-x: hidden;
}

/* soft pastel shapes behind everything */
.blobs { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.blobs span { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; }
.blobs .b1 { width: 460px; height: 460px; background: #fde3b8; top: -120px; left: -80px; }
.blobs .b2 { width: 420px; height: 420px; background: #dcefd5; top: 30%; right: -140px; }
.blobs .b3 { width: 380px; height: 380px; background: #ece2f6; bottom: -140px; left: 30%; }

h1, h2 { font-family: Fraunces, Georgia, serif; font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: clamp(44px, 8vw, 72px); line-height: 1; }
h2 { font-size: 21px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 18px 0 6px; font-weight: 700; }
a { color: var(--accent-ink); }
sub { font-size: .72em; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }

/* ---------- hero ---------- */
.hero {
  max-width: 1240px; margin: 0 auto; padding: 46px 0 26px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 34px; align-items: center;
}
.hero h1 { font-size: clamp(56px, 9vw, 104px); letter-spacing: -.035em; line-height: .9; }
.hero h1 .accent { color: var(--accent); }
.hero-line { font-family: Fraunces, Georgia, serif; font-size: clamp(19px, 2.2vw, 24px); line-height: 1.35; margin: 18px 0 18px; max-width: 30ch; }
.byline { margin: 0; padding-left: 12px; border-left: 3px solid var(--accent); color: var(--muted); font-size: 13.5px; line-height: 1.6; }

/* the animated argument on graph paper */
.scene {
  margin: 0; padding: 22px 22px 16px; border-radius: 28px; border: 1px solid var(--line);
  background:
    radial-gradient(circle, rgba(154, 139, 118, .22) 1px, transparent 1.4px) 0 0 / 18px 18px,
    linear-gradient(135deg, rgba(255, 253, 247, .95), rgba(253, 240, 214, .8));
  box-shadow: var(--shadow);
}
.scene svg { width: 100%; height: auto; display: block; overflow: visible; }
.scene-node circle { fill: #fffdf7; stroke: var(--ink); stroke-width: 1.6; transition: fill .6s ease, stroke .6s ease, opacity .6s ease, transform .6s ease; }
.scene-node text { font-family: "Plus Jakarta Sans", sans-serif; font-weight: 600; font-size: 14px; fill: var(--ink); text-anchor: middle; dominant-baseline: central; transition: opacity .6s; }
.scene-node, .scene-edge { opacity: 0; transition: opacity .6s ease; }
.scene-node.show, .scene-edge.show { opacity: 1; }
.scene-node.in circle { fill: var(--sage); stroke: var(--sage-ink); stroke-width: 3; }
.scene-node.out circle { fill: var(--rose); stroke: var(--rose-ink); stroke-width: 2.2; stroke-dasharray: 6 5; }
.scene-node.out text { text-decoration: line-through; opacity: .7; }
.scene-edge { fill: none; stroke: var(--rose-ink); stroke-width: 2.6; stroke-dasharray: 7 5; animation: flow 1s linear infinite; }
.scene-head { fill: var(--rose-ink); }
.scene figcaption { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-size: 15px; min-height: 26px; }
.beat-dots { display: inline-flex; gap: 5px; }
.beat-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2); transition: background .3s, width .3s; }
.scene[data-beat="0"] .beat-dots i:nth-child(1),
.scene[data-beat="1"] .beat-dots i:nth-child(2),
.scene[data-beat="2"] .beat-dots i:nth-child(3),
.scene[data-beat="3"] .beat-dots i:nth-child(3) { background: var(--accent); width: 18px; border-radius: 4px; }
#scene-caption { transition: opacity .3s; }

.tabs {
  display: flex; width: fit-content; margin: 0 auto 22px; gap: 4px; padding: 5px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(10px);
}
.chapter-tab {
  font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); background: transparent;
  border: 0; border-radius: 999px; padding: 9px 20px; transition: background .2s, color .2s;
}
.chapter-tab:hover { color: var(--ink); }
.chapter-tab.active { background: var(--ink); color: #fffaf0; }

/* ---------- layout ---------- */
main { max-width: 1240px; margin: 0 auto; }
.chapter { display: none; }
.chapter.active { display: block; animation: rise .4s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.grid.trials { grid-template-columns: 320px minmax(0, 1fr); }
.stack { display: grid; gap: 18px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow); backdrop-filter: blur(12px);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.card-head .field:not(.small) { flex: 1 1 220px; max-width: 360px; }
.graph-card { position: sticky; top: 16px; }

/* ---------- controls ---------- */
.field {
  font: inherit; font-size: 14.5px; color: var(--ink); background: #fffdf7;
  border: 1px solid var(--line-2); border-radius: 12px; padding: 8px 12px; width: 100%;
  transition: border-color .2s, box-shadow .2s;
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(227, 160, 79, .2); }
.field.small { width: auto; padding: 5px 10px; font-size: 13.5px; }
label { display: block; margin: 10px 0; color: var(--muted); font-size: 13.5px; font-weight: 500; }
label .field { margin-top: 4px; }
label.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--ink); }
.btn {
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; color: #fffaf0; background: var(--ink);
  border: 1px solid var(--ink); border-radius: 999px; padding: 8px 18px;
  transition: transform .15s, background .2s, box-shadow .2s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(58, 49, 41, .18); }
.btn:disabled { opacity: .45; cursor: default; transform: none; box-shadow: none; }
.btn.small { padding: 4px 12px; font-size: 13px; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { background: #fff6e2; box-shadow: none; }
.btn.soft { background: #fff3dc; color: var(--accent-ink); border-color: #f2ddb4; }
.btn.icon { width: 38px; height: 38px; padding: 0; font-size: 16px; }
.wide-btn { width: 100%; margin-top: 6px; }

.builder { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.builder summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--accent-ink); }
.builder-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.builder-grid .wide { grid-column: 1 / -1; }

/* ---------- graph ---------- */
.graph { width: 100%; height: auto; max-height: 460px; display: block; }
.edge { fill: none; stroke: #9a8b76; stroke-width: 1.8; transition: stroke .3s, opacity .3s, stroke-width .3s; }
.edge.faded { opacity: .18; }
.edge.kill { stroke: var(--rose-ink); stroke-width: 2.3; }
.edge.chain { stroke: var(--vermilion); stroke-width: 3.4; stroke-dasharray: 8 6; animation: flow 1s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -14; } }
.arrow { fill: #9a8b76; }
.arrow-kill { fill: var(--rose-ink); }
.arrow-chain { fill: var(--vermilion); }

.node { cursor: pointer; outline: none; }
.node circle.body { stroke: var(--ink); stroke-width: 1.5; transition: fill .35s, stroke .35s; filter: drop-shadow(0 3px 5px rgba(90, 70, 40, .14)); }
.node:hover circle.body, .node:focus-visible circle.body { stroke-width: 2.4; }
.node text { font-family: "Plus Jakarta Sans", sans-serif; font-weight: 600; font-size: 19px; fill: var(--ink); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.node text.cap { font-size: 12px; font-weight: 500; fill: var(--muted); }
.node circle.halo { fill: none; stroke: var(--accent); stroke-width: 3; opacity: 0; transition: opacity .25s; }
.node.chosen circle.halo { opacity: 1; }
.node.in circle.body { stroke: var(--sage-ink); stroke-width: 3; }
.node.out circle.body { stroke: var(--rose-ink); stroke-width: 2.2; stroke-dasharray: 5 4; }
.node.undec circle.body { stroke: var(--lavender-ink); stroke-width: 2.2; stroke-dasharray: 2 4; }
.node.hidden { opacity: .35; }
.node.hidden circle.body { stroke-dasharray: 4 4; filter: none; }
.node.chainnode circle.halo { opacity: 1; stroke: var(--vermilion); }
.node line.strike { stroke: var(--rose-ink); stroke-width: 2; opacity: 0; transition: opacity .3s; }
.node.out line.strike { opacity: .75; }

.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: center; font-size: 13px; color: var(--muted); margin-top: 6px; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; border: 1.5px solid var(--ink); }
.dot.in { background: var(--sage); border-color: var(--sage-ink); }
.dot.out { background: var(--rose); border-color: var(--rose-ink); border-style: dashed; }
.dot.undec { background: var(--lavender); border-color: var(--lavender-ink); border-style: dotted; }
.dot.chosen { background: #fffdf7; border: 3px solid var(--accent); }
.caption { text-align: center; color: var(--ink); margin: 10px 0 0; min-height: 24px; font-size: 14.5px; }

/* ---------- side cards ---------- */
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0 4px; padding: 6px; border-radius: 999px; background: var(--bg-2); }
.round-label { font-weight: 700; }
.note { margin: 8px 0 0; font-size: 14.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip {
  font: inherit; font-size: 14px; cursor: pointer; color: var(--ink); background: #fffdf7;
  border: 1px solid var(--line-2); border-radius: 999px; padding: 4px 12px; transition: background .2s, border-color .2s;
}
.chip:hover { border-color: var(--accent); }
.chip.active { background: #fff0d6; border-color: var(--accent); }
.none { color: var(--muted); font-style: italic; font-size: 14px; }

.ledger { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.ledger th, .ledger td { border-bottom: 1px solid var(--line); padding: 7px 6px; text-align: right; }
.ledger tr:last-child td { border-bottom: 0; }
.ledger th:first-child, .ledger td:first-child { text-align: left; }
.ledger th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.yes { color: var(--sage-ink); font-weight: 700; }
.no { color: var(--rose-ink); font-weight: 700; }
.pill { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; }
.pill.skeptical { background: var(--sage); color: #2f5f3b; }
.pill.credulous { background: #fdebc9; color: #8a5413; }
.pill.rejected { background: var(--rose); color: #8f3b29; }

.agent-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.agent-row:last-child { border-bottom: 0; }
.agent-name { font-weight: 700; min-width: 70px; }
.toggle {
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; border: 1.5px solid var(--ink); border-radius: 50%;
  width: 40px; height: 40px; color: var(--ink); transition: opacity .2s, transform .15s;
}
.toggle:hover { transform: translateY(-2px); }
.toggle.off { opacity: .4; border-style: dashed; background: transparent !important; }
.score { margin-left: auto; font-size: 13px; color: var(--muted); }
.score b { color: var(--ink); font-size: 17px; }
#g-judgement p { margin: 6px 0; }

.exam-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.exam { margin-top: 14px; }
.verdict { border-radius: 16px; padding: 14px 16px; background: #fffdf7; border: 1px solid var(--line-2); animation: rise .3s ease; }
.verdict.good { background: #f1f8ec; border-color: #cfe5c6; }
.verdict.bad { background: #fdf0ec; border-color: #f3cfc5; }
.verdict h3 { margin: 0 0 6px; color: var(--ink); font-size: 13px; }
.verdict p { margin: 6px 0; }
.verdict ul { margin: 4px 0; padding-left: 18px; }
.verdict li { margin: 4px 0; }
.verdict .btn { margin-top: 8px; }
.linkish { font: inherit; background: none; border: 0; padding: 0; color: var(--accent-ink); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-align: left; }

/* ---------- experiments ---------- */
.progress { height: 8px; border-radius: 999px; background: var(--bg-2); margin-top: 14px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, #f2c27a, var(--accent)); transition: width .25s; }
.trial-results { display: grid; gap: 18px; }
.placeholder { text-align: center; color: var(--muted); padding: 40px 20px; }
.chart { width: 100%; max-width: 600px; height: auto; display: block; margin: 10px auto; }
.chart text { font-family: "Plus Jakarta Sans", sans-serif; font-size: 12.5px; fill: var(--muted); }
.chart .value { fill: var(--ink); font-weight: 700; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.key { display: flex; gap: 16px; justify-content: center; font-size: 13px; color: var(--muted); }
.key i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; }
.headline { font-size: 15px; margin: 10px 0 0; }
.open-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.open-row:last-child { border-bottom: 0; }

/* ---------- loading and toast ---------- */
.loading { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(251, 246, 232, .85); backdrop-filter: blur(8px); transition: opacity .5s, visibility .5s; padding: 16px; }
.loading.done { opacity: 0; visibility: hidden; }
.loading-card { text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 30px 46px; box-shadow: var(--shadow); }
.loading-title { font-family: Fraunces, serif; font-size: 24px; font-weight: 600; margin: 14px 0 2px; }
.loading-card p { margin: 2px 0; }
.loader { display: inline-block; width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); opacity: 0; z-index: 30;
  background: #fdf0ec; border: 1px solid #f3cfc5; color: var(--ink); padding: 10px 18px; border-radius: 14px;
  box-shadow: var(--shadow); transition: opacity .3s, transform .3s; max-width: calc(100% - 32px); pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 960px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 22px; padding-top: 32px; }
  .grid, .grid.trials, .two { grid-template-columns: minmax(0, 1fr); }
  .graph-card { position: static; }
}
@media (max-width: 560px) {
  body { font-size: 15px; }
  .hero-line br, .byline br { display: none; }
  .byline { line-height: 1.5; }
  .scene { padding: 16px 12px 12px; border-radius: 22px; }
  .scene figcaption { font-size: 14px; }
  .tabs { width: 100%; justify-content: space-between; }
  .chapter-tab { padding: 8px 12px; flex: 1; }
  .card { padding: 16px; }
  .builder-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
