#guide-stage { min-width: 0; width: 100%; }
.cs-demo {
  --studio-frame: #301d35;
  --studio-light: #fffbff;
  box-sizing: border-box;
  width: 100%;
  padding: clamp(10px, 1.38vw, 22px);
  color: var(--studio-light);
  border: 1px solid #92679f;
  border-radius: 23px;
  background: linear-gradient(135deg, #3c2640, #27172d 68%, #35203b);
  box-shadow: 0 2px 4px #31173a17, 0 22px 43px -25px #42284f56, inset 0 1px 0 #dfade747;
  scroll-margin-top: 18px;
  text-align: left;
  container-type: inline-size;
}
.cs-demo *, .cs-demo *::before, .cs-demo *::after { box-sizing: border-box; }
.cs-demo button, .cs-demo a { font-family: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.cs-demo button { margin: 0; border: 0; cursor: pointer; font-size: inherit; line-height: 1.2; }
.cs-demo button:focus-visible, .cs-demo a:focus-visible { outline: 3px solid #edbaff; outline-offset: 3px; }
.cs-demo [hidden] { display: none !important; }
.cs-demo svg { flex: 0 0 auto; width: 17px; height: 17px; }
.cs-demo-scene {
  position: relative;
  isolation: isolate;
  aspect-ratio: 1.76;
  width: 100%;
  overflow: hidden;
  border-radius: 13px;
  background: #c9b697;
}
.cs-demo-room { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 52% 57%; }
.cs-demo-sign {
  position: absolute;
  left: 6%; top: 11%;
  display: flex;
  align-items: center;
  gap: .36em;
  padding: .53em .71em .59em .58em;
  border: 1px solid #fff8e5d9;
  border-radius: .22em;
  background: linear-gradient(125deg, #fff5da 2%, #f6e8cb 68%, #ecdec3);
  box-shadow: 0 1px 1px #916f4a, 1px 4px 7px #4b392c59;
  color: #234437;
  font-family: Georgia, serif;
  font-size: clamp(15px, 3.4cqw, 28px);
  font-weight: 600;
  line-height: .94;
  letter-spacing: -.045em;
}
.cs-demo-sign svg { width: 1.28em; height: 1.28em; }
.cs-demo-sample {
  position: absolute; left: 3%; bottom: 4%;
  display: inline-flex; align-items: center; gap: 6px;
  background: #2a2420e8; color: #fff8e9;
  padding: 5px 8px; border: 1px solid #ffffff30; border-radius: 5px;
  font-size: clamp(10px, 1.75cqw, 12px); font-weight: 600; line-height: 1.1;
}
.cs-demo-sample::before { content: ''; width: 5px; height: 5px; background: #eccf9e; border-radius: 50%; }
.cs-demo-character {
  position: absolute; left: 68%; bottom: 1.8%; transform: translateX(-50%);
  display: block; width: 38%; height: 96%; padding: 0;
  background: transparent; border-radius: 12px;
}
.cs-demo-character::before {
  position: absolute; left: 50%; bottom: -.1%; transform: translateX(-50%); width: 51%; height: 4%;
  content: ''; background: radial-gradient(ellipse closest-side, #44210f70, #7648252e 62%, transparent 100%);
}
.cs-demo-character img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: contain; object-position: center bottom; filter: drop-shadow(1px 3px 2px #40251030); }
.cs-demo-character:focus-visible { outline-offset: -3px !important; outline-color: #452050 !important; }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .cs-demo-character .cs-demo-still { transition: transform .23s cubic-bezier(.22,1,.36,1); transform-origin: 50% 100%; }
  .cs-demo-character:hover .cs-demo-still { transform: rotate(.9deg) scale(1.012); }
}
.cs-demo-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: clamp(10px, 2.4cqw, 19px); }
.cs-demo-switch {
  display: inline-flex; align-items: stretch; min-width: 0; max-width: 100%; padding: 2px;
  border: 1px solid #82628a; border-radius: 13px; background: #29192f;
}
.cs-demo-switch button {
  flex: 1; min-height: 41px; padding: 6px clamp(11px, 3.8cqw, 28px);
  border-radius: 10px; background: transparent; color: #f6e9f8; font-size: clamp(13px, 2.25cqw, 16px); font-weight: 650;
}
.cs-demo-switch button[aria-pressed=true] { background: #ead8f1; color: #2d1933; box-shadow: inset 0 1px 0 #fff6ffb8; }
.cs-demo-switch button:hover:not([aria-pressed=true]) { background: #47304e; }
.cs-demo .cs-demo-trigger {
  display: inline-flex; align-items: center; justify-content: center; gap: .48em; min-height: 45px;
  border: 1px solid #a46ab9; border-radius: 12px; padding: 7px clamp(10px, 3.4cqw, 25px);
  background: #78379a; color: #fff; font-size: clamp(13px, 2.25cqw, 16px); font-weight: 700; white-space: nowrap;
}
.cs-demo-trigger:hover { background: #8d46ad; }
.cs-demo-trigger svg { width: 1.05em; height: 1.05em; }
@container (max-width: 390px) {
  .cs-demo-scene { aspect-ratio: 1.56; border-radius: 10px; }
  .cs-demo-bar { gap: 7px; }
  .cs-demo-switch button { padding-inline: 11px; min-height: 40px; }
  .cs-demo .cs-demo-trigger { min-height: 44px; padding-inline: 11px; }
}
@container (max-width: 275px) {
  .cs-demo-switch button { padding-inline: 7px; }
  .cs-demo .cs-demo-trigger { padding-inline: 7px; }
  .cs-demo-bar { gap: 4px; }
}

/* Moving guide (stageMarkup motion: true). The clip covers the still while it plays,
   and both share the same first and last frame, so the swap is invisible. */
.cs-demo-act { position: absolute; z-index: 1; max-width: none; opacity: 0; pointer-events: none; }
.cs-demo-character.is-acting .cs-demo-act { opacity: 1; }
.cs-demo-character.is-acting .cs-demo-still { visibility: hidden; }
.cs-demo[data-motion] .cs-demo-character { cursor: pointer; }
.cs-demo-say {
  position: absolute; z-index: 3;
  right: calc(100% - var(--guide-left, 60%) + 1.5%);
  top: calc(var(--guide-top, 8%) + 9%);
  max-width: min(46%, 300px); margin: 0; padding: .7em .95em;
  border-radius: 16px 16px 4px 16px;
  background: #fffdf8; color: #251d2c;
  box-shadow: 0 10px 30px -12px #0008, 0 1px 2px #0003;
  font-size: clamp(12.5px, 2.3cqw, 16px); font-weight: 600; line-height: 1.35;
  text-wrap: pretty;
}
.cs-demo-say::after { content: ''; position: absolute; right: -6px; bottom: 9px; border: 7px solid transparent; border-left-color: #fffdf8; border-right: 0; }
.cs-demo-hint { font-weight: 500; opacity: .85; }
@media (prefers-reduced-motion: no-preference) {
  .cs-demo[data-motion] .cs-demo-still { transform-origin: 50% 100%; animation: cs-breathe 5.2s ease-in-out infinite; }
  .cs-demo-say:not([hidden]) { animation: cs-say-in .32s cubic-bezier(.16,1,.3,1) both; }
}
@keyframes cs-breathe { 50% { transform: scale(1.004, 1.009); } }
@keyframes cs-say-in { from { opacity: 0; transform: translateY(6px) scale(.97); } }
@container (max-width: 390px) {
  .cs-demo-say { max-width: 52%; padding: .55em .7em; border-radius: 13px 13px 3px 13px; }
}

.cs-guide-popup {
  position: fixed;
  z-index: 150;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(420px, calc(100vw - 28px));
  --guide-height: 465px;
  height: min(var(--guide-height), calc(100vh - 32px));
  height: min(var(--guide-height), calc(100dvh - 32px));
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid #cfb8d3;
  border-radius: 23px;
  background: #fffbf7;
  color: #321d39;
  box-shadow: 0 22px 80px -20px #30133880, 0 2px 10px #32193630;
}
.cs-guide-popup[hidden], .cs-guide-popup [hidden] { display: none !important; }
.cs-guide-popup[data-size="gallery"] { --guide-height: 655px; }
.cs-guide-popup[data-size="conversation"] { --guide-height: 570px; }
.cs-guide-popup iframe { display: block; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; }
.cs-guide-loading {
  position: absolute; z-index: 1; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 20px; background: linear-gradient(145deg, #fffbf7, #f6ecf5); text-align: center;
}
.cs-guide-loading p { margin: 0; font-size: 1.13rem; font-weight: 600; line-height: 1.5; color: #432849; }
.cs-guide-popup button, .cs-guide-popup a { color: #5a2c72; font: inherit; touch-action: manipulation; }
.cs-guide-dismiss, .cs-guide-retry { cursor: pointer; background: #fffafa; border: 1px solid #d6c7d8; }
.cs-guide-dismiss { position: absolute; top: 10px; right: 10px; display: grid; place-items: center; border-radius: 50%; width: 44px; height: 44px; }
.cs-guide-dismiss svg { width: 20px; height: 20px; }
.cs-guide-retry { min-height: 44px; padding: 5px 16px; border-radius: 9px; }
.cs-guide-fallback { display: inline-flex; align-items: center; min-height: 44px; }
.cs-guide-popup :focus-visible { outline: 3px solid #7c4592; outline-offset: 2px; }
.cs-guide-loading[data-pending]::before { content: ''; width: 24px; height: 24px; border: 2px solid #ddc5e3; border-top-color: #70368a; border-radius: 50%; }
@media (prefers-reduced-motion: no-preference) { .cs-guide-loading[data-pending]::before { animation: cs-guide-load 1s linear infinite; } }
@keyframes cs-guide-load { to { transform: rotate(360deg); } }
@media (max-width: 600px) {
  .cs-guide-popup {
    right: max(6px, env(safe-area-inset-right));
    bottom: max(6px, env(safe-area-inset-bottom));
    width: calc(100% - max(6px, env(safe-area-inset-right)) - max(6px, env(safe-area-inset-left)));
    height: min(var(--guide-height), calc(100dvh - max(8px, env(safe-area-inset-top)) - max(8px, env(safe-area-inset-bottom))));
    border-radius: 18px;
  }
}
