.story-cast-summary {
  align-items: center;
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--story-line);
  border-radius: 16px;
  box-shadow: var(--story-shadow-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 5px;
}

.story-cast-summary span {
  background: var(--story-panel-soft);
  border-radius: 11px;
  color: var(--story-muted-dark);
  font-size: 12px;
  font-weight: 650;
  padding: 9px 14px;
}

.story-cast-summary span:first-child {
  background: var(--story-pink);
  color: #fff;
}

.story-cast-summary b {
  color: inherit;
  font-weight: 800;
}

#manPreview,
#womanPreview {
  object-position: 50% 18% !important;
}

#scenePreview {
  object-position: 50% 50% !important;
}

.story-upload-heading {
  align-items: flex-start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 20px;
}

.story-upload-heading .story-simple-title {
  margin-bottom: 0;
}

.story-prompt-actions {
  align-items: center;
  display: flex;
  gap: 8px;
  grid-column: 2;
  grid-row: 1;
}

.story-prompt-actions .story-random-prompt {
  grid-column: auto;
  grid-row: auto;
}

.story-custom-prompt {
  background: #fff;
  border: 1px solid rgba(242, 79, 120, 0.28);
  box-shadow: 0 8px 20px rgba(70, 45, 78, 0.1);
  color: var(--story-pink-dark);
}

.story-custom-prompt:hover {
  box-shadow: 0 11px 24px rgba(70, 45, 78, 0.16);
}

.story-prompt-warning {
  color: #e11d48;
  font-weight: 700;
}

.story-upload-item-scene {
  z-index: 4;
}

.story-scene-switch {
  align-items: center;
  backdrop-filter: blur(12px);
  background: var(--story-pink);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 11px;
  box-shadow: 0 8px 22px rgba(242, 79, 120, 0.28);
  color: #fff;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  gap: 6px;
  justify-content: center;
  min-height: 35px;
  padding: 7px 12px;
  flex: 0 0 auto;
  margin-top: 2px;
  position: static;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  z-index: 6;
}

.story-scene-switch svg {
  fill: none;
  flex: 0 0 16px;
  height: 16px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
  width: 16px;
}

.story-scene-switch:hover {
  box-shadow: 0 10px 26px rgba(242, 79, 120, 0.36);
  transform: translateY(-1px);
}

.story-scene-switch:focus-visible,
.story-scene-options button:focus-visible {
  outline: 3px solid rgba(242, 79, 120, 0.28);
  outline-offset: 2px;
}

.story-scene-popover {
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--story-line-dark);
  border-radius: 16px;
  box-shadow: 0 24px 55px rgba(40, 27, 47, 0.24);
  padding: 12px;
  position: absolute;
  right: 8px;
  top: 56px;
  width: min(360px, calc(100vw - 36px));
  z-index: 12;
}

.story-scene-popover[hidden] {
  display: none;
}

.story-scene-popover > header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 9px;
}

.story-scene-popover > header b {
  color: var(--story-text-dark);
  font-size: 14px;
}

#sceneChoiceName {
  background: rgba(242, 79, 120, 0.1);
  border-radius: 999px;
  color: var(--story-pink-dark);
  font-size: 10px;
  font-weight: 800;
  padding: 6px 9px;
}

.story-scene-options {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.story-scene-options button {
  background: #fff;
  border: 2px solid transparent;
  border-radius: 11px;
  color: var(--story-muted-dark);
  overflow: hidden;
  padding: 3px 3px 7px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.story-scene-options button:hover {
  transform: translateY(-2px);
}

.story-scene-options button.is-active {
  border-color: var(--story-pink);
  box-shadow: 0 8px 18px rgba(242, 79, 120, 0.17);
  color: var(--story-pink-dark);
}

.story-scene-options img {
  aspect-ratio: 4 / 3;
  border-radius: 7px;
  display: block;
  height: 104px !important;
  object-fit: cover;
  width: 100%;
}

.story-scene-options span {
  display: block;
  font-size: 10px;
  font-weight: 750;
  margin-top: 6px;
  text-align: center;
}

@media (max-width: 767.98px) {
  .story-cast-summary {
    flex-wrap: nowrap;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .story-cast-summary::-webkit-scrollbar {
    display: none;
  }

  .story-cast-summary span {
    flex: 0 0 auto;
    padding: 8px 11px;
  }

  .story-prompt-actions {
    gap: 7px;
    grid-column: 1;
    grid-row: auto;
    width: 100%;
  }

  .story-prompt-actions .story-random-prompt {
    flex: 1 1 0;
    min-width: 0;
    padding-left: 8px;
    padding-right: 8px;
    width: auto;
  }

  .story-prompt-field textarea {
    min-height: 260px;
  }

  .story-scene-switch {
    border-radius: 8px;
    font-size: 10px;
    gap: 4px;
    min-height: 0;
    padding: 5px 7px;
    margin-top: 0;
  }

  .story-scene-switch svg {
    flex-basis: 13px;
    height: 13px;
    width: 13px;
  }

  .story-upload-heading {
    gap: 8px;
    margin-bottom: 13px;
  }

  .story-scene-popover {
    right: 0;
    top: 40px;
    width: min(320px, calc(100vw - 24px));
  }

  .story-scene-options {
    gap: 6px;
  }

  .story-scene-options img {
    height: 72px !important;
  }
}
