:root {
  --ink: #17211e;
  --muted: #63706b;
  --paper: #f4f1e8;
  --surface: #fffdf7;
  --surface-muted: #f0eee6;
  --line: #d8d9d0;
  --green: #173f34;
  --rust: #9d482f;
  --peach: #f3a37e;
  --shadow: 0 18px 50px rgba(29, 48, 41, 0.09);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 4% 0%, rgba(244, 180, 91, 0.2), transparent 25rem),
    radial-gradient(circle at 95% 12%, rgba(91, 181, 164, 0.15), transparent 24rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.site-header,
main {
  width: min(1400px, calc(100% - 44px));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  border-bottom: 1px solid rgba(23, 63, 52, 0.15);
}

.brand,
.header-actions,
.model-badge {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  color: #fffaf0;
  background: var(--green);
  font-family: Georgia, serif;
  font-style: italic;
}

.header-actions { gap: 16px; }

.model-badge {
  gap: 7px;
  color: #416057;
  font-size: 0.73rem;
  font-weight: 750;
}

.model-badge > span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #55aa82;
  box-shadow: 0 0 0 4px rgba(85, 170, 130, 0.13);
}

.text-button,
.page-note button {
  padding: 0;
  border: 0;
  color: var(--green);
  background: none;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-color: rgba(23, 63, 52, 0.3);
  text-underline-offset: 4px;
  cursor: pointer;
}

.source-link { font-size: 0.82rem; }

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: clamp(40px, 8vw, 110px);
  align-items: stretch;
  padding: clamp(32px, 5vw, 64px) 0 30px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 8px;
  color: var(--rust);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, h3, h4, p { margin-top: 0; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; letter-spacing: -0.04em; }
h1 { max-width: 820px; margin-bottom: 0; font-size: clamp(2.7rem, 5.3vw, 5.2rem); line-height: 0.98; }
h2 { margin-bottom: 0; font-size: 2rem; line-height: 1; }
h3, h4 { letter-spacing: -0.02em; }

.intro-copy {
  margin: 18px 0 0;
  color: #4d5a55;
  font-size: 1.02rem;
}

.intro-copy a { font-weight: 800; text-underline-offset: 3px; }

.intro-aside {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 0 16px;
}

.hero-chain {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 9px;
  align-items: center;
  padding: 14px;
  border: 1px solid rgba(23, 63, 52, 0.14);
  border-radius: 12px;
  background: rgba(255, 253, 247, 0.52);
  color: var(--muted);
  font-size: 0.74rem;
  text-align: center;
}

.hero-chain span,
.hero-chain strong { padding: 7px 8px; border-radius: 7px; background: #e7eee9; }
.hero-chain strong { color: #fff; background: var(--green); }
.hero-chain i { color: var(--rust); font-style: normal; font-weight: 900; }

.coachmark {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px 16px;
  border: 1px solid #d8ccb7;
  border-radius: 14px;
  background: #fff7e7;
  box-shadow: 0 8px 28px rgba(54, 46, 31, 0.06);
}

.coachmark strong { font-size: 0.9rem; }
.coachmark p { margin: 2px 0 0; color: #6a6254; font-size: 0.84rem; }

.mini-chain { display: flex; align-items: center; }
.mini-chain span { padding: 4px 7px; border-radius: 5px; color: #5f473a; background: #f3d8c7; font-size: 0.7rem; font-weight: 800; }
.mini-chain i { width: 12px; height: 1px; background: #a8836e; }

.coachmark-link {
  border: 0;
  color: var(--rust);
  background: none;
  font-size: 0.84rem;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.icon-button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  color: #756d60;
  background: rgba(255, 255, 255, 0.5);
  font-size: 1.2rem;
  cursor: pointer;
}

.workbench {
  overflow: hidden;
  border: 1px solid rgba(23, 63, 52, 0.12);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workbench-topbar,
.sequence-toolbar,
.inspector-heading,
.section-heading,
.input-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.workbench-topbar {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}

.workbench-topbar h2 { font-family: inherit; font-size: 1.4rem; font-weight: 790; letter-spacing: -0.025em; }
.workbench-topbar .panel-kicker { margin-bottom: 3px; }
.privacy-note { margin: 0; color: var(--muted); font-size: 0.84rem; }
.privacy-note strong { color: #287258; }

.tag-form {
  padding: 18px 24px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
}

.tag-form > label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px;
}

.input-row input {
  min-width: 0;
  padding: 13px 15px;
  border: 1px solid #bec3bb;
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: #fff;
  font-size: 1rem;
}

.input-row input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 63, 52, 0.12); }
.input-row > button { padding: 0 22px; border: 0; border-radius: 10px; color: #fff; background: var(--green); font-weight: 800; cursor: pointer; }
.input-row > button:hover { background: #245a4b; }

.input-meta { margin-top: 9px; }
.input-meta p { margin: 0; color: var(--muted); font-size: 0.78rem; }

.examples { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.examples > span { color: var(--muted); font-size: 0.78rem; font-weight: 700; }

.example-button {
  padding: 4px 9px;
  border: 1px solid #c7c9c0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  font-size: 0.78rem;
  font-weight: 750;
  cursor: pointer;
}

.example-button:hover,
.example-button[aria-pressed="true"] { border-color: var(--green); color: #fff; background: var(--green); }

.model-status { min-height: 1em; margin: 8px 0 0; color: #4c665d; font-size: 0.78rem; font-weight: 700; }
.model-status.is-error { color: #a13d2c; }

.results {
  display: grid;
  grid-template-columns: minmax(0, 1.48fr) minmax(350px, 0.72fr);
  min-height: 435px;
}

.sequence-panel,
.inspector { padding: 22px 24px; }
.sequence-panel { min-width: 0; border-right: 1px solid var(--line); }
.inspector { overflow-y: auto; max-height: 540px; background: #fbfaf5; }

.panel-kicker { margin-bottom: 3px; color: var(--muted); font-size: 0.7rem; }
.sequence-toolbar h3, .inspector-heading h3 { margin: 0; font-size: 1.05rem; }

.play-button {
  padding: 7px 11px;
  border: 1px solid #bfc8c3;
  border-radius: 8px;
  color: var(--green);
  background: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}

.play-button span { margin-right: 4px; font-size: 0.6rem; }

.process-steps {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin: 18px 0 16px;
  padding: 0;
  list-style: none;
}

.process-steps li { position: relative; }
.process-steps li:not(:last-child)::after { position: absolute; top: 14px; right: -50%; width: 100%; height: 1px; background: #d5d9d4; content: ""; }

.process-steps button {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 4px;
  justify-items: center;
  width: 100%;
  border: 0;
  color: #7b8581;
  background: transparent;
  font-size: 0.72rem;
  font-weight: 750;
  cursor: pointer;
}

.process-steps button span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid #cdd2ce;
  border-radius: 50%;
  background: var(--surface);
}

.process-steps button.is-complete span,
.process-steps button[aria-current="step"] span { border-color: var(--green); color: #fff; background: var(--green); }
.process-steps button[aria-current="step"] { color: var(--green); }

.stage {
  min-height: 220px;
  padding: 16px;
  border: 1px solid #dde0da;
  border-radius: 14px;
  background:
    linear-gradient(rgba(23, 63, 52, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 63, 52, 0.025) 1px, transparent 1px),
    #faf9f3;
  background-size: 22px 22px;
}

.stage-copy { display: flex; gap: 10px; align-items: baseline; color: var(--muted); font-size: 0.86rem; }
.stage-copy strong { color: var(--ink); font-size: 0.9rem; }

.sequence-track {
  display: flex;
  overflow-x: auto;
  gap: 16px;
  align-items: center;
  min-height: 160px;
  padding: 24px 12px 12px;
}

.token-node {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 112px;
  height: 98px;
  padding: 12px 10px;
  border: 2px solid transparent;
  border-radius: 11px;
  text-align: center;
  cursor: pointer;
  transition: opacity 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.token-node:hover { transform: translateY(-2px); }
.token-node[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 3px #faf9f3, 0 0 0 5px var(--ink); transform: translateY(-3px); }
.token-node.is-neighbor { box-shadow: 0 0 0 3px rgba(23, 63, 52, 0.12); }
.token-node.is-muted { opacity: 0.38; }
.token-node .word { display: block; font-size: 1.05rem; font-weight: 800; }
.token-node .tag { display: block; min-height: 1.25em; margin-top: 2px; font-size: 0.7rem; font-weight: 900; letter-spacing: 0.08em; }
.token-node .node-score { display: block; min-height: 1.2em; margin-top: 5px; font-family: ui-monospace, monospace; font-size: 0.68rem; font-weight: 750; white-space: nowrap; }
.token-node .observation-dot { position: absolute; top: -10px; left: 50%; width: 7px; height: 7px; border-radius: 50%; background: var(--rust); box-shadow: 0 0 0 4px rgba(157, 72, 47, 0.12); transform: translateX(-50%); }
.token-node .transition-arrow { position: absolute; top: 50%; left: calc(100% + 2px); width: 12px; height: 1px; background: #789087; }
.token-node .transition-arrow::after { position: absolute; top: -3px; right: 0; width: 6px; height: 6px; border-top: 1px solid #789087; border-right: 1px solid #789087; content: ""; transform: rotate(45deg); }

.token--violet, .inspector-tag--violet { color: #493487; background: #e9e3ff; }
.token--coral, .inspector-tag--coral { color: #873b2d; background: #ffe1d8; }
.token--green, .inspector-tag--green { color: #235f4b; background: #d9f1e6; }
.token--cyan, .inspector-tag--cyan { color: #1d5b69; background: #dceff2; }
.token--amber, .inspector-tag--amber { color: #795318; background: #fae8bd; }
.token--blue, .inspector-tag--blue { color: #31558c; background: #e1eafd; }
.token--slate, .inspector-tag--slate { color: #55615d; background: #e9ece8; }
.token--pink, .inspector-tag--pink { color: #7f3e68; background: #f7deed; }
.token--teal, .inspector-tag--teal { color: #1e625f; background: #d8efec; }
.token--gold, .inspector-tag--gold { color: #775713; background: #f5e8b7; }
.token--rose, .inspector-tag--rose { color: #873c50; background: #f8dfe5; }
.token--indigo, .inspector-tag--indigo { color: #3f4b91; background: #e2e5fa; }
.token--lime, .inspector-tag--lime { color: #496222; background: #e5efcb; }
.token--orange, .inspector-tag--orange { color: #884814; background: #fae2c9; }

.legend { display: flex; gap: 16px; align-items: center; margin-top: 14px; }
.legend h4 { flex: 0 0 auto; margin: 0; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; }
.legend ul { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; padding: 0; list-style: none; }
.legend li { display: flex; gap: 5px; align-items: center; color: var(--muted); font-size: 0.76rem; }
.legend li i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.legend li strong { color: var(--ink); font-size: 0.7rem; }
.sequence-panel[data-step="1"] .legend,
.sequence-panel[data-step="2"] .legend { visibility: hidden; }

.inspector-tag { padding: 5px 8px; border-radius: 7px; font-size: 0.72rem; font-weight: 900; white-space: nowrap; }

.context-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  margin: 14px 0;
  padding: 9px;
  border-radius: 10px;
  color: #79827e;
  background: #efeee7;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  text-align: center;
}

.context-strip span:last-child { text-align: left; }
.context-strip span:first-child { text-align: right; }
.context-strip strong { padding: 5px 8px; border-radius: 6px; color: #fff; background: var(--green); }

.inspector-section { padding: 12px 0; border-top: 1px solid #e2e2da; }
.section-heading h4 { margin: 0; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
.section-heading span { color: var(--muted); font-size: 0.68rem; text-transform: uppercase; }

.feature-list { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 16px; margin: 9px 0 0; }
.feature-list div { display: flex; justify-content: space-between; gap: 8px; min-width: 0; font-size: 0.74rem; }
.feature-list dt { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.feature-list dd { margin: 0; overflow: hidden; font-family: ui-monospace, monospace; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }

.contribution-list { display: grid; gap: 7px; margin: 10px 0 0; padding: 0; list-style: none; }
.contribution-list li { display: grid; grid-template-columns: minmax(0, 1fr) 70px auto; gap: 8px; align-items: center; font-size: 0.72rem; }
.contribution-list code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.weight-track { height: 5px; border-radius: 999px; background: #e3e4df; }
.weight-track i { display: block; height: 100%; border-radius: inherit; background: #408b6f; }
.weight-track i.is-negative { margin-left: auto; background: #cb6d57; }
.score-positive { color: #1e7658; }
.score-negative { color: #a34736; }

.transition-evidence { display: flex; justify-content: space-between; gap: 12px; margin-top: 9px; padding: 9px 10px; border-radius: 8px; background: #efeee7; font-family: ui-monospace, monospace; font-size: 0.74rem; }
.score-caveat { margin: 9px 0 0; color: var(--muted); font-size: 0.7rem; }

.inspector[data-step="1"] .inspector-tag,
.inspector[data-step="1"] .context-strip,
.inspector[data-step="1"] .inspector-section,
.inspector[data-step="1"] .score-caveat,
.inspector[data-step="2"] .inspector-tag,
.inspector[data-step="2"] .weights-section,
.inspector[data-step="2"] .transition-section,
.inspector[data-step="2"] .score-caveat,
.inspector[data-step="3"] .transition-section { display: none; }

.page-note { margin: 12px 2px 28px; color: var(--muted); font-size: 0.76rem; text-align: right; }
.page-note button { margin-left: 10px; font-size: inherit; }

.crf-dialog {
  width: min(760px, calc(100% - 30px));
  max-height: min(850px, calc(100vh - 30px));
  padding: 0;
  border: 0;
  border-radius: 22px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 28px 100px rgba(13, 31, 25, 0.32);
}

.crf-dialog::backdrop { background: rgba(13, 28, 23, 0.58); backdrop-filter: blur(3px); }
.dialog-frame { margin: 0; }
.dialog-header { display: flex; justify-content: space-between; gap: 20px; padding: 26px 30px 22px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { max-width: 600px; font-size: clamp(1.8rem, 4vw, 2.7rem); }
.dialog-close { align-self: start; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: #fff; font-size: 1.35rem; cursor: pointer; }
.dialog-body { overflow-y: auto; max-height: calc(100vh - 160px); padding: 24px 30px 30px; }

.graph-explainer { margin-bottom: 22px; padding: 18px; border-radius: 14px; background: #edf2ee; }
.graph-label-row, .graph-word-row { display: grid; grid-template-columns: 70px 1fr 70px 1fr 70px; align-items: center; width: min(100%, 400px); margin: auto; text-align: center; }
.graph-label-row span { padding: 8px; border-radius: 8px; color: #fff; background: var(--green); font-size: 0.68rem; font-weight: 850; }
.graph-label-row i { height: 2px; background: #749187; }
.graph-word-row { grid-template-columns: repeat(3, 70px); justify-content: space-between; margin-top: 13px; }
.graph-word-row span { position: relative; padding-top: 10px; border-top: 1px solid #9cafaa; font-family: Georgia, serif; font-size: 1.1rem; }
.graph-explainer p { margin: 14px 0 0; color: var(--muted); font-size: 0.7rem; text-align: center; }

.dialog-copy { columns: 2; column-gap: 26px; color: #4e5b56; font-size: 0.85rem; }
.dialog-copy p { break-inside: avoid; margin-bottom: 0; }

.reading-list { margin-top: 24px; border-top: 1px solid var(--line); }
.reading-list h3 { margin: 18px 0 6px; font-size: 0.85rem; }
.reading-list a { display: grid; grid-template-columns: 80px minmax(0, 1fr) auto; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); text-decoration: none; font-size: 0.72rem; }
.reading-list a:hover strong { color: var(--rust); }
.reading-list span { color: var(--muted); }

.methodology { margin-top: 18px; padding: 12px 14px; border-radius: 10px; background: #f0eee7; font-size: 0.75rem; }
.methodology summary { font-weight: 800; cursor: pointer; }
.methodology p { margin: 10px 0 0; color: #53605b; }
.methodology a { font-weight: 750; text-underline-offset: 2px; }

button:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid #e07c54; outline-offset: 3px; }

@media (max-width: 900px) {
  .intro, .results { grid-template-columns: 1fr; }
  .intro { gap: 18px; }
  .intro-copy { max-width: 760px; }
  .sequence-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .inspector { max-height: none; }
  .coachmark { grid-template-columns: minmax(0, 1fr) auto auto; }
  .mini-chain { display: none; }
}

@media (max-width: 620px) {
  .site-header, main { width: min(100% - 24px, 1400px); }
  .site-header { min-height: 60px; }
  .brand > span:last-child, .model-badge { display: none; }
  .intro { padding-top: 30px; }
  h1 { font-size: clamp(2.6rem, 13vw, 4rem); }
  .coachmark { grid-template-columns: 1fr auto; }
  .coachmark-link { justify-self: start; }
  .icon-button { grid-column: 2; grid-row: 1; }
  .input-row { grid-template-columns: 1fr; }
  .input-row > button { min-height: 44px; }
  .input-meta { align-items: start; flex-direction: column; }
  .workbench-topbar, .sequence-toolbar { align-items: start; }
  .privacy-note { max-width: 130px; text-align: right; }
  .process-steps button { font-size: 0.54rem; }
  .process-steps button span { width: 25px; height: 25px; }
  .process-steps li:not(:last-child)::after { top: 12px; }
  .stage-copy { align-items: start; flex-direction: column; gap: 2px; }
  .sequence-track { min-height: 175px; }
  .legend { align-items: start; flex-direction: column; gap: 8px; }
  .feature-list { grid-template-columns: 1fr; }
  .page-note { text-align: left; }
  .page-note button { display: block; margin: 5px 0 0; }
  .dialog-header, .dialog-body { padding-inline: 20px; }
  .dialog-copy { columns: 1; }
  .dialog-copy p + p { margin-top: 12px; }
  .reading-list a { grid-template-columns: 68px minmax(0, 1fr) auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .token-node { transition: none; }
}
