/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Fonts */
@font-face {
  font-family: 'HakgyoansimDunggeunmiso';
  src: url('/fonts/Hakgyoansim Dunggeunmiso TTF R.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'HakgyoansimDunggeunmiso';
  src: url('/fonts/Hakgyoansim Dunggeunmiso TTF B.ttf') format('truetype');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Aridadaburi';
  src: url('/fonts/AritaBuriKR-Medium.ttf') format('truetype');
  font-display: swap;
}

/* Step 4 새로운 디자인 Import */
@import url('step4-new.css');

/* CSS Variables */
:root {
  --main-bg-gradient: linear-gradient(243deg, #ffe594 0% 0%, #ffdf7c 100%);
  --card-bg-gradient: linear-gradient(257deg, #fffae6 0%, #FFF4E6 100%);
  --purple-gradient: linear-gradient(223deg, #c799f7 0%, #c18cf3 100%);
  --button-gradient: linear-gradient(224deg, #c799f7 0%, #b574f3 100%);
  --text-gradient: linear-gradient(260deg, #ba76ff 0%, #b478f1 100%);

  --white: #ffffff;
  --dark-purple: #3b2141;
  --brown: #9f7737;
  --purple: #b97ef5;
  --purple-dark: #b87af3;
  --light-yellow: #f6e8b19c;
  --shadow-yellow: #e9e3ad8f;
  --shadow-gold: #FFD87A;

  --text-primary: #2d2d2d;
  --text-secondary: #6b7280;
  --border-light: #e5e7eb;
  --success-green: #10b981;
  --warning-orange: #f59e0b;
  --error-red: #ef4444;
}

body {
  font-family: 'HakgyoansimDunggeunmiso', "Inter", -apple-system, BlinkMacSystemFont, "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  min-height: 100vh;
  background: var(--main-bg-gradient);
  overflow-x: hidden;
}

/* App Loader (초기 로딩 화면) */
.app-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--main-bg-gradient);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 1;
}

/* Wrapper */
.wrapper {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Header Section */
.header-section {
  width: 100%;
  padding: 26px 20px 20px;
  position: relative;
  z-index: 10;
}

.main-title {
  text-align: center;
  margin-bottom: 30px;
}

.main-title h1 {
  font-family: "Itim", "Comic Sans MS", cursive, sans-serif;
  font-size: 120px;
  font-weight: 400;
  background: linear-gradient(260deg, rgba(197, 140, 255, 1) 0%, rgba(185, 128, 244, 1) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
  margin: 0;
  letter-spacing: 0;
  line-height: 1;
  font-display: swap;
}

/* Progress Bar */
.stepper-progress {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
}

.progress-bar-container {
  width: 100%;
  height: 42px;
  background-color: var(--white);
  border-radius: 50px;
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 118px;
  background-color: var(--purple-dark);
  border-radius: 50px;
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25),
    inset -3px 3px 4px rgba(255, 255, 255, 0.25);
  transition: width 0.5s ease;
}

/* Hide original step items */
.progress-steps {
  display: none;
}

/* Container */
.container {
  width: 100%;
  max-width: 1500px;
  margin: 30px auto;
  padding: 0 20px;
  position: relative;
}

/* Content Area */
.content-area {
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  background: var(--card-bg-gradient);
  border-radius: 50px;
  box-shadow: 4px 4px 80px var(--shadow-yellow), inset -4px 5px 15px rgba(255, 255, 255, 0.5);
  padding: 30px 10px 70px 10px;
  position: relative;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Step containers smooth transitions */
[id*="step"] {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Step 1 전체 컨테이너 */
#step1 {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

/* Step 정보 */
.step-info-section {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  margin-bottom: 50px;
}

.step-info-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.step-info-right {
  display: flex;
  align-items: center;
}

.step-info-section .step-icon {
  width: 78px;
  height: 78px;
  object-fit: cover;
  flex-shrink: 0;
}

.step-text {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-text .step-title {
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 25px;
  color: var(--dark-purple);
  margin: 0;
}

.step-text .step-description {
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--brown);
  margin: 0;
}

/* Step 주의사항 (우측) */
.step-notice {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.notice-text {
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 12px;
  color: #e74c3c;
  margin: 0;
  line-height: 1.4;
  text-align: right;
}

/* 메인 콘텐츠 영역 - 기본 상태: 세로 배치 (모바일 우선) */
.step-main-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 15px;
  position: relative;
}

/* 업로드 섹션 - 기본 스타일 (모바일 우선) */
.upload-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 448px;
  flex-shrink: 0;
  transition: transform 0.6s ease;
}

/* PC 전용 (768px 이상): 1단계 캐릭터 업로드에서만 row 방향 */
@media (min-width: 768px) {
  #stepMainContent.step-main-content {
    flex-direction: row;
    align-items: flex-start;
    gap: 170px;
  }

  .upload-section {
    width: 448px;
    max-width: 448px;
    /*
      ⚠️ 중요: translateX 값 계산 공식
      - 이 값은 upload-section을 왼쪽에서 중앙으로 이동시키기 위한 값입니다
      - content-area의 padding, container의 max-width, gap 등이 변경되면 이 값도 조정 필요
      - 현재 설정: content-area padding 30px 10px 60px 10px 기준으로 304px 최적값
    */
    transform: translateX(304px);
  }

  /* 업로드 후 좌측 고정 - 크기 일관성 유지 */
  .step-main-content.uploaded .upload-section {
    transform: translateX(0); /* 이미 왼쪽 위치에 있으므로 이동 없음 */
  }
}


/* 프리뷰 섹션 - 기본 상태: 모바일에서는 완전히 숨김 (공간 차지 안함) */
.preview-section {
  display: none; /* 모바일 기본값: 완전히 숨김 */
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 448px;
  flex-shrink: 0;
}

/* 모바일에서 업로드 후: display block으로 나타남 */
.step-main-content.uploaded .preview-section {
  display: flex;
}

/* PC 전용 (768px 이상): opacity 애니메이션 사용 */
@media (min-width: 768px) {
  .preview-section {
    display: flex; /* PC에서는 항상 flex */
    opacity: 0;
    visibility: hidden;
    width: 448px;
    max-width: 448px;
    transition: opacity 0.5s ease 0.6s, visibility 0s ease 0.6s;
  }

  /* 업로드 후 프리뷰 표시 - 심플한 페이드인 */
  .step-main-content.uploaded .preview-section {
    opacity: 1;
    visibility: visible;
  }
}

@keyframes fadeInAfterDelay {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Upload Circle - 일관된 크기 유지 */
.upload-circle-wrapper {
  width: 448px;
  height: 448px;
  background-color: #fffcc985;
  border-radius: 224px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.step-main-content.uploaded .upload-circle-wrapper {
  width: 448px;
  height: 448px;
  border-radius: 224px;
}

.upload-circle {
  width: 320px; /* 344px에서 320px로 조정 */
  height: 320px;
  border-radius: 160px;
  background: var(--purple-gradient);
  box-shadow: 0px 0px 50px var(--shadow-gold), inset -4px 3px 2px rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.step-main-content.uploaded .upload-circle {
  width: 320px; /* 크기 일관성 유지 - 변경 없음 */
  height: 320px;
  border-radius: 160px;
}

.upload-circle:hover {
  background: var(--purple-gradient);
  box-shadow: 0px 0px 60px var(--shadow-gold),
    inset -4px 3px 2px rgba(255, 255, 255, 0.35);
}

.upload-circle.dragover {
  background: var(--purple-gradient);
  box-shadow: 0px 0px 80px var(--shadow-gold),
    inset -4px 3px 2px rgba(255, 255, 255, 0.5);
}

.upload-inner-circle {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.sample-character {
  width: 370px;
  height: 370px;
  object-fit: cover;
  position: absolute;
  z-index: 1;
  border-radius: 160px;
}

.step-main-content.uploaded .sample-character {
  width: 370px;
  height: 370px;
  border-radius: 20px;
}

/* Upload Icon Button */
.upload-icon-btn {
  position: absolute;
  bottom: 15px;
  right: 15px;
  width: 70px;
  height: 70px;
  border-radius: 35px;
  border-radius: 48px;
  border: 5px solid var(--white);
  background: var(--button-gradient);
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25),
    inset -4px 3px 4px rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease;
  z-index: 2;
}

.step-main-content.uploaded .upload-icon-btn {
  width: 70px;
  height: 70px;
  border-radius: 35px;
  bottom: 15px;
  right: 15px;
}

.upload-icon-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0px 6px 8px rgba(0, 0, 0, 0.25),
    inset -4px 3px 4px rgba(255, 255, 255, 0.25);
}

.upload-icon-btn:active {
  transform: translateY(0);
  box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.25),
    inset -4px 3px 4px rgba(255, 255, 255, 0.25);
}

.upload-icon-btn img {
  width: 32px;
  height: 30px;
}

.step-main-content.uploaded .upload-icon-btn img {
  width: 32px;
  height: 30px;
}

/* 프리뷰 박스 - 일관된 크기 유지 */
.preview-box {
  background-color: #fffcf2;
  border-radius: 30px;
  box-shadow: 0px 4px 4px #0000001a, inset -4px 4px 4px #ffffff40;
  padding: 30px;
  width: 448px;
  height: 448px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.preview-image-container {
  width: 340px;
  height: 340px;
  border-radius: 20px;
  overflow: hidden;
  background: var(--white);
  box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-uploaded-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 캐릭터 업로드 버튼 - 일관된 크기 유지 */
.upload-character-btn {
  width: 100%;
  max-width: 448px;
  height: 70px;
  background: var(--button-gradient);
  border: none;
  border-radius: 50px;
  color: var(--white);
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 24px;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease;
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25),
    inset -5px 4px 6px rgba(255, 255, 255, 0.25);
  margin-top: 20px;
}

.step-main-content.uploaded .upload-character-btn {
  width: 448px;
  height: 70px; /* 60px에서 70px로 변경하여 높이 일관성 유지 */
  font-size: 24px;
}

.upload-character-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0px 6px 8px rgba(0, 0, 0, 0.25),
    inset -5px 4px 6px rgba(255, 255, 255, 0.25);
}

.upload-character-btn:active {
  transform: translateY(0);
  box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.25),
    inset -5px 4px 6px rgba(255, 255, 255, 0.25);
}

/* 이름 입력 섹션 - 업로드 후에만 표시, 일관된 크기 */
.name-input-section {
  width: 448px;
  margin-top: 20px;
  display: none;
  position: relative; /* name-preview-text의 absolute 기준점 */
}

.name-input-section.show {
  display: block !important;
}

.character-name-input {
  width: 100%;
  height: 70px;
  padding: 0 25px;
  font-size: 19px;
  font-family: "Inter", sans-serif;
  font-weight: 500;
  border: none;
  border-radius: 30px;
  text-align: center;
  background: var(--white);
  color: var(--dark-purple);
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
}

.character-name-input:focus,
.character-name-input.has-content {
  outline: none;
  box-shadow: 0px 4px 4px #0000001a, inset -4px 4px 4px #ffffff40, 0px 0px 30px 10px var(--shadow-gold);
}

.character-name-input::placeholder {
  color: rgba(59, 33, 65, 0.4);
}

/* 자동완성 시 배경색 변화 방지 */
.character-name-input:-webkit-autofill,
.character-name-input:-webkit-autofill:hover,
.character-name-input:-webkit-autofill:focus,
.character-name-input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px var(--white) inset !important;
  -webkit-text-fill-color: var(--dark-purple) !important;
  box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1) !important;
}

.character-name-input:-webkit-autofill:focus,
.character-name-input:-webkit-autofill.has-content {
  -webkit-box-shadow: 0 0 0 1000px var(--white) inset !important;
  box-shadow: 0px 4px 4px #0000001a, inset -4px 4px 4px #ffffff40, 0px 0px 30px 10px var(--shadow-gold) !important;
}

/* 이름 미리보기 텍스트 */
.name-preview-text {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 15px); /* 입력 필드 아래 15px */
  font-family: "Inter", sans-serif;
  font-weight: 500;
  font-size: 16px;
  color: var(--brown);
  text-align: center;
  opacity: 0.5;
  transition: opacity 0.3s ease;
  line-height: 1.5;
  pointer-events: none; /* 클릭 이벤트 통과 */
}

/* Character Name Input - 기존 스타일 숨김 */
.name-input-wrapper {
  display: none;
}

/* Button Group */
.button-group {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-top: 40px;
  padding: 0 20px 40px;
}

/* Main Action Button */
.btn {
  min-width: 200px;
  padding: 20px 40px;
  border: none;
  border-radius: 50px;
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 22px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background-color: var(--purple);
  color: var(--white);
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25),
    inset -5px 4px 6px rgba(255, 255, 255, 0.25);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0px 6px 8px rgba(0, 0, 0, 0.25),
    inset -5px 4px 6px rgba(255, 255, 255, 0.25);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.25),
    inset -5px 4px 6px rgba(255, 255, 255, 0.25);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.8);
  color: var(--dark-purple);
  box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.15);
}

.btn-secondary:hover {
  background: var(--white);
  transform: translateY(-2px);
  box-shadow: 0px 6px 8px rgba(0, 0, 0, 0.15);
}

/* Hidden Elements */
.hidden {
  display: none !important;
}

/* 기존 2-6단계 스타일 유지 */
.step-content {
  width: 100%;
}


/* Step 2: Style Selection Grid */
.style-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 40px;
  margin-top: 30px;
  width: 100%;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

.style-card {
  position: relative;
  width: 100%;
  min-width: 300px;
  height: 450px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
  overflow: hidden;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  border: 3px solid transparent;
  display: flex;
  flex-direction: column;
  background: white;
}

.style-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
  border-color: var(--purple);
}

.style-card.selected {
  border-color: var(--purple);
  box-shadow: 0 15px 40px rgba(124, 95, 240, 0.3);
  transform: translateY(-3px);
}

/* 이미지 영역 */
.style-image-area {
  flex: 1;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 17px 17px 0 0;
}

/* 텍스트 영역 */
.style-text-area {
  background: #fffbf5;
  padding: 24px 20px;
  text-align: center;
  border-radius: 0 0 17px 17px;
  border-top: 1px solid #f0f0f0;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.style-text-area h3 {
  color: var(--dark-purple);
  font-size: 1.2em;
  font-weight: 700;
  margin: 0 0 6px 0;
  letter-spacing: 0.3px;
}

.style-text-area p {
  color: var(--dark-purple);
  font-size: 0.85em;
  font-weight: 400;
  margin: 0;
  opacity: 0.75;
  line-height: 1.3;
}

/* 체크마크 스타일 */
.style-check-mark {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 30px;
  height: 30px;
  background: var(--purple-gradient);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  opacity: 0;
  transform: scale(0);
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(185, 126, 245, 0.4);
}

.style-card.selected .style-check-mark {
  opacity: 1;
  transform: scale(1);
}

/* Step 2: Navigation Buttons */
.step2-buttons {
  display: flex;
  justify-content: space-between;
  gap: min(20px, 2vw);
  margin-top: 30px;
  width: 100%;
  max-width: 1000px;
}

.prev-button, .next-button {
  flex: 1;
  width: 100%;
  max-width: 470px;
  min-width: 200px;
  height: clamp(50px, 10vw, 78px);
  border: none;
  border-radius: 50px;
  box-shadow: 0px 4px 4px #00000040, inset -5px 4px 6px #ffffff40;
  font-size: clamp(14px, 2.5vw, 18px);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.prev-button {
  background: var(--white);
  color: var(--text-primary);
}

.prev-button:hover {
  transform: translateY(-2px);
  box-shadow: 0px 6px 16px rgba(0, 0, 0, 0.15);
}

.next-button {
  background: var(--button-gradient);
  color: var(--white);
}

.next-button:hover {
  transform: translateY(-2px);
  box-shadow: 0px 6px 16px rgba(183, 122, 243, 0.4);
}

.next-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.next-button:disabled:hover {
  transform: none;
}

/* Step 2 Responsive Styles */
@media (max-width: 1024px) {
  .content-area {
    max-width: 1200px;
  }

  .style-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    max-width: 900px;
  }

  .style-card {
    height: 400px;
    min-width: 280px;
  }
  
  .style-card {
    max-width: 380px;
    border-radius: 25px;
    padding: 25px;
  }
  
  .step2-buttons {
    gap: 15px;
    max-width: 800px;
  }
  
  .prev-button, .next-button {
    max-width: 380px;
    height: clamp(45px, 8vw, 65px);
    font-size: clamp(14px, 2vw, 16px);
  }
}

@media (max-width: 768px) {
  /* Step 4 특정 스타일 제거됨 - 모든 step이 동일한 기본 스타일 사용 */

  .style-grid {
    grid-template-columns: 1fr;
    gap: 25px;
    max-width: 450px;
  }

  .style-card {
    height: 380px;
    border-radius: 15px;
  }

  .style-text-area {
    padding: 15px 16px;
    min-height: 75px;
  }

  .style-text-area h3 {
    font-size: 1.1em;
    margin-bottom: 5px;
  }

  .style-text-area p {
    font-size: 0.8em;
  }

  .step2-buttons {
    flex-direction: column;
    gap: 15px;
    max-width: 500px;
  }

  .prev-button, .next-button {
    max-width: 100%;
    height: 55px;
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .style-grid {
    gap: 20px;
    max-width: 350px;
  }

  .style-card {
    height: 350px;
    border-radius: 12px;
  }

  .style-text-area {
    padding: 12px 14px;
    min-height: 65px;
  }

  .style-text-area h3 {
    font-size: 1em;
    margin-bottom: 4px;
  }

  .style-text-area p {
    font-size: 0.75em;
  }

  .style-check-mark {
    width: 25px;
    height: 25px;
    top: 10px;
    right: 10px;
    font-size: 14px;
  }

  .prev-button, .next-button {
    height: 50px;
    font-size: 14px;
  }
}

/* Loading States */
.loading {
  text-align: center;
  color: var(--text-primary);
}

.loading-message {
  color: var(--text-secondary);
  margin-top: 15px;
  font-size: 0.9em;
}

.spinner {
  width: 200px;
  height: 200px;
  background-image: url('../images/loading.gif');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  margin: 0 auto 20px;
}

/* Conversion Error UI */
.conversion-error-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 40px;
  background: white;
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  max-width: 600px;
  margin: 40px auto;
  animation: fadeIn 0.3s ease-in-out;
}

.conversion-error-ui .error-icon {
  font-size: 80px;
  margin-bottom: 20px;
  animation: shake 0.5s ease-in-out;
}

.conversion-error-ui .error-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--error-red);
  margin-bottom: 16px;
}

.conversion-error-ui .error-message {
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 12px;
  line-height: 1.5;
}

.conversion-error-ui .error-type {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 30px;
  padding: 8px 16px;
  background: #f3f4f6;
  border-radius: 8px;
  display: inline-block;
}

.conversion-error-ui .retry-conversion-btn {
  background: var(--button-gradient);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(185, 126, 245, 0.3);
  margin-bottom: 16px;
}

.conversion-error-ui .retry-conversion-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(185, 126, 245, 0.4);
}

.conversion-error-ui .retry-conversion-btn:active {
  transform: translateY(0);
}

.conversion-error-ui .error-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* 모바일 반응형 */
@media (max-width: 768px) {
  .conversion-error-ui {
    padding: 40px 24px;
    margin: 20px 16px;
  }

  .conversion-error-ui .error-icon {
    font-size: 60px;
  }

  .conversion-error-ui .error-title {
    font-size: 20px;
  }

  .conversion-error-ui .error-message {
    font-size: 14px;
  }

  .conversion-error-ui .retry-conversion-btn {
    padding: 12px 24px;
    font-size: 14px;
  }
}

.spinner.completed {
  background-image: url('../images/complete.png');
}

/* Complete Message */
.complete-message {
  font-family: 'Aridadaburi', cursive;
  font-size: 28px;
  font-weight: bold;
  color: #b97ef5;
  text-align: center;
  margin: 15px auto 25px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
  animation: bounceIn 0.8s ease-out;
  background: linear-gradient(45deg, #b97ef5, #c799f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* loading.gif 사용으로 spin 애니메이션 제거 */

/* Analysis Loading */
.analysis-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.analysis-loading-content {
  background: var(--white);
  padding: 40px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Comparison Container */
.comparison-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-top: 30px;
  min-height: 500px;
  align-items: stretch;
}

/* version-card 스타일은 아래 1690번째 줄에 정의되어 있음 (중복 제거) */

/* 버전2 테마 선택 스타일 - Enhanced Design */
.theme-selection-section {
  margin-bottom: 20px;
  padding: 0;
}

/* 테마 드롭다운 커스텀 스타일 */
.theme-select-custom {
  position: relative;
  width: 100%;
  margin-bottom: 15px;
}

/* 드롭다운 카테고리 구분 */
.theme-category-group {
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.theme-category-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.theme-category-header {
  padding: 8px 12px;
  font-size: 0.85em;
  font-weight: 700;
  color: var(--purple);
  background: rgba(185, 126, 245, 0.08);
  border-radius: 6px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.version2-themes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 15px;
  padding: 0;
}

.theme-option {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 14px 16px;
  border: 2px solid var(--border-light);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(135deg, #ffffff 0%, #fafbff 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  position: relative;
  overflow: hidden;
  min-height: 56px;
}

.theme-option::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--purple), rgba(185, 126, 245, 0.8));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-option:hover {
  border-color: var(--purple);
  background: linear-gradient(135deg, #f8f7ff 0%, #f2f1f9 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(185, 126, 245, 0.15);
}

.theme-option:hover::before {
  transform: scaleX(1);
}

.theme-option.selected {
  border-color: var(--purple);
  background: linear-gradient(135deg, #f0ebff 0%, #e8e1ff 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(185, 126, 245, 0.25);
}

.theme-option.selected::before {
  transform: scaleX(1);
}

.theme-option:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(185, 126, 245, 0.2);
}

.theme-emoji {
  font-size: 1.3em;
  margin-right: 12px;
  width: 28px;
  text-align: center;
  filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.1));
  flex-shrink: 0;
}

.theme-option span {
  font-weight: 600;
  color: var(--dark-purple);
  font-size: 0.95em;
  line-height: 1.3;
  flex: 1;
}

.selected-theme-display {
  font-size: 0.9em;
  font-weight: 600;
  color: var(--purple);
  background: linear-gradient(135deg, #f0ebff 0%, #e8e1ff 100%);
  border-radius: 8px;
  border: 2px solid rgba(185, 126, 245, 0.3);
  transition: all 0.3s ease;
}

.selected-theme-display.show {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(185, 126, 245, 0.2);
}

.preview-image {
  max-width: 100%;
  max-height: 350px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  margin: 15px auto;
  display: block;
}

/* 6단계 스타일 */
/* 진행률 컨테이너 */
.progress-container {
  width: 100%;
  margin: 20px 0;
}

.progress-text {
  text-align: center;
  margin: 15px 0 5px;
  font-size: 1.1em;
  color: var(--text-primary);
  font-weight: 500;
}

/* 성공 메시지 컨테이너 */
.success-container {
  text-align: center;
  margin: 30px 0;
}

.success-message .complete-image {
  width: 150px;
  height: 150px;
  margin-bottom: 20px;
  object-fit: contain;
}

.warning-text {
  color: #e53e3e;
  font-size: 0.85em;
  font-weight: 500;
}

.success-message h2 {
  color: var(--success-green);
  font-size: 1.5em;
  margin-bottom: 15px;
  font-weight: 600;
}

.success-message p {
  color: var(--text-secondary);
  font-size: 1em;
  line-height: 1.5;
  margin-bottom: 0;
}

/* 에러 카드 스타일 */
.error-card {
  background: #fff3f3;
  border: 1px solid #ffcdd2;
  border-radius: 12px;
  padding: 25px;
  text-align: center;
  margin: 20px 0;
}

.error-card h3 {
  color: var(--error-red);
  font-size: 1.2em;
  margin-bottom: 15px;
}

/* 미리보기 컨테이너 */
.preview-container {
  margin-top: 30px;
}

/* 6단계 - 스토리북 스타일 미리보기 */
.preview-scenes-grid {
  display: flex;
  flex-direction: column;
  gap: 40px;
  margin-bottom: 40px;
}

/* 스토리북 씬 아이템 */
.storybook-scene-item {
  background: #f8f9fa;
  border-radius: 20px;
  padding: 30px;
  border: 2px solid #e9ecef;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.storybook-scene-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.15);
  border-color: var(--purple);
}

.storybook-scene-content {
  display: flex;
  align-items: flex-start;
  gap: 30px;
}

.storybook-image-container {
  position: relative;
  flex-shrink: 0;
  width: 320px;
}

.storybook-scene-image {
  width: 100%;
  aspect-ratio: 1/1; /* 1024x1024 비율 (1:1) */
  object-fit: cover;
  border-radius: 15px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  transition: transform 0.2s ease;
}

.storybook-scene-image:hover {
  transform: scale(1.02);
}

.regenerate-overlay-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(118, 75, 162, 0.9);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
  opacity: 0;
  transform: translateY(-5px);
}

.storybook-image-container:hover .regenerate-overlay-btn {
  opacity: 1;
  transform: translateY(0);
}

.regenerate-overlay-btn:hover {
  background: var(--purple);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(118, 75, 162, 0.3);
}

.storybook-scene-text {
  flex: 1;
  padding-left: 10px;
}

.storybook-scene-text h2 {
  color: var(--purple);
  margin: 0 0 20px 0;
  font-size: 1.8em;
  font-weight: 700;
}

.storybook-scene-text p {
  color: #333;
  line-height: 1.8;
  font-size: 1.1em;
  margin: 0;
  text-align: justify;
  font-family: 'Aridadaburi', 'Malgun Gothic', '맑은 고딕', 'Apple SD Gothic Neo', sans-serif;
}

/* 최종 액션 버튼 */
.final-actions {
  text-align: center;
  margin-top: 40px;
  padding-top: 30px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}

.btn-large {
  padding: 15px 40px;
  font-size: 1.1em;
  font-weight: 600;
  min-width: 280px;
}

/* 인쇄업체용 버튼 스타일 */
#generatePrintingPDF {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  border: none;
  color: white;
}

#generatePrintingPDF:hover {
  background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(245, 87, 108, 0.3);
}

/* 반응형 디자인 - 스토리북 스타일 */
@media (max-width: 1024px) {
  .storybook-image-container {
    width: 280px;
  }
  
  .storybook-scene-content {
    gap: 25px;
  }
  
  .storybook-scene-text h2 {
    font-size: 1.6em;
  }
  
  .storybook-scene-text p {
    font-size: 1.05em;
  }
}

@media (max-width: 768px) {
  .storybook-scene-item {
    padding: 20px;
  }
  
  .storybook-scene-content {
    flex-direction: column;
    gap: 20px;
    align-items: center;
  }
  
  .storybook-image-container {
    width: 100%;
    max-width: 300px;
  }
  
  .storybook-scene-text {
    padding-left: 0;
    text-align: center;
  }
  
  .storybook-scene-text h2 {
    font-size: 1.5em;
  }
  
  .storybook-scene-text p {
    font-size: 1em;
    text-align: left;
  }
}

@media (max-width: 480px) {
  .preview-scenes-grid {
    gap: 25px;
  }
  
  .storybook-scene-item {
    padding: 15px;
  }
  
  .storybook-scene-text h2 {
    font-size: 1.3em;
    margin-bottom: 15px;
  }
  
  .storybook-scene-text p {
    font-size: 0.95em;
    line-height: 1.6;
  }
  
  .regenerate-overlay-btn {
    position: static;
    margin-top: 10px;
    opacity: 1;
    transform: none;
    width: 100%;
  }
}

.select-btn {
  padding: 10px 24px;
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95em;
  margin-top: 15px;
  transition: all 0.3s ease;
  font-weight: 500;
}

.select-btn:hover {
  background: #a399d8;
  transform: translateY(-1px);
}

.select-btn.selected {
  background: var(--success-green);
}

.regenerate-btn {
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, #ffffff 0%, #fafbff 100%);
  border: 2px solid var(--purple);
  color: var(--purple);
  border-radius: 50px;
  cursor: pointer;
  font-size: 1em;
  margin-top: 15px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(185, 126, 245, 0.1);
  position: relative;
  overflow: hidden;
}

.regenerate-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s;
}

.regenerate-btn:hover {
  background: var(--button-gradient);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(185, 126, 245, 0.3);
}

.regenerate-btn:hover::before {
  left: 100%;
}

.regenerate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  background: #f5f5f5;
  color: #999;
  border-color: #ddd;
}

.regenerate-btn:disabled:hover {
  transform: none;
  box-shadow: none;
}

/* Basic Service Theme Options */
.basic-theme-option {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 14px 16px !important;
  border: 2px solid var(--border-light) !important;
  border-radius: 12px !important;
  cursor: pointer !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  background: linear-gradient(135deg, #ffffff 0%, #fafbff 100%) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
  position: relative !important;
  overflow: hidden !important;
  min-height: 56px !important;
  margin: 5px !important;
  min-width: 160px !important;
}

.basic-theme-option::before {
  display: none; /* 위쪽 선 제거 */
}

.basic-theme-option:hover {
  border-color: var(--purple) !important;
  background: linear-gradient(135deg, #f8f7ff 0%, #f2f1f9 100%) !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 20px rgba(185, 126, 245, 0.15) !important;
}

.basic-theme-option:hover::before {
  display: none; /* hover 시에도 선 제거 */
}

.basic-theme-option.selected,
.basic-theme-option[style*="background: var(--primary-blue)"] {
  border-color: var(--purple) !important;
  background: linear-gradient(135deg, #f0ebff 0%, #e8e1ff 100%) !important;
  color: var(--dark-purple) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 12px rgba(185, 126, 245, 0.25) !important;
}

.basic-theme-option.selected::before,
.basic-theme-option[style*="background: var(--primary-blue)"]::before {
  display: none; /* 선택된 상태에서도 선 제거 */
}

.theme-emoji {
  font-size: 1.3em !important;
  margin-right: 12px !important;
  filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.1)) !important;
  flex-shrink: 0 !important;
}

/* Step 5 버전2 테마 선택 스타일 */
.theme-selector-title {
  font-size: 1.3em;
  font-weight: 700;
  color: var(--text-dark);
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border-light);
}

.theme-category-section {
  margin-bottom: 28px;
  padding: 20px;
  background: #fafbff;
  border-radius: 12px;
  border: 1px solid var(--border-light);
}

.category-title-step5 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05em;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e0e0e0;
}

.category-title-step5 .category-icon {
  font-size: 1.3em;
}

.theme-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.theme-item-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border: 2px solid var(--border-light);
  border-radius: 10px;
  background: white;
  color: var(--text-dark);
  font-size: 0.95em;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  min-height: 50px;
}

.theme-item-btn:hover:not(:disabled):not(.current) {
  border-color: var(--purple);
  background: linear-gradient(135deg, #f8f7ff 0%, #f2f1f9 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(185, 126, 245, 0.15);
}

.theme-item-btn.selected {
  border-color: var(--purple);
  background: linear-gradient(135deg, #b97ef5 0%, #9d6fe0 100%);
  color: white;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(185, 126, 245, 0.3);
}

.theme-item-btn.current {
  border-color: #ddd;
  background: #f5f5f5;
  color: #999;
  cursor: not-allowed;
  opacity: 0.6;
}

.theme-item-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

@media (max-width: 768px) {
  .theme-list-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
  }

  .theme-item-btn {
    padding: 10px 12px;
    font-size: 0.9em;
    min-height: 44px;
  }

  .theme-category-section {
    padding: 16px;
  }
}

#availableThemes h4 {
  color: var(--dark-purple);
  font-size: 1.1em;
  font-weight: 600;
  margin-bottom: 15px;
  text-align: center;
}

#availableThemes {
  padding: 20px;
  background: linear-gradient(135deg, #f8f7ff 0%, #f2f1f9 100%);
  border-radius: 16px;
  border: 2px solid rgba(185, 126, 245, 0.2);
  margin-bottom: 15px;
}

/* Version 2 Card Container Improvements */
.version-card {
  border: 2px solid var(--border-light);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  background: linear-gradient(135deg, #ffffff 0%, #fafbff 100%);
  transition: all 0.3s ease;
  min-height: 500px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.version-card.selected {
  border: 3px solid var(--purple);
  background: linear-gradient(135deg, #f8f7ff 0%, #f0ebff 100%);
  box-shadow: 0 8px 25px rgba(185, 126, 245, 0.2);
  transform: translateY(-2px);
}

.version-title {
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 20px;
  font-size: 1.2em;
  text-align: center;
}

#storyRegenerateArea {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  padding: 0;
  width: 100%;
}

/* Responsive Design for Version 2 Card */
@media (max-width: 1023px) {
  .comparison-container {
    gap: 20px;
    margin-top: 25px;
  }

  .version-card {
    padding: 20px;
    min-height: 450px;
  }

  .version2-themes {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
  }

  .theme-option {
    padding: 12px 14px;
    min-height: 50px;
  }

  .theme-emoji {
    font-size: 1.2em !important;
    width: 24px;
  }

  .theme-option span {
    font-size: 0.9em;
  }

  #availableThemes {
    padding: 16px;
  }

  .basic-theme-option {
    min-width: 140px !important;
    padding: 12px 14px !important;
    min-height: 50px !important;
  }
}

@media (max-width: 767px) {
  .comparison-container {
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 20px;
  }

  .version-card {
    padding: 18px;
    min-height: 400px;
    border-radius: 12px;
  }

  .version-title {
    font-size: 1.1em;
    margin-bottom: 16px;
  }

  .version2-themes {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .theme-option {
    padding: 12px 16px;
    border-radius: 10px;
    min-height: 48px;
  }

  .theme-emoji {
    font-size: 1.1em !important;
    width: 22px;
    margin-right: 10px !important;
  }

  .theme-option span {
    font-size: 0.85em;
  }

  #availableThemes {
    padding: 14px;
    border-radius: 12px;
  }

  #availableThemes h4 {
    font-size: 1em;
    margin-bottom: 12px;
  }

  .basic-theme-option {
    min-width: 100% !important;
    margin: 3px 0 !important;
    padding: 12px 16px !important;
    min-height: 48px !important;
    border-radius: 10px !important;
  }

  .regenerate-btn {
    padding: 12px 18px;
    font-size: 0.95em;
    margin-top: 12px;
  }

  .selected-theme-display {
    font-size: 0.85em;
    padding: 8px 12px;
    margin-top: 8px;
    border-radius: 6px;
  }
}

@media (max-width: 480px) {
  .version-card {
    padding: 16px;
    min-height: 350px;
    border-radius: 10px;
  }

  .version-title {
    font-size: 1em;
    margin-bottom: 14px;
  }

  .theme-option {
    padding: 10px 12px;
    border-radius: 8px;
    min-height: 44px;
  }

  .theme-emoji {
    font-size: 1em !important;
    width: 20px;
    margin-right: 8px !important;
  }

  .theme-option span {
    font-size: 0.8em;
  }

  #availableThemes {
    padding: 12px;
    border-radius: 10px;
  }

  #availableThemes h4 {
    font-size: 0.95em;
    margin-bottom: 10px;
  }

  .basic-theme-option {
    padding: 10px 12px !important;
    min-height: 44px !important;
    border-radius: 8px !important;
  }

  .regenerate-btn {
    padding: 10px 16px;
    font-size: 0.9em;
    margin-top: 10px;
    border-radius: 25px;
  }

  .selected-theme-display {
    font-size: 0.8em;
    padding: 6px 10px;
    margin-top: 6px;
  }
}

/* Hide previous button in Step 3 */
#step3:not(.hidden) ~ .button-group #prevBtn,
body:has(#step3:not(.hidden)) #prevBtn {
  display: none;
}

/* Step 4: Theme Selection - Enhanced Card Style */
.step-main-content {
  max-width: 1400px;
  margin: 0 auto;
}

.age-selector {
  display: flex;
  gap: 30px;
  justify-content: center;
  margin-bottom: 50px;
  padding: 0 20px;
}

.age-card {
  border: 1px solid var(--border-light);
  border-radius: 24px;
  padding: 30px 25px;
  background: linear-gradient(135deg, #fdf5e3 0%, #f9f0dc 100%);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  min-width: 180px;
  box-shadow: 0px 6px 16px rgba(0, 0, 0, 0.08), inset -4px 4px 8px rgba(255, 255, 255, 0.4);
  position: relative;
  overflow: hidden;
}

.age-card:hover {
  transform: translateY(-2px);
  box-shadow: 0px 8px 20px rgba(191, 172, 228, 0.15);
}

.age-card.selected {
  box-shadow: 0px 4px 4px #0000001a, inset -4px 4px 4px #ffffff40, 0px 0px 30px 10px var(--shadow-gold);
  transform: translateY(-1px);
}

.age-emoji {
  font-size: 2.8em;
  margin-bottom: 12px;
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.1));
}

.age-card h3 {
  font-size: 1.3em;
  font-weight: 700;
  color: var(--dark-purple);
  margin: 12px 0 8px 0;
  letter-spacing: -0.02em;
}

.age-card p {
  font-size: 0.95em;
  color: var(--brown);
  margin: 0;
  opacity: 0.8;
}

.keyword-container {
  margin-bottom: 40px;
  padding: 0 20px;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.keyword-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
  margin-top: 30px;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.keyword-card {
  border: 2px solid var(--border-light);
  border-radius: 20px;
  padding: 24px 18px;
  background: linear-gradient(135deg, #fdf5e3 0%, #f9f0dc 100%);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
  color: var(--text-primary);
  box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.08), inset -2px 2px 6px rgba(255, 255, 255, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
  min-height: 120px;
  justify-content: center;
}

.keyword-card:hover {
  transform: translateY(-2px);
  box-shadow: 0px 8px 20px rgba(191, 172, 228, 0.15);
}

.keyword-card.selected {
  box-shadow: 0px 4px 4px #0000001a, inset -4px 4px 4px #ffffff40, 0px 0px 30px 10px #ff5f0340;
  transform: translateY(-1px);
}

.keyword-emoji {
  font-size: 2em;
  margin-bottom: 6px;
  filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.1));
}

.keyword-card span {
  font-size: 1em;
  font-weight: 600;
  color: var(--dark-purple);
  letter-spacing: -0.01em;
  line-height: 1.3;
}

/* Enhanced Keyword Preview Card */
.keyword-preview-card {
  background: linear-gradient(135deg, #f8f3f0 0%, #f2ede0 100%);
  border: 2px solid var(--border-light);
  border-radius: 24px;
  padding: 32px;
  margin: 40px 20px 0;
  box-shadow: 0px 8px 24px rgba(0, 0, 0, 0.08), inset -4px 4px 8px rgba(255, 255, 255, 0.4);
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1), max-height 1.0s cubic-bezier(0.4, 0, 0.2, 1), margin 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px);
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
}

.keyword-preview-card.show {
  opacity: 1;
  transform: translateY(0);
  max-height: 800px; /* 충분히 큰 값으로 설정 */
  margin-top: 40px;
  margin-bottom: 0;
}

.keyword-preview-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--purple), rgba(185, 126, 245, 0.8));
  animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.preview-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 2px solid rgba(240, 230, 214, 0.6);
  position: relative;
}

.selected-keyword-emoji {
  font-size: 2.4em;
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.1));
  animation: float 3s ease-in-out infinite;
}

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

.preview-header h3 {
  font-size: 1.5em;
  font-weight: 700;
  color: var(--dark-purple);
  margin: 0;
  letter-spacing: -0.02em;
}

.preview-content {
  color: var(--text-primary);
  line-height: 1.7;
}

.preview-content p {
  line-height: 1.7;
  margin-bottom: 18px;
  font-size: 1.05em;
}

.preview-content .keyword-lesson {
  font-weight: 600;
  color: var(--brown);
  background: rgba(255, 255, 255, 0.3);
  padding: 12px 16px;
  border-radius: 12px;
  border-left: 4px solid var(--purple);
}

.preview-content .keyword-growth {
  font-style: italic;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.2);
  padding: 12px 16px;
  border-radius: 12px;
  border-left: 4px solid rgba(185, 126, 245, 0.6);
}

.preview-content .keyword-examples {
  background: rgba(255, 255, 255, 0.25);
  padding: 16px 20px;
  border-radius: 12px;
  border-left: 4px solid #ff9b07;
  margin-top: 20px;
}

.preview-content .keyword-examples ul {
  margin: 12px 0 0 0;
  padding-left: 20px;
}

.preview-content .keyword-examples li {
  margin-bottom: 8px;
  color: var(--text-primary);
  font-size: 0.95em;
}

/* Enhanced Character Selection */
.character-selection {
  margin-top: 30px;
  padding: 0 20px;
}

/* Character Selection Card - matching keyword preview card style */
.character-selection {
  background: linear-gradient(135deg, #f8f3f0 0%, #f2ede0 100%);
  border: 2px solid var(--border-light);
  border-radius: 24px;
  padding: 32px;
  margin: 40px 20px 0;
  box-shadow: 0px 8px 24px rgba(0, 0, 0, 0.08), inset -4px 4px 8px rgba(255, 255, 255, 0.4);
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1), max-height 1.0s cubic-bezier(0.4, 0, 0.2, 1), margin 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px);
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
}

.character-selection.show {
  opacity: 1;
  transform: translateY(0);
  max-height: 1000px;
  margin-top: 40px;
  margin-bottom: 0;
}

.character-selection::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--purple), rgba(185, 126, 245, 0.8));
  border-radius: 24px 24px 0 0;
}

.advanced-settings-header {
  background: linear-gradient(135deg, #ffffff 0%, #faf9f7 100%);
  border: 1px solid rgba(185, 126, 245, 0.2);
  border-radius: 16px;
  padding: 20px 24px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0px 4px 12px rgba(185, 126, 245, 0.1);
}

.advanced-settings-header:hover {
  background: linear-gradient(135deg, #f8f7ff 0%, #f2f1f9 100%);
  transform: translateY(-2px);
  box-shadow: 0px 8px 20px rgba(185, 126, 245, 0.15);
}

.advanced-settings-title {
  font-size: 1.2em;
  font-weight: 600;
  color: var(--dark-purple);
  margin: 0;
  letter-spacing: -0.01em;
}

.toggle-icon {
  font-size: 1.2em;
  color: var(--purple);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: bold;
}

.toggle-icon.expanded {
  transform: rotate(180deg);
}

.advanced-settings-content {
  margin-top: 20px;
  padding: 0 24px;
  background: transparent;
  border-radius: 16px;
  max-height: 0;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.advanced-settings-content.expanded {
  max-height: 800px;
  padding: 24px;
}

/* Character Category Styles */
.character-category {
  margin-bottom: 24px;
}

.character-category h4 {
  color: var(--dark-purple);
  font-size: 1.1em;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.character-category h4::before {
  content: '👥';
  font-size: 1.2em;
}

.character-checkbox-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.character-checkbox {
  background: linear-gradient(135deg, #ffffff 0%, #faf9f7 100%);
  border: 2px solid rgba(185, 126, 245, 0.2);
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.character-checkbox::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--purple), rgba(185, 126, 245, 0.8));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.character-checkbox:hover {
  background: linear-gradient(135deg, #f8f7ff 0%, #f2f1f9 100%);
  border-color: rgba(185, 126, 245, 0.4);
  transform: translateY(-2px);
  box-shadow: 0px 8px 20px rgba(185, 126, 245, 0.15);
}

.character-checkbox:hover::before {
  transform: scaleX(1);
}

.character-checkbox.checked {
  background: linear-gradient(135deg, #f0ebff 0%, #e8e1ff 100%);
  border-color: var(--purple);
  color: var(--dark-purple);
}

.character-checkbox.checked::before {
  transform: scaleX(1);
}

.character-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border: 2px solid var(--purple);
  border-radius: 4px;
  background: white;
  cursor: pointer;
  position: relative;
  margin: 0;
}

.character-checkbox input[type="checkbox"]:checked {
  background: var(--purple);
  border-color: var(--purple);
}

.character-checkbox input[type="checkbox"]:checked::after {
  content: '✓';
  color: white;
  font-size: 12px;
  font-weight: bold;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Selected Characters List */
.selected-characters {
  margin-top: 24px;
  padding: 20px;
  background: linear-gradient(135deg, #f8f7ff 0%, #f2f1f9 100%);
  border-radius: 16px;
  border: 1px solid rgba(185, 126, 245, 0.2);
}

.selected-characters h4 {
  color: var(--dark-purple);
  font-size: 1.1em;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.selected-characters h4::before {
  content: '⭐';
  font-size: 1.2em;
}

.character-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.character-item {
  background: white;
  border: 2px solid rgba(185, 126, 245, 0.3);
  border-radius: 20px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9em;
  color: var(--dark-purple);
  box-shadow: 0px 4px 12px rgba(185, 126, 245, 0.1);
}

.character-item button {
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.8em;
  cursor: pointer;
  transition: all 0.3s ease;
}

.character-item button:hover {
  background: var(--dark-purple);
  transform: scale(1.05);
}

/* Theme Select */
.theme-select {
  width: 100%;
  padding: 12px;
  font-size: 1em;
  border: 2px solid var(--border-light);
  border-radius: 8px;
  margin-bottom: 15px;
  background: var(--white);
  color: var(--text-primary);
}

.theme-select:focus {
  outline: none;
  border-color: var(--purple);
}

/* Story Container */
.story-container {
  max-height: 400px;
  overflow-y: auto;
  padding: 20px;
  margin-top: 20px;
  background: var(--white);
  border-radius: 8px;
}

/* Story Meta Tags */
/* 기존 story-meta-tags 스타일 유지 (하위 호환성) */
.story-meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
  justify-content: center;
  align-items: center;
}

/* 새로운 story-theme-display 스타일 */
.story-theme-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 20px 0;
  padding: 16px 24px;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 16px;
  border: 2px solid var(--primary-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.story-theme-display:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.story-theme-display .theme-icon {
  font-size: 24px;
  animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.1); }
}

.story-theme-display .theme-title {
  font-size: 1.1em;
  font-weight: 600;
  color: var(--primary-color);
  letter-spacing: 0.5px;
}

.meta-tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85em;
  font-weight: 500;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px solid var(--border-light);
  color: var(--text-dark);
  white-space: nowrap;
  transition: all 0.2s ease;
}

.meta-tag.age-tag {
  background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
  border-color: #90caf9;
  color: #1565c0;
}

.meta-tag.theme-tag {
  background: linear-gradient(135deg, #f3e5f5 0%, #e1bee7 100%);
  border-color: #ce93d8;
  color: #7b1fa2;
}

.meta-tag.characters-tag {
  background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c8 100%);
  border-color: #a5d6a7;
  color: #2e7d32;
}

.scene-item {
  margin-bottom: 25px;
  padding-bottom: 25px;
  border-bottom: 1px solid var(--border-light);
}

.scene-item:last-child {
  border-bottom: none;
}

.scene-number {
  color: var(--purple);
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 1em;
}

.scene-story {
  line-height: 1.7;
  color: var(--text-primary);
}

/* Progress Bar for Image Generation */
.progress-bar {
  width: 300px;
  height: 20px;
  background: var(--border-light);
  border-radius: 10px;
  overflow: hidden;
  margin: 20px auto;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple), rgba(185, 126, 245, 0.8));
  transition: width 0.3s ease;
}

/* Regenerate Area - Step 3 (캐릭터 재생성) */
#step3 #regenerateArea {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  padding: 20px;
}

/* Responsive Design - 완전히 새로 작성 */

/* 대형 데스크톱 (1440px+) - 기본값 사용 */

/* 중형 데스크톱 및 노트북 (1024px - 1439px) */
@media (max-width: 1439px) {
  .main-title h1 {
    font-size: 100px;
  }
  
  .container {
    max-width: 1200px;
  }
  
  .content-area {
    padding: 40px 20px;
  }
  
  /* 업로드 후 간격 조정 - 일관된 레이아웃 */
  .step-main-content {
    gap: 40px; /* 120px에서 40px로 축소하여 밀착된 레이아웃 */
  }
}

/* 태블릿 (768px - 1023px) */
@media (max-width: 1023px) {
  .main-title h1 {
    font-size: 80px;
  }
  
  .container {
    max-width: 900px;
    padding: 0 15px;
  }
  
  .content-area {
    padding: 30px 15px;
  }
  
  /* Step 정보 섹션 */
  .step-info-section {
    padding: 0 15px;
    gap: 15px;
  }
  
  .step-info-section .step-icon {
    width: 65px;
    height: 65px;
  }
  
  .step-text .step-title {
    font-size: 22px;
  }
  
  .step-text .step-description {
    font-size: 14px;
  }
  
  /* 태블릿 업로드 후 간격 및 크기 조정 - 일관성 유지 */
  .step-main-content {
    gap: 40px; /* 80px에서 40px로 축소하여 일관된 간격 */
  }

  .step-main-content.uploaded .upload-section {
    width: 350px; /* 320px에서 350px로 확대 */
    max-width: 350px;
  }

  .preview-section {
    width: 350px; /* 320px에서 350px로 확대 */
  }
  
  /* 크기 조정 - 비례 유지 */
  .step-main-content.uploaded .upload-circle-wrapper {
    width: 350px; /* 320px에서 350px로 확대 */
    height: 350px;
    border-radius: 175px;
  }

  .step-main-content.uploaded .upload-circle {
    width: 290px; /* 260px에서 290px로 확대 */
    height: 290px;
    border-radius: 145px;
  }
  
  .step-main-content.uploaded .sample-character {
    width: 320px;
    height: 320px;
  }
  
  .preview-box {
    width: 320px;
    height: 320px;
  }
  
  .preview-image-container {
    width: 320px;
    height: 320px;
  }
  
  .step-main-content.uploaded .upload-character-btn,
  .name-input-section {
    width: 350px; /* 320px에서 350px로 변경하여 일관성 유지 */
  }
  
  .step-main-content.uploaded .upload-character-btn {
    height: 55px;
  }
  
  /* 기타 요소들 */
  .style-grid {
    grid-template-columns: 1fr 1fr;
    gap: 15px;
  }
  
  .comparison-container {
    gap: 20px;
  }
  
  /* Step 4 태블릿 반응형 */
  .step-main-content {
    max-width: 1100px;
  }
  
  .age-selector {
    gap: 20px;
    margin-bottom: 35px;
    padding: 0 15px;
  }
  
  .age-card {
    min-width: 150px;
    padding: 24px 20px;
    font-size: 0.95em;
  }
  
  .age-emoji {
    font-size: 2.4em;
  }
  
  .keyword-container {
    padding: 0 15px;
  }
  
  .keyword-group {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 18px;
    max-width: 800px;
  }
  
  .keyword-card {
    padding: 20px 14px;
    min-height: 100px;
  }
  
  .keyword-emoji {
    font-size: 1.8em;
  }
  
  .keyword-card span {
    font-size: 0.9em;
  }
  
  .keyword-preview-card {
    margin: 30px 15px 0;
    padding: 24px 20px;
  }
  
  .preview-header h3 {
    font-size: 1.3em;
  }
  
  .character-selection {
    padding: 0 15px;
  }
}

/* 모바일 (320px - 767px) */
@media (max-width: 767px) {
  .main-title h1 {
    font-size: 60px;
  }
  
  .container {
    margin: 20px auto;
    padding: 0 10px;
  }
  
  .content-area {
    padding: 20px 10px 50px 10px;
    min-height: 600px;
  }
  
  /* Step 정보 섹션 */
  .step-info-section {
    flex-direction: column;
    text-align: center;
    gap: 15px;
    padding: 0 10px;
  }

  .step-info-section .step-icon {
    width: 60px;
    height: 60px;
  }

  .step-text .step-title {
    font-size: 20px;
  }

  .step-text .step-description {
    font-size: 13px;
  }

  /* Step 주의사항 모바일 */
  .step-notice {
    margin-left: 0;
    align-items: center;
    width: 100%;
  }

  .notice-text {
    font-size: 11px;
    text-align: center;
  }

  /* Step 1 모바일 레이아웃 - 간격 조정 */
  .step-main-content {
    gap: 40px;
  }

  .upload-section,
  .step-main-content.uploaded .upload-section {
    width: 100%;
    max-width: 300px;
  }

  .preview-section {
    width: 100%;
    max-width: 300px;
  }
  
  /* 기본 상태 업로드 영역 */
  .upload-circle-wrapper {
    width: 300px;
    height: 300px;
    border-radius: 150px;
  }
  
  .upload-circle {
    width: 240px;
    height: 240px;
    border-radius: 120px;
  }
  
  .sample-character {
    width: 280px;
    height: 280px;
    border-radius: 120px;
  }
  
  /* 업로드 후 상태 */
  .step-main-content.uploaded .upload-circle-wrapper {
    width: 300px;
    height: 300px;
    border-radius: 150px;
  }
  
  .step-main-content.uploaded .upload-circle {
    width: 240px;
    height: 240px;
    border-radius: 120px;
  }
  
  .step-main-content.uploaded .sample-character {
    width: 280px;
    height: 280px;
  }
  
  /* 프리뷰 박스 */
  .preview-box {
    width: 320px;
    height: 320px;
    padding: 20px;
  }
  
  .preview-image-container {
    width: 300px;
    height: 300px;
  }
  
  /* 버튼들 */
  .upload-character-btn {
    max-width: 300px;
    height: 55px;
    font-size: 20px;
  }
  

  .character-name-input {
    height: 55px;
    font-size: 15px;
  }

  .step-main-content.uploaded .upload-character-btn {
    height: 55px;
  }

  /* 이름 입력 섹션 모바일 */
  .name-input-section {
    width: 100%;
    max-width: 300px;
  }

  /* 이름 미리보기 모바일 */
  .name-preview-text {
    font-size: 14px;
    top: calc(100% + 12px); /* 모바일에서는 12px 간격 */
  }
  
  /* 업로드 아이콘 버튼 */
  .upload-icon-btn {
    width: 70px !important;
    height: 70px !important;
    border-radius: 35px !important;
    bottom: 15px !important;
    right: 15px !important;
  }
  
  /* .step-main-content.uploaded .upload-icon-btn 은 위와 동일하므로 삭제 */
  
  .upload-icon-btn img {
    width: 32px !important;
    height: 30px !important;
  }
  
  /* 기타 반응형 요소들 */
  .style-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }
  
  .comparison-container {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  /* Step 4 모바일 반응형 */
  .step-main-content {
    max-width: 100%;
    padding: 0;
  }
  
  .age-selector {
    flex-direction: row;
    gap: 12px;
    margin-bottom: 25px;
    padding: 0 10px;
    justify-content: center;
  }
  
  .age-card {
    min-width: unset;
    width: 100%;
    max-width: 140px;
    flex: 1;
    padding: 18px 12px;
    border-radius: 16px;
  }
  
  .age-emoji {
    font-size: 2.2em;
    margin-bottom: 8px;
  }
  
  .age-card h3 {
    font-size: 1.1em;
    margin: 8px 0 4px 0;
  }
  
  .age-card p {
    font-size: 0.85em;
  }
  
  .keyword-container {
    padding: 0 10px;
    margin-bottom: 25px;
  }
  
  .keyword-group {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 20px;
    max-width: 100%;
  }
  
  .keyword-card {
    padding: 18px 12px;
    min-height: 85px;
    border-radius: 16px;
  }
  
  .keyword-emoji {
    font-size: 1.6em;
    margin-bottom: 4px;
  }
  
  .keyword-card span {
    font-size: 0.85em;
    line-height: 1.2;
  }
  
  .keyword-preview-card {
    margin: 25px 10px 0;
    padding: 20px 16px;
    border-radius: 20px;
  }
  
  .preview-header {
    flex-direction: column;
    text-align: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 16px;
  }
  
  .selected-keyword-emoji {
    font-size: 2em;
  }
  
  .preview-header h3 {
    font-size: 1.2em;
  }
  
  .preview-content p {
    font-size: 0.95em;
    margin-bottom: 14px;
  }
  
  .preview-content .keyword-lesson,
  .preview-content .keyword-growth {
    padding: 10px 12px;
    font-size: 0.9em;
  }
  
  .preview-content .keyword-examples {
    padding: 12px 16px;
    font-size: 0.9em;
  }
  
  .character-selection {
    padding: 0 10px;
  }
  
  .advanced-settings-header {
    padding: 16px 18px;
    border-radius: 14px;
  }
  
  .advanced-settings-title {
    font-size: 1em;
  }
  
  .button-group {
    padding: 0 10px 30px;
  }
  
  .btn {
    min-width: 150px;
    padding: 15px 30px;
    font-size: 18px;
  }
}

/* 서비스 선택 스타일 */
.service-selection {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  max-width: 1000px;
  margin: 0 auto;
}

/* Service Type Selection (A/B Type Buttons) */
.service-type-selection {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 30px;
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
}

.service-type-btn {
  background: var(--white);
  border: 3px solid transparent;
  border-radius: 20px;
  padding: 60px 40px;
  font-size: 2em;
  font-weight: bold;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.service-type-btn:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
  border-color: var(--purple);
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
}

.service-type-btn:active {
  transform: translateY(-2px);
}

.service-card {
  background: var(--white);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  cursor: pointer;
  border: 3px solid transparent;
  position: relative;
  overflow: hidden;
}

.service-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
  border-color: var(--purple);
}

.service-card.selected {
  border-color: var(--purple);
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
}

.service-icon {
  font-size: 3em;
  text-align: center;
  margin-bottom: 20px;
}

.service-title {
  font-size: 1.8em;
  font-weight: bold;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 15px;
}

.service-description {
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 20px;
  font-size: 1.1em;
}

.service-feature-list {
  list-style: none;
  margin-bottom: 25px;
}

.service-feature-list li {
  padding: 8px 0;
  color: var(--text-primary);
  font-size: 0.95em;
}

.service-themes {
  margin-bottom: 25px;
}

.service-themes h4 {
  font-size: 1.1em;
  color: var(--text-primary);
  margin-bottom: 15px;
  text-align: center;
}

.theme-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.theme-tag {
  background: var(--purple-gradient);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8em;
  font-weight: 500;
}

.select-service-btn {
  width: 100%;
  background: var(--button-gradient);
  color: white;
  border: none;
  border-radius: 15px;
  padding: 15px;
  font-size: 1.1em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.select-service-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(185, 126, 245, 0.4);
}

.select-service-btn:active {
  transform: translateY(0);
}

/* 반응형 서비스 선택 */
@media (max-width: 768px) {
  .service-selection {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 0 15px;
  }

  .service-card {
    padding: 25px 20px;
  }

  .service-icon {
    font-size: 2.5em;
  }

  .service-title {
    font-size: 1.5em;
  }

  .theme-tags {
    gap: 6px;
  }

  .theme-tag {
    font-size: 0.75em;
    padding: 5px 10px;
  }
}

/* Advanced Theme Selection Styles */
.advanced-keyword-selection {
  padding: 20px 0;
}

.advanced-themes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 24px;
  padding: 0;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.advanced-theme-card {
  border: 2px solid #e8e8f0;
  border-radius: 24px;
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  background: linear-gradient(135deg, #ffffff 0%, #fafbff 100%);
  height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.advanced-theme-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 32px rgba(124, 95, 240, 0.15);
  border-color: #c799f7;
}

.advanced-theme-card.selected {
  transform: translateY(-2px) scale(1.01);
  border-color: #7c5ff0;
  background: linear-gradient(135deg, #f6f3ff 0%, #ebe6ff 100%);
  box-shadow: 0 8px 24px rgba(124, 95, 240, 0.25),
              0 0 0 4px rgba(124, 95, 240, 0.1);
}

.advanced-theme-emoji {
  font-size: 2.5em;
  margin-bottom: 12px;
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.1));
  line-height: 1;
}

.advanced-theme-title {
  font-size: 1rem;
  font-weight: 700;
  color: #2d1b69;
  line-height: 1.4;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.advanced-theme-lesson {
  font-size: 0.85em;
  color: #6b7280;
  line-height: 1.4;
  font-weight: 500;
  text-align: center;
}


/* Service Type Specific Visibility */
.basic-keyword-selection {
  display: none;
}

.advanced-keyword-selection {
  display: none;
}

/* Show appropriate section based on service type */
body[data-service-type="basic"] .basic-keyword-selection {
  display: block;
}

body[data-service-type="advanced"] .advanced-keyword-selection {
  display: block;
}

/* Category Notice Styling */
.category-notice {
  background: linear-gradient(135deg, #f0f7ff 0%, #e6f1ff 100%);
  border: 2px solid #bdd7ff;
  border-radius: 20px;
  padding: 20px 24px;
  margin-bottom: 24px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.category-notice::before {
  content: '✨';
  position: absolute;
  top: 12px;
  left: 20px;
  font-size: 1.5em;
  opacity: 0.7;
}

.category-notice::after {
  content: '📚';
  position: absolute;
  top: 12px;
  right: 20px;
  font-size: 1.5em;
  opacity: 0.7;
}

.category-notice p {
  color: #4a5568 !important;
  margin-bottom: 0 !important;
  font-size: 1rem !important;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

/* Advanced Character Selection Styles */
.character-category {
  margin-bottom: 24px;
}

.category-title {
  font-size: 1rem;
  font-weight: 700;
  color: #2d1b69;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #e8e8f0;
}

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

.character-option {
  padding: 12px 16px;
  border: 2px solid #e8e8f0;
  border-radius: 16px;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  position: relative;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.character-option:hover {
  border-color: #c799f7;
  background: #fafbff;
  transform: translateY(-2px);
}

.character-option.selected {
  border-color: #7c5ff0;
  background: linear-gradient(135deg, #f6f3ff 0%, #ebe6ff 100%);
  box-shadow: 0 4px 12px rgba(124, 95, 240, 0.2);
}

.character-name {
  font-weight: 600;
  color: #2d1b69;
  font-size: 0.9em;
}

.default-badge {
  background: #7c5ff0;
  color: white;
  font-size: 0.7em;
  padding: 2px 6px;
  border-radius: 8px;
  margin-top: 4px;
  font-weight: 600;
}

.selected-characters {
  margin-top: 20px;
  padding: 16px;
  background: #f8f9ff;
  border-radius: 16px;
  border: 2px solid #e8e8f0;
}

.selected-characters h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #2d1b69;
  margin-bottom: 12px;
}

.selected-character-tag {
  display: inline-block;
  background: #7c5ff0;
  color: white;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: 600;
  margin: 4px 6px 4px 0;
}

/* Responsive Design for Advanced Themes */
@media (max-width: 768px) {
  .advanced-themes-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 20px;
    max-width: 600px;
  }

  .category-notice {
    padding: 16px 20px;
    margin-bottom: 20px;
    border-radius: 16px;
  }

  .category-notice::before,
  .category-notice::after {
    font-size: 1.3em;
    top: 10px;
  }

  .category-notice p {
    font-size: 0.95rem !important;
  }

  .advanced-theme-card {
    padding: 20px 16px;
    height: 140px;
    border-radius: 20px;
  }

  .advanced-theme-emoji {
    font-size: 2.2em;
    margin-bottom: 10px;
  }

  .advanced-theme-title {
    font-size: 0.95em;
    margin-bottom: 6px;
  }

  .advanced-theme-lesson {
    font-size: 0.8em;
  }

  .character-grid {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
  }

  .character-option {
    padding: 10px 12px;
    min-height: 45px;
  }

  .category-title {
    font-size: 0.95rem;
    margin-bottom: 10px;
  }
}

@media (max-width: 480px) {
  .advanced-keyword-selection {
    padding: 16px 0;
  }

  .advanced-themes-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 16px;
    max-width: 400px;
  }

  .category-notice {
    padding: 14px 16px;
    margin-bottom: 16px;
    border-radius: 14px;
  }

  .category-notice::before,
  .category-notice::after {
    font-size: 1.2em;
    top: 8px;
  }

  .category-notice::before {
    left: 14px;
  }

  .category-notice::after {
    right: 14px;
  }

  .category-notice p {
    font-size: 0.9rem !important;
    padding: 0 30px;
  }

  .advanced-theme-card {
    padding: 18px 14px;
    height: 120px;
    border-radius: 18px;
  }

  .advanced-theme-emoji {
    font-size: 2em;
    margin-bottom: 8px;
  }

  .advanced-theme-title {
    font-size: 0.9em;
    margin-bottom: 6px;
  }

  .advanced-theme-lesson {
    font-size: 0.75em;
  }

  .character-grid {
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 8px;
  }

  .character-option {
    padding: 8px 10px;
    min-height: 40px;
    border-radius: 12px;
  }

  .character-name {
    font-size: 0.8em;
  }

  .category-title {
    font-size: 0.9rem;
    margin-bottom: 8px;
  }

  .selected-characters {
    padding: 12px;
    margin-top: 16px;
  }

  .selected-character-tag {
    font-size: 0.8em;
    padding: 4px 8px;
  }
}


/* ========================= */
/* ACCESSIBILITY ENHANCEMENTS */
/* ========================= */

/* Screen Reader Only Content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus Management for Theme Options */
.theme-option:focus,
.basic-theme-option:focus {
  outline: none !important;
  outline-offset: 2px !important;
  z-index: 10 !important;
  position: relative !important;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .theme-option,
  .basic-theme-option {
    border-width: 3px !important;
  }
  
  .theme-option:hover,
  .basic-theme-option:hover {
    border-width: 4px !important;
  }
  
  .theme-option.selected,
  .basic-theme-option.selected,
  .theme-option[style*="background: var(--primary-blue)"],
  .basic-theme-option[style*="background: var(--primary-blue)"] {
    border-width: 4px !important;
    background: #000 !important;
    color: #fff !important;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .theme-option,
  .basic-theme-option,
  .regenerate-btn,
  .version-card {
    transition: none !important;
    animation: none !important;
  }
  
  .theme-option:hover,
  .basic-theme-option:hover {
    transform: none !important;
  }
  
  .theme-option::before,
  .basic-theme-option::before {
    display: none !important;
  }
}


/* Theme option button reset */
.theme-option,
.basic-theme-option {
  font-family: inherit;
  text-align: left;
}

/* Loading state accessibility */
.regenerate-btn[disabled] {
  cursor: not-allowed;
  opacity: 0.6;
}

.regenerate-btn[disabled]:focus {
  outline: 3px solid #999 !important;
  outline-offset: 2px !important;
}


/* Touch Target Size (44px minimum) */
@media (pointer: coarse) {
  .theme-option,
  .basic-theme-option {
    min-height: 44px !important;
    min-width: 44px !important;
  }

  .regenerate-btn {
    min-height: 44px !important;
  }
}

/* 새로운 재생성 UI 스타일 */
.scene-regenerate-section {
  margin-top: 15px;
  padding: 0 15px 15px 15px;
  border-top: 1px solid #f0f0f0;
}

.scene-regenerate-btn {
  width: 100%;
  padding: 12px 20px;
  background: #f8f9fa;
  color: var(--purple);
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 15px;
}

.scene-regenerate-btn:hover {
  background: var(--purple);
  color: white;
  border-color: var(--purple);
  transform: translateY(-1px);
}

.regenerate-input-panel {
  margin-top: 15px;
  padding: 20px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.regenerate-input-panel.hidden {
  display: none;
}

.input-group {
  margin-bottom: 15px;
}

.input-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.9em;
}

.regenerate-input {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 0.9em;
  line-height: 1.4;
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.regenerate-input:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(118, 75, 162, 0.1);
}

.regenerate-input::placeholder {
  color: #999;
  font-style: italic;
}

.input-counter {
  text-align: right;
  margin-top: 5px;
  font-size: 0.8em;
  color: #666;
}

.regenerate-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #e9ecef;
}

/* 이미지 수정 섹션 */
.image-edit-section {
  margin-bottom: 20px;
}

.image-edit-section h4 {
  font-size: 1em;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.edit-status {
  font-size: 0.85em;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
}

.edit-status.available {
  background: #d1fae5;
  color: #065f46;
}

.edit-status.used {
  background: #fee2e2;
  color: #991b1b;
}

.image-edit-section .warning-text {
  display: block;
  font-size: 0.85em;
  color: var(--warning-orange);
  margin-bottom: 10px;
  font-weight: 500;
}

.btn-image-edit {
  width: 100%;
  padding: 12px 20px;
  background: var(--button-gradient);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 10px;
}

.btn-image-edit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(185, 126, 245, 0.4);
}

.btn-image-edit:disabled {
  background: #d1d5db;
  cursor: not-allowed;
  opacity: 0.6;
}

/* 구분선 */
.section-divider {
  height: 1px;
  background: #e9ecef;
  margin: 20px 0;
}

/* 스토리 편집 섹션 */
.story-edit-section h4 {
  font-size: 1em;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.edit-info {
  font-size: 0.85em;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
  background: #dbeafe;
  color: #1e40af;
}

.story-edit-input {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 0.9em;
  line-height: 1.6;
  resize: vertical;
  min-height: 100px;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

.story-edit-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.story-edit-input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
}

.btn-story-save {
  width: 100%;
  padding: 12px 20px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 10px;
}

.btn-story-save:hover:not(:disabled) {
  background: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-story-save:disabled {
  background: #d1d5db;
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-regenerate-cancel,
.btn-regenerate-submit {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-regenerate-cancel {
  background: #e9ecef;
  color: #6c757d;
}

.btn-regenerate-cancel:hover {
  background: #dee2e6;
}

.btn-regenerate-submit {
  background: var(--purple);
  color: white;
}

.btn-regenerate-submit:hover:not(:disabled) {
  background: #5a3c80;
  transform: translateY(-1px);
}

.btn-regenerate-submit:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

/* 애니메이션 키프레임 */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* 모바일 반응형 스타일 */
@media (max-width: 768px) {
  .scene-regenerate-section {
    padding: 0 10px 10px 10px;
  }

  .scene-regenerate-btn {
    font-size: 0.9em;
    padding: 10px 15px;
  }

  .regenerate-input-panel {
    padding: 15px;
  }

  .regenerate-input {
    font-size: 16px; /* iOS 줌 방지 */
  }

  .regenerate-actions {
    flex-direction: column;
    gap: 8px;
  }

  .btn-regenerate-cancel,
  .btn-regenerate-submit {
    width: 100%;
    min-height: 44px;
  }
}

/* 커스텀 주제 작성 기능 */
.custom-theme-card {
  background: linear-gradient(135deg, #fff 0%, #fef9ff 100%);
  border: 2px dashed var(--primary-color);
  border-radius: 20px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0.8;
}

.custom-theme-card:hover {
  opacity: 1;
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(185, 126, 245, 0.2);
  border-color: var(--accent-color);
}

.custom-theme-card .icon {
  font-size: 3em;
  color: var(--primary-color);
  margin-bottom: 15px;
}

.custom-theme-card .title {
  font-size: 1.3em;
  font-weight: bold;
  color: var(--primary-color);
  margin-bottom: 10px;
}

.custom-theme-card .description {
  color: var(--neutral-gray);
  font-size: 0.9em;
  line-height: 1.4;
}

/* 커스텀 주제 입력 폼 */
.custom-theme-form {
  background: white;
  border-radius: 20px;
  padding: 0;
  margin-top: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  border: 2px solid var(--primary-color);
  overflow: hidden;
}

.custom-form-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
  color: white;
  padding: 20px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.custom-form-header h3 {
  margin: 0;
  font-size: 1.4em;
  font-weight: bold;
}

.close-custom-form {
  background: none;
  border: none;
  color: white;
  font-size: 1.5em;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
}

.close-custom-form:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.custom-form-content {
  padding: 30px;
}

.form-group {
  margin-bottom: 25px;
  position: relative;
}

.form-group label {
  display: block;
  font-weight: bold;
  color: var(--text-dark);
  margin-bottom: 8px;
  font-size: 1em;
}

.form-group.required label::after {
  content: " *";
  color: #e74c3c;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 15px;
  border: 2px solid #e0e6ed;
  border-radius: 12px;
  font-size: 1em;
  font-family: inherit;
  resize: vertical;
  transition: all 0.3s ease;
  box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(185, 126, 245, 0.1);
}

.form-group textarea {
  min-height: 80px;
  max-height: 120px;
}

.char-count {
  position: absolute;
  bottom: -20px;
  right: 0;
  font-size: 0.8em;
  color: var(--neutral-gray);
}

.warning-message {
  background: #fff5f5;
  border: 2px solid #fed7d7;
  border-radius: 12px;
  padding: 15px;
  margin: 25px 0;
}

.warning-message p {
  margin: 0;
  color: #c53030;
  font-size: 0.9em;
  line-height: 1.4;
}

.form-buttons {
  display: flex;
  gap: 15px;
  justify-content: flex-end;
  margin-top: 30px;
}

.btn-secondary,
.btn-primary {
  padding: 12px 25px;
  border-radius: 10px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  font-size: 1em;
}

.btn-secondary {
  background: #f7f9fc;
  color: var(--neutral-gray);
  border: 2px solid #e0e6ed;
}

.btn-secondary:hover {
  background: #e9ecef;
}

.btn-primary {
  background: var(--button-gradient);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(185, 126, 245, 0.4);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
  .custom-theme-card {
    padding: 20px;
    min-height: 150px;
  }

  .custom-theme-card .icon {
    font-size: 2.5em;
  }

  .custom-theme-card .title {
    font-size: 1.1em;
  }

  .custom-form-header {
    padding: 15px 20px;
  }

  .custom-form-header h3 {
    font-size: 1.2em;
  }

  .custom-form-content {
    padding: 20px;
  }

  .form-group {
    margin-bottom: 20px;
  }

  .form-buttons {
    flex-direction: column;
  }

  .btn-secondary,
  .btn-primary {
    width: 100%;
  }
}

/* 커스텀 주제 등장인물 선택 */
.character-help {
  color: var(--neutral-gray);
  font-size: 0.9em;
  margin: 5px 0 15px 0;
}

.character-selection-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 15px 0;
}

.character-option {
  cursor: pointer;
}

.character-option input[type="checkbox"] {
  display: none;
}

.character-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 15px 10px;
  border: 2px solid #e0e6ed;
  border-radius: 12px;
  background: white;
  transition: all 0.3s ease;
  min-height: 80px;
}

.character-card:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(185, 126, 245, 0.2);
}

.character-option input:checked + .character-card {
  border-color: var(--primary-color);
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
  color: white;
}

.character-option input:disabled + .character-card {
  opacity: 0.4;
  cursor: not-allowed;
}

.character-option input:disabled + .character-card:hover {
  border-color: #e0e6ed;
  box-shadow: none;
}

.character-emoji {
  font-size: 1.8em;
  margin-bottom: 8px;
  display: block;
}

.character-name {
  font-size: 0.9em;
  font-weight: 600;
  text-align: center;
}

.selection-counter {
  text-align: center;
  color: var(--neutral-gray);
  font-size: 0.9em;
  margin-top: 10px;
}

.selection-counter #character-count {
  color: var(--primary-color);
  font-weight: 600;
}

/* 반응형 등장인물 선택 */
@media (max-width: 768px) {
  .character-selection-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .character-card {
    padding: 12px 8px;
    min-height: 70px;
  }

  .character-emoji {
    font-size: 1.5em;
    margin-bottom: 6px;
  }

  .character-name {
    font-size: 0.8em;
  }
}

/* ==========================================
   3단계 - 재생성 영역 스타일
   ========================================== */

/* 재생성 안내 텍스트 블록 (카드 상단) */
.regenerate-info-block {
  text-align: center;
  margin-bottom: 20px;
  padding: 0;
  width: 100%;
  display: block;
}

.regenerate-title {
  font-size: 1.1em;
  color: #000000;
  font-weight: 700;
  margin: 0 0 5px 0;
  line-height: 1.4;
  text-align: center;
}

.regenerate-subtitle {
  font-size: 0.85em;
  color: #7c3aed;
  font-weight: 500;
  margin: 0;
  line-height: 1.4;
  text-align: center;
}

/* 커스텀 셀렉트 박스 컨테이너 */
.style-select-custom {
  position: relative;
  width: 100%;
  margin-bottom: 15px;
}

/* 셀렉트 디스플레이 (클릭 가능한 영역) */
.select-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #ffffff 0%, #faf5ff 100%);
  border: 2px solid var(--purple);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(185, 126, 245, 0.15);
  user-select: none;
}

.select-display:hover {
  background: linear-gradient(135deg, #faf5ff 0%, #f3e7ff 100%);
  border-color: var(--purple-dark);
  box-shadow: 0 4px 12px rgba(185, 126, 245, 0.25);
  transform: translateY(-1px);
}

.select-display.active {
  border-color: var(--purple-dark);
  box-shadow: 0 0 0 4px rgba(185, 126, 245, 0.2);
}

.selected-text {
  font-size: 1em;
  font-weight: 600;
  color: var(--dark-purple);
  flex: 1;
}

.select-icon {
  color: var(--purple);
  font-size: 0.8em;
  transition: transform 0.3s ease;
}

.select-display.active .select-icon {
  transform: rotate(180deg);
}

/* 드롭다운 옵션 리스트 */
.select-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: white;
  border: 2px solid var(--purple);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(185, 126, 245, 0.3);
  z-index: 1000;
  max-height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.select-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* 각 옵션 아이템 */
.select-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 1px solid #f3e7ff;
}

.select-option:last-child {
  border-bottom: none;
}

.select-option:hover {
  background: linear-gradient(135deg, #faf5ff 0%, #f3e7ff 100%);
}

.select-option.selected {
  background: linear-gradient(135deg, #e9d5ff 0%, #ddd6fe 100%);
}

.option-emoji {
  font-size: 1.3em;
  flex-shrink: 0;
}

.option-text {
  font-size: 0.95em;
  font-weight: 600;
  color: var(--dark-purple);
  flex: 1;
}

/* 재생성 버튼 */
.regenerate-btn {
  width: 100%;
  padding: 14px 24px;
  font-size: 1.05em;
  font-weight: 700;
  color: white;
  background: var(--button-gradient);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(185, 126, 245, 0.3);
}

.regenerate-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(185, 126, 245, 0.4);
  background: linear-gradient(224deg, #d0a4ff 0%, #c68fff 100%);
}

.regenerate-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(185, 126, 245, 0.3);
}

.regenerate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* 반응형 */
@media (max-width: 768px) {
  .regenerate-info-inline {
    font-size: 0.85em;
    margin-bottom: 12px;
  }

  .select-display {
    padding: 12px 14px;
  }

  .selected-text {
    font-size: 0.95em;
  }

  .select-option {
    padding: 12px 14px;
  }

  .option-text {
    font-size: 0.9em;
  }

  .regenerate-btn {
    padding: 12px 20px;
    font-size: 1em;
  }
}

/* ==========================================
   Step 4 - 새로운 카테고리 및 테마 선택 UI
   ========================================== */

/* ========================================
   Step 4: 주제 선택 - 새로운 디자인
   ======================================== */

/* 카테고리 탭 섹션 */
.category-tabs {
  margin-bottom: 30px;
  background: linear-gradient(135deg, #fff5f7 0%, #ffe4e9 100%);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(255, 105, 135, 0.1);
}

.category-tabs-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  max-width: 100%;
}

/* 카테고리 탭 버튼 */
.category-tab {
  background: white;
  border: 3px solid transparent;
  border-radius: 16px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.category-tab::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 105, 135, 0.05) 0%, rgba(255, 182, 193, 0.05) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.category-tab:hover::before {
  opacity: 1;
}

.category-tab:hover {
  border-color: #ffb6c1;
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(255, 105, 135, 0.2);
}

.category-tab.active {
  border-color: #ff6987;
  background: linear-gradient(135deg, #fff0f3 0%, #ffe4e9 100%);
  box-shadow: 0 4px 16px rgba(255, 105, 135, 0.3);
  transform: translateY(-2px);
}

.category-tab-icon {
  font-size: 2.5em;
  display: block;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.05));
}

.category-tab-title {
  font-size: 1.1em;
  color: #2d2d2d;
  margin: 0;
  font-weight: 700;
  position: relative;
  z-index: 1;
}

.category-tab.active .category-tab-title {
  color: #ff6987;
}


/* ========================================
   OLD STEP 4 STYLES REMOVED
   Now using step4-new.css (imported at line 16)
   Removed to prevent conflicts with new design
   ======================================== */

/* ========================================
   Image Modal (확대 이미지 모달)
   ======================================== */
.image-modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 30px;
  right: 50px;
  color: white;
  font-size: 50px;
  font-weight: 300;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 10000;
  line-height: 1;
  user-select: none;
}

.modal-close:hover {
  color: var(--purple);
  transform: rotate(90deg);
}

.modal-content {
  margin: auto;
  display: block;
  max-width: 90%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 20px;
  box-shadow: 0 0 50px rgba(185, 126, 245, 0.5);
  animation: zoomIn 0.3s ease;
}

@keyframes zoomIn {
  from {
    transform: scale(0.5);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* 이미지에 확대 커서 표시 */
.storybook-scene-image {
  cursor: zoom-in !important;
  transition: transform 0.2s ease;
}

.storybook-scene-image:hover {
  transform: scale(1.02);
}

/* 모바일 대응 */
@media screen and (max-width: 768px) {
  .modal-close {
    top: 20px;
    right: 20px;
    font-size: 40px;
  }

  .modal-content {
    max-width: 95%;
    max-height: 85vh;
  }
}
