:root {
  --bg: #ffffff;
  --ink: #162024;
  --muted: #5e6b73;
  --line: #dde5e8;
  --soft: #f5f8f9;
  --teal: #16736b;
  --blue: #264f8f;
  --amber: #b87918;
  --red: #b94c4a;
  --purple: #6555a6;
  --shadow: 0 18px 48px rgba(22, 32, 36, 0.09);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.nav-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 740;
  text-decoration: none;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border: 2px solid var(--teal);
  border-radius: 50%;
  position: relative;
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  background: var(--teal);
  border-radius: 99px;
}

.brand-mark::before {
  width: 15px;
  height: 2px;
  left: 4px;
  top: 10px;
  transform: rotate(35deg);
}

.brand-mark::after {
  width: 2px;
  height: 15px;
  left: 10px;
  top: 4px;
  transform: rotate(35deg);
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 22px;
  color: var(--muted);
  font-size: 0.94rem;
}

.nav-links a {
  text-decoration: none;
}

.nav-links a:hover {
  color: var(--ink);
}

.hero {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 88px 0 54px;
  display: block;
  /* display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: 44px;
  align-items: end; */
}

.compact-hero {
  padding: 64px 0 38px;
  gap: 34px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 780;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

/* h1 {
  max-width: 100%;
  margin-bottom: 22px;
  font-size: clamp(2.25rem, 6vw, 5.15rem);
  line-height: 0.98;
  letter-spacing: 0;
} */

h1 {
  max-width: 100%;
  margin-bottom: 22px;
  font-size: clamp(1.9rem, 3.3vw, 3.25rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  max-width: 100%;
  margin-bottom: 14px;
  font-size: clamp(1.6rem, 2.6vw, 2.25rem);
  line-height: 1.06;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  font-size: 1.35rem;
}

.hero-summary {
  max-width: 800px;
  color: #344248;
  font-size: 1.12rem;
  text-align: justify;
}

.author-block {
  max-width: 860px;
  margin: 28px 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.96rem;
}

.author-block p {
  margin-bottom: 6px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid #cbd8dc;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 720;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.button:hover {
  border-color: #9eb5bc;
  transform: translateY(-1px);
}

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

.button.muted {
  color: var(--muted);
  background: var(--soft);
}

.button.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.88rem;
}

.button-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 0.95em;
}

.button-label {
  display: inline-block;
}

.hero-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
  border: 1px solid #e6edf0;
  border-radius: 7px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfb 100%);
}

.metric-value {
  display: block;
  margin-bottom: 6px;
  color: var(--blue);
  font-size: 1.65rem;
  line-height: 1;
  font-weight: 820;
}

.metric-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.section {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 58px 0;
}

.compact-section {
  padding: 42px 0;
}

.section-heading {
  /* max-width: 820px; */
  max-width: 100%;
  margin-bottom: 28px;
}

.compact-heading {
  margin-bottom: 20px;
}

.section-heading p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.02rem;
  text-align: justify;
}

.narrative-section {
  padding-top: 72px;
}

.narrative-section.compact-section {
  padding-top: 46px;
}

.split-section,
.text-figure-grid,
.result-story {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 32px;
  align-items: start;
}

.split-section.reverse {
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
}

.split-section.reverse .prose {
  order: -1;
}

.prose {
  color: #344248;
  font-size: 1.02rem;
  text-align: justify;
}

.prose p {
  margin-bottom: 16px;
}

.prose h3 {
  color: var(--ink);
  font-size: 1.35rem;
  line-height: 1.2;
}

code {
  padding: 0.05em 0.28em;
  border: 1px solid #d9e4e7;
  border-radius: 5px;
  background: var(--soft);
  color: #203138;
  font-size: 0.92em;
}

.pipeline-panel {
  display: grid;
  gap: 12px;
  padding-left: 22px;
  border-left: 2px solid var(--line);
}

.pipeline-step {
  padding: 18px 18px 18px 0;
  border-bottom: 1px solid var(--line);
}

.pipeline-step:last-child {
  border-bottom: 0;
}

.pipeline-step span {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--amber);
  font-weight: 820;
}

.pipeline-step strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 1.08rem;
}

.pipeline-step p {
  margin-bottom: 0;
  color: var(--muted);
}

.equation-box {
  margin: 18px 0;
  padding: 18px;
  border: 1px solid #bfd4d2;
  border-radius: 8px;
  background: #f4faf8;
  color: #0f5f58;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.1rem;
  font-weight: 760;
  text-align: center;
}

.compact-figure {
  margin-top: 0;
}

.method-stack {
  display: grid;
  gap: 12px;
}

.method-stack article {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.method-stack p {
  margin-bottom: 0;
  color: var(--muted);
}

.method-route-grid {
  margin-top: 28px;
}

.callout {
  margin-top: 22px;
  padding: 18px;
  border-left: 4px solid var(--teal);
  background: var(--soft);
  color: #314147;
}

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

.concept-grid {
  margin-bottom: 30px;
}

.concept-grid.tight-grid {
  margin-bottom: 16px;
}

.decoder-route-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 24px;
}

.code-family-grid {
  display: grid;
  gap: 14px;
}

.intro-compact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.dense-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.dense-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.approach-grid article,
.concept-grid article,
.decoder-route-grid article,
.code-family-grid article,
.figure1-card,
.result-card,
.lattice-card,
.chart-card,
.citation-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.approach-grid article,
.concept-grid article,
.decoder-route-grid article,
.code-family-grid article {
  padding: 22px;
}

.code-family-grid strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.08rem;
}

.step-index {
  display: block;
  margin-bottom: 28px;
  color: var(--amber);
  font-weight: 800;
}

.approach-grid p,
.concept-grid p,
.decoder-route-grid p,
.code-family-grid p,
.result-card figcaption,
.wide-figure figcaption {
  color: var(--muted);
}

.concept-grid p,
.decoder-route-grid p,
.code-family-grid p {
  margin-bottom: 0;
}

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

.figure1-card {
  display: grid;
  gap: 14px;
  padding: 12px;
  overflow: hidden;
}

.figure1-card:first-child {
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  align-items: center;
}

.figure1-card:nth-child(2) {
  grid-column: span 8;
}

.figure1-card:nth-child(3) {
  grid-column: span 4;
}

.figure1-card figure {
  margin: 0;
  overflow: hidden;
  border-radius: 6px;
  background: var(--soft);
}

.figure1-card img {
  width: 100%;
  border-radius: 6px;
  background: #fff;
}

.figure1-card div {
  padding: 4px 4px 6px;
}

.figure1-card h3 {
  margin-bottom: 8px;
  font-size: 1.08rem;
}

.figure1-card p:not(.eyebrow) {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.96rem;
}

.wide-figure {
  margin: 22px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.wide-figure img {
  width: 100%;
  border-radius: 6px;
  background: #fff;
}

figcaption {
  padding: 12px 4px 2px;
  font-size: 0.94rem;
}

.lab-section {
  width: 100%;
  max-width: none;
  padding: 68px max(16px, calc((100% - 1180px) / 2));
  background: #fff;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.embedded-lab {
  padding-top: 44px;
  padding-bottom: 46px;
  background: #f8fbfb;
}

.lab-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 16px;
}

.interaction-shell {
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
  align-items: start;
  gap: 20px;
  margin-top: 32px;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qec-controls {
  gap: 18px;
  padding: 18px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend,
label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 720;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  min-height: 44px;
  padding: 0 36px 0 12px;
  border: 1px solid #cbd8dc;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
}

input[type="range"] {
  accent-color: var(--teal);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid #d7e1e4;
  border-radius: 8px;
  background: var(--soft);
}

.segmented.three {
  grid-template-columns: repeat(3, 1fr);
}

.pattern-control {
  display: grid;
  gap: 8px;
}

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

.pattern-seg {
  min-height: 40px;
  padding: 0 8px;
}

.pattern-note {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #dfe9ec;
  border-radius: 8px;
  color: var(--muted);
  background: #f8fbfb;
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.35;
}

.seg {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 720;
  line-height: 1.15;
  cursor: pointer;
}

.seg.active {
  color: #fff;
  background: var(--teal);
}

.control-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.qec-controls .control-actions {
  grid-template-columns: 1fr;
}

.qec-controls .button {
  min-height: 44px;
  white-space: nowrap;
}

.legend {
  display: grid;
  gap: 7px;
  padding-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.qec-legend {
  gap: 10px;
  margin-top: 2px;
  padding: 14px;
  border: 1px solid #e3ebee;
  border-radius: 8px;
  background: var(--soft);
  font-size: 0.86rem;
}

.legend-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.qec-legend span {
  display: block;
  min-width: 0;
  line-height: 1.25;
}

.qec-legend svg,
.legend-icon {
  width: 20px;
  height: 20px;
  display: block;
  justify-self: center;
  flex: 0 0 auto;
}

.legend-icon.wide {
  width: 40px;
  height: 20px;
}

.legend-dot {
  width: 11px;
  height: 11px;
  display: inline-block;
  border: 1px solid #cbd8dc;
  border-radius: 50%;
}

.legend-dot.data {
  background: #dce8eb;
}

.legend-dot.error {
  background: var(--red);
}

.legend-dot.detector {
  background: var(--amber);
}

.legend-dot.motif {
  border-color: var(--teal);
  border-radius: 3px;
  background: rgba(22, 115, 107, 0.18);
}

.lab-visuals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.qec-visuals {
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

.qec-lattice-card {
  margin: 0;
  padding: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 12px;
  background: #fdfdfd;
}

.qec-panel-title {
  margin: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--soft);
}

.qec-panel-title span {
  font-weight: 720;
}

.qec-panel-title strong {
  color: var(--teal);
}

.chart-card {
  grid-column: 1 / -1;
}

.lattice-card,
.chart-card {
  min-height: 372px;
  padding: 14px;
  overflow: hidden;
}

.embedded-lab .lattice-card,
.embedded-lab .chart-card {
  min-height: 0;
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 740;
}

.panel-title strong {
  color: var(--ink);
}

svg {
  width: 100%;
  height: auto;
  display: block;
}

#code-lattice {
  width: 100%;
  height: auto;
  display: block;
}

.qec-legend svg,
.qec-legend .legend-icon {
  width: 20px;
  height: 20px;
}

.qec-legend .legend-icon.wide {
  width: 40px;
  height: 20px;
}

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

.readout-grid.qec-readout {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.interaction-shell .qec-readout {
  grid-column: 1 / -1;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 0;
}

.readout-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.readout-grid span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  text-transform: uppercase;
}

.readout-grid strong {
  font-size: 1.08rem;
}

.perception-card {
  min-height: 300px;
}

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

.result-story {
  margin: 32px 0 42px;
  padding-bottom: 36px;
  border-bottom: 1px solid var(--line);
}

.result-story.compact-story {
  grid-template-columns: minmax(0, 0.62fr) minmax(0, 1.38fr);
  margin: 24px 0 28px;
  padding-bottom: 26px;
}

.result-story.flipped .prose {
  order: 2;
}

.result-story.flipped .result-card {
  order: 1;
}

.result-story h3 {
  margin-bottom: 14px;
  font-size: clamp(1.45rem, 2.4vw, 2.1rem);
  line-height: 1.1;
}

.result-card {
  margin: 0;
  padding: 10px;
  background: #fff;
}

.result-card.large {
  grid-column: span 3;
}

.result-card img {
  width: 100%;
  border-radius: 6px;
  background: #fff;
}

.figure-link {
  display: inline-flex;
  margin-left: 8px;
  color: var(--teal);
  font-weight: 760;
  text-decoration: none;
}

.figure-link:hover {
  text-decoration: underline;
}

.methods-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.method-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.method-card-header {
  margin-bottom: 16px;
}

.method-card-header h3 {
  margin-bottom: 8px;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  line-height: 1.1;
}

.method-card-header p:not(.eyebrow) {
  margin-bottom: 0;
  color: var(--muted);
}

.io-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.io-strip div {
  padding: 14px;
  border: 1px solid #d7e1e4;
  border-radius: 8px;
  background: var(--soft);
}

.io-strip span,
.method-detail-grid h4,
.flow-step span {
  display: block;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 820;
  text-transform: uppercase;
}

.io-strip strong {
  display: block;
  margin: 6px 0 4px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.14rem;
  line-height: 1.2;
}

.io-strip small {
  color: var(--muted);
  font-size: 0.82rem;
}

.method-flow {
  display: grid;
  gap: 10px;
}

.flow-step {
  position: relative;
  padding: 14px 14px 14px 18px;
  border: 1px solid #e3ebee;
  border-radius: 8px;
  background: #fff;
}

.flow-step::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 999px;
  background: var(--teal);
}

.flow-step h4,
.method-detail-grid h4 {
  margin: 4px 0 6px;
  color: var(--ink);
  font-size: 1rem;
}

.flow-step p,
.method-detail-grid p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.physical-method {
  background: linear-gradient(180deg, #ffffff 0%, #fbfdfd 100%);
}

.tanner-panel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 96px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid #d7e1e4;
  border-radius: 8px;
  background: var(--soft);
}

.tanner-node {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 820;
  text-align: center;
}

.check-node {
  border: 1px solid #e2c493;
  background: #fff7ea;
}

.variable-node {
  border: 1px solid #a9cfca;
  background: #f2faf8;
}

.tanner-edges {
  height: 54px;
  background:
    linear-gradient(24deg, transparent 47%, #9eb5bc 48%, #9eb5bc 52%, transparent 53%),
    linear-gradient(-24deg, transparent 47%, #9eb5bc 48%, #9eb5bc 52%, transparent 53%),
    linear-gradient(90deg, transparent 47%, #9eb5bc 48%, #9eb5bc 52%, transparent 53%);
}

.method-detail-grid {
  display: grid;
  gap: 10px;
}

.method-detail-grid div {
  padding: 13px;
  border: 1px solid #e3ebee;
  border-radius: 8px;
  background: #fff;
}

.compact-split {
  gap: 24px;
}

.compact-method-stack {
  gap: 10px;
}

.compact-method-stack article {
  padding: 16px;
}

.compact-method-stack h3 {
  margin-bottom: 6px;
}

.compact-callout {
  margin-top: 18px;
}

.citation-section {
  padding: 28px;
}

.bibtex {
  width: 100%;
  margin: 0 0 12px;
  padding: 16px;
  overflow: auto;
  border: 1px solid #d7e1e4;
  border-radius: 8px;
  background: #f7faf9;
  color: #1f3035;
  font-size: 0.9rem;
  line-height: 1.5;
}

.footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 48px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 0.92rem;
}

.assistant-widget {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  font-family: inherit;
}

.assistant-fab {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid #bfd4d2;
  border-radius: 999px;
  color: #fff;
  background: var(--teal);
  box-shadow: 0 10px 24px rgba(22, 32, 36, 0.16);
  font: inherit;
  font-weight: 780;
  cursor: pointer;
}

.assistant-panel {
  position: absolute;
  right: 0;
  bottom: 62px;
  width: min(390px, calc(100vw - 32px));
  max-height: min(660px, calc(100vh - 110px));
  display: none;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(22, 32, 36, 0.18);
}

.assistant-widget.open .assistant-panel {
  display: grid;
}

.assistant-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.assistant-header .eyebrow {
  margin-bottom: 4px;
}

.assistant-header h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
  line-height: 1.2;
}

.assistant-close {
  width: 32px;
  height: 32px;
  border: 1px solid #d4e0e3;
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.assistant-status {
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: var(--soft);
  font-size: 0.82rem;
}

.assistant-status.ready {
  color: #126057;
  background: #f2faf8;
}

.assistant-status.error {
  color: #8c3533;
  background: #fff5f4;
}

.assistant-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px;
  overflow: auto;
}

.assistant-message {
  width: fit-content;
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.assistant-message-bot {
  align-self: flex-start;
  border: 1px solid #dbe6e9;
  background: var(--soft);
  color: #26363c;
}

.assistant-message-user {
  align-self: flex-end;
  color: #fff;
  background: var(--teal);
}

.assistant-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.assistant-form textarea {
  width: 100%;
  min-height: 42px;
  max-height: 130px;
  resize: vertical;
  padding: 10px;
  border: 1px solid #cbd8dc;
  border-radius: 8px;
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
}

.assistant-form textarea:disabled,
.assistant-form button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.grid-line {
  stroke: #e6edf0;
  stroke-width: 1;
}

.qubit {
  fill: #dce8eb;
  stroke: #ffffff;
  stroke-width: 1;
  cursor: pointer;
}

.qubit.error {
  fill: var(--red);
}

.qubit.selected {
  stroke: #0d403d;
  stroke-width: 2.4;
}

.check {
  fill: #edf3f4;
  stroke: #ffffff;
  stroke-width: 1;
}

.check.event {
  fill: var(--amber);
  stroke: #8d5d12;
  stroke-width: 1.2;
}

.check.local {
  stroke: var(--teal);
  stroke-width: 1.6;
}

.detector {
  fill: #dce8eb;
  stroke: #ffffff;
  stroke-width: 1;
  cursor: pointer;
}

.detector.event {
  fill: var(--red);
}

.detector.selected {
  fill: var(--teal);
  stroke: #0d403d;
  stroke-width: 2;
}

.motif {
  fill: rgba(22, 115, 107, 0.18);
  stroke: var(--teal);
  stroke-width: 2;
}

.detector-window {
  fill: rgba(184, 121, 24, 0.13);
  stroke: rgba(184, 121, 24, 0.78);
  stroke-width: 1.8;
}

.bb-plane {
  fill: none;
  stroke: #d7e1e4;
  stroke-width: 1.4;
}

.chart-axis {
  stroke: #cbd8dc;
  stroke-width: 1.2;
}

.chart-grid {
  stroke: #edf2f4;
  stroke-width: 1;
}

.line-transfer {
  fill: none;
  stroke: var(--teal);
  stroke-width: 4;
}

.line-scratch {
  fill: none;
  stroke: var(--purple);
  stroke-width: 3;
  stroke-dasharray: 8 8;
}

.chart-marker {
  stroke: var(--amber);
  stroke-width: 2;
}

.chart-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mini-grid-line {
  stroke: #dfe8eb;
  stroke-width: 1.2;
}

.mini-motif {
  fill: rgba(22, 115, 107, 0.2);
  stroke: var(--teal);
  stroke-width: 2;
}

.perception-node {
  fill: #ffffff;
  stroke: #d7e1e4;
  stroke-width: 1.5;
}

.perception-node.hot {
  fill: #fff8f7;
  stroke: #e8b7b5;
}

.perception-node.warm {
  fill: #fffaf2;
  stroke: #e5c58e;
}

.perception-node.cool {
  fill: #f2faf8;
  stroke: #a9cfca;
}

.perception-title {
  fill: var(--ink);
  font-size: 16px;
  font-weight: 800;
}

.perception-body,
.perception-label,
.perception-note {
  fill: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.perception-label {
  fill: var(--ink);
}

.perception-note {
  font-size: 16px;
}

.perception-equation {
  fill: #0f5f58;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 19px;
  font-weight: 800;
}

.perception-arrow {
  stroke: #9eb5bc;
  stroke-width: 2;
}

.perception-arrow-head {
  fill: #9eb5bc;
}

.qec-grid-line {
  stroke: #e2e8f0;
  stroke-width: 1.4;
}

.qec-data {
  fill: #fbbf24;
  stroke: #b45309;
  stroke-width: 1.5;
}

.qec-data.bb-data.right-register {
  fill: #fbbf24;
}

.qec-data.error {
  fill: #1e293b;
  stroke: #1e293b;
  stroke-width: 2;
}

.qec-check {
  fill: #f8fafc;
  stroke-width: 1.8;
  opacity: 0.58;
}

.qec-check.x-check {
  stroke: #ef4444;
}

.qec-check.z-check {
  stroke: #3b82f6;
}

.qec-check.active {
  opacity: 1;
  stroke-width: 2.4;
}

.qec-check.bb-check {
  fill: #fff;
  opacity: 1;
  stroke-width: 2.1;
}

.qec-check.x-check.active {
  fill: #ef4444;
}

.qec-check.z-check.active {
  fill: #3b82f6;
}

.qec-error-label {
  fill: #fff;
  font-size: 13px;
  font-weight: 820;
  pointer-events: none;
}

.qec-svg-caption {
  fill: var(--muted);
  font-size: 14px;
  font-weight: 720;
}

.bb-torus-frame {
  fill: #fff;
  stroke: #c4c4c4;
  stroke-width: 1.4;
}

.bb-edge {
  fill: none;
  stroke-width: 2.4;
  opacity: 0.66;
  pointer-events: none;
}

.bb-edge.a-edge {
  stroke: #16736b;
}

.bb-edge.b-edge {
  stroke: #7c3aed;
  stroke-dasharray: 5 4;
}

.bb-edge.wrap-edge {
  opacity: 0.86;
  stroke-dasharray: 7 5;
}

.bb-boundary-arrow {
  fill: none;
  stroke: #b8b8b8;
  stroke-width: 1.6;
}

.bb-arrow-head {
  fill: #b8b8b8;
}

@media (max-width: 960px) {
  .hero,
  .lab-shell,
  .split-section,
  .text-figure-grid,
  .result-story,
  .result-story.compact-story,
  .methods-grid,
  .split-section.reverse {
    grid-template-columns: 1fr;
  }

  .hero {
    padding-top: 58px;
  }

  .split-section.reverse .prose,
  .result-story.flipped .prose,
  .result-story.flipped .result-card {
    order: initial;
  }

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

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

  .interaction-shell .qec-readout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .concept-grid,
  .intro-compact-grid,
  .approach-grid,
  .decoder-route-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

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

  .figure1-card:first-child,
  .figure1-card:nth-child(2),
  .figure1-card:nth-child(3) {
    grid-column: 1;
  }

  .figure1-card:first-child {
    grid-template-columns: 1fr;
  }

  .io-strip {
    grid-template-columns: 1fr;
  }

  .result-card.large {
    grid-column: span 1;
  }
}

@media (max-width: 720px) {
  .site-header {
    position: static;
  }

  .nav-shell {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 0;
  }

  .nav-links {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.78rem;
  }

  .hero-actions,
  .control-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .lab-visuals,
  .readout-grid,
  .readout-grid.qec-readout {
    grid-template-columns: 1fr;
  }

  .interaction-shell .qec-readout {
    grid-template-columns: 1fr;
  }

  .lattice-card,
  .chart-card {
    min-height: 0;
  }

  .pipeline-panel {
    padding-left: 0;
    border-left: 0;
  }

  .assistant-widget {
    right: 12px;
    bottom: 12px;
  }

  .assistant-panel {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 86px);
    bottom: 58px;
  }

  .assistant-form {
    grid-template-columns: 1fr;
  }
}
