/* AvatarStudio v4 — Character-Editor und DOM-Rigs.
   Die Klassennamen aus v3 bleiben absichtlich unterstützt, damit Profil,
   allgemeiner Join und Quiz-Lobby während der Migration stabil bleiben. */

.avstudio {
  --av-violet: #6548b8;
  --av-violet-deep: #382065;
  --av-violet-soft: #eee9fb;
  --av-aqua: #2db6bd;
  --av-coral: #ff6c79;
  --av-sun: #ffd45a;
  --av-ink: #272235;
  --av-muted: #6b6578;
  --av-line: #ddd8e6;
  --av-paper: #fff;
  --av-soft: #f6f4f9;
  --av-focus: #ffcb33;
  --av-danger: #b32f45;
  --av-success: #13795b;
  --av-stage-shadow: rgba(27, 12, 57, .34);
  width: 100%;
  min-width: 0;
  color: var(--av-ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}

.avstudio *,
.avstudio *::before,
.avstudio *::after { box-sizing: border-box; }

.avstudio button,
.avstudio select,
.avstudio input { font: inherit; }

.avstudio button { touch-action: manipulation; }

.avstudio-svg {
  display: block;
  max-width: 100%;
  max-height: 100%;
  overflow: visible;
}

/* ---------- Editor-Rahmen ---------- */

.avstudio-shell,
.avstudio-editor {
  position: relative;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #d5cce6;
  border-radius: 26px;
  background: var(--av-paper);
  box-shadow: 0 18px 48px rgba(43, 25, 72, .2);
}

.avstudio-stage {
  position: relative;
  min-height: 304px;
  padding: 48px 24px 22px;
  display: grid;
  justify-items: center;
  align-content: center;
  overflow: hidden;
  isolation: isolate;
  color: #fff;
  background:
    radial-gradient(circle at 14% 20%, rgba(255, 212, 90, .3) 0 7%, transparent 7.6%),
    radial-gradient(circle at 89% 75%, rgba(45, 182, 189, .38) 0 11%, transparent 11.6%),
    linear-gradient(145deg, var(--av-violet) 0%, #5140aa 54%, #256f8a 100%);
}

.avstudio-stage::before,
.avstudio-stage::after {
  content: "";
  position: absolute;
  z-index: -2;
  border: 2px solid rgba(255, 255, 255, .16);
  pointer-events: none;
}

.avstudio-stage::before {
  width: 250px;
  height: 250px;
  left: -120px;
  bottom: -126px;
  border-radius: 46% 54% 62% 38%;
  transform: rotate(24deg);
}

.avstudio-stage::after {
  width: 180px;
  height: 180px;
  right: -82px;
  top: -96px;
  border-radius: 58% 42% 36% 64%;
  transform: rotate(-18deg);
}

.avstudio-stage__title,
.avstudio-stage__badge {
  position: absolute;
  z-index: 4;
  top: 16px;
  left: 18px;
  min-height: 30px;
  padding: 6px 11px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, .26);
  border-radius: 999px;
  color: #fff;
  background: rgba(20, 9, 42, .3);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .055em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.avstudio-preview,
.avstudio-stage__preview {
  position: relative;
  width: 226px;
  height: 226px;
  display: grid;
  place-items: center;
  overflow: visible;
  border: 4px solid rgba(255, 255, 255, .96);
  border-radius: 30px;
  background:
    radial-gradient(circle at 32% 23%, #fff 0 9%, transparent 9.5%),
    linear-gradient(145deg, #fff 0%, #f3effb 58%, #d9d0ea 100%);
  box-shadow:
    0 16px 34px var(--av-stage-shadow),
    0 0 0 7px rgba(255, 255, 255, .14);
}

.avstudio-preview--portrait { border-radius: 50%; }
.avstudio-preview--rig { border-radius: 30px; }

.avstudio-preview::after,
.avstudio-stage__preview::after {
  content: "";
  position: absolute;
  z-index: 0;
  left: 17%;
  right: 17%;
  bottom: 8%;
  height: 8%;
  border-radius: 50%;
  background: rgba(44, 32, 67, .15);
  filter: blur(3px);
  pointer-events: none;
}

.avstudio-preview > *,
.avstudio-stage__preview > * { position: relative; z-index: 1; }

.avstudio-preview .avstudio-svg,
.avstudio-preview .avstudio-rig,
.avstudio-stage__preview .avstudio-svg,
.avstudio-stage__preview .avstudio-rig {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 6px 6px rgba(31, 18, 52, .2));
}

.avstudio-preview__name,
.avstudio-stage__name {
  max-width: min(100%, 32rem);
  min-height: 1.5em;
  margin-top: 12px;
  overflow: hidden;
  color: #fff;
  font-size: 15px;
  font-weight: 850;
  letter-spacing: .01em;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 2px 8px rgba(26, 10, 52, .38);
}

.avstudio-random,
.avstudio-edit,
.avstudio-stage__action {
  position: absolute;
  z-index: 5;
  right: 15px;
  top: 13px;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, .58);
  border-radius: 999px;
  color: #fff;
  background: rgba(18, 8, 37, .3);
  font-weight: 850;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.avstudio-random:hover,
.avstudio-edit:hover,
.avstudio-stage__action:hover { background: rgba(18, 8, 37, .48); }

.avstudio-edit { display: none; top: auto; bottom: 15px; }

/* ---------- Tabs und Arbeitsfläche ---------- */

.avstudio-workbench { min-width: 0; background: var(--av-paper); }

.avstudio-tabs {
  position: relative;
  z-index: 4;
  min-width: 0;
  display: flex;
  overflow-x: auto;
  padding: 8px 10px 0;
  border-bottom: 1px solid var(--av-line);
  background: rgba(255, 255, 255, .97);
  scrollbar-width: thin;
  scrollbar-color: #c4b9d8 transparent;
}

.avstudio-tab {
  position: relative;
  flex: 1 0 112px;
  min-width: 112px;
  min-height: 50px;
  padding: 8px 13px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 10px 10px 0 0;
  color: var(--av-muted);
  background: transparent;
  font-weight: 850;
  cursor: pointer;
}

.avstudio-tab:hover { color: var(--av-violet-deep); background: #f8f6fc; }
.avstudio-tab[aria-selected="true"],
.avstudio-tab.is-active { color: var(--av-violet-deep); }

.avstudio-tab[aria-selected="true"]::after,
.avstudio-tab.is-active::after {
  content: "";
  position: absolute;
  left: 15%;
  right: 15%;
  bottom: -1px;
  height: 4px;
  border-radius: 999px 999px 0 0;
  background: linear-gradient(90deg, var(--av-violet), var(--av-aqua));
}

.avstudio-panel {
  min-width: 0;
  max-height: min(48vh, 440px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 6px 15px 12px;
  background: var(--av-paper);
  scrollbar-width: thin;
  scrollbar-color: #bfb2d6 transparent;
}

.avstudio-group {
  min-width: 0;
  margin: 13px 0 19px;
  padding: 0;
  border: 0;
}

.avstudio-label,
.avstudio-group__title {
  display: flex;
  min-height: 24px;
  margin: 0 0 8px;
  align-items: center;
  gap: 7px;
  color: var(--av-ink);
  font-size: 13px;
  font-weight: 850;
}

.avstudio-group__hint { margin-left: auto; color: var(--av-muted); font-size: 11px; font-weight: 700; }

/* Die Reihen bleiben horizontal: So sehen Join und Profil denselben Editor,
   ohne dass 20 Characters den gesamten Bildschirm füllen. */
.avstudio-row,
.avstudio-options,
.avstudio-carousel {
  min-width: 0;
  display: flex;
  gap: 9px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 5px 4px 9px;
  scroll-padding-inline: 4px;
  scroll-snap-type: inline proximity;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  scrollbar-color: #c2b5d7 transparent;
}

.avstudio-row::-webkit-scrollbar,
.avstudio-options::-webkit-scrollbar,
.avstudio-carousel::-webkit-scrollbar { height: 7px; }

.avstudio-row::-webkit-scrollbar-thumb,
.avstudio-options::-webkit-scrollbar-thumb,
.avstudio-carousel::-webkit-scrollbar-thumb { border-radius: 99px; background: #c2b5d7; }

.avstudio-opt,
.avstudio-card,
.avstudio-character-card,
.avstudio-prop-card {
  position: relative;
  flex: 0 0 104px;
  min-width: 104px;
  min-height: 116px;
  padding: 7px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  scroll-snap-align: start;
  border: 2px solid var(--av-line);
  border-radius: 18px;
  color: var(--av-ink);
  background: #fff;
  box-shadow: 0 2px 0 rgba(41, 28, 62, .04);
  font: inherit;
  cursor: pointer;
}

.avstudio-opt:hover,
.avstudio-card:hover,
.avstudio-character-card:hover,
.avstudio-prop-card:hover {
  border-color: #a991d1;
  background: #fcfbfe;
  transform: translateY(-1px);
}

.avstudio-opt[aria-pressed="true"],
.avstudio-opt[aria-selected="true"],
.avstudio-card[aria-pressed="true"],
.avstudio-character-card[aria-pressed="true"],
.avstudio-prop-card[aria-pressed="true"],
.avstudio-opt.is-selected,
.avstudio-card.is-selected {
  border-color: var(--av-violet);
  background: var(--av-violet-soft);
  box-shadow: 0 0 0 2px #fff, 0 0 0 5px rgba(101, 72, 184, .28);
}

.avstudio-opt[aria-pressed="true"]::after,
.avstudio-opt[aria-selected="true"]::after,
.avstudio-card[aria-pressed="true"]::after,
.avstudio-character-card[aria-pressed="true"]::after,
.avstudio-prop-card[aria-pressed="true"]::after,
.avstudio-opt.is-selected::after,
.avstudio-card.is-selected::after {
  content: "✓";
  position: absolute;
  z-index: 4;
  top: 5px;
  right: 5px;
  width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: var(--av-violet);
  box-shadow: 0 2px 7px rgba(42, 22, 75, .24);
  font-size: 12px;
  font-weight: 900;
}

.avstudio-opt__visual,
.avstudio-card__visual,
.avstudio-character-card__visual,
.avstudio-prop-card__visual {
  width: 78px;
  height: 78px;
  flex: 0 0 78px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 16px;
  background:
    radial-gradient(circle at 34% 25%, #fff 0 10%, transparent 10.5%),
    linear-gradient(145deg, #fbfafe, #ece7f5);
}

.avstudio-opt--character,
.avstudio-character-card { flex-basis: 116px; min-width: 116px; min-height: 136px; }

.avstudio-opt--character .avstudio-opt__visual,
.avstudio-character-card__visual { width: 90px; height: 90px; flex-basis: 90px; }

.avstudio-opt__visual > *,
.avstudio-card__visual > *,
.avstudio-character-card__visual > *,
.avstudio-prop-card__visual > * {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.avstudio-opt__visual > img,
.avstudio-card__visual > img,
.avstudio-character-card__visual > img,
.avstudio-prop-card__visual > img { width: 100%; height: 100%; object-fit: contain; }

.avstudio-opt__label,
.avstudio-card__label,
.avstudio-character-card__label,
.avstudio-prop-card__label {
  width: 100%;
  min-height: 1.25em;
  overflow: hidden;
  color: var(--av-muted);
  font-size: 11px;
  font-weight: 780;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avstudio-opt[aria-pressed="true"] .avstudio-opt__label,
.avstudio-opt[aria-selected="true"] .avstudio-opt__label,
.avstudio-card[aria-pressed="true"] .avstudio-card__label,
.avstudio-opt.is-selected .avstudio-opt__label { color: var(--av-violet-deep); }

.avstudio-opt__none,
.avstudio-expression-icon {
  color: var(--av-violet-deep);
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
}

.avstudio-expression-icon { font-family: Georgia, "Times New Roman", serif; }

.avstudio-opt[disabled],
.avstudio-card[disabled],
.avstudio-opt--locked,
.avstudio-card--locked {
  border-style: dashed;
  color: #8e8798;
  background: #f3f1f6;
  cursor: not-allowed;
  filter: grayscale(.65);
  opacity: .72;
  transform: none;
}

.avstudio-lockbadge,
.avstudio-lock-badge {
  position: absolute;
  z-index: 4;
  top: 5px;
  left: 5px;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 1px solid var(--av-line);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 7px rgba(33, 20, 51, .14);
  font-size: 12px;
}

.avstudio-row--swatches { flex-wrap: wrap; overflow: visible; }

.avstudio-swatch {
  flex: 0 0 48px;
  min-width: 48px;
  width: 48px;
  min-height: 48px;
  height: 48px;
  padding: 4px;
  border-radius: 50%;
}

.avstudio-swatch__color {
  width: 100%;
  height: 100%;
  display: block;
  border: 1px solid rgba(0, 0, 0, .14);
  border-radius: inherit;
}

/* ---------- Status, Fortschritt und Abschluss ---------- */

.avstudio-status,
.avstudio-hint,
.avstudio-progress {
  margin: 0;
  padding: 9px 14px;
  border-top: 1px solid var(--av-line);
  color: var(--av-muted);
  background: #fbfafc;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.avstudio-status:empty,
.avstudio-hint:empty,
.avstudio-progress:empty { display: none; }

.avstudio-hint { display: none; margin: 9px 0 0; border: 1px solid #ecd49a; border-radius: 11px; color: #6d4800; background: #fff7dc; text-align: left; }
.avstudio-hint--show { display: block; }
.avstudio-status[data-state="success"], .avstudio-status--success { color: #0d654a; background: #e9f8f1; }
.avstudio-status[data-state="warning"], .avstudio-status--warning { color: #704700; background: #fff6d8; }
.avstudio-status[data-state="error"], .avstudio-status--error { color: #8e2335; background: #ffedf0; }

.avstudio-footer {
  position: sticky;
  z-index: 6;
  bottom: 0;
  display: flex;
  justify-content: center;
  padding: 10px 15px 14px;
  border-top: 1px solid var(--av-line);
  background: linear-gradient(180deg, rgba(255, 255, 255, .93), #fff 28%);
  backdrop-filter: blur(8px);
}

.avstudio-footer:empty { display: none; }

.avstudio-done,
.avstudio-primary {
  width: min(100%, 360px);
  min-height: 48px;
  padding: 10px 18px;
  border: 0;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(135deg, var(--av-violet), #4b3ba3);
  box-shadow: 0 4px 0 var(--av-violet-deep);
  font-size: 16px;
  font-weight: 850;
  cursor: pointer;
}

.avstudio-done:hover,
.avstudio-primary:hover { filter: brightness(1.07); }

.avstudio-done:active,
.avstudio-primary:active { translate: 0 2px; box-shadow: 0 2px 0 var(--av-violet-deep); }

.avstudio-shell.is-complete .avstudio-workbench,
.avstudio-editor.is-complete .avstudio-workbench { display: none; }
.avstudio-shell.is-complete .avstudio-edit,
.avstudio-editor.is-complete .avstudio-edit { display: inline-flex; }
.avstudio-shell.is-complete .avstudio-random,
.avstudio-editor.is-complete .avstudio-random { display: none; }
.avstudio-shell.is-complete .avstudio-stage,
.avstudio-editor.is-complete .avstudio-stage { min-height: 320px; }

/* ---------- DOM-Rig ---------- */

.avstudio-rig {
  --av-rig-duration: 900ms;
  --av-pivot-x: 50%;
  --av-pivot-y: 90%;
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: visible;
  isolation: isolate;
  contain: layout style;
  transform-origin: var(--av-pivot-x) var(--av-pivot-y);
}

.avstudio-rig__motion {
  position: absolute;
  inset: 0;
  transform-origin: var(--av-pivot-x) var(--av-pivot-y);
  will-change: transform;
}

.avstudio-rig__figure,
.avstudio-figure,
.avstudio-rig__props,
.avstudio-props,
.avstudio-rig__layer,
.avstudio-rig-part,
.avstudio-rig__part,
.avstudio-prop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  pointer-events: none;
}

.avstudio-rig__figure,
.avstudio-figure { z-index: 20; }
.avstudio-rig__props,
.avstudio-props { z-index: 30; }
.avstudio-rig__shadow,
.avstudio-rig__layer--shadow { z-index: 2; }
.avstudio-rig__back,
.avstudio-rig__layer--back,
.avstudio-prop--back { z-index: 10; }
.avstudio-rig__body,
.avstudio-rig__layer--body { z-index: 20; }
.avstudio-rig__front,
.avstudio-rig__layer--front,
.avstudio-prop--front { z-index: 40; }
.avstudio-rig__effect,
.avstudio-rig__layer--effect,
.avstudio-prop--effect { z-index: 50; }
.avstudio-rig__debug,
.avstudio-rig__anchors { z-index: 90; }

.avstudio-rig img,
.avstudio-rig svg,
.avstudio-rig canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  overflow: visible;
  user-select: none;
  -webkit-user-drag: none;
}

.avstudio-rig__part,
.avstudio-rig-part,
.avstudio-prop {
  transform-origin: var(--av-part-pivot-x, 50%) var(--av-part-pivot-y, 50%);
  will-change: transform;
}

.avstudio-rig[data-facing="left"] .avstudio-rig__motion,
.avstudio-rig.is-facing-left .avstudio-rig__motion { scale: -1 1; }

.avstudio-rig.is-paused .avstudio-rig__motion,
.avstudio-rig[aria-busy="true"] .avstudio-rig__motion { animation-play-state: paused !important; }

/* Actions bewegen nur den Motion-Wrapper. Bone- und Prop-Transforms des
   Renderers bleiben dadurch unberührt. */
.avstudio-rig[data-action="idle"] .avstudio-rig__motion,
.avstudio-rig--idle .avstudio-rig__motion,
.avstudio-rig.is-idle .avstudio-rig__motion { animation: avstudio-rig-idle 2.5s ease-in-out infinite; }

.avstudio-rig[data-action="run"] .avstudio-rig__motion,
.avstudio-rig--run .avstudio-rig__motion,
.avstudio-rig.is-run .avstudio-rig__motion { animation: avstudio-rig-run 360ms ease-in-out infinite; }

.avstudio-rig[data-action="jump"] .avstudio-rig__motion,
.avstudio-rig--jump .avstudio-rig__motion,
.avstudio-rig.is-jump .avstudio-rig__motion { animation: avstudio-rig-jump 820ms cubic-bezier(.3, .05, .25, 1) infinite; }

.avstudio-rig[data-action="duck"] .avstudio-rig__motion,
.avstudio-rig--duck .avstudio-rig__motion,
.avstudio-rig.is-duck .avstudio-rig__motion { animation: avstudio-rig-duck 1.1s ease-in-out infinite; }

.avstudio-rig[data-action="cheer"] .avstudio-rig__motion,
.avstudio-rig--cheer .avstudio-rig__motion,
.avstudio-rig.is-cheer .avstudio-rig__motion { animation: avstudio-rig-cheer 720ms cubic-bezier(.2, .75, .25, 1) infinite; }

.avstudio-rig[data-action="hurt"] .avstudio-rig__motion,
.avstudio-rig--hurt .avstudio-rig__motion,
.avstudio-rig.is-hurt .avstudio-rig__motion { animation: avstudio-rig-hurt 520ms ease-out infinite; filter: saturate(.72); }

@keyframes avstudio-rig-idle {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-2.2%) scale(1.012, .988); }
}

@keyframes avstudio-rig-run {
  0%, 100% { transform: translateY(0) rotate(-1.5deg) scale(1.015, .985); }
  50% { transform: translateY(-4%) rotate(1.5deg) scale(.985, 1.015); }
}

@keyframes avstudio-rig-jump {
  0%, 100% { transform: translateY(0) scale(1.04, .96); }
  20% { transform: translateY(2%) scale(1.08, .92); }
  55% { transform: translateY(-15%) scale(.97, 1.03); }
  75% { transform: translateY(-8%) scale(1); }
}

@keyframes avstudio-rig-duck {
  0%, 100% { transform: translateY(0) scale(1); }
  45%, 65% { transform: translateY(8%) scale(1.08, .78); }
}

@keyframes avstudio-rig-cheer {
  0%, 100% { transform: translateY(0) rotate(0) scale(1); }
  32% { transform: translateY(-9%) rotate(-2deg) scale(.97, 1.04); }
  64% { transform: translateY(-5%) rotate(2deg) scale(1.02, .98); }
}

@keyframes avstudio-rig-hurt {
  0%, 100% { transform: translateX(0) rotate(0) scale(1); }
  24% { transform: translateX(-4%) rotate(-3deg) scale(.98); }
  52% { transform: translateX(3%) rotate(2deg) scale(.98); }
  76% { transform: translateX(-2%) rotate(-1deg) scale(.99); }
}

/* ---------- Fokus und Screenreader ---------- */

.avstudio :is(button, [role="button"], [role="tab"], select, input):focus-visible {
  outline: 3px solid var(--av-focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(45, 35, 68, .3);
}

.avstudio-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ---------- Quiz-Join und kleine Viewports ---------- */

.kq-join__avatar .avstudio-shell,
.qz-player-lobby__editor .avstudio-shell,
.kq-join__avatar .avstudio-editor,
.qz-player-lobby__editor .avstudio-editor { max-width: 100%; }

.kq-join__avatar .avstudio-stage,
.qz-player-lobby__editor .avstudio-stage { min-height: 270px; }

.kq-join__avatar .avstudio-panel,
.qz-player-lobby__editor .avstudio-panel { max-height: min(42vh, 360px); }

@media (max-width: 600px) {
  .avstudio-shell,
  .avstudio-editor { border-radius: 20px; }

  .avstudio-stage {
    min-height: 226px;
    padding: 42px 12px 15px;
  }

  .avstudio-preview,
  .avstudio-stage__preview { width: 168px; height: 168px; border-width: 3px; border-radius: 24px; }
  .avstudio-preview--portrait { border-radius: 50%; }
  .avstudio-stage__title,
  .avstudio-stage__badge { top: 11px; left: 11px; }
  .avstudio-random,
  .avstudio-edit,
  .avstudio-stage__action { top: 9px; right: 9px; padding-inline: 10px; }
  .avstudio-edit { top: auto; bottom: 10px; }

  .avstudio-tabs { padding-inline: 5px; }
  .avstudio-tab { flex-basis: 104px; min-width: 104px; min-height: 48px; padding-inline: 9px; font-size: 13px; }
  .avstudio-panel { max-height: min(44vh, 370px); padding-inline: 8px; }
  .avstudio-row,
  .avstudio-options,
  .avstudio-carousel { gap: 7px; margin-inline: -2px; padding-inline: 3px; }

  .avstudio-opt,
  .avstudio-card,
  .avstudio-character-card,
  .avstudio-prop-card { flex-basis: 92px; min-width: 92px; min-height: 106px; border-radius: 15px; }

  .avstudio-opt__visual,
  .avstudio-card__visual,
  .avstudio-character-card__visual,
  .avstudio-prop-card__visual { width: 68px; height: 68px; flex-basis: 68px; border-radius: 14px; }

  .avstudio-opt--character,
  .avstudio-character-card { flex-basis: 100px; min-width: 100px; min-height: 120px; }
  .avstudio-opt--character .avstudio-opt__visual,
  .avstudio-character-card__visual { width: 78px; height: 78px; flex-basis: 78px; }
  .avstudio-opt__label,
  .avstudio-card__label,
  .avstudio-character-card__label,
  .avstudio-prop-card__label { font-size: 10px; }

  .kq-join__avatar .avstudio-stage,
  .qz-player-lobby__editor .avstudio-stage { min-height: 218px; }
  .kq-join__avatar .avstudio-panel,
  .qz-player-lobby__editor .avstudio-panel { max-height: min(40vh, 330px); }
  .avstudio-shell.is-complete .avstudio-stage,
  .avstudio-editor.is-complete .avstudio-stage { min-height: 242px; }
}

@media (max-width: 360px) {
  .avstudio-preview,
  .avstudio-stage__preview { width: 154px; height: 154px; }
  .avstudio-stage__title,
  .avstudio-stage__badge { max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .avstudio-random,
  .avstudio-edit,
  .avstudio-stage__action { max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (prefers-reduced-motion: no-preference) {
  .avstudio-opt,
  .avstudio-card,
  .avstudio-character-card,
  .avstudio-prop-card { transition: transform .11s ease, border-color .16s ease, background-color .16s ease, box-shadow .16s ease; }

  .avstudio-opt:active,
  .avstudio-card:active,
  .avstudio-character-card:active,
  .avstudio-prop-card:active { transform: scale(.97); }

  .avstudio-preview > .avstudio-svg:not(.avstudio-rig),
  .avstudio-stage__preview > .avstudio-svg:not(.avstudio-rig) { animation: avstudio-preview-bob 2.8s ease-in-out infinite; }

  .avstudio-opt--shake { animation: avstudio-card-shake .26s; }
}

@keyframes avstudio-preview-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes avstudio-card-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

@media (prefers-reduced-motion: reduce) {
  .avstudio *,
  .avstudio *::before,
  .avstudio *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}

.avstudio-reduced-motion *,
.avstudio-reduced-motion *::before,
.avstudio-reduced-motion *::after,
.avstudio[data-reduced-motion="true"] *,
.avstudio[data-reduced-motion="true"] *::before,
.avstudio[data-reduced-motion="true"] *::after,
.avstudio-rig[data-reduced-motion="true"] *,
.avstudio-rig[data-reduced-motion="true"] *::before,
.avstudio-rig[data-reduced-motion="true"] *::after {
  animation: none !important;
  transition: none !important;
}
