:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  --ink: #f7fafc;
  --muted: #a9b6c0;
  --subtle: #7f909d;
  --page: #071018;
  --panel: rgba(10, 18, 25, 0.94);
  --panel-solid: #0d1821;
  --control: #182733;
  --control-hover: #213441;
  --line: rgba(226, 232, 240, 0.18);
  --line-strong: rgba(226, 232, 240, 0.34);
  --accent: #55c6b6;
  --accent-ink: #07211d;
  --warm: #f3bd4f;
  --warm-ink: #201704;
  --danger: #ef7b6f;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--page);
  color: var(--ink);
}

button,
select,
input {
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  min-height: 38px;
  color: var(--ink);
  background: var(--control);
  border: 1px solid var(--line);
  border-radius: 6px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  cursor: pointer;
}

button:hover:not(:disabled),
select:hover {
  background: var(--control-hover);
  border-color: var(--line-strong);
}

button:disabled {
  cursor: default;
  opacity: 0.42;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--warm);
  outline-offset: 2px;
}

button svg,
.summary-title svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  stroke-width: 1.8;
}

.viewer-shell,
#viewport {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

#viewport {
  display: block;
  cursor: grab;
  touch-action: none;
}

#viewport:active {
  cursor: grabbing;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  position: fixed;
  z-index: 6;
  top: 0;
  left: 0;
  right: 0;
  min-height: 58px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 9px 18px;
  background: rgba(7, 16, 24, 0.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.identity {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.identity strong {
  min-width: 0;
  overflow: hidden;
  color: #ffffff;
  font-size: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity span {
  /* The subtitle gives way first; the title is cut with an ellipsis only when it alone no longer fits. */
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #dce6ee;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(85, 198, 182, 0.16);
}

.top-actions {
  justify-self: end;
  display: flex;
  gap: 7px;
}

.icon-action {
  min-width: 82px;
  color: #e5edf2;
}

/* The "← Catalogue" link of the topbar (a link: it leaves the page for the tour) looks like the other top
   actions. Class selectors only, so the narrow-screen .icon-action rules below still win for its size. */
.link-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 13px;
  background: var(--control);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.link-action:hover {
  background: var(--control-hover);
  border-color: var(--line-strong);
}

.link-action:focus-visible {
  outline: 2px solid var(--warm);
  outline-offset: 2px;
}

.link-action svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  stroke-width: 1.8;
}

.camera-action[aria-pressed="true"],
.grid-action[aria-pressed="true"] {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

.camera-action[aria-pressed="true"]:hover,
.grid-action[aria-pressed="true"]:hover {
  background: #78d7ca;
  border-color: #78d7ca;
}

.square-action {
  width: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
}

.interaction-hint {
  position: fixed;
  z-index: 3;
  left: 50%;
  top: 45%;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  min-height: 42px;
  padding: 0 14px;
  transform: translate(-50%, -50%);
  color: #f3f7f9;
  background: rgba(6, 13, 18, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  backdrop-filter: blur(10px);
  transition: opacity 180ms ease, visibility 180ms ease;
}

.interaction-hint.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.interaction-hint svg {
  width: 16px;
  height: 16px;
  color: var(--warm);
}

.hint-separator {
  width: 1px;
  height: 18px;
  margin: 0 3px;
  background: var(--line-strong);
}

.tracking-panel {
  position: fixed;
  z-index: 5;
  top: 76px;
  left: 18px;
  width: min(300px, calc(100vw - 36px));
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
}

.tracking-panel[hidden] {
  display: none;
}

.tracking-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.tracking-header > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.tracking-header .eyebrow {
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tracking-header strong {
  color: #ffffff;
  font-size: 12px;
  line-height: 1.3;
}

.tracking-badge {
  flex: 0 0 auto;
  padding: 4px 7px;
  color: var(--subtle);
  background: rgba(127, 144, 157, 0.12);
  border: 1px solid rgba(127, 144, 157, 0.25);
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.tracking-badge[data-state="tracking"] {
  color: #bdf8ef;
  background: rgba(85, 198, 182, 0.14);
  border-color: rgba(85, 198, 182, 0.42);
}

.tracking-badge[data-state="error"] {
  color: #ffd0cb;
  background: rgba(239, 123, 111, 0.14);
  border-color: rgba(239, 123, 111, 0.42);
}

.camera-preview {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #050a0e;
  border: 1px solid rgba(226, 232, 240, 0.15);
  border-radius: 6px;
}

.camera-preview video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transform: scaleX(-1);
}

.face-guide {
  position: absolute;
  inset: 14% 31%;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 50%;
  box-shadow: 0 0 0 999px rgba(3, 8, 12, 0.14);
}

.face-guide::before,
.face-guide::after {
  content: "";
  position: absolute;
  background: rgba(85, 198, 182, 0.82);
}

.face-guide::before {
  top: 50%;
  left: -8px;
  right: -8px;
  height: 1px;
}

.face-guide::after {
  top: -8px;
  bottom: -8px;
  left: 50%;
  width: 1px;
}

.privacy-chip {
  position: absolute;
  right: 7px;
  bottom: 7px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  color: #eafaf7;
  background: rgba(5, 12, 17, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  font-size: 9px;
}

.privacy-chip svg {
  width: 12px;
  height: 12px;
}

.tracking-status {
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 1px 4px;
  color: #dfe9ed;
  font-size: 10px;
}

.tracking-status .status-dot {
  width: 6px;
  height: 6px;
}

.tracking-readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin: 5px 0 0;
}

.tracking-readout > div {
  padding: 7px 8px;
  background: rgba(24, 39, 51, 0.72);
  border: 1px solid rgba(226, 232, 240, 0.1);
  border-radius: 5px;
}

.tracking-readout dt {
  color: var(--subtle);
  font-size: 8px;
  text-transform: uppercase;
}

.tracking-readout dd {
  margin: 2px 0 0;
  color: #ffffff;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.tracking-note {
  margin: 9px 1px;
  color: var(--subtle);
  font-size: 9px;
  line-height: 1.45;
}

.tracking-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.command.compact {
  min-height: 34px;
  padding-inline: 9px;
  font-size: 10px;
}

.command.compact svg {
  width: 14px;
  height: 14px;
}

.gaze-cursor {
  position: fixed;
  z-index: 4;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity 120ms ease;
}

.gaze-cursor.is-active {
  visibility: visible;
  opacity: 1;
}

.gaze-cursor::before,
.gaze-cursor::after {
  content: "";
  position: absolute;
  background: rgba(243, 189, 79, 0.82);
}

.gaze-cursor::before {
  width: 34px;
  height: 1px;
}

.gaze-cursor::after {
  width: 1px;
  height: 34px;
}

.gaze-cursor span {
  width: 10px;
  height: 10px;
  background: rgba(243, 189, 79, 0.2);
  border: 1px solid var(--warm);
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(243, 189, 79, 0.55);
}

.calibration-overlay {
  position: fixed;
  z-index: 12;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 82px 24px 34px;
  background:
    radial-gradient(circle at center, rgba(13, 31, 43, 0.42), rgba(2, 7, 11, 0.88)),
    rgba(2, 7, 11, 0.68);
  backdrop-filter: blur(5px);
}

.calibration-overlay[hidden] {
  display: none;
}

.calibration-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  min-height: 64px;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(220px, 360px) minmax(190px, 1fr);
  align-items: center;
  gap: 22px;
  padding: 10px 18px;
  background: rgba(7, 16, 24, 0.96);
  border-bottom: 1px solid var(--line);
}

.calibration-topbar > div:first-child {
  display: grid;
  gap: 2px;
}

.calibration-topbar .eyebrow {
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.calibration-topbar strong {
  color: #ffffff;
  font-size: 13px;
}

.calibration-topbar .square-action {
  justify-self: end;
}

.calibration-progress-wrap {
  display: grid;
  gap: 6px;
}

.calibration-progress-wrap > span {
  color: var(--muted);
  font-size: 9px;
  text-align: center;
  text-transform: uppercase;
}

.calibration-progress {
  height: 4px;
  overflow: hidden;
  background: #263845;
  border-radius: 999px;
}

.calibration-progress span {
  width: 0%;
  height: 100%;
  display: block;
  background: linear-gradient(90deg, var(--accent), #8ce6da);
  border-radius: inherit;
  transition: width 180ms ease;
}

.calibration-card {
  width: min(560px, calc(100vw - 32px));
  padding: 30px;
  color: var(--ink);
  background: rgba(13, 24, 33, 0.97);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}

.calibration-card[hidden] {
  display: none;
}

.calibration-icon {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: 20px;
  color: var(--warm);
  background: rgba(243, 189, 79, 0.1);
  border: 1px solid rgba(243, 189, 79, 0.3);
  border-radius: 8px;
}

.calibration-icon.success {
  color: var(--accent);
  background: rgba(85, 198, 182, 0.1);
  border-color: rgba(85, 198, 182, 0.35);
}

.calibration-icon.is-warning {
  color: var(--danger);
  background: rgba(239, 123, 111, 0.1);
  border-color: rgba(239, 123, 111, 0.35);
}

.calibration-icon svg {
  width: 25px;
  height: 25px;
}

.calibration-card h1 {
  margin: 8px 0 0;
  color: #ffffff;
  font-size: clamp(25px, 4vw, 34px);
  line-height: 1.12;
}

.calibration-card > p:not(.step-number) {
  margin: 14px 0 0;
  color: #bdc9d0;
  font-size: 14px;
  line-height: 1.6;
}

.readiness-list {
  display: grid;
  gap: 8px;
  margin: 21px 0 23px;
  padding: 0;
  list-style: none;
}

.readiness-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 7px 10px;
  color: #e3ebef;
  background: rgba(24, 39, 51, 0.68);
  border: 1px solid rgba(226, 232, 240, 0.1);
  border-radius: 6px;
  font-size: 12px;
}

.readiness-list svg {
  width: 17px;
  height: 17px;
  color: var(--accent);
}

.calibration-primary {
  width: 100%;
}

.calibration-target {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: left 180ms ease, top 180ms ease;
}

.calibration-target[hidden] {
  display: none;
}

.target-ring {
  position: absolute;
  inset: 0;
  border: 3px solid rgba(243, 189, 79, 0.92);
  border-radius: 50%;
  box-shadow: 0 0 0 9px rgba(243, 189, 79, 0.12), 0 0 30px rgba(243, 189, 79, 0.32);
  animation: target-pulse 900ms ease-in-out infinite alternate;
}

.calibration-target.is-collecting .target-ring {
  border-color: var(--accent);
  box-shadow: 0 0 0 9px rgba(85, 198, 182, 0.12), 0 0 30px rgba(85, 198, 182, 0.38);
}

.target-core {
  width: 12px;
  height: 12px;
  background: #ffffff;
  border: 3px solid var(--warm);
  border-radius: 50%;
}

.calibration-target.is-collecting .target-core {
  border-color: var(--accent);
}

@keyframes target-pulse {
  from { transform: scale(0.9); opacity: 0.72; }
  to { transform: scale(1.06); opacity: 1; }
}

.calibration-capture-status {
  position: absolute;
  left: 50%;
  bottom: 28px;
  display: grid;
  gap: 2px;
  min-width: 220px;
  padding: 9px 14px;
  transform: translateX(-50%);
  text-align: center;
  color: var(--ink);
  background: rgba(7, 16, 24, 0.9);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.calibration-capture-status[hidden] {
  display: none;
}

.calibration-capture-status strong {
  font-size: 12px;
}

.calibration-capture-status span {
  color: var(--muted);
  font-size: 10px;
}

.calibration-capture-status.is-warning {
  border-color: rgba(239, 123, 111, 0.62);
}

.calibration-capture-status.is-warning span {
  color: #ffd0cb;
}

.calibration-score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 22px 0;
}

.calibration-score-grid > div {
  min-width: 0;
  display: grid;
  gap: 5px;
  padding: 12px;
  background: rgba(24, 39, 51, 0.68);
  border: 1px solid rgba(226, 232, 240, 0.11);
  border-radius: 7px;
}

.calibration-score-grid span {
  color: var(--subtle);
  font-size: 9px;
  text-transform: uppercase;
}

.calibration-score-grid strong {
  overflow: hidden;
  color: #ffffff;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
}

.calibration-result-actions {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 9px;
}

.wizard-overview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin: 22px 0;
  padding: 0;
  list-style: none;
}

.wizard-overview li {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 9px 11px;
  background: rgba(24, 39, 51, 0.68);
  border: 1px solid rgba(226, 232, 240, 0.1);
  border-radius: 7px;
}

.wizard-overview li > span {
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  color: #061015;
  background: var(--accent);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
}

.wizard-overview div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.wizard-overview strong {
  color: #ffffff;
  font-size: 12px;
}

.wizard-overview small {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}

.calibration-workspace {
  width: min(1120px, calc(100vw - 36px));
  height: min(720px, calc(100vh - 112px));
  min-height: 510px;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  overflow: hidden;
  color: var(--ink);
  background: rgba(7, 16, 24, 0.97);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.54);
}

.calibration-workspace[hidden] {
  display: none;
}

.calibration-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  background: rgba(12, 26, 36, 0.94);
  border-right: 1px solid var(--line);
}

.calibration-demo {
  padding: 12px;
  background: linear-gradient(145deg, rgba(85, 198, 182, 0.08), rgba(243, 189, 79, 0.04));
  border: 1px solid rgba(85, 198, 182, 0.24);
  border-radius: 9px;
}

.demo-caption {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #d8e7e7;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.demo-live-dot {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(85, 198, 182, 0.5);
  animation: demo-live 1.4s ease-out infinite;
}

.demo-frame {
  position: relative;
  height: 150px;
  margin-top: 8px;
  overflow: hidden;
  background:
    linear-gradient(rgba(85, 198, 182, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(85, 198, 182, 0.06) 1px, transparent 1px),
    #09141c;
  background-size: 24px 24px;
  border-radius: 7px;
  perspective: 420px;
}

.demo-face {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 82px;
  height: 104px;
  transform: translate(-50%, -50%);
  transform-origin: 50% 64%;
  background: linear-gradient(145deg, #e5c4a9, #bd8d72);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 44% 44% 48% 48%;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.36);
}

.demo-ear {
  position: absolute;
  top: 42px;
  width: 10px;
  height: 24px;
  background: #bd8d72;
  border-radius: 50%;
}

.demo-ear-left { left: -7px; }
.demo-ear-right { right: -7px; }

.demo-eyes {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 37px;
  display: flex;
  justify-content: space-between;
}

.demo-eyes > span {
  position: relative;
  width: 21px;
  height: 11px;
  overflow: hidden;
  background: #f8fbfc;
  border-radius: 50%;
}

.demo-eyes i {
  position: absolute;
  left: 7px;
  top: 2px;
  width: 8px;
  height: 8px;
  background: #173e48;
  border: 2px solid #0b1c24;
  border-radius: 50%;
  transform: translate(var(--eye-x, 0), var(--eye-y, 0));
  animation: demo-eye-look 1.6s ease-in-out infinite alternate;
}

.demo-nose {
  position: absolute;
  left: 38px;
  top: 52px;
  width: 6px;
  height: 18px;
  border-right: 2px solid rgba(89, 48, 34, 0.38);
  border-bottom: 2px solid rgba(89, 48, 34, 0.38);
  border-radius: 0 0 5px;
}

.demo-mouth {
  position: absolute;
  left: 29px;
  top: 81px;
  width: 24px;
  height: 7px;
  border-bottom: 2px solid rgba(89, 48, 34, 0.55);
  border-radius: 50%;
}

.demo-camera {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--warm);
  background: rgba(243, 189, 79, 0.1);
  border: 1px solid rgba(243, 189, 79, 0.3);
  border-radius: 6px;
}

.demo-camera svg { width: 14px; height: 14px; }

.calibration-demo p {
  min-height: 36px;
  margin: 10px 1px 0;
  color: #b8c7cd;
  font-size: 10px;
  line-height: 1.5;
}

.calibration-demo[data-mode="eye"] .demo-face,
.calibration-demo[data-mode="validation"] .demo-face {
  animation: demo-still 1.8s ease-in-out infinite;
}

.calibration-demo[data-action*="left"] { --eye-x: -6px; }
.calibration-demo[data-action*="right"] { --eye-x: 6px; }
.calibration-demo[data-action*="upper"] { --eye-y: -3px; }
.calibration-demo[data-action*="lower"] { --eye-y: 3px; }
.calibration-demo[data-action="up"] .demo-face { animation: demo-head-up 2s ease-in-out infinite; }
.calibration-demo[data-action="down"] .demo-face { animation: demo-head-down 2s ease-in-out infinite; }
.calibration-demo[data-action="left"] .demo-face { animation: demo-head-left 2s ease-in-out infinite; }
.calibration-demo[data-action="right"] .demo-face { animation: demo-head-right 2s ease-in-out infinite; }
.calibration-demo[data-mode="zoom"][data-action="closer"] .demo-face { animation: demo-zoom-in 2s ease-in-out infinite; }
.calibration-demo[data-mode="zoom"][data-action="farther"] .demo-face { animation: demo-zoom-out 2s ease-in-out infinite; }

@keyframes demo-live { 70%, 100% { box-shadow: 0 0 0 7px rgba(85, 198, 182, 0); } }
@keyframes demo-eye-look { from { transform: translate(0, 0); } to { transform: translate(var(--eye-x, 0), var(--eye-y, 0)); } }
@keyframes demo-still { 0%, 100% { transform: translate(-50%, -50%); } 50% { transform: translate(-50%, calc(-50% - 2px)); } }
@keyframes demo-head-left { 0%, 20% { transform: translate(-50%, -50%) rotateY(0); } 65%, 100% { transform: translate(-50%, -50%) rotateY(-34deg); } }
@keyframes demo-head-right { 0%, 20% { transform: translate(-50%, -50%) rotateY(0); } 65%, 100% { transform: translate(-50%, -50%) rotateY(34deg); } }
@keyframes demo-head-up { 0%, 20% { transform: translate(-50%, -50%) rotateX(0); } 65%, 100% { transform: translate(-50%, -50%) rotateX(24deg); } }
@keyframes demo-head-down { 0%, 20% { transform: translate(-50%, -50%) rotateX(0); } 65%, 100% { transform: translate(-50%, -50%) rotateX(-24deg); } }
@keyframes demo-zoom-in { 0%, 20% { transform: translate(-50%, -50%) scale(1); } 65%, 100% { transform: translate(-50%, -50%) scale(1.28); } }
@keyframes demo-zoom-out { 0%, 20% { transform: translate(-50%, -50%) scale(1); } 65%, 100% { transform: translate(-50%, -50%) scale(0.76); } }

.calibration-stage-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.calibration-stage-list li {
  display: grid;
  grid-template-columns: 29px 1fr 18px;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 7px 9px;
  color: #80919a;
  border: 1px solid transparent;
  border-radius: 7px;
}

.calibration-stage-list li > span {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  background: #172936;
  border: 1px solid #2b4352;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
}

.calibration-stage-list li div { display: grid; gap: 1px; }
.calibration-stage-list strong { color: inherit; font-size: 10px; }
.calibration-stage-list small { color: inherit; font-size: 8px; }
.calibration-stage-list svg { width: 15px; height: 15px; }

.calibration-stage-list li.is-current {
  color: #e8f7f4;
  background: rgba(85, 198, 182, 0.09);
  border-color: rgba(85, 198, 182, 0.28);
}

.calibration-stage-list li.is-current > span {
  color: #061015;
  background: var(--accent);
  border-color: var(--accent);
}

.calibration-stage-list li.is-complete { color: var(--accent); }

.calibration-main {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  padding: 20px 24px;
}

.calibration-instruction {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-height: 66px;
}

.calibration-item-number {
  flex: 0 0 48px;
  height: 36px;
  display: grid;
  place-items: center;
  color: #061015;
  background: var(--warm);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 900;
}

.calibration-instruction h1 {
  margin: 0;
  color: #ffffff;
  font-size: clamp(20px, 3vw, 30px);
  line-height: 1.15;
}

.calibration-instruction p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.calibration-grid {
  position: relative;
  min-height: 260px;
  overflow: hidden;
  background:
    linear-gradient(rgba(85, 198, 182, 0.075) 1px, transparent 1px),
    linear-gradient(90deg, rgba(85, 198, 182, 0.075) 1px, transparent 1px),
    radial-gradient(circle at center, rgba(24, 51, 64, 0.66), rgba(7, 16, 24, 0.42));
  background-size: 33.333% 33.333%, 33.333% 33.333%, auto;
  border: 1px solid rgba(85, 198, 182, 0.22);
  border-radius: 9px;
}

.calibration-grid[data-layout="cards"] {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  align-content: center;
  gap: 12px;
  padding: 26px;
  background-size: 32px 32px, 32px 32px, auto;
}

.calibration-grid-point {
  position: absolute;
  left: calc(var(--point-x) * 100%);
  top: calc(var(--point-y) * 100%);
  width: 38px;
  height: 27px;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  color: #91a3ab;
  background: rgba(7, 16, 24, 0.88);
  border: 1px solid #37505e;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.calibration-grid[data-layout="cards"] .calibration-grid-point {
  position: relative;
  left: auto;
  top: auto;
  width: auto;
  height: 74px;
  transform: none;
  border-radius: 8px;
}

.calibration-grid-point.is-current {
  color: #061015;
  background: var(--warm);
  border-color: var(--warm);
  box-shadow: 0 0 0 6px rgba(243, 189, 79, 0.12);
}

.calibration-grid-point.is-complete {
  color: #061015;
  background: var(--accent);
  border-color: var(--accent);
}

.calibration-grid-point.is-complete::after {
  content: "✓";
  margin-left: 2px;
}

.calibration-main .calibration-target {
  z-index: 3;
  left: var(--target-left, 50%);
  top: var(--target-top, 50%);
}

.calibration-target.is-captured .target-ring {
  border-color: var(--accent);
  box-shadow: 0 0 0 12px rgba(85, 198, 182, 0.14), 0 0 34px rgba(85, 198, 182, 0.44);
}

.calibration-target.is-captured .target-core { border-color: var(--accent); }

.target-progress {
  position: absolute;
  inset: -8px;
  border: 4px solid transparent;
  border-top-color: var(--accent);
  border-radius: 50%;
  opacity: calc(var(--hold-progress, 0) * 1);
  transform: rotate(calc(-90deg + var(--hold-progress, 0) * 360deg));
  transition: transform 90ms linear;
}

.calibration-main .calibration-capture-status {
  position: static;
  left: auto;
  bottom: auto;
  min-width: 0;
  width: 100%;
  padding: 10px 12px;
  transform: none;
}

.calibration-capture-status.is-captured {
  border-color: rgba(85, 198, 182, 0.5);
  background: rgba(23, 65, 62, 0.5);
}

.hold-progress {
  height: 3px;
  margin-top: 7px;
  overflow: hidden;
  background: #263845;
  border-radius: 999px;
}

.hold-progress span {
  width: 0%;
  height: 100%;
  display: block;
  background: var(--accent);
  border-radius: inherit;
  transition: width 90ms linear;
}

.calibration-navigation {
  display: grid;
  grid-template-columns: auto auto minmax(160px, 1fr);
  gap: 9px;
}

.calibration-navigation .command.primary { justify-self: end; min-width: 190px; }

.calibration-navigation button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.metrics {
  position: fixed;
  z-index: 5;
  top: 76px;
  right: 18px;
  width: min(278px, calc(100vw - 36px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  backdrop-filter: blur(14px);
  overflow: hidden;
}

.metrics-header {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 8px 7px 11px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.12);
}

.metrics-header > div {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.metrics-header strong {
  color: #ffffff;
  font-size: 13px;
}

.metrics-header span {
  color: var(--subtle);
  font-size: 10px;
}

.metrics-header button svg {
  transition: transform 160ms ease;
}

.metrics.is-expanded .metrics-header button svg {
  transform: rotate(180deg);
}

.metrics dl {
  margin: 0;
}

.metrics-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.metrics-summary > div {
  min-width: 0;
  padding: 8px 10px 9px;
  border-right: 1px solid rgba(226, 232, 240, 0.1);
  border-bottom: 1px solid rgba(226, 232, 240, 0.1);
}

.metrics-summary > div:nth-child(2n) {
  border-right: 0;
}

.metrics-summary > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.metrics-summary dt,
.metrics-detail dt {
  color: var(--subtle);
  font-size: 10px;
  text-transform: uppercase;
}

.metrics-summary dd {
  margin: 3px 0 0;
  overflow: hidden;
  color: #ffffff;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metrics-detail {
  max-height: min(430px, calc(100vh - 270px));
  overflow-y: auto;
  border-top: 1px solid rgba(226, 232, 240, 0.12);
}

.metrics-detail[hidden] {
  display: none;
}

.metrics-detail > div {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 10px;
  padding: 7px 10px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.09);
}

.metrics-detail > div:last-child {
  border-bottom: 0;
}

.metrics-detail dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  text-align: right;
  color: #f7fafc;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.metrics a {
  color: #91e1d5;
  text-decoration: none;
}

.metrics a[href]:hover {
  text-decoration: underline;
}

.control-dock {
  position: fixed;
  z-index: 6;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(58vh, 560px);
  overflow-y: auto;
  padding: 11px 16px 14px;
  background: rgba(7, 16, 24, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.control-primary,
.experiment-panel {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.control-primary {
  display: grid;
  grid-template-columns: minmax(270px, 1.35fr) minmax(220px, 1fr) auto;
  align-items: end;
  gap: 14px;
}

.field,
.slider-field {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.field > span,
.slider-field > span,
.segmented legend {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.slider-field > span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.slider-field output {
  color: #f0f5f7;
  font-variant-numeric: tabular-nums;
  text-transform: none;
}

.slider-field small {
  color: var(--subtle);
  font-size: 10px;
  line-height: 1.35;
}

select {
  width: 100%;
  padding: 0 34px 0 11px;
}

input[type="range"] {
  width: 100%;
  margin: 1px 0;
  accent-color: var(--accent);
}

.command.primary {
  min-height: 40px;
  color: var(--warm-ink);
  background: var(--warm);
  border-color: var(--warm);
  font-weight: 700;
}

.command.primary:hover:not(:disabled) {
  background: #ffd16f;
  border-color: #ffd16f;
}

.command.primary.is-running {
  color: #2b0905;
  background: var(--danger);
  border-color: var(--danger);
}

.replay-label-compact {
  display: none;
}

.command.secondary {
  color: #eaf1f4;
  background: var(--control);
}

.command.ghost {
  color: #d9e3e8;
  background: transparent;
}

.experiment-panel {
  margin-top: 10px;
  border-top: 1px solid rgba(226, 232, 240, 0.13);
}

.experiment-panel > summary {
  min-height: 43px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 1px 0;
  cursor: pointer;
  list-style: none;
}

.experiment-panel > summary::-webkit-details-marker {
  display: none;
}

.summary-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #e8f0f3;
}

.summary-title > span {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.summary-title strong {
  font-size: 12px;
}

.summary-title small {
  overflow: hidden;
  color: var(--subtle);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-chevron {
  width: 17px;
  height: 17px;
  transform: rotate(180deg);
  transition: transform 160ms ease;
}

.experiment-panel[open] .summary-chevron {
  transform: rotate(0deg);
}

.experiment-content {
  display: grid;
  grid-template-columns: minmax(250px, 0.9fr) minmax(360px, 1.4fr) minmax(180px, 0.8fr) minmax(190px, 0.8fr);
  gap: 14px;
  align-items: start;
  padding: 10px 0 2px;
}

.segmented {
  min-width: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented legend {
  position: absolute;
  transform: translateY(-17px);
}

.segmented label {
  position: relative;
  min-width: 0;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label > span {
  min-height: 40px;
  display: grid;
  place-items: center;
  padding: 4px 9px;
  background: var(--control);
  border: 1px solid var(--line);
  color: #cbd6dc;
  font-size: 11px;
  text-align: center;
  cursor: pointer;
}

.method-segment label > span {
  line-height: 1.05;
}

.method-segment label > span small {
  color: var(--subtle);
  font-size: 9px;
}

.segmented label:first-of-type > span {
  border-radius: 6px 0 0 6px;
}

.segmented label:last-of-type > span {
  border-radius: 0 6px 6px 0;
}

.segmented label + label > span {
  border-left: 0;
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--warm);
  outline-offset: 2px;
}

.segmented input:checked + span {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

.segmented input:checked + span small {
  color: rgba(7, 33, 29, 0.72);
}

.experiment-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 8px;
  border-top: 1px solid rgba(226, 232, 240, 0.11);
}

.switch-field {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #d5dfe4;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.switch-field input {
  position: absolute;
  opacity: 0;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 39px;
  height: 22px;
  border-radius: 11px;
  background: #344755;
  border: 1px solid var(--line);
}

.switch::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 2px;
  left: 3px;
  border-radius: 50%;
  background: #f8fafc;
  transition: transform 150ms ease;
}

.switch-field input:focus-visible + .switch {
  outline: 2px solid var(--warm);
  outline-offset: 2px;
}

.switch-field input:checked + .switch {
  background: var(--accent);
}

.switch-field input:checked + .switch::after {
  transform: translateX(15px);
}

.guide-dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: min(640px, calc(100vh - 28px));
  margin: auto;
  padding: 0;
  color: var(--ink);
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.48);
  overflow: hidden;
}

.guide-dialog::backdrop {
  background: rgba(2, 7, 11, 0.76);
  backdrop-filter: blur(5px);
}

.guide-topline {
  min-height: 49px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 8px 7px 20px;
  border-bottom: 1px solid var(--line);
}

.guide-topline > span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.guide-steps {
  min-height: 290px;
  display: grid;
  align-items: center;
  padding: 34px 36px 26px;
}

.guide-step {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 20px;
  align-items: start;
}

.guide-step[hidden] {
  display: none;
}

.guide-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  color: var(--warm);
  background: rgba(243, 189, 79, 0.1);
  border: 1px solid rgba(243, 189, 79, 0.28);
  border-radius: 7px;
}

.guide-icon svg {
  width: 27px;
  height: 27px;
  stroke-width: 1.7;
}

.step-number {
  margin: 0 0 7px;
  color: var(--subtle);
  font-size: 11px;
  text-transform: uppercase;
}

.guide-step h2 {
  margin: 0;
  color: #ffffff;
  font-size: 26px;
  line-height: 1.2;
}

.guide-step p:last-child {
  margin: 14px 0 0;
  color: #bdc9d0;
  font-size: 14px;
  line-height: 1.6;
}

.guide-footer {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 18px;
  background: #0a141c;
  border-top: 1px solid var(--line);
}

.guide-progress {
  display: flex;
  gap: 6px;
}

.guide-progress span {
  width: 18px;
  height: 3px;
  background: #344550;
  border-radius: 2px;
}

.guide-progress span.active {
  background: var(--accent);
}

.guide-actions {
  display: flex;
  gap: 8px;
}

@media (max-width: 980px) {
  .control-primary {
    grid-template-columns: minmax(230px, 1.2fr) minmax(190px, 0.8fr) auto;
  }

  .experiment-content {
    grid-template-columns: minmax(220px, 0.85fr) minmax(340px, 1.3fr);
    row-gap: 23px;
  }

  .budget-field,
  .timeline-field {
    grid-row: 2;
  }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding-inline: 12px;
  }

  .live-status {
    display: none;
  }

  .icon-action {
    min-width: 40px;
    width: 40px;
    padding: 0;
  }

  .icon-action span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .metrics {
    top: 68px;
    right: 10px;
    width: min(250px, calc(100vw - 20px));
  }

  .tracking-panel {
    top: 68px;
    left: 10px;
    width: min(270px, calc(100vw - 20px));
  }

  .calibration-topbar {
    grid-template-columns: 1fr auto;
    gap: 12px;
    min-height: 72px;
    padding-inline: 12px;
  }

  .calibration-progress-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: -8px;
  }

  .calibration-topbar .square-action {
    grid-column: 2;
    grid-row: 1;
  }

  .calibration-overlay {
    padding-top: 92px;
  }

  .control-primary {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .scene-field {
    grid-column: 1 / -1;
  }

  .zoom-field {
    grid-column: 1;
  }

  .control-primary .command.primary {
    grid-column: 2;
  }

  .experiment-content {
    grid-template-columns: 1fr;
    row-gap: 23px;
    padding-top: 22px;
  }

  .budget-field,
  .timeline-field {
    grid-row: auto;
  }

  .projection-segment {
    grid-auto-flow: row;
    grid-template-columns: 1fr 1fr;
  }

  .projection-segment label:first-of-type > span {
    border-radius: 6px 0 0 0;
  }

  .projection-segment label:nth-of-type(2) > span {
    border-radius: 0 6px 0 0;
  }

  .projection-segment label:nth-of-type(3) > span {
    border-left: 1px solid var(--line);
    border-radius: 0 0 0 6px;
  }

  .projection-segment label:last-of-type > span {
    border-radius: 0 0 6px 0;
  }

  .projection-segment label:nth-of-type(n + 3) > span {
    border-top: 0;
  }
}

@media (max-width: 520px) {
  .topbar {
    min-height: 52px;
    padding: 7px 9px;
  }

  .identity strong {
    font-size: 18px;
  }

  .identity span {
    display: none;
  }

  .top-actions {
    gap: 5px;
  }

  .interaction-hint {
    top: 42%;
    gap: 7px;
    padding: 0 11px;
    font-size: 11px;
  }

  .hint-separator {
    display: none;
  }

  .interaction-hint span:nth-of-type(2),
  .interaction-hint svg:nth-of-type(2) {
    display: none;
  }

  .metrics {
    top: 60px;
    left: 8px;
    right: 8px;
    width: auto;
  }

  .tracking-panel {
    top: 160px;
    left: 8px;
    width: min(236px, calc(100vw - 16px));
    padding: 9px;
  }

  .tracking-note {
    display: none;
  }

  .tracking-readout,
  .tracking-actions {
    gap: 5px;
  }

  .metrics-header {
    min-height: 42px;
  }

  .metrics-header > div {
    display: flex;
    align-items: baseline;
    gap: 7px;
  }

  .metrics-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .metrics-summary > div {
    padding: 7px 7px 8px;
    border-right: 1px solid rgba(226, 232, 240, 0.1);
    border-bottom: 0;
  }

  .metrics-summary > div:last-child {
    border-right: 0;
  }

  .metrics-summary dt {
    font-size: 8px;
  }

  .metrics-summary dd {
    font-size: 10px;
  }

  .metrics-detail {
    max-height: clamp(120px, calc(100vh - 500px), 220px);
  }

  .control-dock {
    max-height: 52vh;
    padding: 9px 9px 11px;
  }

  .control-primary {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .control-primary .command.primary {
    width: auto;
    min-width: 82px;
    padding: 0 10px;
  }

  .replay-label-full {
    display: none;
  }

  .replay-label-compact {
    display: inline;
  }

  .summary-title small {
    max-width: 260px;
  }

  .experiment-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .experiment-actions .command {
    width: 100%;
  }

  .guide-steps {
    min-height: 330px;
    padding: 26px 22px 22px;
  }

  .guide-step {
    grid-template-columns: 1fr;
    gap: 17px;
  }

  .guide-icon {
    width: 48px;
    height: 48px;
  }

  .guide-step h2 {
    font-size: 22px;
  }

  .guide-step p:last-child {
    font-size: 13px;
  }

  .guide-footer {
    align-items: flex-end;
    flex-direction: column;
    gap: 12px;
  }

  .guide-progress {
    align-self: flex-start;
  }

  .guide-actions {
    width: 100%;
  }

  .guide-actions button {
    flex: 1;
  }

  .calibration-card {
    padding: 22px 18px;
  }

  .calibration-icon {
    width: 44px;
    height: 44px;
    margin-bottom: 14px;
  }

  .calibration-card h1 {
    font-size: 24px;
  }

  .calibration-card > p:not(.step-number) {
    font-size: 12px;
  }

  .readiness-list {
    margin-block: 16px;
  }

  .readiness-list li {
    min-height: 34px;
    font-size: 11px;
  }

  .calibration-score-grid {
    grid-template-columns: 1fr;
    margin: 16px 0;
  }

  .calibration-score-grid > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 11px;
  }

  .calibration-score-grid strong {
    font-size: 16px;
  }

  .calibration-result-actions {
    grid-template-columns: 1fr;
  }

  .calibration-capture-status {
    bottom: 16px;
  }
}

@media (max-width: 860px) {
  .calibration-workspace {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .calibration-sidebar { padding: 12px; }
  .demo-frame { height: 118px; }
  .calibration-main { padding: 16px; }
  .calibration-grid[data-layout="cards"] { padding: 16px; }
}

@media (max-width: 640px) {
  .calibration-overlay { padding: 90px 8px 8px; }

  .calibration-workspace {
    width: 100%;
    height: 100%;
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    border-radius: 8px;
  }

  .calibration-sidebar {
    display: grid;
    grid-template-columns: 128px minmax(0, 1fr);
    gap: 9px;
    padding: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .calibration-demo { padding: 7px; }
  .demo-caption { font-size: 7px; }
  .demo-frame { height: 72px; }
  .demo-face { width: 42px; height: 54px; }
  .demo-eyes { left: 7px; right: 7px; top: 18px; }
  .demo-eyes > span { width: 11px; height: 7px; }
  .demo-eyes i { left: 3px; top: 1px; width: 5px; height: 5px; border-width: 1px; }
  .demo-nose, .demo-mouth, .demo-ear { display: none; }
  .demo-camera { width: 20px; height: 20px; right: 5px; bottom: 5px; }
  .calibration-demo p { display: none; }

  .calibration-stage-list {
    grid-template-columns: 1fr 1fr;
    gap: 5px;
  }

  .calibration-stage-list li {
    grid-template-columns: 22px 1fr;
    min-height: 36px;
    gap: 5px;
    padding: 4px 6px;
  }

  .calibration-stage-list li > span { width: 21px; height: 21px; }
  .calibration-stage-list li > svg { display: none; }
  .calibration-stage-list small { display: none; }

  .calibration-main {
    gap: 7px;
    padding: 10px;
  }

  .calibration-instruction { min-height: 50px; gap: 8px; }
  .calibration-item-number { flex-basis: 40px; height: 31px; }
  .calibration-instruction h1 { font-size: 17px; }
  .calibration-instruction p { font-size: 9px; }
  .calibration-grid { min-height: 160px; }
  .calibration-grid[data-layout="cards"] { gap: 7px; padding: 8px; }
  .calibration-grid[data-layout="cards"] .calibration-grid-point { height: 48px; }
  .calibration-grid-point { width: 32px; height: 23px; font-size: 8px; }
  .calibration-target { width: 48px; height: 48px; }
  .calibration-main .calibration-capture-status { padding: 7px 9px; }
  .calibration-navigation { grid-template-columns: auto auto 1fr; gap: 5px; }
  .calibration-navigation .command { min-height: 36px; padding-inline: 9px; }
  .calibration-navigation .command span { font-size: 9px; }
  .calibration-navigation .command.primary { min-width: 116px; }

  .wizard-overview { grid-template-columns: 1fr; gap: 6px; }
  .wizard-overview li { min-height: 46px; }
}

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

/* ------------------------------------------------------------------------- */
/* Diagnostic tile grid (generated) scene — appended 2026-09-17.              */
/* The overlay and panel are hidden unless the scene is active.               */
/* ------------------------------------------------------------------------- */

.diagnostic-overlay {
  position: fixed;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.diagnostic-overlay[hidden] {
  display: none;
}

.diagnostic-panel {
  position: fixed;
  z-index: 5;
  top: 76px;
  left: 18px;
  width: min(300px, calc(100vw - 36px));
  max-height: calc(100vh - 76px - 124px);
  overflow-y: auto;
  padding: 0 0 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  backdrop-filter: blur(14px);
  font-size: 12px;
}

.diagnostic-panel[hidden] {
  display: none;
}

.diagnostic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 40px;
  padding: 6px 12px 5px;
  border-bottom: 1px solid var(--line);
}

.diagnostic-header strong {
  display: block;
  font-size: 13px;
}

.diagnostic-header span:not(.diagnostic-badge) {
  display: block;
  color: var(--muted);
  font-size: 10.5px;
}

.diagnostic-header .square-action {
  flex: 0 0 auto;
  width: 30px;
  min-height: 30px;
  height: 30px;
}

.diagnostic-header .square-action svg {
  transition: transform 150ms ease;
}

.diagnostic-panel.is-collapsed .diagnostic-header .square-action svg {
  transform: rotate(180deg);
}

.diagnostic-panel.is-collapsed .diagnostic-header {
  border-bottom: 0;
}

.diagnostic-panel.is-collapsed .diagnostic-body {
  display: none;
}

.diagnostic-badge {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(85, 198, 182, 0.16);
  border: 1px solid rgba(85, 198, 182, 0.45);
  color: var(--accent);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.diagnostic-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
}

.diagnostic-controls label {
  display: grid;
  gap: 3px;
  min-width: 0;
  color: var(--muted);
  font-size: 10.5px;
}

.diagnostic-controls label > span:first-child {
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.diagnostic-controls select {
  min-height: 27px;
  width: 100%;
  padding: 0 6px;
  font-size: 11.5px;
}

.diagnostic-controls .switch-field.compact {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding-top: 4px;
  font-size: 11.5px;
  color: #d5dfe4;
  text-transform: none;
  letter-spacing: 0;
}

.diagnostic-controls .switch-field.compact .switch {
  width: 32px;
  height: 18px;
}

.diagnostic-controls .switch-field.compact .switch::after {
  width: 12px;
  height: 12px;
}

.diagnostic-controls .switch-field.compact input:checked + .switch::after {
  transform: translateX(14px);
}

.diagnostic-stats {
  margin: 0;
  padding: 5px 12px;
  display: grid;
  gap: 1px;
}

.diagnostic-stats > div {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 8px;
  align-items: baseline;
}

.diagnostic-stats dt {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.diagnostic-stats dd {
  margin: 0;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  line-height: 1.25;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.diagnostic-atlas {
  display: block;
  width: calc(100% - 24px);
  height: auto;
  margin: 4px 12px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #0b141b;
}

.diagnostic-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 9px;
  padding: 0 12px 6px;
  color: var(--muted);
  font-size: 10.5px;
}

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

.diagnostic-legend i {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.45);
}

.diagnostic-legend i.hatch {
  background: repeating-linear-gradient(135deg, #5b6168 0 2px, #8a9096 2px 4px);
}

.diagnostic-why {
  margin: 0;
  padding: 6px 12px 4px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.4;
}

@media (max-width: 980px) {
  .diagnostic-panel {
    width: min(270px, calc(100vw - 36px));
    max-height: calc(100vh - 76px - 170px);
  }
}

@media (max-width: 760px) {
  /* Below the collapsed Live-result panel; starts collapsed (diagnostic-grid.js COLLAPSE_MEDIA_QUERY). */
  .diagnostic-panel {
    top: 158px;
    left: 10px;
    width: min(300px, calc(100vw - 20px));
    max-height: calc(100vh - 158px - 150px);
    font-size: 11px;
  }

  .diagnostic-header {
    min-height: 36px;
    padding: 5px 10px 4px;
  }

  .diagnostic-header strong {
    font-size: 12px;
  }

  .diagnostic-controls {
    grid-template-columns: 1fr 1fr;
    padding: 6px 10px;
  }

  .diagnostic-stats > div {
    grid-template-columns: 92px 1fr;
  }

  .diagnostic-stats dd {
    font-size: 11px;
  }

  .diagnostic-why {
    display: none;
  }
}

@media (max-width: 520px) {
  .diagnostic-panel {
    top: 150px;
    left: 8px;
    width: calc(100vw - 16px);
    max-height: calc(100vh - 150px - 132px);
  }

  .diagnostic-controls {
    grid-template-columns: 1fr;
  }

  .diagnostic-atlas,
  .diagnostic-legend {
    display: none;
  }
}

/* ------------------------------------------------------------------------- */
/* Tile grid overlay (every scene) — appended 2026-10-25.                     */
/* The label canvas reuses .diagnostic-overlay (fixed, inset 0, z-index 3,    */
/* no pointer events); the lines are drawn by the shader.                     */
/* ------------------------------------------------------------------------- */

.tile-grid-overlay {
  z-index: 3;
}

.tile-grid-caption {
  position: fixed;
  z-index: 4;
  top: 70px;
  left: 50%;
  max-width: min(680px, calc(100vw - 640px));
  padding: 4px 10px;
  transform: translateX(-50%);
  color: #f3f7f9;
  background: rgba(6, 13, 18, 0.84);
  border: 1px solid rgba(243, 189, 79, 0.45);
  border-radius: 6px;
  font-size: 11.5px;
  line-height: 1.35;
  text-align: center;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.tile-grid-caption[hidden] {
  display: none;
}

.tile-grid-settings {
  grid-column: 1 / -1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px 14px;
  padding-top: 8px;
  border-top: 1px solid rgba(226, 232, 240, 0.11);
}

.tile-grid-title {
  flex: 1 1 100%;
  color: #e8f0f3;
  font-size: 12px;
  font-weight: 600;
}

.tile-grid-title small {
  margin-left: 6px;
  color: var(--subtle);
  font-size: 10px;
  font-weight: 400;
}

.tile-grid-field {
  flex: 1 1 160px;
}

.tile-grid-opacity {
  flex: 1 1 170px;
}

.tile-grid-labels {
  flex: 0 0 auto;
  min-height: 38px;
}

@media (max-width: 1100px) {
  /* The fourth topbar button is icon-only until the labels return at full width. */
  .grid-action {
    min-width: 40px;
    width: 40px;
    padding: 0;
  }

  .grid-action span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .tile-grid-caption {
    left: 18px;
    max-width: calc(100vw - 350px);
    transform: none;
    text-align: left;
  }
}

@media (max-width: 760px) {
  /* Left of the collapsed Live-result panel. */
  .tile-grid-caption {
    top: 68px;
    left: 10px;
    max-width: calc(100vw - 280px);
    font-size: 10.5px;
  }
}

@media (max-width: 520px) {
  /* Below the full-width Live-result panel. */
  .tile-grid-caption {
    top: 154px;
    left: 8px;
    right: 8px;
    max-width: none;
  }

  .tile-grid-field,
  .tile-grid-opacity {
    flex-basis: 140px;
  }
}
