.webxr-compact-heading {
  margin-bottom: 12px;
}

.webxr-compact-heading h1 {
  font-size: clamp(26px, 4vw, 34px);
}

.webxr-ready {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  box-shadow: var(--shadow-soft);
}

.webxr-ready > div {
  min-width: 0;
}

.webxr-ready-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.webxr-ready-summary .status-dot {
  margin-top: 0;
}

.webxr-ready-summary strong {
  margin-right: 2px;
  font-size: 15px;
  line-height: 1.2;
}

.webxr-ready-summary span:not(.status-dot) {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(22, 183, 166, .24);
  border-radius: 999px;
  color: #0d645f;
  background: #f0fbfa;
  font-size: 12px;
  font-weight: 760;
}

.webxr-status-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  gap: 8px;
  margin-top: 0;
}

.compact-status {
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
}

.compact-status .status-dot {
  margin-top: 0;
}

.compact-status h2 {
  margin: 0;
  font-size: 12px;
}

.compact-status p {
  margin: 1px 0 0;
  font-size: 12px;
  line-height: 1.2;
}

.compact-status small {
  display: none;
}

.webxr-ready .muted {
  margin: 0;
  font-size: 13px;
}

.webxr-pairing-form input[name="pairing_code"] {
  max-width: 220px;
  font-size: 28px;
  font-weight: 860;
  letter-spacing: .16em;
  text-align: center;
}

.webxr-paired-waiting {
  display: grid;
  justify-items: center;
  gap: 18px;
  width: min(100%, 760px);
  margin-inline: auto;
  padding: clamp(24px, 5vw, 48px);
  border-top: 4px solid var(--ok);
  text-align: center;
}

.webxr-paired-status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #0d645f;
  font-size: 13px;
  font-weight: 840;
  text-transform: uppercase;
}

.webxr-paired-status .status-dot {
  margin-top: 0;
  box-shadow: 0 0 0 5px rgba(22, 183, 166, .13);
}

.webxr-paired-copy {
  display: grid;
  gap: 8px;
  max-width: 650px;
}

.webxr-paired-copy h2,
.webxr-paired-copy p {
  margin: 0;
}

.webxr-paired-copy h2 {
  font-size: 34px;
}

.webxr-paired-copy .lead {
  color: #0d645f;
  font-weight: 780;
}

.webxr-entry-reminder {
  display: grid;
  gap: 5px;
  width: min(100%, 620px);
  padding: 15px 18px;
  border-left: 4px solid #315d8c;
  background: #eef5fa;
  color: #123047;
  text-align: left;
}

.webxr-entry-reminder strong {
  color: #315d8c;
  font-size: 12px;
  text-transform: uppercase;
}

.webxr-entry-reminder span {
  font-size: 17px;
  line-height: 1.4;
}

.webxr-refresh-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.webxr-exercise-stage {
  width: 100%;
  margin-top: 14px;
  padding: clamp(14px, 2.2vw, 22px);
}

.exercise-stage-header {
  align-items: center;
  margin-bottom: 10px;
}

.exercise-stage-header .eyebrow {
  margin-bottom: 5px;
  font-size: 12px;
}

.exercise-stage-header h2 {
  font-size: clamp(20px, 3vw, 28px);
}

.exercise-counter {
  min-width: 78px;
}

.exercise-counter span {
  font-size: clamp(24px, 4vw, 34px);
}

.target-workspace {
  min-height: clamp(430px, 68svh, 780px);
}

.webxr-patient-waiting {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 15px;
  padding: clamp(22px, 6vw, 64px);
  background: rgba(248, 251, 252, .94);
  text-align: center;
}

.webxr-patient-waiting[hidden] {
  display: none;
}

.webxr-patient-waiting h3,
.webxr-patient-waiting p {
  margin: 0;
}

.webxr-patient-waiting h3 {
  color: #123047;
  font-size: 32px;
  line-height: 1.15;
}

.webxr-patient-waiting > p {
  max-width: 620px;
  color: #52697d;
  font-size: 18px;
  line-height: 1.5;
}

.webxr-exercise-stage[data-state="waiting"] .exercise-counter {
  display: none;
}

.webxr-exercise-stage[data-state="waiting"] #webxr-exercise-feedback {
  color: #315d8c;
  font-weight: 760;
  text-align: center;
}

.touch-target-3d-shell {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  background: #f4f9fb;
  z-index: 10;
}

.touch-target-3d-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.touch-target-3d-hud {
  position: absolute;
  z-index: 2;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(18, 52, 77, .14);
  border-radius: 14px;
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 12px 28px rgba(18, 52, 77, .10);
  pointer-events: none;
}

.touch-target-3d-hud div {
  display: grid;
  gap: 2px;
}

.touch-target-3d-hud strong {
  color: #12344d;
  font-size: 14px;
  line-height: 1.1;
}

.touch-target-3d-hud span {
  color: #6d7f8f;
  font-size: 12px;
  font-weight: 700;
}

.touch-target-3d-hud button {
  pointer-events: auto;
  white-space: nowrap;
}

.touch-target-3d-shell.is-unavailable {
  z-index: 0;
  background: rgba(244, 249, 251, .74);
  pointer-events: none;
}

.release-zone {
  position: absolute;
  top: 50%;
  right: clamp(18px, 7vw, 72px);
  display: grid;
  place-items: center;
  min-width: 96px;
  min-height: 96px;
  padding: 12px;
  border: 3px dashed rgba(22, 183, 166, .74);
  border-radius: 50%;
  background: rgba(224, 247, 244, .82);
  color: #0d645f;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  transform: translateY(-50%);
  box-shadow: inset 0 0 0 8px rgba(255, 255, 255, .62);
  cursor: pointer;
}

.release-zone.active {
  border-color: rgba(37, 99, 235, .86);
  background: rgba(219, 234, 254, .92);
  color: #1d4ed8;
  box-shadow:
    inset 0 0 0 8px rgba(255, 255, 255, .68),
    0 0 0 8px rgba(37, 99, 235, .12);
}

.release-zone span {
  max-width: 92px;
  line-height: 1.15;
}

.release-zone:disabled {
  opacity: .62;
  cursor: default;
}

.pinch-object {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 42px;
  min-height: 42px;
  border: 4px solid #ffffff;
  border-radius: 18px;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .95) 0 10%, transparent 11%),
    linear-gradient(135deg, #ffbf5f 0%, #f08a3c 48%, #cf5e3c 100%);
  box-shadow: 0 16px 34px rgba(207, 94, 60, .26);
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.pinch-object.grabbed {
  outline: 5px solid rgba(22, 183, 166, .28);
  box-shadow: 0 18px 38px rgba(22, 183, 166, .32);
  cursor: grabbing;
}

.pinch-object:disabled {
  opacity: .58;
  cursor: default;
}

.sorting-layer,
.wrist-layer,
.bimanual-layer {
  position: absolute;
  inset: 0;
}

.sorting-prompt {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(18, 52, 77, .12);
  border-radius: 8px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 12px 26px rgba(18, 52, 77, .08);
}

.sorting-prompt strong {
  color: #12344d;
  font-size: 14px;
  line-height: 1.1;
}

.sorting-prompt span {
  color: #52697d;
  font-size: 13px;
  font-weight: 760;
  text-align: right;
}

.sorting-containers {
  position: absolute;
  top: clamp(86px, 15vh, 128px);
  right: clamp(14px, 5vw, 56px);
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 12px;
  width: min(56%, 420px);
}

.sorting-containers[data-count="1"] {
  grid-template-columns: minmax(150px, 1fr);
  width: min(38%, 240px);
}

.sorting-containers[data-count="3"],
.sorting-containers[data-count="4"] {
  width: min(60%, 460px);
}

.sorting-container {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 108px;
  padding: 10px;
  border: 3px solid var(--container-color);
  border-radius: 8px;
  color: var(--container-color);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfc 100%);
  font-size: 15px;
  font-weight: 900;
  box-shadow: inset 0 0 0 6px rgba(255, 255, 255, .62);
}

.sorting-container small,
.sorting-object small {
  color: #6d7f8f;
  font-size: 10px;
  font-weight: 860;
  letter-spacing: .04em;
  line-height: 1;
  text-transform: uppercase;
}

.sorting-object small {
  display: none;
}

.sorting-container strong,
.sorting-object strong {
  line-height: 1;
  text-align: center;
}

.sorting-container.active {
  box-shadow:
    inset 0 0 0 6px rgba(255, 255, 255, .72),
    0 0 0 7px rgba(37, 99, 235, .14);
}

.sorting-object {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  gap: 3px;
  min-width: 52px;
  min-height: 52px;
  padding: 6px;
  border: 4px solid #fff;
  border-radius: 16px;
  color: #fff;
  background: var(--object-color, #315d8c);
  box-shadow: 0 16px 34px rgba(49, 93, 140, .28);
  font-size: 13px;
  font-weight: 900;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.sorting-object.sorting-mode-shape,
.sorting-object.sorting-mode-size {
  color: #12344d;
  background: #ffffff;
  border-color: #315d8c;
}

.sorting-object.sorting-mode-shape {
  box-shadow: 0 16px 34px rgba(49, 93, 140, .24);
}

.sorting-object.sorting-mode-size {
  box-shadow: 0 16px 34px rgba(22, 183, 166, .22);
}

.sort-visual {
  display: block;
  width: 34px;
  height: 34px;
  background: currentColor;
}

.sorting-object .sort-visual {
  width: min(34px, 58%);
  height: min(34px, 58%);
  background: #fff;
}

.sorting-object.sorting-mode-shape .sort-visual,
.sorting-object.sorting-mode-size .sort-visual {
  background: currentColor;
}

.sorting-mode-color .sort-visual {
  border-radius: 50%;
}

.sorting-mode-shape .sort-visual.shape-circle {
  border-radius: 50%;
}

.sorting-mode-shape .sort-visual.shape-square {
  border-radius: 7px;
}

.sorting-mode-shape .sort-visual.shape-triangle {
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.sorting-mode-shape .sort-visual.shape-diamond {
  transform: rotate(45deg);
  border-radius: 5px;
}

.sorting-mode-size .sort-visual {
  border-radius: 50%;
}

.sorting-mode-size[data-index="1"] .sort-visual {
  width: 22px;
  height: 22px;
}

.sorting-mode-size[data-index="2"] .sort-visual {
  width: 30px;
  height: 30px;
}

.sorting-mode-size[data-index="3"] .sort-visual {
  width: 38px;
  height: 38px;
}

.sorting-mode-size[data-index="4"] .sort-visual {
  width: 46px;
  height: 46px;
}

.sorting-object.sorting-mode-size .sort-visual {
  width: 52%;
  height: 52%;
}

.sorting-object:active {
  cursor: grabbing;
}

.wrist-layer {
  display: grid;
  place-items: center;
}

.wrist-dial {
  position: relative;
  width: min(66vw, 420px);
  aspect-ratio: 1;
  border: 2px solid rgba(49, 93, 140, .18);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 49.5%, rgba(49, 93, 140, .22) 49.5% 50.5%, transparent 50.5%),
    linear-gradient(0deg, transparent 49.5%, rgba(49, 93, 140, .22) 49.5% 50.5%, transparent 50.5%),
    radial-gradient(circle, #fff 0 42%, #eef7fb 43% 100%);
  box-shadow: inset 0 0 0 12px rgba(255, 255, 255, .68);
}

.wrist-target,
.wrist-pointer {
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 8px;
  height: 42%;
  transform-origin: 50% 100%;
}

.wrist-target {
  margin-left: -4px;
  border-radius: 999px;
  background: rgba(22, 183, 166, .32);
}

.wrist-pointer {
  margin-left: -9px;
  border: 0;
  border-radius: 999px;
  background: #315d8c;
  box-shadow: 0 8px 18px rgba(49, 93, 140, .28);
  cursor: grab;
  touch-action: none;
}

.wrist-target-label,
.wrist-angle {
  position: absolute;
  left: 50%;
  display: grid;
  gap: 2px;
  min-width: 138px;
  padding: 10px 14px;
  border: 1px solid rgba(49, 93, 140, .14);
  border-radius: 14px;
  background: rgba(255, 255, 255, .88);
  color: #123047;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 12px 24px rgba(18, 48, 71, .12);
}

.wrist-target-label {
  top: 50%;
  transform: translate(-50%, -118%);
}

.wrist-angle {
  top: 50%;
  transform: translate(-50%, 18%);
}

.wrist-target-label strong,
.wrist-angle strong {
  font-size: 32px;
  line-height: 1;
}

.wrist-target-label strong {
  color: #0f8f83;
}

.wrist-angle strong {
  color: #315d8c;
}

.bimanual-layer {
  display: grid;
  place-items: center;
}

.bimanual-track {
  position: relative;
  width: min(88%, 760px);
  height: 260px;
  overflow: hidden;
  border: 2px solid rgba(49, 93, 140, .2);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 49.8%, rgba(49, 93, 140, .18) 49.8% 50.2%, transparent 50.2%),
    linear-gradient(0deg, transparent 57.5%, rgba(49, 93, 140, .12) 57.5% 58.5%, transparent 58.5%),
    #f7fbfd;
}

.bimanual-goal {
  position: absolute;
  left: 24px;
  right: 24px;
  top: 18px;
  display: grid;
  gap: 4px;
  text-align: center;
  pointer-events: none;
}

.bimanual-goal strong {
  color: #0f8f83;
  font-size: 13px;
  font-weight: 950;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.bimanual-goal span {
  color: #12344d;
  font-size: clamp(17px, 2.4vw, 23px);
  font-weight: 900;
  line-height: 1.2;
}

.bimanual-guide {
  position: absolute;
  left: 0;
  top: 58%;
  height: 8px;
  margin-top: -4px;
  border-radius: 999px;
  opacity: .45;
  pointer-events: none;
}

.bimanual-guide.left {
  background: linear-gradient(90deg, rgba(37, 99, 235, .08), rgba(37, 99, 235, .62));
}

.bimanual-guide.right {
  background: linear-gradient(90deg, rgba(22, 183, 166, .08), rgba(22, 183, 166, .62));
}

.bimanual-guide.is-hit {
  opacity: .16;
}

.bimanual-target,
.bimanual-cursor {
  position: absolute;
  top: 58%;
  left: 0;
  transform: translateX(0);
}

.bimanual-target {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  width: 94px;
  height: 118px;
  margin: -59px 0 0 -47px;
  border: 4px solid rgba(22, 183, 166, .88);
  border-radius: 999px;
  background: rgba(224, 247, 244, .88);
  box-shadow:
    0 0 0 9px rgba(22, 183, 166, .12),
    inset 0 0 0 4px rgba(255, 255, 255, .72);
}

.bimanual-target.left {
  border-color: rgba(37, 99, 235, .88);
  background: rgba(219, 234, 254, .88);
  box-shadow:
    0 0 0 9px rgba(37, 99, 235, .12),
    inset 0 0 0 4px rgba(255, 255, 255, .72);
}

.bimanual-target.is-hit {
  border-style: solid;
  box-shadow:
    0 0 0 12px rgba(22, 183, 166, .18),
    0 12px 30px rgba(22, 183, 166, .22),
    inset 0 0 0 4px rgba(255, 255, 255, .82);
}

.bimanual-target.left.is-hit {
  box-shadow:
    0 0 0 12px rgba(37, 99, 235, .18),
    0 12px 30px rgba(37, 99, 235, .2),
    inset 0 0 0 4px rgba(255, 255, 255, .82);
}

.bimanual-target strong,
.bimanual-target em,
.bimanual-cursor small,
.bimanual-cursor span {
  font-style: normal;
  font-weight: 950;
  line-height: 1;
}

.bimanual-target strong {
  color: #12344d;
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.bimanual-target em {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: #fff;
  color: #12344d;
  font-size: 19px;
  box-shadow: 0 8px 18px rgba(18, 52, 77, .12);
}

.bimanual-cursor {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  width: 70px;
  height: 70px;
  margin: -35px 0 0 -35px;
  border: 4px solid #fff;
  border-radius: 50%;
  box-shadow: 0 14px 28px rgba(49, 93, 140, .24);
}

.bimanual-cursor.left {
  background: #315d8c;
}

.bimanual-cursor.right {
  background: #16b7a6;
}

.bimanual-cursor span {
  color: #fff;
  font-size: 18px;
}

.bimanual-cursor small {
  color: rgba(255, 255, 255, .82);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.controller-fallback {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(49, 93, 140, .18);
  border-radius: 8px;
  background: #f7fbfd;
}

.controller-fallback > div {
  min-width: 0;
}

.controller-fallback span {
  display: block;
  color: #123047;
  font-size: 14px;
  font-weight: 820;
}

.controller-fallback small {
  display: block;
  margin-top: 4px;
  color: #667987;
  font-size: 13px;
}

.controller-fallback-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 640px) {
  .webxr-status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .webxr-ready-summary span:not(.status-dot) {
    max-width: 100%;
    min-height: 26px;
  }

  .target-workspace {
    min-height: clamp(360px, 62svh, 620px);
  }

  .webxr-paired-waiting {
    gap: 15px;
    padding: 22px 18px;
  }

  .webxr-patient-waiting {
    padding: 20px 16px;
  }

  .webxr-paired-copy h2 {
    font-size: 28px;
  }

  .webxr-entry-reminder span {
    font-size: 15px;
  }

  .webxr-patient-waiting h3 {
    font-size: 26px;
  }

  .webxr-patient-waiting > p {
    font-size: 16px;
  }

  .controller-fallback {
    align-items: stretch;
    flex-direction: column;
  }

  .controller-fallback-actions {
    justify-content: stretch;
  }

  .controller-fallback-actions .button {
    flex: 1 1 140px;
  }
}
