:root {
  color-scheme: light;
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  background: #f7f5fb;
  color: #20223b;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 6%, rgba(255, 196, 125, 0.2), transparent 25rem),
    radial-gradient(circle at 90% 92%, rgba(108, 205, 218, 0.18), transparent 30rem),
    #f7f5fb;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.demo-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 42px;
}

.demo-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: #6d62c6;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.17em;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4.6vw, 3.5rem);
  line-height: 1;
  letter-spacing: -0.055em;
}

.intro {
  margin: 9px 0 0;
  color: #6f7187;
  font-size: clamp(0.95rem, 2vw, 1.1rem);
}

.live-state {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 116px;
  padding: 10px 14px;
  border: 1px solid rgba(75, 68, 112, 0.13);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 8px 30px rgba(46, 39, 79, 0.06);
  font-size: 0.84rem;
  font-weight: 750;
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #35c789;
  box-shadow: 0 0 0 5px rgba(53, 199, 137, 0.13);
}

.demo-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(310px, 0.8fr);
  gap: 22px;
  align-items: stretch;
}

.stage-card,
.control-card {
  border: 1px solid rgba(67, 61, 100, 0.11);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 22px 70px rgba(54, 46, 91, 0.1);
}

.stage-card {
  position: relative;
  display: grid;
  min-height: 680px;
  overflow: hidden;
  place-items: center;
  isolation: isolate;
}

#stage {
  display: block;
  width: 100%;
  max-height: 710px;
  touch-action: none;
  user-select: none;
}

.stage-hint {
  position: absolute;
  z-index: 3;
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid rgba(61, 55, 96, 0.11);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  color: #65677c;
  backdrop-filter: blur(12px);
  font-size: 0.78rem;
  font-weight: 650;
  pointer-events: none;
}

.mouse-icon {
  position: relative;
  width: 15px;
  height: 20px;
  border: 2px solid #77708f;
  border-radius: 8px;
}

.mouse-icon::after {
  position: absolute;
  top: 3px;
  left: 5px;
  width: 2px;
  height: 5px;
  border-radius: 1px;
  background: #77708f;
  content: "";
}

.control-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.control-section {
  padding: 2px 0 22px;
  border-bottom: 1px solid #eeeaf5;
}

.control-section + .control-section {
  padding-top: 21px;
}

.control-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 13px;
}

.control-heading h2 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.control-heading > span {
  color: #9a98a9;
  font-size: 0.7rem;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.action-grid button,
.expression-row button,
.reset-button {
  border: 1px solid #e6e1ef;
  color: #45465e;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.action-grid button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 9px 12px;
  border-radius: 14px;
  background: #faf9fc;
  font-size: 0.84rem;
  font-weight: 760;
  text-align: left;
}

.action-grid button span {
  display: grid;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: #efebf8;
  color: #7265c8;
  font-size: 0.86rem;
  place-items: center;
}

.action-grid button:hover,
.expression-row button:hover,
.reset-button:hover {
  transform: translateY(-1px);
  border-color: #cfc6e7;
}

.action-grid button[aria-pressed="true"] {
  border-color: #7165c9;
  background: #f1eefc;
  box-shadow: 0 8px 20px rgba(91, 76, 172, 0.11);
  color: #44399a;
}

.action-grid button[aria-pressed="true"] span {
  background: #7165c9;
  color: #ffffff;
}

.expression-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
}

.expression-row button {
  min-height: 49px;
  border-radius: 14px;
  background: #faf9fc;
  font-size: 1.22rem;
}

.expression-row button[aria-pressed="true"] {
  border-color: #ff8868;
  background: #fff1eb;
  box-shadow: inset 0 0 0 1px rgba(255, 117, 87, 0.12);
}

.sliders label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  color: #55576d;
  font-size: 0.78rem;
  font-weight: 690;
}

.sliders label:not(:first-child) {
  margin-top: 17px;
}

.sliders output {
  color: #77718f;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

input[type="range"] {
  width: 100%;
  height: 5px;
  margin: 5px 0;
  border-radius: 99px;
  appearance: none;
  background: linear-gradient(90deg, #7569ce, #ff896c);
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  appearance: none;
  background: #6f64c6;
  box-shadow: 0 2px 8px rgba(42, 35, 83, 0.28);
}

.control-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 21px;
}

.rig-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #65667b;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 680;
}

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

.toggle-track {
  display: inline-flex;
  width: 38px;
  height: 22px;
  padding: 3px;
  border-radius: 999px;
  background: #ddd9e7;
  transition: background 180ms ease;
}

.toggle-track span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 5px rgba(36, 31, 61, 0.22);
  transition: transform 180ms ease;
}

.rig-toggle input:checked + .toggle-track {
  background: #7165c9;
}

.rig-toggle input:checked + .toggle-track span {
  transform: translateX(16px);
}

.reset-button {
  padding: 9px 12px;
  border-radius: 12px;
  background: #ffffff;
  font-size: 0.72rem;
  font-weight: 750;
}

button:focus-visible,
input:focus-visible,
.hand-handle:focus-visible {
  outline: 3px solid rgba(101, 88, 199, 0.32);
  outline-offset: 3px;
}

.arm {
  pointer-events: none;
}

#rig-overlay {
  opacity: 0;
  transition: opacity 180ms ease;
  pointer-events: none;
}

.stage-card.is-rigging #rig-overlay {
  opacity: 1;
}

.bone-line,
.spine {
  fill: none;
  stroke: #55d9cb;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 8 7;
  vector-effect: non-scaling-stroke;
}

.joint {
  fill: #ffffff;
  stroke: #36bcae;
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
}

.hand-handle {
  fill: rgba(255, 255, 255, 0.02);
  stroke: rgba(105, 93, 191, 0.24);
  stroke-width: 2;
  cursor: grab;
  opacity: 0.48;
  transition: opacity 160ms ease, fill 160ms ease, stroke 160ms ease;
  touch-action: none;
  vector-effect: non-scaling-stroke;
}

.hand-handle:hover,
.hand-handle.is-dragging,
.stage-card.is-rigging .hand-handle {
  fill: rgba(255, 255, 255, 0.28);
  stroke: #7569ce;
  opacity: 1;
}

.hand-handle.is-dragging {
  cursor: grabbing;
}

.mouth {
  display: none;
}

#puppet-root[data-expression="happy"] .mouth-happy,
#puppet-root[data-expression="curious"] .mouth-curious,
#puppet-root[data-expression="surprised"] .mouth-surprised,
#puppet-root[data-expression="determined"] .mouth-determined,
#puppet-root[data-speaking="true"] .mouth-talk {
  display: block;
}

#puppet-root[data-speaking="true"] .mouth-happy,
#puppet-root[data-speaking="true"] .mouth-curious,
#puppet-root[data-speaking="true"] .mouth-surprised,
#puppet-root[data-speaking="true"] .mouth-determined {
  display: none;
}

@media (max-width: 840px) {
  .demo-shell {
    width: min(700px, calc(100% - 20px));
    padding-top: 22px;
  }

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

  .stage-card {
    min-height: 0;
  }

  #stage {
    max-height: 68vh;
  }

  .control-card {
    min-height: 500px;
  }
}

@media (max-width: 520px) {
  .demo-header {
    align-items: flex-start;
  }

  .intro {
    max-width: 245px;
  }

  .live-state {
    min-width: 0;
    padding: 9px 11px;
  }

  .stage-hint {
    right: 10px;
    bottom: 10px;
    font-size: 0.68rem;
  }

  .control-card {
    min-height: 480px;
    padding: 19px;
    border-radius: 22px;
  }
}

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