/* 휴대폰 편집기 다듬기 (2026-11-22)
 * - 세부 편집·저장·발행은 편집기를 짓누르지 않고 위에 덮는 시트로
 * - 빈 화면 정리, 트랙 이름 칸 축소, 분석 줄이 화면을 밀지 않게
 * - 위쪽은 로고 대신 '영상 편집기' 제목, 주 버튼은 제작 화면과 같은 밝은 흰색
 * - '내 영상으로 쇼츠 만들기'에서 편집기를 띄우는 창 */

/* 공통: 주 버튼은 밝은 흰색 */
.primary { background: #ededed; color: #141415; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5); }
.primary:disabled { opacity: .35; }
#download { background: #2a2b30; color: #ededed; }
.me-title { display: none; }

/* 쇼츠 화면 → 편집기 창 */
dialog.ar-video-editor { position: fixed; inset: 0; width: 100%; max-width: none; height: 100dvh; max-height: none; padding: 0; margin: 0; border: 0; background: #101113; }
dialog.ar-video-editor iframe { display: block; width: 100%; height: 100%; border: 0; }
.shorts-handoff #openInEditor { margin-top: 16px; }
.shorts-handoff #openInEditor + #save { background: #2a2b30; color: #ededed; box-shadow: none; margin-top: 8px; }
.shorts-handoff #editor { display: none !important; }

/* ── 편집기 모드 ── */
/* 위쪽: 로고 대신 제목, 오른쪽 '저장·발행' */
.quick-video header { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; }
.quick-video header b { display: none; }
.quick-video .me-title { display: block; margin: 0; text-align: center; font-size: 15px; font-weight: 600; color: #ededed; letter-spacing: -0.01em; }
#mixPublish, #mixDone { background: #ededed; color: #141415; border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 600; }
#mixPublish:disabled { opacity: .35; }
/* 영상이 없을 때는 저장·발행과 닫기 버튼을 숨김 */
.quick-video:not(:has(#cutTimeline.has-media)) #mixPublish { visibility: hidden; }
.quick-video:not(.show-tools) #mixHideTools { display: none; }
.quick-video:not(:has(#cutTimeline.has-media)) #trackClips:empty::after {
  content: '영상을 추가하면 여기에 컷이 놓여요'; display: flex; align-items: center; height: 100%; padding: 0 10px;
  color: #85858b; font-size: 12px;
}

/* 세부 편집·저장·발행: 편집기 아래에 나란히 (타임라인도 계속 만질 수 있게)
   미리보기가 너무 작아지지 않게 최소 높이를 두고, 타임라인과 시트가 남은 높이를 나눔 */
.quick-video.show-tools main:has(#work:not([hidden])) { grid-template-rows: 42px minmax(190px, 1fr) auto minmax(170px, 36dvh); }
.quick-video.show-tools #cutTimeline { max-height: 30dvh; }
.quick-video.show-tools .sheet {
  padding: 0 16px max(20px, env(safe-area-inset-bottom));
  border-radius: 16px 16px 0 0; border-top: 1px solid #34363c; background: #17181c;
}
/* '닫기'는 시트 맨 위 자기 줄에 (저장 버튼을 덮지 않게) */
.quick-video #mixHideTools {
  position: sticky; top: 0; z-index: 3; float: none; display: block; width: fit-content; margin: 0 0 6px auto;
  border-radius: 0 0 10px 10px; padding: 6px 14px; background: #2a2b30; color: #ededed; font-size: 13px;
}
/* 세부 편집 안의 옛 자르기 버튼 줄: 잘려 보이지 않게 한 줄로 정돈 */
.quick-video #editSettings #trackTools { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.quick-video #editSettings #trackTools button { min-height: 36px; padding: 6px 12px; border: 0; border-radius: 8px; background: #2a2b30; color: #ededed; font-size: 13px; }
.quick-video #editSettings #trackTools button:disabled { opacity: .35; }
/* 발행으로 열었을 때는 저장·발행만, 세부 편집으로 열었을 때는 편집 항목 먼저 */
.quick-video[data-tools="publish"] #editSettings { display: none; }
.quick-video[data-tools="publish"] #status { margin-bottom: 4px; }

/* 트랙 이름 칸: 아이콘 위·이름 아래로 좁게 */
.quick-video #cutTimeline { --label: 56px; }
.quick-video .mix-label { flex-direction: column; justify-content: center; gap: 3px; padding: 0 2px; font-size: 10.5px; text-align: center; letter-spacing: -0.03em; }
.quick-video .mix-label .mix-icon { width: 18px; height: 18px; }
.quick-video .mix-label[aria-pressed=true] { box-shadow: inset 2px 0 0 #ededed; }

/* 분석 진행 줄: 끼었다 빠지며 트랙을 밀지 않게 눈금 위에 겹쳐 표시 */
.quick-video #cutTimeline.has-media { position: relative; }
.quick-video #analysisInfo {
  position: absolute; top: 48px; right: 8px; z-index: 4; min-height: 0;
  padding: 3px 10px; border-radius: 999px; background: rgba(23, 24, 28, .92); box-shadow: inset 0 0 0 1px #34363c;
}

/* 효과 창: 탭 강조색을 파랑 대신 흰색 */
.fx-tabs button[aria-pressed=true] { color: #ededed; border-color: #ededed; }

/* 시작 시간 옆 '지금 재생 위치로' */
#mixOptions .mix-now { margin-top: 6px; padding: 6px 10px; border: 0; border-radius: 8px; background: #2a2b30; color: #ededed; font: inherit; font-size: 12px; }

/* 쇼츠 화면 '적용' 버튼 글자가 꺾이지 않게 */
.guide-row button { white-space: nowrap; flex: none; }

/* 꺼진 도구: 흐리게 보이되 누르면 이유 안내 */
#mixActions button.is-off { opacity: .35; }
#mixHint {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 40;
  width: max-content; max-width: calc(100% - 32px); margin: 0; padding: 10px 14px; border-radius: 12px;
  background: #ededed; color: #141415; font-size: 13px; font-weight: 500; line-height: 1.45; text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  opacity: 0; transform: translate(-50%, 8px); pointer-events: none; transition: opacity 180ms ease, transform 180ms ease;
}
#mixHint.show { opacity: 1; transform: translate(-50%, 0); }

/* 세부 편집: 편집기에만 있는 항목을 먼저, 트랙에도 있는 소리·속도는 아래 한데 모아 표시 */
.quick-video #quickControls:not([hidden]) { display: flex; flex-direction: column; }
.quick-video #quickControls > * { order: 1; }
.quick-video #quickControls > :is(label[for=speed], #speed, .toggle:has(#sourceSound), label[for=music], #music) { order: 3; }
.quick-video #quickControls > :is(label[for=captionStyle], #captionStyle) { order: 2; }
.quick-video #quickControls > label[for=speed]::before {
  content: '트랙에서도 바꿀 수 있는 설정'; display: block; margin: 18px 0 10px; padding-top: 14px;
  border-top: 1px solid #2c2d33; color: #85858b; font-size: 12px; font-weight: 500;
}

/* ── 편집기다운 타임라인 (2026-11-22) ──
 * 0초가 왼쪽 끝에서 바로 시작하고, 눈금 클릭·드래그로 재생선을 이동, 트랙은 가로 스크롤로 탐색. */
#cutTimeline.has-media .mix-scroll { display: flex; padding-inline: 12px 35%; scrollbar-width: thin; touch-action: pan-x pan-y; cursor: grab; }
.quick-video #cutTimeline.has-media .track-board { flex: none; min-width: 0; position: relative; background: transparent; }
.quick-video #trackCursor { pointer-events: none; }
.quick-video .track-ruler { cursor: pointer; }
/* 재생선: 굵은 흰 선 + 위쪽 손잡이 */
.quick-video #trackNeedle { top: 4px; width: 2px; margin-left: -1px; z-index: 5; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .35); }
.quick-video #trackNeedle::before { top: -1px; left: -5px; width: 12px; height: 10px; border-radius: 2px 2px 0 0; }
/* 클립: 필름처럼 둥근 테두리와 이음새, 고른 클립은 흰 테두리 */
.quick-video #trackClips { background: transparent; }
.quick-video #trackClips button { border-radius: 6px; overflow: hidden; }
.quick-video #trackClips button[aria-pressed=true] { border-color: #fff; }
/* 원본 소리: 파형을 줄 가득, 밝게 */
#sourceLane:has(canvas:not([hidden])) { background: #0c2a2a; border-radius: 6px; }
.quick-video #sourceLane { height: calc(var(--lane) - 6px); }

/* 스튜디오 테마 입히기: 저장·발행 시트에서 저장 버튼 바로 아래 */
#applyTheme { display: block; width: 100%; margin-top: 8px; min-height: 46px; border: 1px solid #3a3b42; border-radius: 12px; background: #1f2025; color: #ededed; font: inherit; font-size: 15px; font-weight: 600; }
#applyTheme:disabled { opacity: .45; }
#applyTheme[hidden] { display: none; }
.quick-video:not(:has(#cutTimeline.has-media)) #applyTheme { display: none; }

.quick-video #headerStudioEdit { border: 1px solid #3b82f6; background: #132038; color: #bfdbfe; border-radius: 7px; padding: 5px 9px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; white-space: nowrap; }

/* 영상은 상단에 그대로 두고 하단 절반에서 목록·타임라인·편집 도구를 바꾼다. */
body:has(#work:not([hidden])) #shortsScreen:has(#frame.loaded) {
  display: grid; grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 42px minmax(0, calc(50dvh - 42px)) minmax(0, 1fr);
  height: 100dvh; min-height: 0; overflow: hidden;
}
#shortsScreen:has(#frame.loaded) > header { grid-row: 1; }
#shortsScreen:has(#frame.loaded) > .stage {
  grid-area: 2 / 1; position: relative; min-height: 0; padding: 4px 0 8px;
  background: #090a0c; container-type: size; overflow: hidden;
}
#shortsScreen .stage #frame.loaded {
  width: min(calc(100cqw - 94px), 56.25cqh); height: auto; max-height: none; border-radius: 8px;
}
.shorts-preview-actions {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: grid; justify-items: center; gap: 7px;
}
.stage:not(:has(#play:not([hidden]))) .shorts-preview-actions { display: none; }
.shorts-preview-actions button, .quick-video .shorts-preview-actions #headerStudioEdit {
  position: static; width: 42px; height: 40px; margin: 0; padding: 0;
  border: 1px solid #41454c; border-radius: 9px; color: #eee; background: #1b1c20;
}
.shorts-preview-actions #play { position: static; width: 42px; height: 40px; border-radius: 9px; }
#shortsRewind { font-size: 20px; }
#shortsScreen:has(#frame.loaded) > :is(.sheet, #cutTimeline) {
  grid-area: 3 / 1; min-height: 0; height: 100%; max-height: none !important;
  position: relative; inset: auto; border-radius: 16px 16px 0 0;
  background: #17181c; border-top: 1px solid #34363c;
}
#shortsScreen:has(#frame.loaded) > .sheet { overflow: auto; overscroll-behavior: contain; }
.quick-video.show-tools #shortsScreen:has(#frame.loaded) > #cutTimeline { visibility: hidden; }
.quick-video #shortsScreen .sheet .handle { display: block; }
#shortsScreen .sheet .handle, #cutTimeline.has-media::before, #mixDialog::before {
  display: block; flex: none; width: 36px; height: 4px; border-radius: 8px;
  margin: 9px auto; background: #85858b;
}
#cutTimeline.has-media::before, #mixDialog::before { content: ''; }
#shortsScreen .sheet .handle, #mixDialog::before { position: sticky; top: 4px; z-index: 4; }
.quick-video #mixDialog {
  position: fixed; z-index: 30; inset: auto 0 0; margin: 0 auto;
  width: min(100%, 540px); max-width: 100%; height: 50dvh; max-height: 50dvh;
  padding: 0 14px max(12px, env(safe-area-inset-bottom)); box-sizing: border-box;
  overflow: auto; overscroll-behavior: contain; border-radius: 16px 16px 0 0;
}

@media (min-width:1024px) {
  body #shortsScreen, body:has(#work:not([hidden])) #shortsScreen:has(#frame.loaded) {
    display: grid; grid-template-columns: minmax(300px, 5fr) minmax(0, 7fr);
    grid-template-rows: auto minmax(0,1fr); width: min(100%, 1360px); max-width: none; height: 100dvh; overflow: hidden;
  }
  #shortsScreen > header { grid-column: 1 / -1; grid-row: 1; }
  #shortsScreen > .stage, #shortsScreen:has(#frame.loaded) > .stage {
    grid-area: 2 / 1; position: relative; inset: auto; height: 100%; min-height: 0; container-type: size; padding: 16px; align-self: start;
  }
  #shortsScreen .stage #frame { height: auto; width: min(calc(100cqw - 84px), 56.25cqh); max-height: none; }
  #shortsScreen > .sheet, #shortsScreen > #cutTimeline,
  #shortsScreen:has(#frame.loaded) > :is(.sheet, #cutTimeline) {
    grid-area: 2 / 2; position: relative; inset: auto; align-self: stretch; height: auto;
    max-height: none !important; overflow: auto; border-radius: 0; border: 0; border-left: 1px solid #34363c; box-shadow: none;
  }
  .quick-video.show-tools #shortsScreen > .sheet { z-index: 4; }
  #shortsScreen .sheet .handle, #shortsScreen #cutTimeline::before, .quick-video #mixDialog::before { display: none; }
  .quick-video #mixDialog { inset: 0; margin: auto; height: fit-content; width: min(640px, 90vw); max-height: 85dvh; border-radius: 14px; }
}
