body {
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100vw;
  font-family: Arial, sans-serif;
  background-image: url('marble-texture.png');
  background-repeat: no-repeat;
  background-size: cover;
  background-blend-mode: overlay;
  margin: auto;
  font-size: 16px;
}

#playhtVoiceEngine {
color: white;
z-index: 99999;
}


@keyframes gradientAnimation {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}


h1,
#header {
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding-left: 8%;
}

#topHeader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 10px 0;
  z-index: 1000;
  background: transparent;
}

#headerActions {
  margin-left: auto;
  margin-right: 20px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  min-width: 24px;
}

.omnivoice-modal {
  position: static;
  display: none;
  width: 100%;
  max-width: min(94vw, 1180px);
  margin: 12px auto 0;
  height: auto;
  align-self: stretch;
}

.omnivoice-modal__panel {
  width: 100%;
  height: auto;
  max-height: min(70vh, 720px);
  margin: 0 auto;
  background: #050505;
  border: 1px solid #00b7b3;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  padding: 18px 18px 20px;
  box-sizing: border-box;
  text-align: left;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.omnivoice-modal__close {
  display: none;
  margin-left: auto;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 24px;
  cursor: pointer;
}

.omnivoice-modal__title {
  margin: 0 0 8px;
  text-align: center;
  color: #19c5c0;
  font-size: 24px;
}

.omnivoice-modal__subtitle {
  margin: 0 0 14px;
  text-align: center;
  color: #d6d6d6;
  font-size: 14px;
}

.omnivoice-modal__label {
  display: block;
  margin-bottom: 8px;
  text-align: left;
  color: #f0c24f;
  font-size: 18px;
}

.omnivoice-modal__select {
  display: block;
  width: 100%;
  height: 46px;
  margin: 0 auto 14px;
  background: #000;
  color: #c59655;
  border: 1px solid #c59655;
  border-radius: 6px;
  font-size: 16px;
  text-align: center;
  text-align-last: center;
}

.omnivoice-modal__search {
  display: block;
  width: 100%;
  height: 46px;
  margin: 0 auto 14px;
  padding: 0 14px;
  box-sizing: border-box;
  background: #000;
  color: #c59655;
  border: 1px solid #c59655;
  border-radius: 6px;
  font-size: 16px;
  box-shadow: inset 0 0 0 1px rgba(197, 150, 85, 0.18);
}

.omnivoice-modal__search::placeholder {
  color: rgba(197, 150, 85, 0.58);
}

.omnivoice-modal__search:focus {
  outline: none;
  border-color: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16), 0 0 12px rgba(25, 197, 192, 0.2);
}

#ov_voice_group.omnivoice-modal__select {
  margin-bottom: 16px;
}

.omnivoice-steps-control {
  width: 100%;
  margin-top: 18px;
}

.omnivoice-steps-control__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.omnivoice-steps-control__label {
  color: #f0c24f;
  font-size: 18px;
  font-weight: 700;
}

.omnivoice-steps-control__value {
  color: #19c5c0;
  font-size: 18px;
  font-weight: 700;
}

.omnivoice-steps-control__slider {
  width: 100%;
  display: block;
  margin: 0;
}

.omnivoice-steps-control__legend {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr) minmax(0, auto);
  gap: 10px;
  margin-top: 8px;
  color: #d6d6d6;
  font-size: 13px;
}

/* Media query for smaller screens */
@media (max-width: 768px) {
  h1 {
    display: none;
  }

  #topHeader {
    justify-content: flex-start;
  }

  #headerActions {
    margin-left: auto;
  }
}

/* Media query for smaller screens */
@media (max-width: 468px) {
  h1 {
    display: none;
  }

  #topHeader {
    justify-content: flex-start;
  }

  #headerActions {
    margin-left: auto;
    margin-right: 20px;
  }
}

h2,
#appTitle {
  color: white;
  font-size: 16px;
  font-weight: lighter;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: auto;
  margin-bottom: auto;
  flex-grow: 1;
  left: 50%;
}



#api-key-status {
  text-align: center;
  margin-top: 85px;
  margin-bottom: 5px;
  font-weight: lighter;
  color: lime;
  top: 10px;
  position: fixed;
  font-size: 15px;
}


#resultContainer {
  height: 70%;
  color: #d03cd3;
  width: 90vw;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1em;
  padding: 1em;
  background-color: black;
  border-radius: 5px;
  border: 1px solid #383838;
  top: 150px;
  margin-bottom: 20px;
  position: fixed;
  z-index: 1;
  box-shadow: 0 0 10px rgb(255, 255, 255, 0.5);
}

#generatedTextTitle {
  margin: 0 0 2px;
}

#generatedTextTitleContent {
display: flex;
width: 100%;
flex-direction: row;
top: 0px;
justify-content: left;
align-items: center;
  color: #d03cd3;
  font-size: 0.9em;
  margin-bottom: 0;
  gap: 20px;
}

#generatedTextTitleContent i {
font-size: 25px;
}


#detectedLang {
  color: #0a0a0a;
  font-size: 12px;
  font-weight: lighter;
}

#mp3Container {
  width: auto;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  z-index: 5;
}

#audioIcon {
  z-index: 5;
  width: 50px;
  height: 50px;
}

#downloadMP3 {
  z-index: 5;
  width: 50px;
  height: 50px;
}



#output {
  white-space: pre-line;
  height: 500px;
  /* adjust as needed */
  overflow: auto;
  color: white;
}

.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 999998;
  display: none;
}

#messageForm {
  flex-direction: column;
  justify-content: center;
  z-index: 999999;
  align-items: center;
  position: fixed;
  inset: 0;
  width: 100%;
}

#promptButtons {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 980px);
  gap: 8px;
  position: fixed;
  top: 162px;
  z-index: 1000000;
}

#promptButtons button {
  background: linear-gradient(45deg, #8d0281, #000000, #673AB7);
  background-size: 400% 400%;
  animation: gradientAnimation 8s ease-in-out infinite;
  color: white;
  flex: 1 1 150px;
  width: auto;
  min-width: 0;
  min-height: 38px;
  height: auto;
  margin: 0;
  padding: 0.45em 0.6em;
  border-radius: 5px;
  border: 1px solid white;
  cursor: pointer;  
  transition: all 0.3s ease;
  line-height: 1.15;
  font-size: 15px;
  white-space: normal;
  overflow-wrap: anywhere;
}

#promptButtons button:hover {
  background: linear-gradient(45deg, #c59655, #ffcc00, #ffd700);
  background-size: 400% 400%;
  animation: gradientAnimation 8s ease-in-out infinite;
  border: 1px solid #c59655;
  transform: scale(1.05);
  color: #000000;
  font-weight: bold;
}

#promptButtons button.prompt-button-active {
  background: linear-gradient(45deg, #00d5ff, #0a0a0a, #00b7b3);
  background-size: 400% 400%;
  animation: gradientAnimation 8s ease-in-out infinite;
  border: 1px solid #00e5ff;
  color: #ffffff;
  font-weight: bold;
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.55);
  transform: scale(1.04);
}

.character-studio-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: stretch;
  justify-content: center;
  overflow-x: hidden;
  background: linear-gradient(135deg, #0d0517 0%, #170a29 40%, #260f38 70%, #0d0517 100%);
  backdrop-filter: blur(10px);
  z-index: 2147483640 !important;
}

.character-studio-overlay.is-visible {
  display: flex;
}

/* Fixed top processing banner — matches AI-Music-Video-Maker's .processing-banner exactly.
   Sits above the whole shell while the scene editor keeps rendering live underneath it. */
.character-studio-processing-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2147483647;
  pointer-events: none;
  text-align: center;
  background: linear-gradient(180deg, #1a0b2e 0%, #0d0618 100%);
  border-bottom: 1px solid rgba(186, 77, 245, 0.35);
  padding: 10px 16px 12px;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.55);
}

.character-studio-phase-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 4px;
}

.character-studio-big-status {
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 800;
  background: linear-gradient(90deg, #ba4df5, #ff56bf, #7ec8ff, #ba4df5);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: characterStudioStatusFlow 3s linear infinite;
  text-shadow: 0 0 40px rgba(186, 77, 245, 0.4);
  filter: drop-shadow(0 0 18px rgba(255, 86, 191, 0.35));
}

.character-studio-sub-status {
  font-size: clamp(0.9rem, 2vw, 1.2rem);
  color: rgba(255, 255, 255, 0.65);
  margin-top: 8px;
  font-weight: 700;
}

@keyframes characterStudioStatusFlow {
  0% { background-position: 0% 50%; }
  100% { background-position: 300% 50%; }
}

.character-studio-shell {
  position: relative;
  width: min(96vw, 1280px);
  height: min(92vh, 920px);
  max-width: 100%;
  margin: auto;
  padding: 28px;
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  background:
    radial-gradient(circle at top right, rgba(0, 213, 255, 0.16), transparent 24%),
    radial-gradient(circle at top left, rgba(141, 2, 129, 0.22), transparent 26%),
    linear-gradient(135deg, #1a0b2e 0%, #2d0f4a 40%, #4a1a6b 70%, #1a0b2e 100%);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
  z-index: 2147483647 !important;
  isolation: isolate;
}

.character-studio-header,
.character-studio-toolbar,
.character-studio-guide,
.character-card-top,
.character-scene-header,
.character-scene-role-row {
  display: flex;
  align-items: center;
}

.character-studio-header,
.character-studio-toolbar,
.character-scene-header,
.character-scene-role-row {
  justify-content: space-between;
}

.character-studio-header {
  gap: 20px;
  margin-bottom: 18px;
}

.character-studio-header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.character-studio-view-screenplay {
  background: linear-gradient(135deg, rgba(142, 68, 173, 0.35), rgba(79, 195, 247, 0.25));
  border: 1px solid rgba(181, 123, 238, 0.45);
  color: #ffffff;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
}
.character-studio-view-screenplay:hover {
  background: linear-gradient(135deg, rgba(142, 68, 173, 0.55), rgba(79, 195, 247, 0.4));
  border-color: #b57bee;
  transform: translateY(-1px);
}
.character-studio-view-screenplay i { margin-right: 6px; color: #ffd54f; }

.character-studio-screenplay-accordion {
  border: 1px solid rgba(181, 123, 238, 0.25);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  margin-bottom: 16px;
  overflow: hidden;
  position: relative;
  z-index: 99999;
}
.character-studio-screenplay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(26, 11, 46, 0.6);
  border-bottom: 1px solid rgba(181, 123, 238, 0.15);
  font-weight: 700;
  color: #ffffff;
}
.character-studio-screenplay-header i { color: #ffd54f; margin-right: 6px; }
.character-studio-copy-screenplay {
  background: rgba(142, 68, 173, 0.35);
  border: 1px solid rgba(181, 123, 238, 0.4);
  color: #ffffff;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}
.character-studio-copy-screenplay:hover {
  background: rgba(142, 68, 173, 0.6);
}
.character-studio-screenplay-body {
  padding: 16px 20px;
  max-height: 420px;
  overflow-y: auto;
  font-family: 'Courier New', Courier, monospace;
  line-height: 1.5;
}
.character-studio-screenplay-block {
  margin-bottom: 16px;
}
.character-studio-screenplay-char {
  font-weight: 800;
  color: #ffd54f;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.95rem;
  margin-bottom: 2px;
}
.character-studio-screenplay-cue {
  color: #b0a0c0;
  font-style: italic;
  font-size: 0.88rem;
  margin-bottom: 2px;
  padding-left: 28px;
}
.character-studio-screenplay-line {
  color: #f0f0f0;
  font-size: 0.95rem;
  padding-left: 28px;
}
.character-studio-screenplay-empty {
  color: #b0a0c0;
  font-style: italic;
  font-size: 0.9rem;
}
.screenplay-ref-note {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  color: #b0a0c0;
  background: rgba(181, 123, 238, 0.12);
  border: 1px solid rgba(181, 123, 238, 0.25);
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 12px;
  word-break: break-word;
}
/* Raw organized screenplay document (Create Scene structured format) */
.character-studio-screenplay-rawdoc {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #ece8f4;
  background: rgba(20, 16, 32, 0.55);
  border: 1px solid rgba(181, 123, 238, 0.25);
  border-radius: 8px;
  padding: 12px 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.character-studio-screenplay-rawline { min-height: 1em; }
.screenplay-ref-fixed {
  color: #000000;
  background: #ffd54f;
  border-radius: 3px;
  padding: 0 3px;
  font-weight: 700;
  box-shadow: 0 0 0 1px rgba(255, 213, 79, 0.6);
}

.character-studio-kicker {
  color: #00d5ff;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.character-studio-title {
  margin: 6px 0;
  color: #ffffff;
  font-size: 34px;
}

.character-studio-subtitle {
  margin: 0;
  color: rgba(255, 255, 255, 0.75);
  max-width: 720px;
  line-height: 1.55;
}

.character-studio-toggle,
.character-studio-guide,
.character-scene-badge,
.character-scene-persona,
.character-scene-audio-status {
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
}

.character-studio-toggle {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.character-studio-sound-effects-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(120, 255, 177, 0.06);
  border: 1px solid rgba(120, 255, 177, 0.18);
  cursor: pointer;
}

.character-studio-sound-effects-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #78ffb1;
  cursor: pointer;
}

.character-studio-sound-effects-toggle span {
  margin: 0;
  color: #ddffe9;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
}

.character-studio-close,
.character-studio-toolbar button,
.character-card-remove {
  background: linear-gradient(45deg, #8d0281, #000000, #673AB7);
  background-size: 400% 400%;
  animation: gradientAnimation 8s ease-in-out infinite;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  cursor: pointer;
}

.character-studio-toolbar button.is-busy {
  border-color: rgba(255, 221, 87, 0.85);
  box-shadow: 0 0 22px rgba(255, 204, 0, 0.34);
  opacity: 0.96;
}

.character-studio-action-status.is-warning {
  background: rgba(255, 193, 7, 0.14);
  border: 1px solid rgba(255, 193, 7, 0.55);
  color: #ffd54f;
}

.character-studio-close,
.character-studio-toolbar button {
  padding: 12px 16px;
}

.character-card-remove {
  padding: 8px 12px;
}

.character-studio-toolbar {
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.character-studio-action-status {
  display: none;
  margin: -4px 0 16px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 2px solid rgba(0, 213, 255, 0.55);
  background: rgba(0, 213, 255, 0.18);
  color: #f7feff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 0 22px rgba(0, 213, 255, 0.3);
}

.character-studio-action-status.is-visible {
  display: block;
}

.character-studio-action-status.is-busy {
  border-color: rgba(255, 221, 87, 0.75);
  background: rgba(255, 204, 0, 0.18);
  color: #fff7bf;
  box-shadow: 0 0 28px rgba(255, 204, 0, 0.34);
}

.character-studio-action-status.is-success {
  border-color: rgba(120, 255, 177, 0.8);
  background: rgba(120, 255, 177, 0.16);
  color: #ddffe9;
  box-shadow: 0 0 28px rgba(120, 255, 177, 0.28);
}

.character-studio-action-status.is-error {
  border-color: rgba(255, 104, 104, 0.85);
  background: rgba(255, 104, 104, 0.18);
  color: #ffe1e1;
  box-shadow: 0 0 28px rgba(255, 104, 104, 0.28);
}

.character-studio-popup-audio {
  display: none;
  margin: -4px 0 18px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(120, 255, 177, 0.34);
  background: rgba(120, 255, 177, 0.09);
  box-shadow: 0 0 20px rgba(120, 255, 177, 0.18);
}

.character-studio-popup-audio.is-visible {
  display: block;
}

.character-studio-cast-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(3, 6, 16, 0.72);
  backdrop-filter: blur(8px);
  z-index: 10001;
}

.character-studio-cast-modal.is-visible {
  display: flex;
}

.character-studio-cast-modal-panel {
  width: min(760px, 100%);
  max-height: min(82vh, 900px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(10, 14, 28, 0.98), rgba(8, 10, 22, 0.96));
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
}

.character-studio-cast-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.character-studio-cast-modal-kicker {
  color: #8de7ff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.character-studio-cast-modal-title {
  margin: 6px 0 8px;
  color: #ffffff;
  font-size: 24px;
  line-height: 1.2;
}

.character-studio-cast-modal-subtitle {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.5;
}

.character-studio-cast-modal-close,
.character-studio-cast-modal-actions button {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  cursor: pointer;
}

.character-studio-cast-modal-close {
  padding: 10px 14px;
  white-space: nowrap;
}

.character-studio-cast-modal-status {
  display: none;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: #dff7ff;
}

.character-studio-cast-modal-status.is-visible {
  display: block;
}

.character-studio-cast-modal-status.is-error {
  background: rgba(255, 104, 104, 0.12);
  color: #ffd6d6;
}

.character-studio-cast-modal-status.is-success {
  background: rgba(120, 255, 177, 0.12);
  color: #d7ffeb;
}

.character-studio-cast-controls {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(220px, 0.75fr);
  gap: 14px;
  margin-bottom: 16px;
}

.character-studio-cast-list {
  display: grid;
  gap: 14px;
}

.character-studio-cast-item,
.character-studio-cast-empty {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.character-studio-cast-item {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: end;
}

.character-studio-cast-source {
  grid-column: 1 / -1;
  color: rgba(255, 255, 255, 0.65);
  font-size: 12px;
  line-height: 1.4;
}

.character-studio-cast-suggestion {
  grid-column: 1 / -1;
  color: #b7f7d0;
  font-size: 12px;
  line-height: 1.4;
}

.character-studio-cast-name,
.character-studio-cast-search-input,
.character-studio-cast-group-select,
.character-studio-cast-voice {
  width: 100%;
  box-sizing: border-box;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 8, 17, 0.92);
  color: #ffffff;
  padding: 14px 16px;
}

.character-studio-cast-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.character-studio-cast-modal-actions button {
  padding: 12px 16px;
  font-weight: 700;
}

.character-studio-popup-audio-player {
  display: block;
  width: 100%;
}

.character-studio-popup-audio-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.character-studio-popup-audio-actions button {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(45deg, #8d0281, #000000, #673AB7);
  background-size: 400% 400%;
  animation: gradientAnimation 8s ease-in-out infinite;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.16);
}

.character-studio-film-params {
  margin: 14px 0;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(120, 255, 177, 0.2);
  background: rgba(255, 255, 255, 0.03);
}

.character-studio-film-params-header {
  margin-bottom: 14px;
}

.character-studio-film-params-kicker {
  color: #8de7ff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.character-studio-film-params-title {
  margin: 6px 0 8px;
  color: #ffffff;
  font-size: 22px;
  line-height: 1.2;
}

.character-studio-film-params-subtitle {
  margin: 0 0 14px;
  color: rgba(255, 255, 255, 0.74);
  line-height: 1.5;
}

.character-studio-popup-video-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.character-studio-field-checkbox {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(186, 77, 245, 0.35);
  cursor: pointer;
}

.character-studio-field-checkbox input {
  accent-color: #ba4df5;
  width: 16px;
  height: 16px;
}

button.run-complete {
  background: linear-gradient(90deg, #ba4df5, #ff56bf);
  border: none;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 0 18px rgba(186, 77, 245, 0.45);
}

button.run-complete:hover:not(:disabled) {
  box-shadow: 0 0 26px rgba(186, 77, 245, 0.7);
}

.character-studio-popup-video-spec-summary {
  display: none;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(141, 231, 255, 0.08);
  border: 1px solid rgba(141, 231, 255, 0.16);
  color: #dff7ff;
  font-size: 13px;
  line-height: 1.5;
}

.character-studio-popup-video-spec-summary.is-visible {
  display: block;
}

.character-studio-popup-video-spec-summary.is-error {
  background: rgba(255, 104, 104, 0.12);
  border-color: rgba(255, 104, 104, 0.18);
  color: #ffd6d6;
}

.character-studio-popup-video-reference {
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

.character-studio-popup-video-reference-actions,
.character-studio-popup-video-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.character-studio-popup-video-reference-actions button,
.character-studio-popup-video-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(5, 8, 18, 0.86);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.character-studio-popup-video-reference-actions button i,
.character-studio-popup-video-actions button i {
  font-size: 14px;
}

.character-studio-popup-video-reference-actions button:disabled,
.character-studio-popup-video-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.character-studio-popup-video-reference-summary {
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.character-studio-popup-video-status {
  display: none;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: #dff7ff;
}

.character-studio-popup-video-status.is-visible {
  display: block;
}

.character-studio-popup-video-status.is-busy {
  background: rgba(0, 213, 255, 0.12);
  color: #d7f8ff;
}

.character-studio-popup-video-status.is-success {
  background: rgba(120, 255, 177, 0.12);
  color: #d7ffeb;
}

.character-studio-popup-video-status.is-error {
  background: rgba(255, 104, 104, 0.12);
  color: #ffd6d6;
}

.character-studio-session-images-block {
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  /* Force this container to the top of the stacking order so nothing above
     in the popup overlay ever hides the image chips. The first-frame star
     pin lives here, so users MUST be able to click it. */
  position: relative;
  z-index: 2147483647 !important;
  isolation: isolate;
}

.character-studio-session-images-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.character-studio-session-images-count {
  color: #8de7ff;
  font-weight: 700;
  text-transform: none;
  letter-spacing: normal;
}

.character-studio-session-images-empty {
  grid-column: 1 / -1;
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
  line-height: 1.5;
}

/* .indicators / .ind-chip ported from AI-Music-Video-Maker's #indicators grid exactly --
   each chip is a currently-selected reference image with its own star toggle to pin that
   image as the video's first frame. */
.indicators {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 14px 0;
}

.ind-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 18px;
  background: rgba(186, 77, 245, 0.12);
  border: 1px solid rgba(186, 77, 245, 0.3);
  color: #fff;
  font-size: 0.77rem;
  font-weight: 600;
  cursor: pointer;
}

.ind-chip.first-frame-pinned {
  border-color: #ffd65c;
  box-shadow: 0 0 0 1px rgba(255, 214, 92, 0.5);
}

.ind-chip img {
  width: 20px;
  height: 20px;
  object-fit: cover;
  border-radius: 5px;
  flex-shrink: 0;
}

.character-studio-session-image-first-frame-label {
  color: #ffd65c;
  font-size: 0.7rem;
  font-weight: 700;
  margin-left: 2px;
}

.pin-first-frame {
  cursor: pointer;
  opacity: 0.55;
  margin-left: 4px;
  color: inherit;
}

.ind-chip.first-frame-pinned .pin-first-frame {
  opacity: 1;
  color: #ffd65c;
}

.pin-first-frame:hover {
  opacity: 1;
}

.ind-chip .close {
  cursor: pointer;
  opacity: 0.7;
  margin-left: 2px;
  font-size: 0.95rem;
  line-height: 1;
}

.ind-chip .close:hover {
  opacity: 1;
}

.character-studio-session-image-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
  cursor: zoom-out;
}

.character-studio-session-image-lightbox.is-open {
  display: flex;
}

.character-studio-session-image-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 0 40px rgba(0, 213, 255, 0.35);
}

.character-studio-session-image-lightbox-close {
  position: absolute;
  top: 18px;
  right: 22px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(10, 12, 20, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 120ms ease, border-color 120ms ease;
}

.character-studio-session-image-lightbox-close:hover {
  background: rgba(255, 107, 107, 0.25);
  border-color: rgba(255, 107, 107, 0.6);
}

.character-studio-video-loading-overlay {
  display: none;
  position: relative;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  padding: 30px 20px;
  margin-top: 14px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.55);
  text-align: center;
}

.character-studio-video-loading-overlay.is-visible {
  display: flex;
}

.character-studio-video-loading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(0, 213, 255, 0.25);
  border-top-color: #00d5ff;
  border-radius: 50%;
  animation: characterStudioSpin 1s linear infinite;
}

@keyframes characterStudioSpin {
  to {
    transform: rotate(360deg);
  }
}

.character-studio-video-loading-text {
  color: #8de7ff;
  font-size: 14px;
  font-weight: 600;
}

.character-studio-popup-video-player {
  display: block;
  width: 100%;
  margin-top: 14px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.6);
}

.character-studio-guide {
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.character-studio-notes {
  display: block;
  margin-bottom: 18px;
}

.character-studio-main-ai {
  margin-bottom: 18px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.character-studio-target-language-top {
  display: flex;
  justify-content: center;
  margin: 0 0 16px;
}

.character-studio-target-language-field {
  width: min(100%, 340px);
  text-align: center;
}

.character-studio-target-language-field span {
  text-align: center;
}

.character-studio-director-model-status {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(0, 213, 255, 0.08);
  border: 1px solid rgba(0, 213, 255, 0.18);
  color: #d7f8ff;
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
  overflow-wrap: anywhere;
}

.character-studio-director-model-status.is-empty {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.72);
}

.character-studio-main-ai-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.character-studio-model-group-field {
  margin-bottom: 12px;
}

.character-studio-field {
  display: block;
}

.character-studio-field-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.character-studio-field span {
  display: block;
  color: #d5f2ff;
  font-size: 13px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.character-studio-char-count {
  font-size: 11px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.45);
  font-variant-numeric: tabular-nums;
  text-transform: none;
  letter-spacing: normal;
}

.character-studio-field select,
.character-studio-field textarea {
  width: 100%;
  box-sizing: border-box;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 8, 17, 0.92);
  color: white;
  padding: 14px 16px;
}

.character-studio-field textarea {
  min-height: 110px;
  resize: vertical;
}

.character-studio-story-idea-wrap textarea {
  padding-right: 56px;
}

/* Story Idea textarea is taller so you can see more text without scrolling */
#characterStudioStoryIdea {
  min-height: 240px;
  resize: vertical;
}

/* Upload tag feed — chips below the Story Idea textarea.
   Each chip = one uploaded reference (@Image1, @Video1, @Audio1, etc.).
   Click to insert the tag at the cursor in the textarea. */
.character-studio-upload-feed {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px dashed rgba(181, 123, 238, 0.25);
  border-radius: 12px;
  align-items: flex-start;
  min-height: 44px;
}
.character-studio-upload-feed-label {
  width: 100%;
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.character-studio-upload-feed-hint {
  color: rgba(255, 255, 255, 0.4);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: none;
  font-style: italic;
}
.character-studio-upload-feed-empty {
  color: rgba(255, 255, 255, 0.45);
  font-size: 13px;
  font-style: italic;
}
.character-studio-upload-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  background: rgba(181, 123, 238, 0.18);
  border: 1px solid rgba(181, 123, 238, 0.45);
  color: #ffffff;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.character-studio-upload-chip:hover {
  background: rgba(142, 68, 173, 0.4);
  transform: translateY(-1px);
}
.character-studio-upload-chip:active {
  transform: translateY(0);
}
.character-studio-upload-chip-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-color: rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}
.character-studio-upload-chip-thumb.audio,
.character-studio-upload-chip-thumb.video {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  color: #b57bee;
  font-size: 11px;
}
.character-studio-upload-chip-tag {
  font-weight: 700;
  color: #b57bee;
}
.character-studio-upload-chip-name {
  color: rgba(255, 255, 255, 0.85);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.character-studio-upload-chip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.character-studio-upload-chip-close {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 17px;
  height: 17px;
  min-width: 0;
  padding: 0;
  border-radius: 50%;
  background: #b57bee;
  color: #000;
  border: 1px solid rgba(0, 0, 0, 0.5);
  font-size: 12px;
  line-height: 1;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.character-studio-upload-chip-close:hover {
  background: #ff5252;
  color: #fff;
}
.character-studio-upload-feed-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.character-studio-upload-feed-clear {
  margin-left: auto;
  background: none;
  border: 1px solid rgba(255, 82, 82, 0.55);
  color: #ff6b6b;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
}
.character-studio-upload-feed-clear:hover {
  background: rgba(255, 82, 82, 0.12);
}

.character-studio-story-idea-mic {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: #b71c1c;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(183, 28, 28, 0.3);
  transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
  z-index: 1;
}

.character-studio-story-idea-mic:hover {
  transform: scale(1.03);
}

.character-studio-story-idea-mic.is-recording {
  background: #18a957;
  box-shadow: 0 0 20px rgba(24, 169, 87, 0.38);
}

.character-studio-story-idea-mic.is-busy {
  opacity: 0.78;
  cursor: progress;
}

.character-studio-url-import-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  margin-bottom: 6px;
}

.character-studio-url-import-input {
  flex: 1;
  box-sizing: border-box;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 8, 17, 0.92);
  color: white;
  padding: 12px 14px;
  font-size: 13px;
}

.character-studio-url-import-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.character-studio-url-import-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  border-radius: 14px;
  border: 1px solid rgba(0, 213, 255, 0.35);
  background: linear-gradient(135deg, rgba(0, 213, 255, 0.18), rgba(141, 2, 129, 0.22));
  color: white;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.character-studio-url-import-btn:hover:not(:disabled) {
  transform: scale(1.02);
  box-shadow: 0 0 16px rgba(0, 213, 255, 0.25);
}

.character-studio-url-import-btn:disabled {
  opacity: 0.65;
  cursor: progress;
}

.character-studio-url-import-status {
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  transition: max-height 0.2s ease, margin 0.2s ease;
  margin-bottom: 0;
}

.character-studio-url-import-status.is-visible {
  max-height: 40px;
  margin-bottom: 10px;
}

.character-studio-url-import-status.is-error {
  color: #ff8080;
}

.character-studio-url-import-status.is-success {
  color: #7dffb0;
}

.character-studio-url-import-status.is-busy {
  color: #7ad7ff;
}

.character-studio-model-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 8, 17, 0.92);
  padding: 12px 14px;
}

.character-studio-model-search-row i {
  color: #00d5ff;
}

.character-studio-model-search-row input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: #ffffff;
  padding: 0;
}

.character-studio-model-search-row input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.character-studio-model-search-row button {
  flex: 0 0 auto;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  padding: 8px 12px;
  cursor: pointer;
}

.character-studio-model-search-results {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.74);
  font-size: 12px;
}

.character-studio-voice-search-block {
  margin-bottom: 18px;
}

.character-studio-steps-block {
  margin-bottom: 18px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(5, 5, 8, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.character-studio-steps-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.character-studio-steps-label {
  color: #d5f2ff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.character-studio-steps-value {
  color: #7cffba;
  font-size: 18px;
  font-weight: 700;
}

.character-studio-steps-slider {
  width: 100%;
  display: block;
  margin: 0;
}

.character-studio-steps-legend {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr) minmax(0, auto);
  gap: 10px;
  margin-top: 8px;
  color: #b9cfdf;
  font-size: 12px;
}

.character-studio-voice-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 8, 17, 0.92);
  padding: 12px 14px;
}

.character-studio-voice-search-row i {
  color: #00d5ff;
}

.character-studio-voice-search-row input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: #ffffff;
  padding: 0;
}

.character-studio-voice-search-row input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.character-studio-voice-search-row button {
  flex: 0 0 auto;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  padding: 8px 12px;
  cursor: pointer;
}

.character-studio-voice-search-results {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.74);
  font-size: 12px;
}

.character-studio-notes textarea,
.character-card textarea,
.character-card input,
.character-card select {
  width: 100%;
  box-sizing: border-box;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 8, 17, 0.92);
  color: white;
  padding: 14px 16px;
}

.character-studio-notes textarea,
.character-card textarea {
  min-height: 110px;
  resize: vertical;
}

.character-studio-status {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(0, 213, 255, 0.08);
  border: 1px solid rgba(0, 213, 255, 0.18);
  color: #aeeeff;
}

.character-studio-status.is-error,
.character-scene-audio-status.is-error {
  color: #ff8e8e;
}

.character-studio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.character-card,
.character-studio-empty,
.character-scene-line {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.character-card {
  padding: 18px;
}

.character-card label {
  display: block;
  margin-top: 14px;
}

.character-card label > span {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

/* Per-character @AudioN binding badge — only shown when Seedance 2.0/2.5
   is the selected model AND "Send Voice Refs" is on. The badge is the
   exact slot index Seedance will see in audio_urls[] at submit time,
   so the user can confirm @AudioN matches in their prompt. */
.character-audio-n-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff6ec7 0%, #6f4cff 50%, #4dd0ff 100%);
  background-size: 200% 200%;
  animation: gradientAnimation 6s ease-in-out infinite;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18), 0 2px 8px rgba(111, 76, 255, 0.35);
  white-space: nowrap;
  cursor: help;
  margin-left: auto;
}
.character-audio-n-badge i {
  font-size: 0.68rem;
  opacity: 0.9;
}

.character-scene-textarea {
  min-height: 180px;
  line-height: 1.55;
}

.character-studio-empty {
  padding: 20px;
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
}

.character-scene-message {
  border: 1px solid rgba(0, 213, 255, 0.16);
}

.character-scene-header {
  gap: 10px;
  margin-bottom: 14px;
}

.character-scene-badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 213, 255, 0.12);
  border: 1px solid rgba(0, 213, 255, 0.22);
}

.character-scene-line {
  padding: 14px;
  margin-top: 10px;
}

.character-scene-role-row {
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.character-scene-role {
  color: #00d5ff;
  font-weight: bold;
}

.character-scene-persona {
  opacity: 0.82;
}

.character-scene-text {
  line-height: 1.6;
}

.character-scene-audio-status {
  margin-top: 14px;
}

.character-scene-native-audio {
  display: block;
  width: 100%;
  margin-top: 14px;
  border-radius: 14px;
  box-shadow: 0 0 18px rgba(0, 213, 255, 0.16);
}

.character-scene-processing {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.character-scene-processing-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.character-scene-processing-row.is-active {
  border-color: rgba(0, 213, 255, 0.28);
  box-shadow: 0 0 0 1px rgba(0, 213, 255, 0.08) inset;
}

.character-scene-processing-row.is-ready {
  border-color: rgba(120, 255, 177, 0.24);
}

.character-scene-processing-name {
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

.character-scene-processing-text {
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
  line-height: 1.45;
}

.character-scene-processing-state {
  color: #aeeeff;
  font-size: 12px;
  white-space: nowrap;
}

body.character-studio-open {
  overflow: hidden;
}

html.settings-panel-open,
body.settings-panel-open {
  overflow: hidden;
  overscroll-behavior: none;
}

body.character-studio-open #topHeader,
body.character-studio-open #messageForm,
body.character-studio-open .dropdown-container,
body.character-studio-open .icon-controls-container,
body.character-studio-open .message-form-top-controls,
body.character-studio-open footer,
body.character-studio-open #visionOverlay,
body.character-studio-open #visionModal,
body.character-studio-open #install-button {
  z-index: 1 !important;
}

@media (max-width: 768px) {
  .character-studio-shell {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  }

  .character-studio-header,
  .character-studio-toolbar,
  .character-scene-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .character-studio-header-actions,
  .character-studio-guide,
  .character-scene-role-row,
  .character-studio-cast-modal-actions {
    width: 100%;
  }

  .character-studio-header-actions,
  .character-studio-toolbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .character-studio-header-actions > *,
  .character-studio-toolbar > *,
  .character-studio-toggle,
  .character-studio-close {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    justify-content: center;
    margin: 0;
  }

  .character-scene-processing-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .character-studio-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .character-studio-popup-audio-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .character-studio-popup-video-grid,
  .character-studio-popup-video-reference-actions,
  .character-studio-popup-video-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .character-studio-cast-modal {
    padding: max(12px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
  }

  .character-studio-cast-modal-panel {
    width: 100%;
    max-height: 86vh;
    padding: 18px 14px;
  }

  .character-studio-cast-modal-header,
  .character-studio-cast-controls,
  .character-studio-cast-item,
  .character-studio-cast-modal-actions {
    grid-template-columns: minmax(0, 1fr);
    flex-direction: column;
    align-items: stretch;
  }

  .character-studio-cast-modal-actions button,
  .character-studio-cast-modal-close {
    width: 100%;
  }

  .character-scene-processing-state {
    white-space: normal;
  }

  .character-studio-main-ai-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .omnivoice-steps-control__legend,
  .character-studio-steps-legend {
    grid-template-columns: minmax(0, 1fr);
    text-align: center;
  }


  .character-studio-model-search-row {
    flex-wrap: wrap;
  }

  .character-studio-model-search-row button {
    width: 100%;
  }

  .character-studio-voice-search-row {
    flex-wrap: wrap;
  }

  .character-studio-voice-search-row button {
    width: 100%;
  }

  .character-studio-model-search-results,
  .character-studio-voice-search-results,
  .character-scene-text,
  .character-scene-processing-text {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .character-studio-story-idea-mic {
    top: 10px;
    right: 10px;
    width: 38px;
    height: 38px;
  }

  #promptButtons {
    top: 142px;
    width: 94vw;
    gap: 5px;
    justify-content: flex-start;
  }

  .message-form-top-controls {
    top: 6px;
    gap: 7px;
    padding: 4px 7px;
  }

  .message-form-top-button {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }

  .message-form-top-glyph {
    font-size: 10px;
  }

  #promptButtons button {
    flex: 0 1 calc((100% - 12px) / 3);
    width: calc((100% - 12px) / 3);
    max-width: calc((100% - 12px) / 3);
    min-height: 38px;
    height: auto;
    margin: 0;
    padding: 0.4em 0.3em;
    font-size: 12.5px;
    line-height: 1.1;
  }

  #promptInput {
    top: 236px;
    width: 94vw;
    height: min(39vh, 340px);
    padding-left: 16px;
    padding-right: 16px;
    padding-top: 16px;
    line-height: 1.5;
  }

  #visionDropHint {
    top: 556px;
    width: 94vw;
  }

  #visionThumbnailStrip {
    top: 574px;
    width: 94vw;
  }

  #send-button {
    top: 630px;
    width: 94vw;
  }

  #kiDenkt {
    bottom: 250px;
  }

  .audioControlsContainer {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px !important;
    width: 100%;
    box-sizing: border-box;
    padding-left: 0;
    padding-right: 0;
  }

  .audioControlsContainer button {
    width: 100%;
    margin: 0 !important;
  }
}

@media (max-width: 420px) {
  .character-studio-header-actions,
  .character-studio-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .character-studio-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  #promptButtons {
    width: 94vw;
  }

  #promptButtons button {
    flex-basis: calc((100% - 12px) / 3);
    width: calc((100% - 12px) / 3);
    max-width: calc((100% - 12px) / 3);
    font-size: 11.5px;
  }
}

#promptInput {
  position: fixed;
  top: 230px;
  left: 0;
  right: 0;
  font-size: 16px;
  text-align: left;
  word-wrap: break-word;
  width: 90vw;
  height: 300px;
  border-radius: 2px;
  color: white;
  background: linear-gradient(45deg, #8d0281, #000000, #673AB7);
  background-size: 400% 400%;
  animation: gradientAnimation 8s ease-in-out infinite;
  margin: 0 auto 10px;
  border: 1px dashed white;
  margin-bottom: 30px;
  padding-left: 20px;
  padding-right: 20px;
  padding-top: 20px;
  font-family: Arial, sans-serif;
  box-shadow: 0 0 10px rgb(255, 255, 255, 0.8);
  line-height: 2;
}

#send-button {
  position: fixed;
  top: 580px;
  left: 0;
  right: 0;
  background: linear-gradient(45deg, #8d0281, #000000, #673AB7);
  background-size: 400% 400%;
  animation: gradientAnimation 8s ease-in-out infinite;
  color: white;
  width: 92vw;
  height: 50px;
  margin: auto;
  padding: 0.5em;
  border-radius: 2px;
  border: 1px solid white;
  cursor: pointer;

}



#modelSelector {
  position: fixed;
  bottom: 70px;
  left: 0;
  right: 0;
  font-size: 16px;
  word-wrap: break-word;
  width: 90vw;
  height: 50px;
  border-radius: 2px;
  color: white;
  background: linear-gradient(45deg, #050505, #000000, #673AB7);
  background-size: 400% 400%;
  animation: gradientAnimation 8s ease-in-out infinite;
  margin: 0 auto 10px;
  border: 1px dashed white;
  margin-bottom: 30px;
  padding-left: 20px;
  padding-right: 20px;
  
  font-family: Arial, sans-serif;
  box-shadow: 0 0 10px rgb(255, 255, 255, 0.8);
  text-align: center;
}

#kiDenkt {
  position: fixed;
  bottom: 320px;
  left: 0;
  right: 0;
  font-size: 25px;
  text-align: center;
  word-wrap: break-word;
  width: 100vw;
z-index: 99999;
  font-family: Arial, sans-serif;
  display: none;
}

.message-form-top-controls {
  position: fixed;
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 10px;
  z-index: 1000001;
  padding: 6px 10px;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  border-radius: 999px;
  color: white;
  background: rgba(8, 8, 16, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-family: Arial, sans-serif;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  text-align: center;
  backdrop-filter: blur(8px);
}

.message-form-top-button {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: linear-gradient(45deg, #4d216f, #0f0918);
  color: white;
  cursor: pointer;
  transition: transform 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  font-size: 18px;
}

.message-form-top-button:hover {
  color: #d03cd3;
  border-color: rgba(208, 60, 211, 0.65);
  transform: translateY(-1px);
}

.message-form-top-button--clear {
  font-weight: 700;
}

.message-form-top-glyph {
  font-size: 13px;
  letter-spacing: 0.02em;
}

#fileinput {
  margin-bottom: 10px;
  z-index: 99;
  text-align: center;
  top: 0;
  position: fixed;
}

#languageSelector {
position: fixed;
top: 10px;
left: 2%;
  color: white;
  padding: 10px;
  background-color: transparent;
border: none;
cursor: pointer;
font-size: 20px;
box-shadow: 0 0 10px rgb(250, 249, 250, 0.8);
  border-radius: 5px;
  z-index: 1001;
}

#languageSelector option,
#languageSelector optgroup {
background-color: black;
color: white;
}

.dropdown-container {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  outline: none;
  position: fixed;
  top: 34px;
  bottom: auto;
  left: 50%;
  transform: translateX(-50%);
  width: min(96vw, 620px);
  max-width: 620px;
  z-index: 9999999999;
  overflow: visible;
  padding: 18px 0 0;
  box-sizing: border-box;
  pointer-events: none;
}

.dropdown-container > * {
  pointer-events: auto;
}

#langKeyContainer {
  display: none;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  position: fixed;
  top: 24px;
  bottom: 24px;
  left: 0;
  right: 0;
  transform: none;
  width: min(94vw, 620px);
  max-width: 620px;
  margin: 0 auto;
  padding: 18px 18px 22px;
  border-radius: 18px;
  background: rgba(10, 8, 18, 0.94);
  border: 1px solid rgba(197, 150, 85, 0.55);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(12px);
  z-index: 9999999999999999;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-padding-top: 18px;
  scroll-padding-bottom: 28px;
  box-sizing: border-box;
}

#langKeyContainer label {
  display: block;
  width: 100%;
  max-width: 360px;
  margin: 0 auto 8px;
  color: #f5f0ff;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-align: center;
}

#langKeyContainer #modelSelect,
#langKeyContainer #select_voice,
#langKeyContainer #instructions {
  width: 100% !important;
  max-width: 360px !important;
  margin: 0 auto 14px !important;
  box-sizing: border-box;
}

#langKeyContainer #modelSelect,
#langKeyContainer #select_voice,
#langKeyContainer #voice-group-select {
  min-height: 52px !important;
  height: 52px !important;
  padding: 10px 14px !important;
  border-radius: 12px !important;
  border: 1px solid rgba(197, 150, 85, 0.85) !important;
  background: rgba(0, 0, 0, 0.92) !important;
  color: #f5d6a0 !important;
  font-size: 15px !important;
  line-height: 1.25 !important;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

#langKeyContainer #modelSelect,
#langKeyContainer #select_voice {
  text-align: center;
  text-align-last: center;
}

#langKeyContainer #instructions {
  min-height: 88px !important;
  padding: 12px 14px !important;
  border-radius: 12px !important;
  border: 1px solid rgba(197, 150, 85, 0.85) !important;
  background: rgba(0, 0, 0, 0.92) !important;
  color: #f5d6a0 !important;
  font-size: 15px !important;
  line-height: 1.4 !important;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
}

#langKeyContainer #instructions::placeholder,
#langKeyContainer #model-search-input::placeholder,
#langKeyContainer #voice-search-input::placeholder {
  color: rgba(245, 214, 160, 0.56);
}

#langKeyContainer #model-search-container,
#langKeyContainer #voice-search-container,
#langKeyContainer #voice-group-select,
#langKeyContainer #model-search-results,
#langKeyContainer #voice-search-results {
  width: 100% !important;
  max-width: 360px !important;
}

#langKeyContainer #model-search-container,
#langKeyContainer #voice-search-container {
  min-height: 52px !important;
  margin: 0 auto 10px auto !important;
  border-radius: 12px !important;
  border: 1px solid rgba(197, 150, 85, 0.85) !important;
  background: rgba(0, 0, 0, 0.92) !important;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24) !important;
}

#langKeyContainer #model-search-input,
#langKeyContainer #voice-search-input {
  color: #f5d6a0 !important;
}

#langKeyContainer #model-search-results,
#langKeyContainer #voice-search-results {
  margin: 0 auto 10px auto !important;
  color: rgba(245, 214, 160, 0.88) !important;
  font-size: 12px !important;
}

#langKeyContainer select:focus,
#langKeyContainer textarea:focus,
#langKeyContainer input:focus {
  outline: none;
  border-color: #fff !important;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2), 0 0 12px rgba(197, 150, 85, 0.25) !important;
}

#langKeyContainer select option,
#langKeyContainer select optgroup {
  background: #14041e !important;
  color: #f3e8ff !important;
}

@media (max-width: 768px) {
  .dropdown-container {
    top: 26px;
    bottom: 22px;
    width: 96vw;
    max-width: none;
    padding: 16px 0 30px;
    scroll-padding-top: 16px;
    scroll-padding-bottom: 30px;
  }

  #langKeyContainer {
    top: 16px;
    bottom: 16px;
    width: 96vw;
    max-width: 96vw;
    margin-bottom: 14px;
    padding: 16px 14px 20px;
  }

  #langKeyContainer #modelSelect,
  #langKeyContainer #select_voice,
  #langKeyContainer #instructions,
  #langKeyContainer #voice-group-select,
  #langKeyContainer #model-search-container,
  #langKeyContainer #voice-search-container,
  #langKeyContainer #model-search-results,
  #langKeyContainer #voice-search-results {
    max-width: none !important;
  }
}

.select-row {
  display: flex;
  gap: 10px;
  margin-bottom: 8px;
  width: 100%;
  align-items: flex-start;
}

.current-output-language-label {
  width: 100%;
  text-align: center;
  font-size: 10px;
  line-height: 1.2;
  color: rgba(255, 255, 255, 0.66);
  margin-top: 2px;
  margin-bottom: 0;
  letter-spacing: 0.2px;
}

.current-output-language-label--inside {
  margin-top: 14px;
  margin-bottom: 2px;
}

#currentOutputLanguageName {
  color: #b6ff3c;
  font-weight: 600;
}

.select-controls {
  display: flex;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

.select-controls > .lang-cell,
.select-controls > #select_translation_style {
  flex: 1 1 0;
  min-width: 0;
}

#lang-cell-alt.is-hidden {
  display: none;
}

.secondary-language-toggle {
  width: 44px;
  min-width: 44px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  background: linear-gradient(45deg, #8d0281, #000000, #673AB7);
  background-size: 400% 400%;
  animation: gradientAnimation 8s ease-in-out infinite;
  color: white;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 18px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.secondary-language-toggle.is-active {
  color: #b6ff3c;
  border-color: #b6ff3c;
  box-shadow: 0 0 10px rgba(182, 255, 60, 0.25);
}

.secondary-language-toggle:focus,
.secondary-language-toggle:active {
  border-color: rgba(255, 255, 255, 0.24);
  outline: none;
}

.secondary-language-toggle.is-active:focus,
.secondary-language-toggle.is-active:active {
  border-color: #b6ff3c;
}

#update.is-disabled {
  opacity: 0.4;
}

.dropdown-container select {
  margin-bottom: 10px;
  background: linear-gradient(45deg, #8d0281, #000000, #673AB7);
  background-size: 400% 400%;
  animation: gradientAnimation 8s ease-in-out infinite;
  border-radius: 5px;
  padding: 5px;
  border: none;
  z-index: 99999;
  text-align: center;
  color: white;
  width: 100%; 
  height: auto;
  font-size: 16px;
  outline: none;
}

select {
  text-align: center;
  text-align-last: center;
}
select option,
select optgroup {
  text-align: center;
}

.dropdown-container select option,
.dropdown-container select optgroup { 
  background-color: #d03cd3;
  color: white;
}

#select_translation_style {
font-size: 16px;
}

#lang-cell-active select,
#select_target_language {
  color: #b6ff3c;
}

#select_language option,
#select_target_language option,
#select_translation_style option {
  background: #610061;
  color: white;
}
#select_language option:hover,
#select_target_language option:hover,
#select_translation_style option:hover {
  background: black;
  color: #940094;
}

.lang-cell {
  position: relative;
  display: block;
}


#select_translation_style optgroup {
  background: black;
  color: #cc00cc;
}





#uploadIcon {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  cursor: pointer;
  right: 10%;
  position: fixed;
  bottom: 8px;
}

#heybro {
  width: 42px;
  height: 45px;
  border-radius: 50%;
  cursor: pointer;
  left: 10%;
  position: fixed;
  bottom: 8px;
  z-index: 9999;
  border: 1px solid white;
}

#heybro:hover {  
 background-color: purple; 
  border: 1px solid lime; 
    }



footer {
  position: fixed;
  top: 140px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  width: 100%;
  z-index: 999;
}

footer p {
  font-size: 14px;
  color: purple;
}

#buttonContainer {
  margin-top: 10px;
  height: 50px;
}

#install-button {
  position: fixed;
  top: 10px;
  right: 10px;
  display: block;
  width: 70px;
  height: 30px;
  padding: 5px;
  background-color: black;
  border: 1px solid #4f4f4f;
  color: white;
  border-radius: 5px;
  font-size: 14px;
  font-weight: lighter;
  cursor: pointer;
  justify-content: center;
}

#install-button:hover {
  background-color: #fff;
  border: 1px solid #fff;
  color: black;
}

#waiting-gif {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  position: fixed;
  width: 250px;
  height: 250px;
  z-index: 999;
}


.audioControlsContainer {
padding-left: 10px;
padding-right: 10px;
}

.audioControlsContainer button {
  min-width: 0;
  word-break: break-word;
}

#dropdownContainer {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0;
}

.tooltip {
  position: relative;
}

.tooltip select {
  width: 100%;
  height: 30px;
}



.user-message {
  color: #d03cd3;
 border: none;
  /* Color for the user's text */
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: lighter;
  text-align: left;
  word-wrap: break-word;
  background-color: #101010;
   border-radius: 5px;
  left: 0;
  right: 0;
  padding-top: 10px;
  padding-bottom: 10px;
  padding-left: 10px;
  padding-right: 10px;
  box-shadow: 0 0 10px rgb(255, 255, 255, 0.1);
}

.ai-message {
  color: white;
  border: none;
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: lighter;
  text-align: left;
  word-wrap: break-word;
  background-color: #101010;
  border-radius: 5px;
  left: 0;
  right: 0;
  padding-top: 10px;
  padding-bottom: 10px;
  padding-left: 10px;
  padding-right: 10px;
  box-shadow: 0 0 10px rgb(255, 255, 255, 0.1);
}

.conversation {
  margin-bottom: 50px;
}

audio {
  width: 200px;
  height: 20px;

}


/* Modal Styles */


.modal-content {
  position: fixed;
  justify-content: center;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #000;
  width: 80vw;
  height: auto;
  max-width: 90vw;
  border-radius: 4px;
  padding: 20px;
  padding-bottom: 50px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  z-index: 999999;
  text-align: center;
  border: 2px solid #c59655;

}

.close-button {
  position: absolute;
  top: 10px;
  right: 20px;
  font-size: 24px;
  font-weight: bold;
  color: #c59655;
  cursor: pointer;
}

.close-button:hover {
  color: white;
}

input[type="text"] {
  display: block;
  padding: 10px;
  border: none;
  border-radius: 4px;
  margin-bottom: 10px;
}

button[type="submit"] {
  background-color: #008cba;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
}

.modal-content input[type="text"] {
  border: 2px solid #c59655;
  background-color: #212121;
  color: white;
  width: 250px;
  box-sizing: border-box;
  font-size: 16px;
  display: block;
  margin: 0 auto;
  margin-bottom: 10px;
}



 #search_style {
            margin: 0;
            width: 30%;
            padding: 8px 15px;
            height: 25px;
            position: fixed;
            left: 50%;
            transform: translateX(-50%);
            top: 5px;
            background: black;
            border: 2px solid purple;
            outline: none;
            color: white;
            border-radius: 10px;
            z-index: 1002;
        }

#clear_style_search {
  top: -15px;
  cursor: pointer;
  right: 10px;
  width: 30%;
  text-align: left;
  color: white;
  height: 30px;
  margin-top: 20px;
  margin-bottom: 20px;
  padding-left: 20px;
  padding-right: 20px;
  background-color: transparent;
  }



#langButtons {
  position: fixed;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;  
}

#langButtons button { 
  background-color: #212121;
  color: white;
  width: 100px;
  cursor: pointer;
  border: 1px solid #4f4f4f;
  height: 40px;
  border-radius: 5px;

}
#langButtons button:hover {
  background-color: purple; 
}

#textarea-mic {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* ── Vision drop hint label ───────────────────────────────────────────────── */
#visionDropHint {
  position: fixed;
  top: 534px;
  left: 50%;
  transform: translateX(-50%);
  width: 90vw;
  text-align: right;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  pointer-events: none;
  z-index: 1000001;
  letter-spacing: 0.03em;
}
#visionDropHint i {
  margin-right: 4px;
}

/* ── Multi-Image Vision Modal ─────────────────────────────────────────────── */

#visionOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 1100000;
  backdrop-filter: blur(4px);
}

#visionModal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1100001;
  width: min(92vw, 640px);
  max-height: 88vh;
  overflow-y: auto;
  background: linear-gradient(160deg, #0d0d0d, #1a0a2e, #0d0d0d);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 28px 24px 24px;
  box-shadow: 0 0 40px rgba(141, 2, 129, 0.5), 0 0 80px rgba(103, 58, 183, 0.2);
  color: white;
  font-family: Arial, sans-serif;
}

#visionModalClose {
  position: absolute;
  top: 14px;
  right: 16px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 20px;
  cursor: pointer;
  transition: color 0.2s;
}
#visionModalClose:hover { color: white; }

#visionModalTitle {
  font-size: 17px;
  font-weight: bold;
  margin: 0 0 20px;
  color: white;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Per-image rows ── */
#visionImageList {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.vision-image-row {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 14px 16px;
}

.vision-image-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.vision-image-icon {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
}

.vision-image-name {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.vision-image-status {
  font-size: 12px;
  font-weight: bold;
  flex-shrink: 0;
}
.vision-image-status.waiting  { color: rgba(255,255,255,0.35); }
.vision-image-status.loading  { color: #f0c040; }
.vision-image-status.done     { color: #4cff91; }
.vision-image-status.error    { color: #ff5555; }

.vision-progress-track {
  width: 100%;
  height: 5px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
}

.vision-progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #8d0281, #673AB7);
  transition: width 0.4s ease;
}
.vision-progress-bar.indeterminate {
  width: 40%;
  animation: visionIndeterminate 1.2s ease-in-out infinite;
}
@keyframes visionIndeterminate {
  0%   { margin-left: -40%; }
  100% { margin-left: 100%; }
}
.vision-progress-bar.complete {
  width: 100%;
  background: linear-gradient(90deg, #00c97a, #4cff91);
  animation: none;
}
.vision-progress-bar.errored {
  width: 100%;
  background: #ff5555;
  animation: none;
}

/* ── Result section ── */
#visionResultSection {
  display: none;
  flex-direction: column;
  gap: 10px;
}

#visionResultLabel {
  font-size: 13px;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

#visionResultText {
  width: 100%;
  min-height: 140px;
  max-height: 260px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: white;
  font-size: 14px;
  font-family: Arial, sans-serif;
  padding: 12px;
  resize: vertical;
  box-sizing: border-box;
  line-height: 1.6;
}
#visionResultText:focus { outline: none; border-color: rgba(255,255,255,0.3); }

#visionSendToInput {
  align-self: flex-end;
  background: linear-gradient(45deg, #8d0281, #000000, #673AB7);
  background-size: 400% 400%;
  animation: gradientAnimation 8s ease-in-out infinite;
  color: white;
  border: 1px solid white;
  border-radius: 6px;
  padding: 10px 22px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.2s, box-shadow 0.2s;
}
#visionSendToInput:hover {
  transform: scale(1.03);
  box-shadow: 0 0 12px rgba(255,255,255,0.3);
}

/* ── Thumbnail strip below promptInput ── */
#visionThumbnailStrip {
  display: none;
  position: fixed;
  top: 534px;
  left: 50%;
  transform: translateX(-50%);
  width: 90vw;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  z-index: 1000001;
  padding: 8px 0 4px;
}

.vision-thumb {
  width: 36px;
  height: 36px;
  border-radius: 5px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.35);
  opacity: 0.85;
}

/* ──────────────────────────────────────────────────────────────────────────── */

#mtOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  z-index: 2147483647 !important;
  backdrop-filter: blur(6px);
}

.mt-modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2147483647 !important;
  width: min(92vw, 720px);
  max-height: 88vh;
  overflow-y: auto;
  background: linear-gradient(160deg, #0d0d0d, #1a0a2e, #0d0d0d);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 28px 24px 24px;
  box-shadow: 0 0 40px rgba(141, 2, 129, 0.55), 0 0 90px rgba(103, 58, 183, 0.24);
  color: white;
  font-family: Arial, sans-serif;
}

.mt-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.65);
  font-size: 22px;
  cursor: pointer;
  transition: color 0.2s;
}

.mt-modal-close:hover {
  color: white;
}

.mt-modal-title {
  font-size: 18px;
  font-weight: bold;
  margin: 0 0 10px;
}

.mt-modal-subtitle {
  margin: 0 0 18px;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  line-height: 1.4;
}

.mt-model-info {
  margin: -6px 0 16px;
  font-size: 12px;
  color: rgba(255,255,255,0.8);
  line-height: 1.4;
}

.mt-model-value {
  color: #ffd27a;
  word-break: break-word;
}

.mt-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mt-label {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.mt-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  color: white;
  padding: 10px 12px;
  font-size: 14px;
  box-sizing: border-box;
}

.mt-input:focus {
  outline: none;
  border-color: rgba(255,255,255,0.32);
}

.mt-textarea {
  width: 100%;
  min-height: 140px;
  max-height: 280px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  color: white;
  padding: 12px;
  font-size: 14px;
  box-sizing: border-box;
  resize: vertical;
  line-height: 1.6;
}

.mt-textarea:focus {
  outline: none;
  border-color: rgba(255,255,255,0.32);
}

.mt-modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 8px;
}

.mt-modal-actions button {
  background: linear-gradient(45deg, #8d0281, #000000, #673AB7);
  background-size: 400% 400%;
  animation: gradientAnimation 8s ease-in-out infinite;
  color: white;
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.mt-modal-actions button:hover {
  transform: scale(1.03);
  box-shadow: 0 0 12px rgba(255,255,255,0.25);
}

.mt-modal-actions button:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.mt-status {
  min-height: 18px;
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  line-height: 1.35;
}

.mt-language-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.mt-language-row {
  display: grid;
  grid-template-columns: 34px 1fr 160px 230px 110px;
  gap: 10px;
  align-items: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 12px;
}

.mt-language-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.mt-language-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mt-language-name strong {
  font-size: 14px;
  font-weight: 700;
}

.mt-language-name span {
  font-size: 12px;
  color: rgba(255,255,255,0.65);
}

.mt-language-status {
  font-size: 12px;
  font-weight: 700;
  text-align: right;
  color: rgba(255,255,255,0.55);
}

.mt-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 6px 0 14px;
}

.mt-progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mt-progress-label {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  line-height: 1.2;
}

.mt-progress-percent {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
}

.mt-progress-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.16);
  overflow: hidden;
}

.mt-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #8d0281, #673AB7, #8d0281);
  background-size: 200% 200%;
  animation: gradientAnimation 8s ease-in-out infinite;
  transition: width 0.25s ease;
}

.mt-process-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.mt-process-item {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr 120px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: #000;
  border: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
}

.mt-process-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--mt-accent, linear-gradient(135deg, #8d0281, #673AB7));
  opacity: 0;
  pointer-events: none;
}

.mt-process-item::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--mt-accent, linear-gradient(135deg, #8d0281, #673AB7));
  opacity: 0.9;
  pointer-events: none;
}

.mt-process-item-flag {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: rgba(0,0,0,0.28);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 18px;
}

.mt-process-item-main {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mt-process-item-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mt-process-item-title strong {
  font-size: 14px;
  font-weight: 700;
}

.mt-process-item-title span {
  font-size: 12px;
  color: rgba(255,255,255,0.65);
}

.mt-process-item-status {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.mt-process-status-text {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,0.60);
}

.mt-process-play {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.mt-process-play:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.14);
  border-color: rgba(255,255,255,0.28);
}

.mt-process-play.is-playing {
  background: rgba(141, 2, 129, 0.30);
  border-color: rgba(255,255,255,0.30);
}

.mt-mini-progress {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 10px;
  align-items: center;
}

.mt-mini-progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.16);
  overflow: hidden;
}

.mt-mini-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--mt-accent, linear-gradient(90deg, #8d0281, #673AB7));
  transition: width 0.25s ease;
}

.mt-mini-progress-percent {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
  text-align: right;
}

@media (max-width: 560px) {
  .mt-modal {
    width: 94vw;
    padding: 22px 16px 16px;
    border-radius: 12px;
  }

  .mt-modal-actions {
    justify-content: stretch;
  }

  .mt-modal-actions button {
    width: 100%;
  }

  .mt-language-row {
    grid-template-columns: 34px 1fr;
    grid-template-rows: auto auto auto auto;
    gap: 10px;
  }

  .mt-language-row .mt-language-name {
    grid-column: 2;
  }

  .mt-language-row .mt-language-lang,
  .mt-language-row .mt-language-voice,
  .mt-language-row .mt-language-status {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
  }

  .mt-language-row .mt-language-status {
    text-align: left;
  }

  .mt-process-item {
    grid-template-columns: 40px 1fr;
    gap: 10px;
  }

  .mt-process-item-status {
    grid-column: 1 / -1;
    text-align: left;
    justify-content: flex-start;
  }

  .mt-mini-progress {
    grid-template-columns: 1fr 44px;
  }
}

/* ---------------------------------------------------------------------
   Character Studio Reference Image Library (matches AI-Music-Maker-LG's
   proven Character Library pattern: drop zone + IndexedDB grid + toast)
   --------------------------------------------------------------------- */

.character-studio-image-library-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 2147483647;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.character-studio-image-library-overlay.is-open {
  display: flex;
}

.character-studio-image-library-card-modal {
  background: linear-gradient(160deg, rgba(0, 80, 100, 0.55), rgba(60, 5, 80, 0.85)), rgba(6, 8, 17, 0.96);
  border: 1px solid rgba(0, 213, 255, 0.35);
  border-radius: 22px;
  padding: 22px;
  width: 100%;
  max-width: 560px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  color: white;
}

.character-studio-image-library-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.character-studio-image-library-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.4rem;
  cursor: pointer;
}

.character-studio-image-library-upload {
  margin-bottom: 18px;
}

.character-studio-image-library-drop-zone {
  border: 2px dashed rgba(0, 213, 255, 0.45);
  border-radius: 14px;
  padding: 12px 22px;
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: all 0.2s ease;
}

.character-studio-image-library-drop-zone i {
  font-size: 1.6rem;
  color: #00d5ff;
  margin-bottom: 4px;
}

.character-studio-image-library-drop-zone span {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.82rem;
}

.character-studio-image-library-drop-zone:hover,
.character-studio-image-library-drop-zone.dragover {
  background: rgba(0, 213, 255, 0.1);
  border-color: rgba(0, 213, 255, 0.75);
}

.character-studio-image-library-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
}

.character-studio-image-library-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.character-studio-image-library-heading {
  font-size: 0.88rem;
  font-weight: 700;
  color: #00d5ff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.character-studio-image-library-subheading {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.45);
}

.character-studio-image-library-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  /* Force each grid row to size to its TALLEST content rather than
     stretching all items in the row to match. Without this, a tall
     portrait card next to a small portrait card would force the small
     one to stretch vertically — making the same character look like
     two different aspect ratios in adjacent cards. */
  grid-auto-rows: max-content;
  gap: 14px;
  padding-right: 4px;
}

.character-studio-image-library-grid::-webkit-scrollbar {
  width: 6px;
}

.character-studio-image-library-grid::-webkit-scrollbar-thumb {
  background: rgba(0, 213, 255, 0.35);
  border-radius: 3px;
}

.character-studio-image-library-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: rgba(255, 255, 255, 0.4);
  padding: 30px 0;
  font-size: 0.85rem;
}

.character-studio-image-library-card {
  position: relative;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 8px;
  text-align: center;
  transition: all 0.15s ease;
  /* Card sizes to its natural aspect ratio, which comes from the inline
     aspect-ratio style set by imageAspectRatioStyle() (based on the
     image's actual width/height stored in IndexedDB). No constraints —
     the grid column width is the only cap on card width. */
}

.character-studio-image-library-card:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.character-studio-image-library-card.is-selected {
  border-color: #00d5ff;
  background: rgba(0, 213, 255, 0.15);
  box-shadow: 0 0 20px rgba(0, 213, 255, 0.25);
}

.character-studio-image-library-card.is-selected::after {
  content: "In session";
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(90deg, #00d5ff, #8d0281);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.character-studio-image-library-card img {
  /* The card has its natural aspect ratio from the inline style set by
     imageAspectRatioStyle (driven by the image's actual width/height).
     The img fills the card horizontally and lets its height derive from
     the card's aspect ratio (height: auto). The image preserves its
     source aspect inside the card. */
  width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.3);
  display: block;
}

.character-studio-image-library-name {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.75);
  margin-top: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.character-studio-image-library-check {
  position: absolute;
  bottom: 56px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #00d5ff;
  color: #06080f;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 2;
}

.character-studio-image-library-card.is-selected .character-studio-image-library-check {
  opacity: 1;
  transform: scale(1);
}

.character-studio-image-library-index {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.85);
  margin-top: 8px;
  font-weight: 700;
}

.character-studio-image-library-index-select {
  width: 48px;
  padding: 3px 6px;
  background: rgba(181, 123, 238, 0.18);
  border: 1px solid rgba(181, 123, 238, 0.5);
  border-radius: 6px;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.character-studio-image-library-index-select:focus {
  outline: 2px solid rgba(181, 123, 238, 0.8);
}

.character-studio-image-library-index-prefix {
  color: #b57bee;
  font-weight: 700;
}

.character-studio-image-library-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.68rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 3;
}

.character-studio-image-library-first-frame {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.68rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.character-studio-image-library-card:hover .character-studio-image-library-first-frame,
.character-studio-image-library-first-frame:hover,
.character-studio-image-library-card.is-first-frame .character-studio-image-library-first-frame {
  opacity: 1;
}

.character-studio-image-library-card.is-first-frame .character-studio-image-library-first-frame {
  color: #ffd65c;
  background: rgba(0, 0, 0, 0.85);
}

.character-studio-image-library-first-frame-badge {
  position: absolute;
  bottom: 8px;
  left: 8px;
  padding: 3px 7px;
  border-radius: 10px;
  background: #ffd65c;
  color: #000;
  font-size: 10px;
  font-weight: 700;
  z-index: 4;
  pointer-events: none;
}

.character-studio-image-library-tag-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: 3px 7px;
  border-radius: 10px;
  background: #ba4df5;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  z-index: 4;
  pointer-events: none;
  max-width: calc(100% - 16px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.character-studio-image-library-card:hover .character-studio-image-library-remove {
  opacity: 1;
}

.character-studio-image-library-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 30px;
  height: 30px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 4;
}

.character-studio-image-library-card:hover .character-studio-image-library-tag {
  opacity: 1;
}

.character-studio-image-library-tag:hover {
  background: rgba(102, 51, 153, 0.9);
}

.character-studio-image-library-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.character-studio-image-library-btn {
  padding: 8px 20px;
  border-radius: 10px;
  border: none;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  background: linear-gradient(90deg, #00d5ff, #8d0281);
  color: #fff;
}

.character-studio-image-library-btn-danger {
  background: rgba(255, 75, 75, 0.18);
  color: #ff8b8b;
  border: 1px solid rgba(255, 75, 75, 0.4);
  margin-right: auto; /* push to the left of the action row, Done stays on the right */
}

.character-studio-image-library-btn-danger:hover:not(:disabled) {
  background: rgba(255, 75, 75, 0.32);
  border-color: rgba(255, 75, 75, 0.7);
  color: #fff;
}

.character-studio-image-library-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.character-studio-image-library-toast {
  position: fixed;
  top: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  z-index: 2147483647;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(0, 213, 255, 0.92), rgba(141, 2, 129, 0.9));
  border: 1px solid rgba(0, 213, 255, 0.45);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 14px 40px rgba(0, 213, 255, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.character-studio-image-library-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.character-studio-image-library-create {
  margin-bottom: 18px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(0, 213, 255, 0.25);
  background: rgba(0, 213, 255, 0.05);
}

.character-studio-image-library-create-heading {
  font-size: 0.88rem;
  font-weight: 700;
  color: #00d5ff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.character-studio-image-library-create-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.character-studio-image-library-create-heading-row .character-studio-image-library-create-heading {
  margin-bottom: 0;
}

.character-studio-image-library-clear-prompt {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.85);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 120ms ease, border-color 120ms ease;
}

.character-studio-image-library-clear-prompt:hover {
  background: rgba(255, 107, 107, 0.18);
  border-color: rgba(255, 107, 107, 0.55);
  color: #fff;
}

.character-studio-image-library-create-prompt {
  width: 100%;
  box-sizing: border-box;
  min-height: 60px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 8, 17, 0.92);
  color: white;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  margin-bottom: 10px;
}

.character-studio-image-library-create-prompt::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.character-studio-image-library-create-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.character-studio-image-library-create-aspect-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.character-studio-image-library-create-aspect {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 8, 17, 0.92);
  color: white;
  padding: 8px 10px;
  font-size: 13px;
  width: 100%;
  min-width: 0;
}

/* Model picker — same shape as Aspect Ratio so the two dropdowns visually pair.
   Subtle border accent shifts when the user picks the Seedance-safe option
   (Seedream V5 Lite) so it's obvious a different backend is wired up. */
.character-studio-image-library-create-model-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  /* The row handles flex distribution per-label; no fixed width here. */
}

.character-studio-image-library-create-model {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 8, 17, 0.92);
  color: white;
  padding: 8px 10px;
  font-size: 13px;
  width: 100%;
  /* Critical: prevent the native <select> from being stretched by
     browser default flex sizing — its content (the option text) decides
     the width and the row distributes the rest. */
  min-width: 0;
}

.character-studio-image-library-create-model:focus,
.character-studio-image-library-create-model:hover {
  border-color: rgba(186, 77, 245, 0.55);
  outline: none;
}

/* When Seedream V5 Lite is selected, give the select a soft purple tint so the
   user can see at a glance they're on the Venice-workaround path. */
.character-studio-image-library-create-model[data-active="seedream-v5-lite"] {
  border-color: rgba(186, 77, 245, 0.7);
  background: rgba(20, 8, 32, 0.95);
  box-shadow: 0 0 0 1px rgba(186, 77, 245, 0.25) inset;
}

.character-studio-image-library-create-model-label[data-active="seedream-v5-lite"] > span {
  color: #d8a4ff;
}

/* Safety checker toggle. Loomis rule: default OFF (unchecked) so the
   body always sends enable_safety_checker: false. The checkbox is
   shown plainly — no purple tint, no special accent — because the
   "off" state is the expected default and the user only flips it on
   for rare cases where the keyword filter is wanted. */
.character-studio-image-library-create-safety-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.7);
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
  user-select: none;
}

.character-studio-image-library-create-safety-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: #00d5ff;
}

.character-studio-image-library-create-safety-label input[type="checkbox"]:checked + span {
  color: #ffd97a;
}

/* Prompt library: search input + select that load pre-built prompts
   from /prompts.json into the create-character textarea. */
.character-studio-image-library-prompt-search-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 6px;
}

.character-studio-image-library-prompt-search {
  flex: 1;
  padding: 8px 12px;
  background: var(--true-black, #000);
  border: 1px solid rgba(181, 123, 238, 0.25);
  border-radius: 10px;
  color: white;
  font-size: 0.85rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

.character-studio-image-library-prompt-search:focus {
  outline: none;
  border-color: var(--light-purple, #b57bee);
  box-shadow: 0 0 12px rgba(142, 68, 173, 0.25);
}

.character-studio-image-library-prompt-search-clear {
  background: rgba(181, 123, 238, 0.15);
  border: 1px solid rgba(181, 123, 238, 0.3);
  color: var(--light-purple, #b57bee);
  width: 36px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
}

.character-studio-image-library-prompt-search-clear:hover {
  background: rgba(142, 68, 173, 0.25);
  color: white;
}

.character-studio-image-library-prompt-select {
  width: 100%;
  margin-bottom: 6px;
  background: var(--true-black, #000);
  border: 1px solid rgba(181, 123, 238, 0.25);
  border-radius: 10px;
  color: white;
  font-size: 0.82rem;
  font-family: inherit;
  padding: 6px 8px;
  /* Normal closed dropdown — click to open and pick one prompt. Previously
     size="6" rendered as a listbox showing all options at once (looked like a
     multi-select) and pushed the rest of the modal off-screen. The search box
     above is the primary way to find prompts; the dropdown is the fallback. */
}

.character-studio-image-library-prompt-select:focus {
  outline: none;
  border-color: var(--light-purple, #b57bee);
  box-shadow: 0 0 12px rgba(142, 68, 173, 0.25);
}

.character-studio-image-library-prompt-select optgroup {
  background: var(--true-black, #000);
  color: var(--light-purple, #b57bee);
  font-weight: 600;
  font-style: normal;
}

.character-studio-image-library-prompt-select option {
  background: var(--true-black, #000);
  color: white;
  padding: 2px 4px;
}

/* Error state — visible when loadPromptLibrary fails (network / SW / parse).
   The placeholder option text gets a warning color so it stands out from a
   normal empty list. */
.character-studio-image-library-prompt-select option[data-error="1"] {
  color: #ff9a4d;
  font-style: italic;
}

/* Three-up row (Aspect + Model + Button) shares width evenly. Each label
   column is the same width so the dropdowns pair visually, and the button
   keeps its own intrinsic width so it doesn't get squashed. */
.character-studio-image-library-create-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.character-studio-image-library-create-row > label {
  /* Two sibling labels share the available width equally. The button
     (.character-studio-image-library-create-generate) has flex: 1
     so it absorbs any leftover space on wide screens. */
  flex: 1 1 160px;
  min-width: 160px;
  max-width: 260px;
}

.character-studio-image-library-create-generate {
  flex: 1 1 180px;
  min-width: 180px;
  justify-content: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-end;
}

/* Reference-images hint inside the model select — a small chip below the
   dropdown that tells the user how many library images are currently set as
   "Reference Image" so they know what the AI will see. Hidden when no refs
   are tagged. */
.character-studio-image-library-create-model-refs-hint {
  margin-top: 4px;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.5);
  text-transform: none;
  letter-spacing: 0;
  display: none;
}

.character-studio-image-library-create-model-refs-hint.is-visible {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.character-studio-image-library-create-model-refs-hint .badge {
  background: rgba(186, 77, 245, 0.18);
  color: #d8a4ff;
  border-radius: 999px;
  padding: 1px 8px;
  font-weight: 600;
}

.character-studio-image-library-create-status {
  margin-top: 10px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.6);
  display: none;
}

.character-studio-image-library-create-status.is-visible {
  display: block;
}

.character-studio-image-library-create-status.is-error {
  color: #ff6b6b;
}

.character-studio-image-library-create-status.is-success {
  color: #00e88a;
}

.character-studio-image-library-create-status.is-busy {
  color: #00d5ff;
}

/* === IMAGE LIBRARY ROLE ASSIGNMENTS === */
.character-studio-image-library-role {
  position: relative;
  z-index: 3;
  width: 100%;
  margin-top: 6px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  cursor: pointer;
  appearance: auto;
}

.character-studio-image-library-role:focus {
  outline: none;
  border-color: #00d5ff;
  box-shadow: 0 0 0 2px rgba(0, 213, 255, 0.25);
}

.character-studio-image-library-role option {
  color: #000000;
  background: #ffffff;
}

.character-studio-image-library-role-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 3;
  padding: 3px 10px;
  border-radius: 8px;
  background: rgba(0, 213, 255, 0.92);
  color: #04121a;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  pointer-events: none;
}

/* Seedance-safe watermark badge (green ✓ W = watermarked, red ✗ W = not).
   Sits centered at the top of the card so it never collides with the
   role badge (top-left) or the remove/star buttons (top-right). */
.character-studio-image-library-wm-badge {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  cursor: default;
}
.character-studio-image-library-wm-badge img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: block;
}

/* Per-image "regenerate as watermarked" (↻) button, shown only on
   un-watermarked cards, directly below the badge. */
.character-studio-image-library-wm-replace {
  position: absolute;
  top: 38px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);
  transition: background 0.2s ease, transform 0.2s ease;
}
.character-studio-image-library-wm-replace:hover {
  background: #ba4df5;
  transform: translateX(-50%) scale(1.1);
}

/* Watermark regeneration progress modal — sits ABOVE the library overlay
   (both max z-index; this is appended last so DOM order stacks it on top). */
.wm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
}
.wm-overlay.is-open {
  display: flex;
}
.wm-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.wm-row-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wm-row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.wm-row-body {
  flex: 1;
  min-width: 0;
}
.wm-row-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wm-row-status {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 2px;
}
.wm-row-state {
  width: 24px;
  text-align: center;
  color: #fff;
  flex-shrink: 0;
}

.character-studio-image-library-card.is-assigned {
  border-color: #00d5ff;
  box-shadow: 0 0 14px rgba(0, 213, 255, 0.35);
}

/* === SCENE EDITOR (AI-Music-Video-Maker layout) === */
.character-studio-scene-editor {
  margin: 14px 0;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(186, 77, 245, 0.25);
  background: rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(8px);
}

.character-studio-editor-header {
  margin-bottom: 14px;
}

.character-studio-editor-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.character-studio-editor-kicker {
  color: #ba4df5;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.character-studio-editor-title {
  margin: 6px 0 0;
  font-size: 1.5rem;
  font-weight: 800;
  color: #ffffff;
}

.character-studio-editor-subtitle {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.82rem;
  line-height: 1.4;
}

.character-studio-editor-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.character-studio-editor-actions button {
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.character-studio-editor-actions button:hover:not(:disabled) {
  background: rgba(186, 77, 245, 0.22);
  border-color: rgba(186, 77, 245, 0.45);
}

.character-studio-editor-actions button.primary {
  background: linear-gradient(90deg, #3b5bff, #ba4df5);
  border-color: transparent;
  color: #fff;
}

.character-studio-editor-actions button.danger {
  background: rgba(255, 75, 75, 0.18);
  color: #ff8b8b;
  border-color: rgba(255, 75, 75, 0.4);
}

.character-studio-editor-actions button.danger:hover:not(:disabled) {
  background: rgba(255, 75, 75, 0.32);
  border-color: rgba(255, 75, 75, 0.7);
  color: #fff;
}

.character-studio-editor-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.character-studio-scene-timeline {
  display: flex;
  gap: 6px;
  padding: 8px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  overflow-x: auto;
}

.scene-timeline-item {
  flex: 0 0 auto;
  min-width: 90px;
  max-width: 140px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(186, 77, 245, 0.12);
  border: 1px solid rgba(186, 77, 245, 0.3);
  cursor: pointer;
  transition: all 0.15s ease;
}

.scene-timeline-item:hover {
  border-color: #ba4df5;
}

.scene-timeline-item.speaker {
  border-left: 3px solid #ffd65c;
}

.scene-timeline-item.broll {
  border-left: 3px solid #4ade80;
}

.scene-timeline-item.has-image {
  background: rgba(77, 174, 128, 0.12);
}

.scene-timeline-item.has-video {
  border-color: #4ade80;
}

.scene-timeline-num {
  font-size: 0.68rem;
  font-weight: 800;
  color: #ba4df5;
}

.scene-timeline-text {
  margin-top: 3px;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.8);
  max-height: 32px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scene-timeline-time {
  margin-top: 4px;
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.55);
}

.character-studio-editor-layout {
  display: flex;
  gap: 14px;
  min-height: 420px;
  max-height: 720px;
}

.character-studio-scene-sidebar {
  width: 90px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-right: 2px;
  max-height: 720px;
}

.character-studio-scene-sidebar-title {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}

.character-studio-scene-sidebar-images {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
}

.character-studio-scene-sidebar-empty {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  padding: 12px 6px;
}

.character-studio-scene-thumb {
  position: relative;
  width: 78px;
  height: 78px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.character-studio-scene-thumb:hover {
  border-color: rgba(0, 213, 255, 0.5);
}

.character-studio-scene-thumb.has-image {
  border-color: rgba(0, 213, 255, 0.35);
}

.character-studio-scene-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.character-studio-scene-thumb-num {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: #8de7ff;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 5px;
  z-index: 1;
}

.character-studio-scene-cards {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  max-height: 70vh;
  padding-right: 4px;
}

.character-studio-scene-cards::-webkit-scrollbar {
  width: 6px;
}

.character-studio-scene-cards::-webkit-scrollbar-thumb {
  background: rgba(186, 77, 245, 0.35);
  border-radius: 3px;
}

.character-studio-scene-card {
  display: grid;
  grid-template-columns: minmax(280px, 1.8fr) minmax(160px, 1fr) minmax(160px, 1fr);
  gap: 14px;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(186, 77, 245, 0.10), rgba(255, 86, 191, 0.06), rgba(0, 174, 239, 0.04));
  border: 1px solid rgba(186, 77, 245, 0.22);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.character-studio-scene-card:hover {
  border-color: rgba(186, 77, 245, 0.45);
  box-shadow: 0 8px 28px rgba(186, 77, 245, 0.14);
}

.character-studio-scene-card.speaker {
  border-left: 3px solid #ffd65c;
}

.character-studio-scene-card.broll {
  border-left: 3px solid #4ade80;
}

.character-studio-scene-card.user-inserted {
  border-left: 3px solid #00d5ff;
  background: linear-gradient(135deg, rgba(0, 213, 255, 0.05) 0%, rgba(0, 213, 255, 0.02) 100%);
}

.character-studio-scene-card.is-dragging {
  opacity: 0.4;
  transform: scale(0.98);
}

.character-studio-scene-card.is-drag-over {
  border-color: rgba(0, 213, 255, 0.85);
  box-shadow: 0 0 0 2px rgba(0, 213, 255, 0.4);
}

.character-studio-scene-drag-handle {
  cursor: grab;
  color: rgba(0, 213, 255, 0.85);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 6px 0 0;
  user-select: none;
  flex-shrink: 0;
}

.character-studio-scene-drag-handle:active {
  cursor: grabbing;
}

.character-studio-scene-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.character-studio-scene-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.character-studio-scene-title {
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
}

.character-studio-scene-badge {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 5px;
  font-weight: 700;
}

.character-studio-scene-type-toggle {
  display: flex;
  gap: 4px;
}

.scene-type-btn {
  padding: 3px 8px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.scene-type-btn:hover {
  border-color: rgba(186, 77, 245, 0.4);
  color: #fff;
}

.scene-type-btn.is-active {
  color: #0d0517;
  border-color: transparent;
}

.scene-type-btn.is-active[data-action="set-speaker"] {
  background: #ffd65c;
}

.scene-type-btn.is-active[data-action="set-broll"] {
  background: #4ade80;
}

.character-studio-scene-badge.speaker {
  background: rgba(255, 214, 92, 0.18);
  color: #ffd65c;
}

.character-studio-scene-badge.broll {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
}

.character-studio-scene-status {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
}

.character-studio-scene-status.pending {
  background: rgba(255, 214, 92, 0.12);
  color: #ffd65c;
}

.character-studio-scene-status.done {
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
}

.character-studio-scene-status.error {
  background: rgba(255, 104, 104, 0.12);
  color: #ff6b6b;
}

.character-studio-scene-time {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.55);
  font-weight: 600;
}

.character-studio-scene-speaker {
  margin: 6px 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(186, 77, 245, 0.16);
  border: 1px solid rgba(186, 77, 245, 0.4);
  color: #e0b4ff;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}
.character-studio-scene-card.broll .character-studio-scene-speaker {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.45);
  color: #7dd3fc;
}
.character-studio-scene-speaker:hover {
  background: rgba(186, 77, 245, 0.28);
  transform: translateY(-1px);
}
.character-studio-scene-speaker-name {
  color: #ffffff;
  font-weight: 700;
  text-transform: none;
}

.character-studio-scene-desc {
  font-size: 0.84rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.82);
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
}
.character-studio-desc-label {
  display: inline-block;
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.character-studio-desc-label-lyrics {
  color: #ffb35a;
  background: rgba(255, 179, 90, 0.12);
  border: 1px solid rgba(255, 179, 90, 0.3);
}
.character-studio-desc-label-image {
  color: #6bd9ff;
  background: rgba(107, 217, 255, 0.12);
  border: 1px solid rgba(107, 217, 255, 0.3);
}
.character-studio-desc-label-video {
  color: #c89dff;
  background: rgba(186, 77, 245, 0.18);
  border: 1px solid rgba(186, 77, 245, 0.4);
}
.character-studio-desc-label-placeholder {
  color: rgba(255, 255, 255, 0.35);
  font-style: italic;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.8rem;
  background: transparent;
  border: none;
  padding: 0;
}

/* Collapsible section (Lyrics / Image / Video) inside a scene card.
   Default state: collapsed — only the label + a short preview are visible.
   Click to expand the full content; click again to collapse. */
.character-studio-scene-section {
  display: block;
  margin: 0 0 8px 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.04);
  overflow: hidden;
}
.character-studio-scene-section:last-child {
  margin-bottom: 0;
}
.character-studio-scene-section.is-open {
  background: rgba(0, 0, 0, 0.32);
  border-color: rgba(181, 123, 238, 0.3);
}
.character-studio-scene-section-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 8px 10px;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  text-align: left;
}
.character-studio-scene-section-toggle:hover {
  background: rgba(255, 255, 255, 0.04);
}
.character-studio-scene-section-toggle:focus {
  outline: 1px solid rgba(181, 123, 238, 0.5);
  outline-offset: -1px;
}
.character-studio-scene-section-toggle .character-studio-desc-label {
  flex: 0 0 auto;
  margin-right: 0;
}
.character-studio-scene-section-preview {
  flex: 1 1 auto;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}
.character-studio-scene-section-chevron {
  flex: 0 0 auto;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.4);
  width: 14px;
  text-align: center;
}
.character-studio-scene-section-body {
  padding: 6px 12px 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.84rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.9);
  white-space: pre-wrap;
  word-break: break-word;
}
.character-studio-scene-edit-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #ba4df5, #7a1fff);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  pointer-events: auto;
  transition: transform 0.15s, box-shadow 0.15s;
  line-height: 1;
}
.character-studio-scene-edit-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 14px rgba(186, 77, 245, 0.55);
}
.character-studio-scene-edit-btn:active {
  transform: scale(0.95);
}

.character-studio-scene-ref-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
}

.character-studio-scene-ref-label {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.65);
  display: flex;
  align-items: center;
  gap: 6px;
}

.character-studio-scene-ref-select {
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 0.74rem;
  max-width: 160px;
}

.character-studio-scene-ref-name {
  font-size: 0.7rem;
  color: #ba4df5;
  font-weight: 700;
}

.character-studio-broll-group-selector {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.character-studio-broll-group-label {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.65);
  font-weight: 700;
}

.character-studio-broll-group-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.character-studio-broll-check {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
}

.character-studio-broll-check:has(input:checked) {
  border-color: #4ade80;
  background: rgba(74, 222, 128, 0.12);
  color: #fff;
}

.character-studio-broll-group-count {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.5);
}

.character-studio-scene-media {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.character-studio-scene-media-frame {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.10);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  aspect-ratio: 9 / 16;
}

.character-studio-scene-media-frame img,
.character-studio-scene-media-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.character-studio-scene-media-frame .scene-media-placeholder {
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.74rem;
  text-align: center;
  padding: 12px;
}

.character-studio-scene-media-frame .scene-media-placeholder.processing {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #ba4df5;
}

.scene-media-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(186, 77, 245, 0.25);
  border-top-color: #ba4df5;
  animation: sceneSpinner 1s linear infinite;
}

@keyframes sceneSpinner {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.character-studio-video-cropper {
  margin-top: 8px;
  padding: 8px 10px 10px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  border: 1px solid rgba(186, 77, 245, 0.18);
}

.character-studio-video-cropper-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 6px;
  font-family: 'SF Mono', 'Menlo', monospace;
}

.character-studio-video-cropper-label .crop-duration {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 600;
}

.character-studio-video-cropper-track {
  position: relative;
  height: 36px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.6));
  border-radius: 6px;
  margin-bottom: 10px;
  cursor: default;
  user-select: none;
  touch-action: none;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.character-studio-video-cropper-track::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-image: linear-gradient(90deg, transparent 0%, transparent 9.99%, rgba(255, 255, 255, 0.04) 10%, transparent 10.01%, transparent 19.99%, rgba(255, 255, 255, 0.04) 20%, transparent 20.01%, transparent 29.99%, rgba(255, 255, 255, 0.04) 30%, transparent 30.01%, transparent 39.99%, rgba(255, 255, 255, 0.04) 40%, transparent 40.01%, transparent 49.99%, rgba(255, 255, 255, 0.04) 50%, transparent 50.01%, transparent 59.99%, rgba(255, 255, 255, 0.04) 60%, transparent 60.01%, transparent 69.99%, rgba(255, 255, 255, 0.04) 70%, transparent 70.01%, transparent 79.99%, rgba(255, 255, 255, 0.04) 80%, transparent 80.01%, transparent 89.99%, rgba(255, 255, 255, 0.04) 90%, transparent 90.01%, transparent 100%);
  background-size: 10% 100%;
  pointer-events: none;
}

.character-studio-video-cropper-range {
  position: absolute;
  top: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(186, 77, 245, 0.45), rgba(186, 77, 245, 0.25));
  border-left: 3px solid rgba(186, 77, 245, 1);
  border-right: 3px solid rgba(186, 77, 245, 1);
  pointer-events: none;
  box-shadow: 0 0 12px rgba(186, 77, 245, 0.4);
}

.character-studio-video-cropper-range::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-image: linear-gradient(90deg, transparent 0%, transparent 9.99%, rgba(255, 255, 255, 0.18) 10%, transparent 10.01%, transparent 19.99%, rgba(255, 255, 255, 0.18) 20%, transparent 20.01%, transparent 29.99%, rgba(255, 255, 255, 0.18) 30%, transparent 30.01%, transparent 39.99%, rgba(255, 255, 255, 0.18) 40%, transparent 40.01%, transparent 49.99%, rgba(255, 255, 255, 0.18) 50%, transparent 50.01%, transparent 59.99%, rgba(255, 255, 255, 0.18) 60%, transparent 60.01%, transparent 69.99%, rgba(255, 255, 255, 0.18) 70%, transparent 70.01%, transparent 79.99%, rgba(255, 255, 255, 0.18) 80%, transparent 80.01%, transparent 89.99%, rgba(255, 255, 255, 0.18) 90%, transparent 90.01%, transparent 100%);
  background-size: 10% 100%;
  pointer-events: none;
}

.character-studio-video-cropper-handle {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 16px;
  background: linear-gradient(180deg, #4d9ff5, #1e5a99);
  border-radius: 4px;
  cursor: ew-resize;
  transform: translateX(-50%);
  z-index: 3;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.95);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.character-studio-video-cropper-handle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2px;
  height: 16px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 1px;
  box-shadow: 4px 0 0 rgba(255, 255, 255, 0.7), -4px 0 0 rgba(255, 255, 255, 0.7);
}

.character-studio-video-cropper-handle:hover {
  transform: translateX(-50%) scale(1.15);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.character-studio-video-cropper-handle:active {
  transform: translateX(-50%) scale(1.3);
}

.character-studio-video-cropper-handle.left {
  background: linear-gradient(180deg, #4d9ff5, #1e5a99);
}

.character-studio-video-cropper-handle.right {
  background: linear-gradient(180deg, #f5a14d, #a35e1e);
}

.character-studio-video-cropper-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.character-studio-scene-crop-confirm,
.character-studio-scene-crop-reset {
  font-size: 0.72rem;
  padding: 4px 12px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
  color: #fff;
  background: rgba(186, 77, 245, 0.6);
  transition: background 0.15s ease;
}

.character-studio-scene-crop-confirm:hover:not(:disabled) {
  background: rgba(186, 77, 245, 0.9);
}

/* Live preview under the cropper — mirrors the source video so the user
   can SEE what the cropped selection looks like before confirming. The
   playhead visualizes currentTime within the cropped range. */
.character-studio-video-cropper-preview {
  position: relative;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
  aspect-ratio: 16 / 9;
  max-height: 260px;
  border: 1px solid rgba(186, 77, 245, 0.25);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.character-studio-video-cropper-preview-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}
.character-studio-video-cropper-preview-time {
  position: absolute;
  right: 8px;
  bottom: 6px;
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.02em;
  pointer-events: none;
}
.character-studio-video-cropper-playhead {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.7));
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
  pointer-events: none;
  z-index: 4;
  transform: translateX(-50%);
  transition: left 0.05s linear;
}
.character-studio-video-cropper-play {
  font-size: 0.72rem;
  padding: 4px 12px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
  color: #fff;
  background: rgba(77, 159, 245, 0.65);
  transition: background 0.15s ease;
}
.character-studio-video-cropper-play:hover {
  background: rgba(77, 159, 245, 0.95);
}

/* Delete-scene button on the scene card title row — small, low-attention,
   red on hover so it's destructive but not screaming. */
.character-studio-scene-delete-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.55);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  padding: 0;
}
.character-studio-scene-delete-btn:hover {
  background: rgba(255, 80, 80, 0.18);
  border-color: rgba(255, 80, 80, 0.7);
  color: #ff7070;
}

/* Scene Director prompt formatting — professional layout for the structured
   prompts coming out of the LLM ([Stage N], [Generation Goal], field labels,
   bullets, dialogue, music, sound effects, @Image tags). */
.director-prompt-block {
  margin-top: 6px;
  margin-bottom: 4px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.28);
  border-left: 3px solid rgba(186, 77, 245, 0.5);
  border-radius: 4px;
  font-size: 0.78rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.85);
  font-family: 'SF Mono', 'Menlo', 'Consolas', monospace;
  white-space: normal;
}
.director-prompt-image {
  border-left-color: rgba(77, 159, 245, 0.55);
  background: rgba(15, 25, 50, 0.32);
}
.director-prompt-video {
  border-left-color: rgba(186, 77, 245, 0.55);
  background: rgba(28, 12, 42, 0.32);
}
.director-prompt-spacer {
  height: 6px;
}
.director-prompt-para {
  margin: 0 0 4px 0;
}
.director-prompt-goal-header {
  color: #ffb35a;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.78rem;
  margin: 4px 0 6px 0;
  padding: 4px 0;
  border-bottom: 1px dashed rgba(255, 179, 90, 0.35);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.director-prompt-stage-header {
  color: #6bd9ff;
  font-weight: 700;
  letter-spacing: 0.03em;
  font-size: 0.82rem;
  margin: 10px 0 4px 0;
  padding: 4px 8px;
  background: rgba(107, 217, 255, 0.10);
  border-left: 3px solid #6bd9ff;
  border-radius: 3px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  display: block;
}
.director-prompt-maintain-header {
  color: #b4ffae;
  font-weight: 700;
  letter-spacing: 0.03em;
  font-size: 0.82rem;
  margin: 10px 0 4px 0;
  padding: 4px 8px;
  background: rgba(180, 255, 174, 0.10);
  border-left: 3px solid #b4ffae;
  border-radius: 3px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  display: block;
}
.director-prompt-field {
  margin: 3px 0;
  line-height: 1.55;
}
.director-prompt-field-label {
  color: #ffb35a;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.72rem;
  margin-right: 4px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.director-prompt-field-value {
  color: rgba(255, 255, 255, 0.9);
}
.director-prompt-bullets {
  list-style: none;
  padding: 0;
  margin: 4px 0 4px 14px;
}
.director-prompt-bullets li {
  position: relative;
  padding: 2px 0 2px 16px;
  margin: 0;
}
.director-prompt-bullets li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: #ba4df5;
  font-weight: 700;
}
.director-prompt-numbered {
  margin-left: 4px;
}
.director-prompt-numbered .director-prompt-num {
  color: #ba4df5;
  font-weight: 700;
  margin-right: 4px;
}
.director-prompt-dialogue {
  color: #ffe16a;
  background: rgba(255, 225, 106, 0.10);
  padding: 1px 4px;
  border-radius: 3px;
  font-style: italic;
  font-weight: 500;
}
.director-prompt-sfx {
  color: #ff9d6b;
  font-style: italic;
}
.director-prompt-music {
  color: #c89dff;
  font-style: italic;
}
.director-prompt-tag {
  color: #6bd9ff;
  font-weight: 600;
  background: rgba(107, 217, 255, 0.10);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.78rem;
}

.character-studio-scene-crop-reset {
  background: rgba(255, 255, 255, 0.15);
}

.character-studio-scene-crop-reset:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.25);
}

.character-studio-scene-crop-confirm:disabled,
.character-studio-scene-crop-reset:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.character-studio-direction-accordion {
  margin-top: 8px;
  border: 1px solid rgba(186, 77, 245, 0.25);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  overflow: visible;
  position: relative;
  z-index: 999998;
}

.character-studio-direction-accordion-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
  background: rgba(186, 77, 245, 0.08);
  transition: background 0.15s ease;
  position: relative;
  z-index: 999999;
}

.character-studio-direction-accordion-header:hover {
  background: rgba(186, 77, 245, 0.15);
}

.character-studio-direction-accordion-header .accordion-caret {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 0.7rem;
  color: rgba(186, 77, 245, 0.9);
}

.character-studio-direction-accordion-header .accordion-caret.is-open {
  transform: rotate(90deg);
}

.character-studio-direction-accordion-header .accordion-title {
  font-weight: 600;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.95);
}

.character-studio-direction-accordion-header .accordion-summary {
  margin-left: auto;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.55);
  font-style: italic;
}

.character-studio-direction-accordion-body {
  padding: 10px 12px 12px;
  background: rgba(0, 0, 0, 0.85);
  position: relative;
  z-index: 999999;
}

.character-studio-direction-accordion-body input,
.character-studio-direction-accordion-body select {
  position: relative;
  z-index: 999999;
}

.character-studio-direction-accordion-body .accordion-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.character-studio-direction-accordion-body .accordion-row label code {
  background: rgba(186, 77, 245, 0.2);
  color: rgba(186, 77, 245, 0.95);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.character-studio-direction-accordion-body .accordion-row label {
  flex: 0 0 150px;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
}

.character-studio-direction-accordion-body .accordion-row input,
.character-studio-direction-accordion-body .accordion-row select {
  flex: 1;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(186, 77, 245, 0.2);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.95);
  font-size: 0.75rem;
  font-family: inherit;
}

.character-studio-direction-accordion-body .accordion-row input.accordion-combined-input {
  background: rgba(0, 0, 0, 0.4);
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 0.68rem;
  color: rgba(186, 77, 245, 0.95);
  cursor: text;
}

.character-studio-direction-accordion-body .accordion-hint-top {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 12px;
  padding: 8px 10px;
  background: rgba(186, 77, 245, 0.08);
  border-left: 3px solid rgba(186, 77, 245, 0.7);
  border-radius: 3px;
  line-height: 1.4;
}

.character-studio-direction-accordion-body .accordion-row input:focus,
.character-studio-direction-accordion-body .accordion-row select:focus {
  outline: none;
  border-color: rgba(186, 77, 245, 0.7);
  background: rgba(255, 255, 255, 0.1);
}

.character-studio-direction-accordion-body .accordion-actions {
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
  margin-bottom: 4px;
}

.character-studio-direction-accordion-body .accordion-actions button {
  font-size: 0.72rem;
  padding: 5px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  color: #fff;
  background: rgba(186, 77, 245, 0.6);
  transition: background 0.15s ease;
}

.character-studio-direction-accordion-body .accordion-actions button:hover {
  background: rgba(186, 77, 245, 0.9);
}

.character-studio-direction-accordion-body .accordion-actions button[data-action="reset-direction"] {
  background: rgba(255, 255, 255, 0.15);
}

.character-studio-direction-accordion-body .accordion-actions button[data-action="reset-direction"]:hover {
  background: rgba(255, 255, 255, 0.25);
}

.character-studio-direction-accordion-body .accordion-hint {
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.45);
  font-style: italic;
  margin-top: 6px;
  line-height: 1.4;
}

.character-studio-scene-media-time {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.62rem;
  color: rgba(255, 255, 255, 0.85);
  z-index: 2;
}

.character-studio-scene-actions {
  display: flex;
  gap: 6px;
}

.character-studio-scene-actions button {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.character-studio-scene-actions button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(186, 77, 245, 0.45);
}

.character-studio-scene-actions button.primary {
  background: linear-gradient(135deg, #ba4df5, #7a1fff);
  border-color: transparent;
  color: #fff;
}

.character-studio-scene-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.character-studio-main-video-panel {
  flex: 0 0 auto;
  width: min(320px, 28vw);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(186, 77, 245, 0.22);
  border-radius: 16px;
  backdrop-filter: blur(6px);
  align-self: flex-start;
  position: sticky;
  top: 0;
}

.main-video-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.75);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.main-video-frame {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.10);
  aspect-ratio: 9 / 16;
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-video-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.main-video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.78rem;
  text-align: center;
  padding: 14px;
}

.main-video-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(186, 77, 245, 0.25);
  border-top-color: #ba4df5;
  animation: sceneSpinner 1s linear infinite;
}

.main-video-status {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
}

.main-video-status.done {
  color: #4ade80;
}

.main-video-status.pending {
  color: #ffd65c;
}

@media (max-width: 1000px) {
  .character-studio-editor-layout {
    flex-direction: column;
  }
  .character-studio-scene-sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
  }
  .character-studio-main-video-panel {
    width: 100%;
    position: static;
  }
  .character-studio-scene-card {
    grid-template-columns: 1fr;
  }
  .character-studio-scene-media-frame {
    aspect-ratio: 9 / 16;
    max-width: 220px;
  }
}

/* === EFFECTS WAND + DIRECTION SELECT (ported from AI-Music-Video-Maker) ===
   Gold sparkle trigger next to the "+ Direction" select in the Scene Editor's Video Direction
   controls; opens a modal of 81 categorized "effect" tags with plain-English explanations.
   Clicking a card or a Direction option appends its text as a chip in .tag-display and into
   the Video Direction textarea. */
.character-studio-direction-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.character-studio-direction-row select.tool-select {
  flex: 1;
  min-width: 0;
}

.tool-select {
  padding: 7px 26px 7px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%23aaa' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

.tool-select option {
  text-align: center;
  background: #1a0b2e;
  color: #fff;
}

.tag-display {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  min-height: 30px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 18px;
  background: rgba(59, 91, 255, 0.15);
  border: 1px solid rgba(59, 91, 255, 0.4);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 700;
}

.tag-chip .remove {
  cursor: pointer;
  opacity: 0.7;
}

.tag-chip .remove:hover {
  opacity: 1;
}

.effects-wand-trigger {
  position: relative;
  width: auto;
  height: auto;
  padding: 6px 4px;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, filter 0.18s ease;
  flex-shrink: 0;
}

.effects-wand-trigger:hover {
  transform: scale(1.15);
}

.effects-wand-trigger:active {
  transform: scale(0.92);
}

.effects-wand-trigger-glyph {
  font-size: 1.8rem;
  line-height: 1;
  color: #ffd700;
  filter: drop-shadow(0 0 6px rgba(255, 200, 60, 0.85)) drop-shadow(0 0 16px rgba(255, 210, 80, 0.55));
}

.effects-wand-trigger:hover .effects-wand-trigger-glyph {
  filter: drop-shadow(0 0 10px rgba(255, 210, 80, 1)) drop-shadow(0 0 22px rgba(255, 230, 120, 0.75));
}

.effects-wand-trigger-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff5b5b, #c41e1e);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 2147483647;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  background: linear-gradient(160deg, rgba(90, 35, 130, 0.92), rgba(30, 10, 55, 0.96));
  border: 1px solid rgba(186, 77, 245, 0.4);
  border-radius: 22px;
  padding: 22px;
  width: 100%;
  max-width: 520px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.effects-wand-modal {
  max-width: 980px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.effects-wand-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.effects-wand-title-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}

.effects-wand-title-icon {
  font-size: 2.2rem;
  line-height: 1;
  color: #ffd700;
  filter: drop-shadow(0 0 8px rgba(255, 180, 60, 0.7));
}

.effects-wand-kicker {
  color: #ffd700;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  margin-bottom: 2px;
}

.effects-wand-title {
  color: #fff;
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.2;
}

.effects-wand-subtitle {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.82rem;
  line-height: 1.5;
  margin-top: 4px;
}

.effects-wand-close {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(186, 77, 245, 0.3);
  border-radius: 10px;
  background: rgba(186, 77, 245, 0.08);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
}

.effects-wand-close:hover {
  background: rgba(186, 77, 245, 0.25);
  border-color: #ba4df5;
}

.effects-wand-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  margin-bottom: 14px;
  border-radius: 12px;
  border: 1px solid rgba(186, 77, 245, 0.3);
  background: rgba(0, 0, 0, 0.4);
}

.effects-wand-search-row i {
  color: #8de7ff;
  font-size: 0.95rem;
  flex: 0 0 auto;
}

.effects-wand-search-row input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: #fff;
  font-family: inherit;
  font-size: 0.92rem;
}

.effects-wand-search-row input::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.effects-wand-clear {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid rgba(186, 77, 245, 0.3);
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.78rem;
  cursor: pointer;
}

.effects-wand-clear:hover {
  background: rgba(186, 77, 245, 0.18);
  color: #fff;
}

.effects-wand-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.effects-wand-list::-webkit-scrollbar {
  width: 8px;
}

.effects-wand-list::-webkit-scrollbar-thumb {
  background: rgba(186, 77, 245, 0.35);
  border-radius: 4px;
}

.effects-wand-empty {
  padding: 30px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.9rem;
  text-align: center;
}

.effects-wand-category-label {
  color: #ba4df5;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.effects-wand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.effects-wand-card {
  position: relative;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid rgba(186, 77, 245, 0.25);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.effects-wand-card:hover {
  transform: translateY(-1px);
  border-color: #ba4df5;
  background: rgba(186, 77, 245, 0.1);
  box-shadow: 0 4px 18px rgba(186, 77, 245, 0.18);
}

.effects-wand-card.is-selected {
  border-color: #00d5ff;
  background: rgba(0, 213, 255, 0.1);
  box-shadow: 0 0 14px rgba(0, 213, 255, 0.35);
}

.effects-wand-card.is-selected:hover {
  background: rgba(255, 104, 104, 0.15);
  border-color: #ff5b5b;
  box-shadow: 0 0 14px rgba(255, 104, 104, 0.4);
}

.effects-wand-card-name {
  color: #fff;
  font-weight: 800;
  font-size: 0.92rem;
  line-height: 1.2;
}

.effects-wand-card-explanation {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
  line-height: 1.5;
}

.effects-wand-card-check {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #00d5ff;
  font-size: 0.74rem;
  font-weight: 700;
  margin-top: 2px;
}

.effects-wand-card.is-selected .effects-wand-card-check {
  color: #00d5ff;
}

.effects-wand-card.is-added-this-session .effects-wand-card-check {
  color: #11e892;
}

.effects-wand-card-check i {
  font-size: 0.95rem;
}

.effects-wand-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(186, 77, 245, 0.18);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.effects-wand-done {
  padding: 10px 26px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(90deg, #ba4df5, #7a1fff);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(186, 77, 245, 0.35);
}

.effects-wand-done:hover {
  box-shadow: 0 10px 28px rgba(186, 77, 245, 0.55);
}

body.effects-wand-modal-open .character-studio-overlay {
  filter: blur(2px);
  pointer-events: none;
}

@media (max-width: 640px) {
  .character-studio-editor-actions {
    flex-direction: column;
    width: 100%;
  }
  .character-studio-editor-actions button {
    width: 100%;
  }
  .character-studio-scene-card {
    grid-template-columns: 1fr;
  }
}

/* === Per-scene generation notes modal === */
.character-studio-notes-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
  /* Absolute integer limit to stay in front of everything */
  z-index: 2147483647 !important;
  display: flex;
  align-items: center;
  pointer-events: none;
}

/* === Audio Tools modal — anchored to the LEFT side of the viewport
   so it never covers the final video preview on the right.
   Mirrors VidMaker's audio-modal positioning (app.html), but mirrored
   horizontally because Char Studio's video column is on the right. */
.character-studio-audio-tools-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
  z-index: 2147483647 !important;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 0 24px 24px;
  pointer-events: none;
}
.character-studio-audio-tools-modal-overlay > .character-studio-notes-modal {
  pointer-events: auto;
  width: auto;
  max-width: none;
  min-width: 420px;
  max-width: 480px;
  max-height: calc(100vh - 48px);
}
@media (max-width: 1100px) {
  .character-studio-audio-tools-modal-overlay > .character-studio-notes-modal {
    min-width: 380px;
  }
}
@media (max-width: 900px) {
  /* On small screens, fall back to a centered modal (the video + audio
     share the screen vertically instead of side-by-side). */
  .character-studio-audio-tools-modal-overlay {
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.5);
    pointer-events: auto;
  }
  .character-studio-audio-tools-modal-overlay > .character-studio-notes-modal {
    width: min(720px, calc(100vw - 32px));
    max-width: none;
  }
}

.character-studio-notes-modal {
  width: 90%;
  max-width: 480px;
  max-height: 85vh;
  border-radius: 18px;
  background: rgba(10, 12, 20, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.character-studio-notes-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 14px;
  font-weight: 700;
  color: #d5f2ff;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.character-studio-notes-modal-close {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.character-studio-notes-modal-close:hover {
  background: rgba(186, 77, 245, 0.4);
  border-color: rgba(186, 77, 245, 0.7);
  color: #fff;
  transform: scale(1.1);
}

.character-studio-notes-modal-input {
  width: 100%;
  box-sizing: border-box;
  min-height: 120px;
  max-height: 50vh;
  border: none;
  background: transparent;
  color: #fff;
  padding: 16px 20px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  overflow-y: auto;
  flex: 1;
}

.character-studio-notes-modal-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.character-studio-notes-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.character-studio-notes-modal-clear {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
}

.character-studio-notes-modal-clear:hover {
  color: #ff8e8e;
  border-color: rgba(255, 142, 142, 0.4);
}

/* === Scene edit modal (matches VidMaker) === */
.character-studio-scene-edit-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 2147483647;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.character-studio-scene-edit-modal {
  background: #120726;
  border: 1px solid #ba4df5;
  border-radius: 20px;
  padding: 24px;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}
.character-studio-scene-edit-modal h3 {
  color: #ba4df5;
  margin: 0;
  font-size: 1.1rem;
}
.character-studio-scene-edit-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.character-studio-scene-edit-field label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  font-weight: 700;
}
.character-studio-scene-edit-field textarea {
  background: #000;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #fff;
  padding: 12px;
  font-size: 0.95rem;
  min-height: 80px;
  width: 100%;
  resize: vertical;
  font-family: inherit;
}
.character-studio-scene-edit-field textarea:focus {
  border-color: #ba4df5;
  outline: none;
}
.character-studio-scene-edit-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 10px;
}
.character-studio-scene-edit-actions button {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}
.character-studio-scene-edit-actions button:not(.primary) {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.character-studio-scene-edit-actions button.primary {
  background: linear-gradient(90deg, #3b5bff, #ba4df5);
  color: #fff;
}

.character-studio-notes-modal-save {
  border-radius: 10px;
  border: 1px solid rgba(0, 213, 255, 0.35);
  background: linear-gradient(135deg, rgba(0, 213, 255, 0.18), rgba(141, 2, 129, 0.22));
  color: #fff;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.character-studio-notes-modal-save:hover {
  box-shadow: 0 0 12px rgba(0, 213, 255, 0.25);
}

.character-studio-scene-notes-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}

.character-studio-scene-notes-btn:hover {
  opacity: 1;
}

.character-studio-scene-notes-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.character-studio-scene-notes-indicator {
  font-size: 14px;
  margin-left: 4px;
  cursor: help;
}
/* ============================================================
   Audio Tools Modal — post-stitch SFX, bg music, loudness, mix
   Matches the VidMaker Audio Tools modal section-for-section.
   ============================================================ */

.character-studio-audio-section {
  margin: 18px 0;
  padding: 14px 16px;
  background: rgba(186, 77, 245, 0.05);
  border: 1px solid rgba(186, 77, 245, 0.18);
  border-radius: 10px;
}

.character-studio-audio-section h4 {
  margin: 0 0 6px 0;
  font-size: 1rem;
  color: #d8aaff;
  font-weight: 600;
}

.character-studio-audio-hint {
  margin: 0;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.4;
}

.character-studio-audio-section button {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(186, 77, 245, 0.4);
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.character-studio-audio-section button:hover:not(:disabled) {
  background: rgba(186, 77, 245, 0.2);
  border-color: rgba(186, 77, 245, 0.7);
}

.character-studio-audio-section button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.character-studio-audio-section button.primary {
  background: rgba(186, 77, 245, 0.4);
  border-color: rgba(186, 77, 245, 0.7);
  font-weight: 600;
}

.character-studio-audio-section input[type="range"] {
  height: 4px;
  background: rgba(186, 77, 245, 0.3);
  border-radius: 2px;
  appearance: none;
  outline: none;
}

.character-studio-audio-section input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  background: #ba4df5;
  border-radius: 50%;
  cursor: pointer;
}

.character-studio-loudness-cell {
  background: rgba(186, 77, 245, 0.08);
  border: 1px solid rgba(186, 77, 245, 0.25);
  border-radius: 6px;
  padding: 8px;
  text-align: center;
}

.character-studio-loudness-label {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.character-studio-loudness-value {
  font-size: 0.95rem;
  color: #fff;
  font-weight: 600;
}

#characterStudioBgMusicDropzone:hover {
  background: rgba(186, 77, 245, 0.08);
  border-color: rgba(186, 77, 245, 0.5);
}

/* === Create B-Roll Modal === */
.character-studio-create-broll-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 2147483647;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.character-studio-create-broll-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.character-studio-create-broll-label {
  color: #00d5ff;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.character-studio-create-broll-select {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 213, 255, 0.3);
  color: #fff;
  font-size: 0.9rem;
}

.character-studio-create-broll-desc {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.78rem;
  min-height: 1.2em;
}

.character-studio-create-broll-video-name {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.82rem;
  margin-left: 4px;
}

.character-studio-create-broll-clear {
  background: rgba(255, 107, 107, 0.15);
  border: 1px solid rgba(255, 107, 107, 0.4);
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  margin-left: auto;
}

/* === Create B-Roll Motion Tile Grid === */
.character-studio-create-broll-motion-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  background: rgba(0, 0, 0, 0.18);
  border-radius: 10px;
  border: 1px solid rgba(0, 213, 255, 0.15);
}

.character-studio-create-broll-motion-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
  font-family: inherit;
}

.character-studio-create-broll-motion-tile:hover {
  background: rgba(0, 213, 255, 0.1);
  border-color: rgba(0, 213, 255, 0.5);
  transform: translateY(-1px);
}

.character-studio-create-broll-motion-tile.is-selected {
  background: linear-gradient(135deg, rgba(0, 213, 255, 0.25) 0%, rgba(186, 77, 245, 0.25) 100%);
  border-color: rgba(0, 213, 255, 0.85);
  box-shadow: 0 0 12px rgba(0, 213, 255, 0.4);
}

.motion-tile-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.motion-tile-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.85);
  text-align: center;
}

.motion-tile-none {
  border-style: dashed;
  opacity: 0.7;
}

/* === Create B-Roll Video Preview Tiles === */
.motion-tile-video-wrap {
  width: 100%;
  aspect-ratio: 9 / 16;
  background: #000;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.motion-tile-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* === Create B-Roll Toggle === */
.character-studio-create-broll-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.85rem;
}
.character-studio-create-broll-toggle input[type="checkbox"] {
  accent-color: #00d5ff;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* === # / @ Reference Picker (mirrors FAL playground: "Type # to reference inputs") === */
.character-studio-mention-helper {
  margin-top: 6px;
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.35;
  user-select: none;
  pointer-events: none;
}

.character-studio-mention-helper code {
  background: rgba(0, 213, 255, 0.12);
  color: #7fe6ff;
  border: 1px solid rgba(127, 230, 255, 0.25);
  border-radius: 3px;
  padding: 0 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
}

.character-studio-mention-popup {
  position: absolute;
  z-index: 999999;
  min-width: 260px;
  max-width: 340px;
  max-height: 260px;
  overflow-y: auto;
  background: rgba(20, 22, 36, 0.97);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(127, 230, 255, 0.35);
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 213, 255, 0.08) inset;
  padding: 6px;
  font-size: 0.85rem;
  color: #f1f5fa;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.character-studio-mention-popup-header {
  padding: 4px 8px 6px 8px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.45);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.character-studio-mention-popup-header-hint {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #7fe6ff;
  text-transform: none;
  letter-spacing: 0;
}

.character-studio-mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background 80ms linear;
}

.character-studio-mention-item:hover,
.character-studio-mention-item.is-active {
  background: rgba(0, 213, 255, 0.18);
}

.character-studio-mention-item-thumb {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  background-size: cover;
  background-position: center;
  flex: 0 0 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
}

.character-studio-mention-item-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-studio-mention-item-token {
  flex: 0 0 auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  color: #7fe6ff;
  background: rgba(127, 230, 255, 0.12);
  border: 1px solid rgba(127, 230, 255, 0.25);
  border-radius: 3px;
  padding: 1px 5px;
}

.character-studio-mention-empty {
  padding: 14px 10px;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
  line-height: 1.4;
}

/* Hide the popup when not active (driven by hidden attribute so it doesn't
   trap focus or block pointer events when closed). */
.character-studio-mention-popup[hidden] {
  display: none !important;
}
