* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background: #090909;
  color: #f5f5f5;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px;
}

h1 {
  font-size: 28px;
  margin-bottom: 6px;
}

h2 {
  margin-top: 0;
}

.sub {
  color: #aaa;
  margin-bottom: 20px;
}

.card {
  background: #151515;
  border: 1px solid #2a2a2a;
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.video-card {
  border-color: #b00020;
}

.audio-card {
  border-color: #444;
}

.sync-card {
  border-color: #3a3a3a;
}

.sync-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sync-box {
  background: #202020;
  border: 1px solid #303030;
  border-radius: 14px;
  padding: 12px;
}

.sync-box strong {
  display: block;
  color: #aaa;
  font-size: 13px;
  margin-bottom: 6px;
}

.sync-box span {
  font-size: 22px;
  font-weight: 900;
  color: #fff;
}


.label {
  display: block;
  margin-top: 12px;
  font-size: 14px;
  color: #cfcfcf;
}

input,
textarea,
button,
select {
  width: 100%;
  margin-top: 10px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
}

input,
textarea,
select {
  padding: 12px;
  background: #222;
  color: white;
  outline: none;
  border: 1px solid #333;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #b00020;
}

textarea {
  min-height: 90px;
  resize: vertical;
  line-height: 1.5;
}

audio {
  display: none;
  width: 100%;
  margin-top: 12px;
}

button {
  padding: 14px;
  background: #b00020;
  color: white;
  font-weight: bold;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button:active {
  transform: scale(0.98);
}

.secondary {
  background: #2d2d2d;
}

.danger {
  background: #333;
}

.record-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.status {
  margin: 10px 0 0;
  color: #aaa;
  font-size: 13px;
  line-height: 1.4;
}

.recording {
  color: #ff4b4b;
  font-weight: 800;
}

.preview {
  width: 100%;
  aspect-ratio: 9 / 16;
  background: #000;
  border-radius: 18px;
  overflow: hidden;
  position: relative;
  border: 1px solid #333;
}

.preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: zoom 6s ease-in-out infinite alternate;
}

.caption {
  position: absolute;
  left: 16px;
  right: 16px;
  z-index: 2;
  text-align: center;
  line-height: 1.35;
  text-shadow: 0 2px 8px rgba(0,0,0,0.85);
}

.caption.darkBox {
  bottom: 40px;
  padding: 12px;
  background: rgba(0,0,0,0.68);
  color: white;
  font-size: 22px;
  font-weight: 800;
  border-radius: 12px;
}

.caption.horrorRed {
  bottom: 52px;
  padding: 8px;
  background: rgba(0,0,0,0.35);
  color: #ff2b2b;
  font-size: 26px;
  font-weight: 900;
  border-radius: 10px;
  text-shadow: 0 0 10px rgba(255, 0, 0, 0.75), 0 2px 8px rgba(0,0,0,0.95);
}

.caption.bigWhite {
  bottom: 70px;
  padding: 8px;
  background: transparent;
  color: white;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.5px;
  text-shadow:
    0 3px 8px rgba(0,0,0,0.95),
    2px 2px 0 rgba(0,0,0,0.85),
    -2px 2px 0 rgba(0,0,0,0.85),
    2px -2px 0 rgba(0,0,0,0.85),
    -2px -2px 0 rgba(0,0,0,0.85);
}

.caption.smallBottom {
  bottom: 24px;
  padding: 8px 10px;
  background: rgba(0,0,0,0.62);
  color: #f5f5f5;
  font-size: 17px;
  font-weight: 700;
  border-radius: 10px;
}

.scene-meta {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.65);
  font-size: 13px;
  color: #eee;
  z-index: 2;
}

.empty {
  color: #777;
  text-align: center;
  padding-top: 60%;
}

.preview-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.scene-item {
  background: #202020;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid #303030;
}

.scene-item.active {
  border-color: #b00020;
  box-shadow: 0 0 0 1px rgba(176, 0, 32, 0.5);
}

.scene-item img {
  width: 100%;
  border-radius: 12px;
  margin-top: 8px;
}

.scene-item h3 {
  margin: 4px 0 8px;
}

.scene-item p {
  color: #ddd;
  line-height: 1.5;
  white-space: pre-wrap;
}

.scene-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.scene-order-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.hint {
  color: #aaa;
  font-size: 14px;
  line-height: 1.5;
}

#videoPreview {
  display: none;
  width: 100%;
  margin-top: 12px;
  border-radius: 16px;
  background: #000;
}

#videoCanvas {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #222;
  color: #fff;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid #444;
  z-index: 99;
  max-width: 90%;
  text-align: center;
}

@keyframes zoom {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}


.edit-scene-box {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  background: #181818;
  border: 1px solid #333;
}

.edit-scene-box input,
.edit-scene-box textarea {
  margin-top: 8px;
}

.edit-scene-box textarea {
  min-height: 76px;
}

.edit-save-btn {
  margin-top: 12px;
}


.bgm-card {
  border-color: #3b2f4a;
}

#bgmVolumeRange {
  accent-color: #b00020;
}

#bgmPreview {
  display: none;
  width: 100%;
  margin-top: 12px;
}


.volume-number-row {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 8px;
  align-items: center;
}

.volume-number-row span {
  margin-top: 10px;
  color: #ddd;
  font-weight: 800;
  text-align: center;
}


.project-card {
  border-color: #2f3b4a;
}

.project-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}


.thumbnail-card {
  border-color: #4a2f2f;
}

#thumbnailCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  margin-top: 12px;
  border-radius: 18px;
  background: #000;
  border: 1px solid #333;
}


#thumbnailOffsetRange {
  accent-color: #b00020;
}


.thumb-editor-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.thumb-color-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.thumb-color-grid input[type="color"] {
  width: 100%;
  height: 48px;
  padding: 6px;
  background: #222;
  border: 1px solid #333;
}

#thumbnailFontSizeRange,
#thumbnailXRange,
#thumbnailYRange,
#thumbnailOutlineWidthRange,
#thumbnailBgOpacityRange {
  accent-color: #b00020;
}


#thumbnailCanvas {
  touch-action: none;
  cursor: grab;
}

#thumbnailCanvas.dragging {
  cursor: grabbing;
  border-color: #b00020;
  box-shadow: 0 0 0 2px rgba(176, 0, 32, 0.45);
}


.upload-card {
  border-color: #2f4a3a;
}

.upload-card textarea {
  min-height: 74px;
}


.backup-card {
  border-color: #4a3f2f;
}


.layout-card {
  border-color: #3d334d;
}

.layout-card textarea {
  min-height: 86px;
}

.layout-card input,
.layout-card select,
.layout-card textarea {
  margin-bottom: 8px;
}


#videoTitleRedInput {
  min-height: 72px;
}


.narration-helper-card {
  border-color: #2f3f4a;
}

.narration-helper-card textarea {
  min-height: 130px;
}


#ttsScriptTextInput {
  min-height: 150px;
}


#ttsTimingStatusText {
  color: #d8d8d8;
}


.tts-api-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #333;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.tts-api-box h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.tts-api-box textarea {
  min-height: 92px;
}

#generatedTtsPreview {
  display: none;
  width: 100%;
  margin-top: 10px;
}


#ttsRateSelect,
#ttsPitchSelect {
  margin-bottom: 8px;
}

#ttsTailTrimSelect,
#sceneTransitionSelect {
  margin-bottom: 8px;
}


.hidden-field {
  display: none !important;
}

.caption {
  white-space: pre-wrap;
  transition: all 0.25s ease;
}

.caption.customCaption {
  right: auto;
  bottom: auto;
  box-sizing: border-box;
}

#captionFontSizeRange,
#captionXRange,
#captionYRange,
#captionLineHeightRange,
#captionMaxWidthRange,
#captionOutlineWidthRange,
#captionBgOpacityRange {
  accent-color: #b00020;
}

#captionTextColorInput,
#captionOutlineColorInput {
  width: 100%;
  height: 48px;
  padding: 6px;
  background: #222;
  border: 1px solid #333;
}

.preview img {
  transition: opacity 0.45s ease, transform 0.45s ease;
}


/* ===== 자동 대본 생성 카드 ===== */
.auto-script-card {
  border-color: #2f4a4a;
}

/* ===== 장면 목록 - 이미지 검색어 메모 ===== */
.image-query-box {
  margin-top: 10px;
  padding: 10px 12px;
  background: #16241f;
  border: 1px solid #2c4a3c;
  border-radius: 12px;
}

.image-query-box .query-label {
  display: block;
  font-size: 12px;
  color: #7fd0a8;
  margin-bottom: 6px;
  font-weight: 700;
}

.image-query-box .query-text {
  color: #d8f5e6;
  font-size: 14px;
  word-break: break-word;
}

.image-query-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.image-query-actions a,
.image-query-actions button {
  display: block;
  text-align: center;
  text-decoration: none;
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  background: #245c44;
  color: #eafff3;
  border: none;
  margin-top: 0;
  cursor: pointer;
}

.image-query-actions a:active,
.image-query-actions button:active {
  transform: scale(0.98);
}

.scene-needs-image {
  border-color: #245c44;
}

/* ===== v47 화면 줄이기: 카드 열기/접기 ===== */
.global-collapse-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin: 14px 0 18px;
}

.global-collapse-actions button {
  padding: 11px 8px;
  font-size: 13px;
}

.card {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card.collapsible-card {
  padding: 0;
  overflow: hidden;
}

.card-header-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.card-header-toggle h2 {
  flex: 1;
  margin: 0;
  font-size: 22px;
}

.card-toggle-btn {
  width: auto;
  min-width: 74px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 999px;
  background: #2b2b2b;
  color: #eee;
  font-size: 13px;
  font-weight: 800;
}

.card-body {
  padding: 0 16px 16px;
}

.card.collapsed .card-body {
  display: none;
}

.card.collapsed {
  opacity: 0.96;
}

.card.collapsed .card-header-toggle {
  border-bottom: none;
}

.card.collapsed .card-toggle-btn {
  background: #b00020;
}

.card.is-core-card .card-header-toggle h2::after {
  content: "  · 핵심";
  color: #7fd0a8;
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 420px) {
  .global-collapse-actions {
    grid-template-columns: 1fr;
  }

  .card-toggle-btn {
    min-width: 66px;
    font-size: 12px;
  }
}

.card.collapsed > .card-body {
  display: none !important;
}
