:root {
  color-scheme: light;
  --ink: #18233d;
  --muted: #69758e;
  --blue: #335cff;
  --purple: #8b5cf6;
  --mint: #55d8bb;
  --line: rgba(24, 35, 61, 0.12);
  --surface: rgba(255, 255, 255, 0.84);
  --shadow: 0 24px 70px rgba(49, 66, 122, 0.13);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 9%, rgba(51, 92, 255, 0.12), transparent 25rem),
    radial-gradient(circle at 90% 45%, rgba(139, 92, 246, 0.11), transparent 30rem),
    #f6f8fc;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }

.lab-header, main, footer {
  width: min(1220px, calc(100% - 48px));
  margin-inline: auto;
}

.lab-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 78px;
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 10px; justify-self: start; font-size: 17px; font-weight: 780; }
.brand-mark { position: relative; display: inline-grid; place-items: center; width: 30px; height: 30px; }
.brand-mark::after { width: 7px; height: 7px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 14px rgba(51, 92, 255, 0.7); content: ""; }
.brand-mark span { position: absolute; width: 28px; height: 10px; border: 1px solid rgba(51, 92, 255, 0.7); border-radius: 50%; }
.brand-mark span:nth-child(2) { transform: rotate(60deg); }
.brand-mark span:nth-child(3) { transform: rotate(-60deg); }
.back-link { color: #56627a; font-size: 13px; font-weight: 700; }
.back-link span { margin-right: 7px; color: var(--blue); }
.back-link b { font-weight: 700; }
.header-tools { display: flex; justify-self: end; align-items: center; gap: 10px; }
.lesson-chip { justify-self: end; padding: 8px 12px; border: 1px solid rgba(51, 92, 255, 0.16); border-radius: 999px; color: var(--blue); background: rgba(255,255,255,.58); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.language-switch { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.75); }
.language-switch button { min-width: 37px; padding: 5px 8px; border: 0; border-radius: 999px; color: #7a8499; background: transparent; cursor: pointer; font-size: 9px; font-weight: 800; }
.language-switch button.active { color: #fff; background: var(--blue); }

.lab-intro { display: grid; grid-template-columns: 1fr 480px; align-items: end; gap: 50px; padding: 70px 0 45px; }
.eyebrow, .panel-kicker { display: block; margin: 0 0 10px; color: var(--blue); font-size: 10px; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(3.4rem, 7vw, 6.6rem); font-weight: 720; letter-spacing: -.075em; line-height: .92; }
h1 em { display: block; color: var(--blue); font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
.intro-copy > p { color: var(--muted); font-size: 17px; line-height: 1.65; }
.learning-path { display: flex; align-items: center; gap: 10px; margin-top: 26px; }
.learning-path span { display: flex; align-items: center; gap: 7px; color: #536078; font-size: 11px; font-weight: 750; }
.learning-path em { font-style: normal; }
.learning-path b { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; color: #fff; background: var(--blue); font-size: 9px; }
.learning-path i { width: 24px; height: 1px; background: rgba(51,92,255,.25); }

.lab-workspace { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(350px, .85fr); gap: 18px; }
.scene-panel, .control-panel, .state-card, .measurement-section, .reflection-card { border: 1px solid rgba(255,255,255,.9); border-radius: 28px; background: var(--surface); box-shadow: var(--shadow); }
.scene-panel { overflow: hidden; background: #10172c; }
.scene-topbar { display: flex; align-items: center; justify-content: space-between; min-height: 78px; padding: 0 24px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.09); }
.scene-topbar div { display: flex; flex-direction: column; gap: 3px; }
.scene-topbar .panel-kicker { margin: 0; color: #91a6ff; }
.scene-topbar strong { font-size: 16px; }
.scene-topbar button, .reset-state { padding: 8px 12px; border: 1px solid rgba(255,255,255,.14); border-radius: 10px; color: #d8dff5; background: rgba(255,255,255,.06); cursor: pointer; font-size: 10px; font-weight: 750; }
.scene-topbar button:hover { background: rgba(255,255,255,.12); }
.canvas-shell { position: relative; min-height: 530px; overflow: hidden; background: radial-gradient(circle at 50% 44%, #273463 0, #151e3a 30%, #0c1224 72%); }
.canvas-shell::before { position: absolute; inset: 0; opacity: .26; background-image: linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px); background-size: 34px 34px; content: ""; pointer-events: none; }
#bloch-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#bloch-canvas:active { cursor: grabbing; }
.state-badge { position: absolute; top: 20px; left: 20px; display: flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid rgba(255,255,255,.13); border-radius: 12px; color: #fff; background: rgba(11,17,35,.56); backdrop-filter: blur(14px); font-size: 11px; }
.state-badge > span { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 10px var(--mint); }
.drag-hint { position: absolute; right: 18px; bottom: 16px; margin: 0; color: rgba(226,232,255,.64); font-size: 9px; }
.drag-hint span { margin-right: 5px; color: #91a6ff; }
.axis-key { position: absolute; left: 19px; bottom: 15px; display: flex; gap: 11px; color: rgba(226,232,255,.65); font-size: 9px; text-transform: uppercase; }
.axis-key span { display: flex; align-items: center; gap: 4px; }
.axis-key i { display: inline-block; width: 10px; height: 2px; }
.axis-x { background: #ff6f91; }.axis-y { background: #55d8bb; }.axis-z { background: #718fff; }
.scene-insight { display: grid; grid-template-columns: 110px 1fr; align-items: start; gap: 12px; padding: 18px 24px 20px; color: #d9e0f6; border-top: 1px solid rgba(255,255,255,.08); }
.scene-insight span { color: #91a6ff; font-size: 9px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.scene-insight p { margin: -3px 0 0; color: rgba(226,232,255,.7); font-size: 11px; line-height: 1.55; }

.control-panel { padding: 28px; }
.control-heading h2, .state-card h2, .measurement-section h2, .reflection-card h2 { margin-bottom: 8px; font-size: 24px; letter-spacing: -.035em; }
.control-heading p, .state-card > p, .measurement-copy > p, .reflection-card p { color: var(--muted); font-size: 12px; line-height: 1.65; }
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 22px 0 28px; }
.preset-grid button { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-height: 68px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; cursor: pointer; text-align: left; transition: border-color 160ms ease, background 160ms ease, transform 160ms ease; }
.preset-grid button:hover { transform: translateY(-1px); border-color: rgba(51,92,255,.35); }
.preset-grid button.active { border-color: rgba(51,92,255,.5); background: #eef1ff; box-shadow: inset 0 0 0 1px rgba(51,92,255,.1); }
.preset-grid strong { color: var(--blue); font-family: Georgia, serif; font-size: 19px; }
.preset-grid span { color: var(--muted); font-size: 9px; }
.angle-control { margin-top: 25px; }
.slider-label { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.slider-label div { display: flex; align-items: baseline; gap: 8px; }
.slider-label strong { font-size: 18px; }
.slider-label span { color: var(--muted); font-size: 9px; }
.slider-label output { min-width: 49px; padding: 5px 8px; border-radius: 9px; color: #fff; background: var(--blue); font-size: 10px; font-weight: 800; text-align: center; }
input[type="range"] { width: 100%; margin: 14px 0 4px; accent-color: var(--blue); cursor: pointer; }
.range-labels { display: flex; justify-content: space-between; color: #9aa4b7; font-size: 8px; }
.reset-state { width: 100%; margin-top: 27px; color: #5f6980; border-color: var(--line); background: #f8f9fc; }
.reset-state:hover { color: var(--blue); border-color: rgba(51,92,255,.3); }

.state-section { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.state-card { padding: 28px; }
.equation { margin: 24px 0 18px; padding: 22px; overflow-x: auto; border: 1px solid rgba(51,92,255,.13); border-radius: 16px; color: #29396f; background: linear-gradient(135deg,#f1f4ff,#f7f3ff); font-family: Georgia, "Times New Roman", serif; font-size: clamp(1rem, 2.2vw, 1.45rem); text-align: center; white-space: nowrap; }
.probability-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.probability-heading h2 { margin-bottom: 22px; }
.probability-heading > strong { padding: 8px 11px; border-radius: 10px; color: var(--blue); background: #edf1ff; font-size: 11px; }
.probability-row + .probability-row { margin-top: 17px; }
.probability-label { display: flex; justify-content: space-between; margin-bottom: 7px; color: #59647b; font-size: 10px; }
.probability-label span { display: flex; align-items: center; gap: 7px; }
.probability-label em, .phase-note em { font-style: normal; }
.probability-label i { width: 7px; height: 7px; border-radius: 50%; }
.zero-dot { background: var(--blue); }.one-dot { background: var(--purple); }
.probability-track { height: 9px; overflow: hidden; border-radius: 999px; background: #e9ecf4; }
.probability-track i { display: block; width: 50%; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#315bff,#6f8aff); transition: width 300ms ease; }
.one-track i { background: linear-gradient(90deg,#8b5cf6,#b487ff); }
.phase-note { display: flex; gap: 9px; margin: 20px 0 0; padding: 11px 13px; border-radius: 11px; color: #69758e; background: #f5f7fb; font-size: 9px; line-height: 1.55; }
.phase-note span { flex: 0 0 auto; color: var(--purple); font-weight: 850; text-transform: uppercase; }

.measurement-section { display: grid; grid-template-columns: .85fr 1.15fr; gap: 36px; margin-top: 18px; padding: 32px; }
.shot-control { margin-top: 28px; }
.shot-control .slider-label div { display: block; }
.shot-control .slider-label strong, .shot-control .slider-label span { display: block; }
.shot-control .slider-label strong { margin-bottom: 4px; font-size: 12px; }
.measurement-actions { display: flex; gap: 9px; margin-top: 20px; }
.measurement-actions button { min-height: 42px; padding: 0 15px; border-radius: 12px; cursor: pointer; font-size: 10px; font-weight: 800; }
.run-button { border: 0; color: #fff; background: var(--blue); box-shadow: 0 10px 22px rgba(51,92,255,.2); }
.run-button:disabled { opacity: .55; cursor: wait; }
.run-button span { margin-right: 5px; font-size: 8px; }
.clear-button { border: 1px solid var(--line); color: #66718a; background: #fff; }
.results-card { padding: 22px; border: 1px solid var(--line); border-radius: 21px; background: #f8f9fc; }
.results-header { display: flex; justify-content: space-between; align-items: flex-start; }
.results-header div { display: flex; flex-direction: column; gap: 3px; }
.results-header .panel-kicker { margin: 0; }
.results-header strong { font-size: 13px; }
.results-header > span { color: var(--muted); font-size: 9px; }
.result-chart { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; height: 235px; padding: 25px 34px 0; }
.result-column { display: grid; grid-template-rows: 1fr auto auto; gap: 3px; align-items: end; text-align: center; }
.bar-space { display: flex; align-items: flex-end; justify-content: center; width: 100%; height: 100%; border-bottom: 1px solid #d9deea; }
.result-bar { display: block; width: 54%; height: 0%; min-height: 0; border-radius: 10px 10px 2px 2px; background: linear-gradient(#718fff,#335cff); box-shadow: 0 10px 22px rgba(51,92,255,.18); transition: height 110ms linear; }
.one-result { background: linear-gradient(#b78aff,#8b5cf6); box-shadow: 0 10px 22px rgba(139,92,246,.18); }
.result-column strong { margin-top: 5px; font-size: 16px; }
.result-column > span { color: var(--muted); font-family: Georgia, serif; font-size: 11px; }
.measurement-stream { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 5px; min-height: 39px; margin-top: 14px; padding: 10px; border-radius: 11px; background: #fff; }
.measurement-stream .outcome { width: 8px; height: 8px; border-radius: 50%; animation: dotIn 180ms ease-out; }
.measurement-stream .outcome-zero { background: var(--blue); }.measurement-stream .outcome-one { background: var(--purple); }
.empty-stream { color: #a1a9b8; font-size: 8px; }
@keyframes dotIn { from { opacity: 0; transform: scale(.35); } }

.reflection-card { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 18px; margin: 18px 0 80px; padding: 26px 30px; }
.reflection-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: #fff; background: linear-gradient(145deg,var(--blue),var(--purple)); font-family: Georgia, serif; font-size: 21px; }
.reflection-card h2 { margin-bottom: 5px; font-size: 18px; }
.reflection-card p { margin-bottom: 0; }
.reflection-card a { color: var(--blue); font-size: 10px; font-weight: 800; white-space: nowrap; }

footer { display: flex; align-items: center; justify-content: space-between; min-height: 110px; border-top: 1px solid var(--line); color: #7d879c; font-size: 10px; }
footer p { margin: 0; }

@media (max-width: 950px) {
  .lab-intro { grid-template-columns: 1fr; }
  .lab-workspace { grid-template-columns: 1fr; }
  .canvas-shell { min-height: 500px; }
  .control-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
  .control-heading, .preset-grid, .reset-state { grid-column: 1 / -1; }
  .state-section, .measurement-section { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .lab-header, main, footer { width: min(100% - 26px, 1220px); }
  .lab-header { grid-template-columns: 1fr auto; }
  .back-link { justify-self: end; }
  .lesson-chip { display: none; }
  .lab-intro { padding-top: 50px; }
  h1 { font-size: clamp(3.2rem, 17vw, 5rem); }
  .learning-path { gap: 6px; }
  .learning-path i { width: 12px; }
  .canvas-shell { min-height: 410px; }
  .axis-key { display: none; }
  .drag-hint { left: 18px; right: auto; }
  .scene-insight { grid-template-columns: 1fr; }
  .control-panel { display: block; padding: 22px; }
  .preset-grid { margin-bottom: 30px; }
  .state-section { grid-template-columns: 1fr; }
  .state-card, .measurement-section { padding: 22px; }
  .measurement-actions { flex-direction: column; }
  .result-chart { padding-inline: 12px; }
  .reflection-card { grid-template-columns: 44px 1fr; padding: 22px; }
  .reflection-card a { grid-column: 2; }
  footer { flex-direction: column; justify-content: center; gap: 8px; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
