:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0c0d12;
  color: #f5f6fb;
  --panel: rgba(24, 25, 34, .82);
  --panel-2: rgba(17, 18, 25, .88);
  --line: rgba(255,255,255,.09);
  --muted: #9da1b2;
  --accent: #b9a7ff;
  --accent-2: #ffb9de;
  --shadow: 0 24px 80px rgba(0,0,0,.38);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 8%, rgba(116,90,255,.17), transparent 28%),
    radial-gradient(circle at 88% 28%, rgba(255,93,180,.12), transparent 30%),
    linear-gradient(180deg, #11131a 0%, #090a0f 100%);
}

button, input { font: inherit; }

button { color: inherit; }

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

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .15em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: .95;
  letter-spacing: -.045em;
}

.sub {
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 15px;
  cursor: pointer;
  font-weight: 750;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
  user-select: none;
}

.btn:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.18); }
.btn:active { transform: translateY(0); }

.btn.primary {
  color: #13111a;
  border-color: transparent;
  background: linear-gradient(135deg, #c9bbff, #ffc2e3);
}

.btn.secondary { background: rgba(255,255,255,.055); }
.btn.wide { width: 100%; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(290px, .72fr);
  gap: 18px;
}

.preview-card,
.control-card {
  border: 1px solid var(--line);
  border-radius: 25px;
  background: var(--panel);
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.preview-card { padding: 16px; }
.control-card { padding: 20px; }

.stage-header,
.now-row,
.section-title,
.mini-info > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stage-header {
  min-height: 34px;
  padding: 0 4px 10px;
  color: #e7e8ef;
  font-size: 13px;
  font-weight: 720;
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 999px;
  background: #8ff1bd;
  box-shadow: 0 0 18px rgba(143,241,189,.8);
}

.badge {
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,.055);
  color: var(--muted);
  font-size: 11px;
}

.stage {
  position: relative;
  display: grid;
  place-items: end center;
  min-height: 570px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.075);
  border-radius: 20px;
  background:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
    radial-gradient(circle at 50% 32%, rgba(189,173,255,.19), transparent 35%),
    linear-gradient(180deg, #181a24 0%, #0d0e15 100%);
  background-size: 28px 28px, 28px 28px, auto, auto;
}

.ambient {
  position: absolute;
  border-radius: 999px;
  filter: blur(44px);
  opacity: .42;
  pointer-events: none;
}

.ambient-a {
  width: 200px;
  height: 200px;
  left: 11%;
  top: 16%;
  background: #755cff;
}

.ambient-b {
  width: 170px;
  height: 170px;
  right: 12%;
  bottom: 18%;
  background: #ff70be;
}

.avatar-wrap {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: end center;
  width: min(76%, 470px);
  height: 500px;
  transform-origin: 50% 100%;
  transition: filter .2s ease;
}

.avatar-wrap.motion-on { animation: idleBob 2.4s ease-in-out infinite; }
.avatar-wrap.effect-happy { animation: happyJump .52s cubic-bezier(.2,.8,.2,1); }
.avatar-wrap.effect-surprised { animation: surprisePop .42s cubic-bezier(.2,.8,.2,1); }
.avatar-wrap.effect-angry { animation: angryShake .34s linear 2; }
.avatar-wrap.effect-thinking { animation: thinkTilt 1.3s ease-in-out; }
.avatar-wrap.effect-sad { animation: sadDip .7s ease; }

#avatar {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center bottom;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 24px 26px rgba(0,0,0,.28));
}

.ground-shadow {
  position: absolute;
  z-index: 1;
  bottom: 18px;
  width: 44%;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,.34);
  filter: blur(11px);
}

.speech-chip {
  position: absolute;
  z-index: 3;
  top: 18px;
  right: 18px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  background: rgba(8,9,13,.5);
  color: #d9dbea;
  font-size: 12px;
  backdrop-filter: blur(12px);
}

.now-row { padding: 15px 5px 1px; }

.now-row .label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .18em;
}

#currentState {
  font-size: 19px;
  letter-spacing: -.02em;
}

.now-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.toggle input { accent-color: #b6a2ff; }

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255,255,255,.05);
  cursor: pointer;
}

.section-title { gap: 12px; margin-bottom: 13px; }
.section-title h2 { margin: 0; font-size: 15px; }
.section-title span { color: var(--muted); font-size: 10px; }

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

.state-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 45px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,.04);
  color: #dedfea;
  cursor: pointer;
  text-align: left;
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.state-btn:hover { transform: translateY(-1px); background: rgba(255,255,255,.07); }
.state-btn.active { border-color: rgba(191,174,255,.5); background: rgba(173,147,255,.13); }

.state-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 9px;
  background: rgba(255,255,255,.07);
  font-size: 14px;
}

.state-label { font-size: 12px; font-weight: 760; }

.divider-section {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.drop-zone {
  display: grid;
  place-items: center;
  min-height: 132px;
  padding: 18px;
  border: 1px dashed rgba(255,255,255,.17);
  border-radius: 16px;
  background: rgba(255,255,255,.025);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease;
}

.drop-zone.dragover {
  border-color: rgba(191,174,255,.65);
  background: rgba(172,147,255,.09);
}

.drop-zone strong { margin-top: 5px; color: #ececf3; font-size: 12px; }
.drop-zone span { margin-top: 3px; font-size: 10px; }

.drop-icon {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border-radius: 12px;
  background: rgba(255,255,255,.06);
  color: var(--accent);
  font-size: 20px;
}

.mini-info {
  margin-top: 11px;
  padding: 9px 12px;
  border-radius: 13px;
  background: rgba(0,0,0,.15);
}

.mini-info > div {
  min-height: 25px;
  gap: 12px;
  font-size: 10px;
}

.mini-info span { color: var(--muted); }
.mini-info b { color: #dfe0ea; font-weight: 650; }

.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 4px 0;
  color: #737788;
  font-size: 10px;
}

@keyframes idleBob {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes happyJump {
  0%,100% { transform: translateY(0) scale(1); }
  45% { transform: translateY(-13px) scale(1.02); }
}

@keyframes surprisePop {
  0%,100% { transform: scale(1); }
  45% { transform: scale(1.065); }
}

@keyframes angryShake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@keyframes thinkTilt {
  0%,100% { transform: rotate(0deg); }
  45% { transform: rotate(-2.5deg); }
}

@keyframes sadDip {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(7px); }
}

@media (max-width: 840px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .top-actions { justify-content: flex-start; }
  .workspace { grid-template-columns: 1fr; }
  .stage { min-height: 480px; }
  .avatar-wrap { height: 420px; }
}

@media (max-width: 520px) {
  .app-shell { width: min(100% - 20px, 1180px); padding-top: 22px; }
  .preview-card, .control-card { border-radius: 20px; }
  .stage { min-height: 430px; }
  .avatar-wrap { width: 88%; height: 380px; }
  .footer { flex-direction: column; }
}
