:root {
  --ink: #13261f;
  --muted: #5f6f69;
  --paper: #f4f1e8;
  --surface: #fffdf7;
  --line: #d8ddd6;
  --green: #b7e43f;
  --green-dark: #2a553d;
  --cyan: #bce9e1;
  --orange: #ff8e5c;
  --blue: #4268f6;
  --shadow: 0 24px 70px rgba(30, 55, 45, 0.1);
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 85% 2%, rgba(183, 228, 63, 0.2), transparent 24rem),
    var(--paper);
}

button, input, select { font: inherit; }

button { cursor: pointer; }

code {
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

.skip-link {
  position: fixed;
  z-index: 99;
  left: 1rem;
  top: -5rem;
  padding: 0.75rem 1rem;
  color: white;
  background: var(--ink);
}

.skip-link:focus { top: 1rem; }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1240px;
  margin: 0 auto;
  padding: 1.25rem 2rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 850;
  letter-spacing: 0.16em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2.2rem;
  height: 2.2rem;
  place-items: center;
  border-radius: 50% 50% 44% 56%;
  color: var(--ink);
  background: var(--green);
  font-family: Georgia, serif;
  font-size: 1.3rem;
  font-style: italic;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 0.45rem 0.75rem;
  background: rgba(255, 253, 247, 0.72);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.status-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #d29c39;
}

.status-pill.available .status-dot { background: #4aaf65; }
.status-pill.unavailable .status-dot { background: #9aa39f; }

main { overflow: hidden; }

.hero,
.lab-shell,
.code-section,
.agent-section {
  max-width: 1180px;
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 4rem;
  align-items: center;
  min-height: 610px;
  padding: 4rem 2rem 6rem;
}

.eyebrow {
  margin: 0 0 0.75rem;
  color: var(--green-dark);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

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

h1, h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.04em;
}

h1 {
  max-width: 760px;
  margin-bottom: 1.4rem;
  font-size: clamp(4rem, 9vw, 7.4rem);
  line-height: 0.86;
}

h2 {
  margin-bottom: 0.65rem;
  font-size: clamp(2.1rem, 5vw, 3.7rem);
  line-height: 1;
}

h3 { font-size: 1.15rem; }

.hero-lead {
  max-width: 680px;
  margin-bottom: 2rem;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.24rem);
  line-height: 1.65;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; }

.button, .text-button {
  border: 0;
  border-radius: 999px;
  font-weight: 800;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.button { padding: 0.83rem 1.25rem; }
.button:hover, .text-button:hover { transform: translateY(-2px); }
.button:focus-visible, .text-button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(66, 104, 246, 0.35);
  outline-offset: 2px;
}

.button-primary { color: var(--ink); background: var(--green); box-shadow: 0 9px 22px rgba(90, 125, 25, 0.15); }
.button-secondary { border: 1px solid var(--line); color: var(--ink); background: var(--surface); }
.button-dark { color: white; background: var(--ink); }
.text-button { padding: 0.5rem; color: var(--green-dark); background: transparent; }

.concept-card {
  position: relative;
  min-height: 390px;
  overflow: hidden;
  border: 1px solid rgba(42, 85, 61, 0.12);
  border-radius: 2.2rem;
  padding: 2rem;
  background: var(--cyan);
  box-shadow: var(--shadow);
}

.concept-card h2 { font-size: 2.4rem; }
.concept-card p:last-child { max-width: 270px; line-height: 1.55; }
.concept-number { color: rgba(19, 38, 31, 0.45); font-weight: 800; }

.bloch {
  position: relative;
  width: 210px;
  height: 210px;
  margin: 0 auto 1.4rem;
  border: 1.5px solid rgba(19, 38, 31, 0.7);
  border-radius: 50%;
}

.bloch-ring {
  position: absolute;
  inset: 45% -8%;
  border: 1.5px solid rgba(19, 38, 31, 0.62);
  border-radius: 50%;
  transform: rotate(-12deg);
}

.bloch-axis { position: absolute; left: 50%; top: -8%; width: 1px; height: 116%; background: rgba(19, 38, 31, 0.48); }
.bloch-axis-x { transform: rotate(59deg); }
.bloch-axis-y { transform: rotate(-58deg); }
.bloch-vector { position: absolute; left: 50%; bottom: 50%; width: 3px; height: 42%; transform: rotate(36deg); transform-origin: bottom; background: var(--blue); }
.bloch-vector::before { content: ""; position: absolute; top: -3px; left: -5px; border: 6px solid transparent; border-bottom: 11px solid var(--blue); transform: translateY(-80%); }

.lab-shell {
  padding: 5.5rem 2rem;
  border-radius: 2.4rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-heading, .results-heading, .minor-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.section-heading { margin-bottom: 2.2rem; }
.section-heading h2 { margin-bottom: 0; }

.lab-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(330px, 0.9fr); gap: 1.5rem; }

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 1.5rem;
  padding: 1.35rem;
  background: white;
}

.compact-fields { max-width: 430px; }
.field-row, .gate-form-grid { display: grid; gap: 0.85rem; }
.field-row { grid-template-columns: repeat(2, 1fr); margin-bottom: 1.4rem; }
.gate-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

label {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

input, select {
  width: 100%;
  min-height: 2.65rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 0.58rem 0.72rem;
  color: var(--ink);
  background: var(--surface);
}

.circuit-wrap {
  min-height: 150px;
  overflow-x: auto;
  border: 1px solid #dfe7e0;
  border-radius: 1rem;
  padding: 1rem;
  background: #f7faf8;
}

.circuit-table { border-collapse: separate; border-spacing: 0 0.8rem; width: max-content; min-width: 100%; }
.circuit-table th { width: 3.6rem; color: var(--muted); text-align: left; font-family: monospace; font-size: 0.8rem; }
.circuit-cell { position: relative; min-width: 3.3rem; height: 2.2rem; text-align: center; }
.circuit-cell::after { content: ""; position: absolute; z-index: 0; top: 50%; left: 0; right: 0; height: 1px; background: #75887f; }
.gate-marker { position: relative; z-index: 2; display: inline-grid; min-width: 2rem; height: 2rem; padding: 0 0.25rem; place-items: center; border: 2px solid var(--green-dark); border-radius: 0.42rem; background: white; color: var(--green-dark); font-family: monospace; font-size: 0.76rem; font-weight: 850; }
.gate-marker.control { min-width: 0.7rem; width: 0.7rem; height: 0.7rem; border: 0; border-radius: 50%; background: var(--green-dark); }
.gate-marker.target { border-radius: 50%; font-size: 1.1rem; }
.circuit-cell.connected::before { content: ""; position: absolute; z-index: 1; left: 50%; top: -1.3rem; bottom: -1.3rem; width: 2px; background: var(--green-dark); }

.empty-circuit { margin: 2.6rem auto; color: var(--muted); text-align: center; }

.gate-form { margin-top: 1.2rem; }
.gate-form .button { margin-top: 1rem; }
.gate-list-wrap { margin-top: 1.7rem; }
.minor-heading { align-items: center; }
.minor-heading h3 { margin-bottom: 0; }
.minor-heading span { color: var(--muted); font-size: 0.8rem; }

.gate-list { display: grid; max-height: 210px; overflow-y: auto; gap: 0.45rem; margin: 0.8rem 0 0; padding: 0; list-style: none; counter-reset: gates; }
.gate-list li { display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; border-radius: 0.75rem; padding: 0.55rem 0.7rem; background: #f2f6f3; counter-increment: gates; font-family: monospace; font-size: 0.8rem; }
.gate-list li::before { content: counter(gates, decimal-leading-zero); color: #8a9892; }
.gate-list li span { flex: 1; }
.gate-list button { border: 0; padding: 0.3rem; color: #9b3f35; background: transparent; font-weight: 850; }

.results-panel { background: var(--ink); color: white; }
.results-panel .eyebrow { color: var(--green); }
.results-panel h3 { margin-bottom: 0; font-family: Georgia, serif; font-size: 2rem; font-weight: 500; }
.result-summary { min-height: 2.8rem; margin: 1.8rem 0 0.7rem; color: #c9d4cf; line-height: 1.5; }

.probability-chart { display: grid; gap: 0.58rem; min-height: 210px; align-content: center; }
.probability-row { display: grid; grid-template-columns: 3.1rem 1fr 3.7rem; gap: 0.65rem; align-items: center; font-family: monospace; font-size: 0.78rem; }
.probability-track { height: 1rem; overflow: hidden; border-radius: 99px; background: rgba(255, 255, 255, 0.12); }
.probability-bar { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green), #e5f9a8); transform-origin: left; animation: grow 420ms ease-out; }
@keyframes grow { from { transform: scaleX(0); } }

.explanation { margin-top: 1.5rem; border-top: 1px solid rgba(255, 255, 255, 0.16); padding-top: 1rem; }
.explanation summary { cursor: pointer; color: var(--green); font-weight: 800; }
.explanation div { padding-top: 0.85rem; color: #c9d4cf; line-height: 1.6; }
.explanation p { margin-bottom: 0.6rem; }

.code-section, .agent-section { padding: 7rem 2rem; }
.code-section { max-width: 1000px; }
.code-block { overflow: auto; margin: 0; border-radius: 1.2rem; padding: 1.5rem; color: #d9f6df; background: #14231e; box-shadow: var(--shadow); font-size: 0.88rem; line-height: 1.65; }
.code-note { margin-top: 1rem; color: var(--muted); font-size: 0.86rem; line-height: 1.5; }

.agent-section { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(380px, 1.1fr); gap: 4rem; align-items: start; border-top: 1px solid var(--line); }
.agent-section p:not(.eyebrow) { color: var(--muted); line-height: 1.65; }
.tool-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin: 0; padding: 0; list-style: none; }
.tool-list li { border: 1px solid var(--line); border-radius: 1rem; padding: 1rem; background: var(--surface); }
.tool-list code { display: block; margin-bottom: 0.4rem; color: var(--green-dark); font-size: 0.78rem; font-weight: 850; }
.tool-list span { color: var(--muted); font-size: 0.8rem; line-height: 1.45; }

footer { display: flex; justify-content: space-between; gap: 2rem; padding: 2rem max(2rem, calc((100vw - 1180px) / 2)); border-top: 1px solid var(--line); color: var(--muted); font-size: 0.76rem; }
footer p { margin: 0; }

.toast { position: fixed; z-index: 50; right: 1.4rem; bottom: 1.4rem; max-width: min(360px, calc(100vw - 2.8rem)); border-radius: 0.85rem; padding: 0.8rem 1rem; color: white; background: var(--ink); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(1rem); transition: 180ms ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .hero, .lab-grid, .agent-section { grid-template-columns: 1fr; }
  .hero { gap: 2rem; padding-top: 3rem; }
  .concept-card { min-height: 330px; }
  .agent-section { gap: 2rem; }
}

@media (max-width: 620px) {
  .site-header { padding: 1rem; }
  .status-pill { max-width: 155px; }
  .hero { min-height: auto; padding: 3.5rem 1rem 4rem; }
  h1 { font-size: 3.8rem; }
  .lab-shell { border-radius: 1.35rem; padding: 3.5rem 1rem; }
  .section-heading { align-items: flex-start; }
  .field-row, .gate-form-grid, .tool-list { grid-template-columns: 1fr; }
  .code-section, .agent-section { padding: 4rem 1rem; }
  footer { flex-direction: column; padding: 1.5rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
