:root {
  color-scheme: light;
  --bg: #fcf8fc;
  --panel: #ffffff;
  --line: #ece7ef;
  --line-strong: #ded5e8;
  --ink: #17141d;
  --muted: #80778c;
  --soft: #f7f1fa;
  --soft-2: #f3eef7;
  --accent: #9b4bed;
  --accent-strong: #7436d7;
  --accent-soft: #efe0ff;
  --teal: #24b5aa;
  --rose: #ea6f9d;
  --shadow: 0 18px 50px rgba(42, 26, 58, 0.1);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 1120px;
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

.topbar {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 15px 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 251, 255, 0.92);
  backdrop-filter: blur(18px);
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background:
    radial-gradient(circle at 64% 18%, rgba(255, 255, 255, 0.84), transparent 17px),
    linear-gradient(135deg, #8f5cff, #e468b4 58%, #42b8d2);
  box-shadow: 0 7px 18px rgba(143, 92, 255, 0.26);
  color: #ffffff;
}

.spark {
  font-size: 16px;
  line-height: 1;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-copy strong {
  font-size: 12px;
  font-weight: 700;
}

.brand-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.admin-badge {
  margin-left: auto;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 700;
}

.workspace {
  height: calc(100vh - 44px);
  display: grid;
  grid-template-columns: 253px minmax(630px, 1fr) 350px;
}

.left-panel,
.right-panel {
  background: rgba(255, 255, 255, 0.78);
}

.left-panel {
  border-right: 1px solid var(--line);
  padding: 16px 11px 20px;
  overflow-y: auto;
}

.panel-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.panel-title-row h1,
.comments-header strong {
  margin: 0;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 800;
}

.panel-title-row p,
.comments-header span,
.studio-head span,
.field small {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.avatar-list {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.avatar-card {
  position: relative;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #ffffff;
  text-align: left;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.avatar-card:hover {
  transform: translateY(-1px);
  border-color: rgba(155, 75, 237, 0.42);
  box-shadow: 0 10px 24px rgba(70, 45, 96, 0.08);
}

.avatar-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(155, 75, 237, 0.09);
}

.avatar-select {
  width: 100%;
  display: block;
  padding: 12px 12px 9px;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.avatar-thumb {
  width: 100%;
  aspect-ratio: 1.78;
  display: block;
  border-radius: 7px;
  object-fit: cover;
  background: #ddd8e5;
}

.avatar-card strong {
  display: block;
  margin-top: 11px;
  font-size: 13px;
}

.avatar-card .meta-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 10px;
  min-width: 0;
}

.status-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(36, 181, 170, 0.12);
}

.avatar-card-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 12px 12px;
}

.detail-button {
  height: 27px;
  padding: 0 10px;
  border: 1px solid #eadbf6;
  border-radius: 7px;
  background: #fbf7ff;
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.detail-button:hover {
  background: var(--accent-soft);
}

.stage-panel {
  min-width: 0;
  display: grid;
  place-items: center;
  background: #fcf8fc;
}

.player-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.avatar-video {
  position: relative;
  width: min(432px, 50vw);
  height: min(576px, calc(100vh - 190px));
  min-height: 420px;
  overflow: hidden;
  border-radius: 8px;
  background: #000000;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset;
}

.avatar-video img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.04);
  transition:
    opacity 0.25s ease,
    transform 6s ease;
}

.avatar-video.playing img {
  opacity: 1;
  transform: scale(1.1);
}

.video-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.24), transparent 32%, rgba(0, 0, 0, 0.68)),
    radial-gradient(circle at 50% 45%, transparent 0 35%, rgba(0, 0, 0, 0.42) 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.avatar-video.playing .video-shade {
  opacity: 1;
}

.loading-card {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  color: #ffffff;
  text-align: center;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.avatar-video.playing .loading-card {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.loading-photo {
  position: relative;
  width: 154px;
  height: 154px;
  margin-bottom: 15px;
  overflow: hidden;
  border-radius: 8px;
  background-position: center;
  background-size: cover;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.35);
}

.loading-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.scan-ring {
  position: absolute;
  z-index: 1;
  top: 29px;
  left: 29px;
  width: 96px;
  height: 96px;
  border: 1px solid #ffffff;
  border-radius: 50%;
  animation: pulse 1.6s ease-in-out infinite;
}

.loading-dots {
  display: flex;
  gap: 7px;
  margin: 2px 0 10px;
}

.loading-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #778094;
  animation: dot 1.35s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.13s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.26s;
}

.loading-card strong {
  font-size: 15px;
}

.loading-card small {
  margin-top: 9px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
}

.live-layer {
  position: absolute;
  right: 18px;
  bottom: 18px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #ffffff;
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.avatar-video.playing .live-layer {
  opacity: 1;
  transform: translateY(0);
}

.live-layer div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.live-layer strong {
  font-size: 14px;
}

.live-layer span:not(.live-pill) {
  margin-top: 3px;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.72);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-pill {
  padding: 4px 7px;
  border-radius: 6px;
  background: #e93f74;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.control-button,
.icon-button,
.send-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  transition:
    transform 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease;
}

.control-button {
  border: 1px solid var(--line);
  box-shadow: 0 8px 20px rgba(62, 42, 80, 0.08);
}

.control-button.primary {
  width: 40px;
  height: 40px;
  background: var(--ink);
  color: #ffffff;
}

.control-button:hover,
.icon-button:hover,
.send-button:hover {
  transform: translateY(-1px);
}

.icon-button.ghost {
  width: 22px;
  height: 22px;
  background: transparent;
  color: #60586b;
}

.add-avatar {
  flex: 0 0 auto;
  border: 1px solid rgba(155, 75, 237, 0.24);
  background: #fbf4ff;
  color: var(--accent);
}

.right-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  border-left: 1px solid var(--line);
}

.comments-panel {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.comments-header {
  flex: 0 0 auto;
  padding: 14px 40px 10px;
  border-bottom: 1px solid var(--line);
}

.comments-header strong,
.comments-header span {
  display: block;
}

.comments-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 26px;
}

.empty-comments {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 210px;
  display: grid;
  transform: translate(-50%, -52%);
  justify-items: center;
  text-align: center;
}

.chat-illustration {
  position: relative;
  width: 60px;
  height: 48px;
  margin-bottom: 10px;
}

.chat-illustration::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 4px;
  width: 38px;
  height: 28px;
  border: 3px solid #e7cdfa;
  border-radius: 18px;
}

.chat-illustration::after {
  content: "";
  position: absolute;
  top: 1px;
  right: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #b074f5;
}

.chat-illustration span {
  position: absolute;
  bottom: 8px;
  left: 11px;
  width: 10px;
  height: 10px;
  border-left: 3px solid #e7cdfa;
  border-bottom: 3px solid #e7cdfa;
  transform: rotate(-15deg);
}

.empty-comments strong {
  font-size: 13px;
}

.empty-comments small {
  margin-top: 9px;
  color: #a178d0;
  font-size: 10px;
}

.comment-thread {
  display: grid;
  gap: 10px;
}

.comment-item {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.comment-item.host {
  border-color: rgba(155, 75, 237, 0.22);
  background: #fcf8ff;
}

.comment-item strong {
  color: var(--accent-strong);
  font-size: 11px;
}

.comment-item p {
  margin: 0;
  color: #312a3b;
  font-size: 12px;
  line-height: 1.55;
}

.comment-composer {
  flex: 0 0 auto;
  padding: 12px 12px 19px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.composer-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px 4px;
  font-size: 11px;
}

.mini-star {
  color: var(--accent);
  font-size: 16px;
}

.composer-row {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 8px;
}

.composer-row input {
  height: 39px;
  min-width: 0;
  padding: 0 13px;
  border: 1px solid #e7d8f3;
  border-radius: 8px;
  outline: none;
  color: var(--ink);
}

.composer-row input::placeholder {
  color: #c2b2cf;
}

.composer-row input:focus {
  border-color: rgba(155, 75, 237, 0.58);
  box-shadow: 0 0 0 3px rgba(155, 75, 237, 0.1);
}

.send-button {
  width: 38px;
  height: 39px;
  background: #e6e7ef;
  color: #7d8090;
}

.editor-window-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.editor-window-head strong,
.prompt-library > strong {
  display: block;
  font-size: 14px;
}

.editor-window-head span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.small-button {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--soft);
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.form-stack {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
}

.field > span {
  font-size: 11px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

.field input,
.field select {
  height: 36px;
  padding: 0 10px;
}

.field textarea {
  min-height: 140px;
  resize: vertical;
  padding: 10px;
  line-height: 1.55;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(155, 75, 237, 0.58);
  box-shadow: 0 0 0 3px rgba(155, 75, 237, 0.1);
}

.upload-box {
  position: relative;
  min-height: 76px;
  display: grid;
  grid-template-columns: 74px 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px dashed #d6c8e6;
  border-radius: 8px;
  background: #fdfaff;
  cursor: pointer;
}

.upload-box:hover {
  border-color: rgba(155, 75, 237, 0.7);
}

.upload-box img {
  width: 74px;
  height: 58px;
  border-radius: 7px;
  object-fit: cover;
  background: var(--soft-2);
}

.upload-box strong {
  display: block;
  font-size: 12px;
}

.upload-box small {
  display: block;
  line-height: 1.4;
}

.upload-box input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.prompt-tools,
.actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.tool-button,
.save-button,
.secondary-button,
.delete-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.tool-button {
  border: 1px solid #eadbf6;
  background: #ffffff;
  color: var(--accent-strong);
}

.save-button {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(155, 75, 237, 0.22);
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: #ffffff;
  color: var(--ink);
}

.delete-button {
  border: 1px solid #f4c9d4;
  background: #fff7f9;
  color: #c9305b;
}

.delete-button:hover {
  background: #ffeaf0;
}

.delete-button:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}

.prompt-library {
  margin-top: 2px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

#promptChips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.prompt-chip {
  padding: 7px 8px;
  border: 1px solid #e7d7f4;
  border-radius: 8px;
  background: #fbf7ff;
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
}

.back-icon,
.plus-icon,
.play-icon,
.pause-icon,
.send-icon,
.skip-prev-icon,
.skip-next-icon,
.wand-icon,
.edit-icon {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 16px;
}

.avatar-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 34px;
}

.avatar-modal.open {
  display: grid;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 18, 31, 0.42);
  backdrop-filter: blur(8px);
}

.avatar-editor-window {
  position: relative;
  width: min(920px, calc(100vw - 72px));
  max-height: calc(100vh - 72px);
  display: flex;
  overflow: hidden;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 28px 80px rgba(36, 23, 48, 0.24);
}

.editor-window-body {
  min-height: 0;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  overflow: hidden;
}

.editor-preview-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: #fcf8fc;
}

.editor-avatar-preview {
  width: 100%;
  overflow: hidden;
  border-radius: 8px;
  background: #000000;
  aspect-ratio: 0.78;
}

.editor-avatar-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.editor-preview-copy {
  display: grid;
  gap: 5px;
}

.editor-preview-copy strong {
  font-size: 14px;
}

.editor-preview-copy span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.editor-form-pane {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px 20px;
}

.editor-window-actions {
  display: grid;
  grid-template-columns: auto 1fr auto minmax(160px, auto);
  gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line);
  background: #ffffff;
}

.editor-window-actions .save-button {
  min-width: 168px;
}

#cancelCreateBtn {
  justify-self: start;
  min-width: 82px;
}

#duplicateAvatarBtn {
  min-width: 140px;
}

.close-editor {
  border: 1px solid var(--line);
  background: #ffffff;
}

.back-icon::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 8px;
  height: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.plus-icon::before,
.plus-icon::after {
  content: "";
  position: absolute;
  background: currentColor;
  border-radius: 2px;
}

.plus-icon::before {
  top: 7px;
  left: 3px;
  width: 10px;
  height: 2px;
}

.plus-icon::after {
  top: 3px;
  left: 7px;
  width: 2px;
  height: 10px;
}

.close-icon {
  position: relative;
  display: inline-block;
  width: 16px;
  height: 16px;
}

.close-icon::before,
.close-icon::after {
  content: "";
  position: absolute;
  top: 7px;
  left: 3px;
  width: 10px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.close-icon::before {
  transform: rotate(45deg);
}

.close-icon::after {
  transform: rotate(-45deg);
}

.play-icon::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 5px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid currentColor;
}

.pause-icon::before,
.pause-icon::after {
  content: "";
  position: absolute;
  top: 3px;
  width: 3px;
  height: 10px;
  border-radius: 1px;
  background: currentColor;
}

.pause-icon::before {
  left: 4px;
}

.pause-icon::after {
  right: 4px;
}

.send-icon::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 2px;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 12px solid currentColor;
  transform: skewX(-8deg);
}

.skip-prev-icon::before,
.skip-next-icon::before,
.skip-prev-icon::after,
.skip-next-icon::after {
  content: "";
  position: absolute;
  top: 4px;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

.skip-prev-icon::before,
.skip-prev-icon::after {
  border-right: 6px solid currentColor;
}

.skip-prev-icon::before {
  left: 2px;
}

.skip-prev-icon::after {
  left: 8px;
}

.skip-next-icon::before,
.skip-next-icon::after {
  border-left: 6px solid currentColor;
}

.skip-next-icon::before {
  left: 2px;
}

.skip-next-icon::after {
  left: 8px;
}

.wand-icon::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 8px;
  width: 2px;
  height: 13px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(38deg);
}

.wand-icon::after {
  content: "✦";
  position: absolute;
  top: -2px;
  left: 0;
  font-size: 10px;
}

.edit-icon::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 5px;
  width: 5px;
  height: 11px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(35deg);
}

.edit-icon::after {
  content: "";
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 9px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.95;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(1.07);
  }
}

@keyframes dot {
  0%,
  100% {
    opacity: 0.4;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

@media (max-width: 1180px) {
  html,
  body {
    min-width: 960px;
  }

  .workspace {
    grid-template-columns: 235px minmax(470px, 1fr) 320px;
  }

  .comments-header {
    padding-inline: 24px;
  }

  .avatar-video {
    width: min(390px, 47vw);
    height: min(520px, calc(100vh - 180px));
  }

  .avatar-editor-window {
    width: min(860px, calc(100vw - 44px));
  }

  .editor-window-body {
    grid-template-columns: 260px 1fr;
  }
}
