/* Salon AutoCut — 거울 조명(step bulbs) + 포슬린/딥티일 팔레트 */
:root {
  --porcelain: #F3F4F1;
  --card: #FFFFFF;
  --ink: #1E2422;
  --muted: #6B7472;
  --teal: #2E6E64;
  --teal-dark: #205049;
  --foil: #C29245;
  --line: #DDE1DC;
  --danger: #A8433C;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--porcelain);
  color: var(--ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}
h1, h2 { font-family: "Hahmlet", serif; font-weight: 700; margin: 0 0 4px; }
h1 { font-size: 26px; letter-spacing: -0.5px; }

/* 한국어 줄바꿈은 어절(공백) 단위로만 — 글자 중간에서 꺾이는 "깨진 줄" 방지.
   공백 없는 긴 토큰(드래프트 이름 등)은 overflow-wrap이 마지막 안전망으로 끊는다 */
body { word-break: keep-all; overflow-wrap: break-word; }
h2 { font-size: 19px; margin-bottom: 12px; }

header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 26px; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }

/* --- 시그니처: 거울 전구 스텝 레일 --- */
.steps {
  display: flex; gap: 6px; margin-bottom: 30px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 10px 2px;
}
.step {
  flex: 1; display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 13px; padding: 4px 8px;
}
.bulb {
  width: 12px; height: 12px; border-radius: 50%;
  background: #E5E2DA; border: 1px solid #CFCBC0;
  transition: background 0.4s, box-shadow 0.4s;
}
.step.active { color: var(--ink); font-weight: 600; }
.step.active .bulb, .step.done .bulb {
  background: var(--foil); border-color: #A87A2F;
  box-shadow: 0 0 10px rgba(194, 146, 69, 0.55);
}
.step.done { color: var(--muted); }
/* 지나온 단계는 뒤로가기 링크 — 클릭 가능함이 보여야 눌러볼 생각을 한다 */
.step.back { cursor: pointer; border-radius: 8px; }
.step.back:hover { color: var(--ink); background: var(--porcelain); text-decoration: underline; }

section { margin-bottom: 34px; }

/* --- 업로드 --- */
#dropzone {
  background: var(--card); border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 44px 20px; text-align: center; cursor: pointer;
}
#dropzone.dragging { border-color: var(--teal); background: #EEF4F2; }
.dz-title { font-family: "Hahmlet", serif; font-size: 18px; font-weight: 500; margin: 0 0 4px; }
.dz-sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
#file-list { list-style: none; padding: 0; margin: 14px 0; }
#file-list li {
  background: var(--card); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 12px; margin-bottom: 6px; font-size: 13.5px;
  display: flex; justify-content: space-between;
}
#file-list .size { color: var(--muted); }

/* --- 버튼 --- */
button { font: inherit; cursor: pointer; border-radius: 8px; }
.primary {
  background: var(--teal); color: #fff; border: none; padding: 9px 18px;
}
.primary:hover { background: var(--teal-dark); }
.primary.big { width: 100%; padding: 13px; font-size: 15.5px; margin-top: 14px; }
/* 두 모드 버튼 — 기본(검수) 경로가 위, 빠른 완성이 아래 보조로 */
#start-btns { margin-top: 14px; }
#start-btns .primary.big { margin-top: 0; }
/* .big 버튼은 어디서든 전체 폭 한 줄 — 드래프트 산출물 버튼 3개(zip·mp4·컷모음)가
   폭 규칙 없이 인라인으로 뭉치던 것 정리 (폰 실사용 피드백) */
.ghost.big { display: block; width: 100%; padding: 12px; font-size: 15px; margin-top: 8px; }
#start-btns .hint { margin-top: 6px; }
.primary:disabled { background: #9DB3AD; cursor: default; }
.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--ink); padding: 7px 14px;
}
.ghost:hover { border-color: var(--muted); }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--teal); outline-offset: 2px;
}

/* --- 진행 --- */
.progress-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 40px; text-align: center;
}
.spinner {
  width: 34px; height: 34px; margin: 0 auto 14px;
  border: 3px solid var(--line); border-top-color: var(--teal);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.5s; } }
#progress-label { color: var(--muted); margin: 0; }

/* --- 전체 화면 잠금 (산출물 생성 중) --- */
#busy-overlay {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(243, 244, 241, 0.78);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
#busy-overlay[hidden] { display: none; }   /* display:flex가 hidden 속성을 이기므로 명시 */
.busy-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 32px; text-align: center; width: 100%; max-width: 380px;
  box-shadow: 0 12px 40px rgba(30, 36, 34, 0.14);
}
#busy-msg { margin: 0; font-weight: 600; font-size: 16px; }

/* --- 빠른 완성 산출물 선택 (폰) — 설명 두 줄짜리 큰 버튼 --- */
.express-opt { white-space: normal; line-height: 1.35; text-align: left; position: relative; }
.express-opt small { display: block; font-size: 12.5px; font-weight: 400; opacity: 0.85; margin-top: 3px; }
.ghost.express-opt small { color: var(--muted); opacity: 1; }
.express-opt.last-pick::after {
  content: "지난번"; position: absolute; top: 8px; right: 10px;
  font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--foil); color: #fff;
}

/* --- 검수 그리드 --- */
.review-head { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.filters button {
  border: 1px solid var(--line); background: var(--card);
  padding: 4px 10px; font-size: 12.5px; border-radius: 999px; color: var(--muted);
}
.filters button.on { border-color: var(--teal); color: var(--teal); font-weight: 600; }

.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px;
}
.seg {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: opacity 0.2s;
}
.seg.off { opacity: 0.38; }
.seg img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: #DDD; }
.seg-body { padding: 8px 10px 10px; }
.seg-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.seg select {
  width: 100%; margin-top: 6px; padding: 4px 6px; font-size: 13px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.seg .toggle {
  margin-top: 6px; width: 100%; padding: 4px; font-size: 12.5px;
  border: 1px solid var(--line); background: #fff; color: var(--muted);
}
.seg .toggle.excluded { color: var(--danger); border-color: var(--danger); }
.q { color: var(--foil); letter-spacing: 1px; }

/* 태그 색 */
.tagchip {
  display: inline-block; font-size: 11.5px; font-weight: 600;
  padding: 1px 8px; border-radius: 999px; color: #fff; background: var(--muted);
}
.tag-before  { background: #7A5C9E; }
.tag-after   { background: var(--foil); }
.tag-detail  { background: #A87A2F; }
.tag-cutting, .tag-styling { background: var(--teal); }
.tag-coloring, .tag-perm   { background: #4A6FA5; }
.tag-washing, .tag-drying  { background: #5E8FA0; }
.tag-consult, .tag-shop, .tag-other { background: #8A8F8C; }
.tag-discard { background: var(--danger); }

/* --- 드래프트 폼 --- */
.field-group { margin-bottom: 20px; }
.field-group .label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 8px; }
.field-group label { display: block; font-size: 13.5px; margin-bottom: 8px; }
.field-group.row { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.field-group.row label { margin: 0; }
input[type="text"], input[type="password"], select {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px;
  width: 100%; max-width: 420px; background: #fff; display: block; margin-top: 4px;
}
.check input { margin-right: 6px; }

.tpl-cards { display: flex; gap: 12px; flex-wrap: wrap; }
.tpl-card {
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; flex: 1; min-width: 240px;
}
.tpl-card.selected { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.tpl-card h3 { margin: 0 0 4px; font-size: 15px; }
.tpl-card p { margin: 0; font-size: 12.5px; color: var(--muted); }

#draft-result {
  margin-top: 16px; background: #EEF4F2; border: 1px solid var(--teal);
  border-radius: var(--radius); padding: 16px; font-size: 14px;
}
#draft-result .warn { color: var(--danger); }

/* --- 설정 다이얼로그 --- */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 24px;
  width: min(480px, 92vw);
}
dialog::backdrop { background: rgba(30, 36, 34, 0.4); }
dialog label { display: block; margin-bottom: 14px; font-size: 13.5px; font-weight: 600; }
dialog input, dialog select { max-width: none; font-weight: 400; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

@media (max-width: 560px) {
  .steps { flex-wrap: wrap; }
  .step { flex: 1 1 40%; }
}

/* ---- 컷별 자막 입력 ---- */
.cut-captions { margin: 4px 0 14px; }
.cut-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 6px; font-size: 14px; font-weight: 600;
}
button.ghost.tiny {
  font-size: 12px; padding: 3px 9px; font-weight: 500;
  border-radius: 6px; white-space: nowrap;
}
.cut-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cut-row input { flex: 1; margin: 0; }
.cut-no {
  flex: 0 0 22px; text-align: center; font-size: 12px;
  color: #8A8578; font-variant-numeric: tabular-nums;
}
.cut-tag {
  flex: 0 0 62px; font-size: 12px; color: #8A8578;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---- AI 카피 ---- */
.label-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 8px;
}
.label-row .label { margin-bottom: 0; }
input.ai-filled {
  background: #FBF7EC;
  border-color: #C9A227;
  animation: aiflash 0.6s ease-out;
}
@keyframes aiflash {
  from { background: #F4E4A8; }
  to   { background: #FBF7EC; }
}

/* ---- 최근 작업 ---- */
#recent-jobs { margin-top: 28px; }
#job-list { list-style: none; padding: 0; margin: 0; }
.job-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border: 1px solid #E4DFD3; border-radius: 8px;
  margin-bottom: 8px; background: #FFF;
}
.job-main { flex: 1; min-width: 0; }
.job-name {
  display: block; font-size: 14px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.job-meta { display: block; font-size: 12px; color: #8A8578; margin-top: 2px; }
button.ghost.tiny.danger { color: #A6501E; border-color: #E0C4B4; }

/* ---- 레퍼런스 템플릿 ---- */
.tpl-card { position: relative; }
button.ghost.tiny.tpl-del {
  position: absolute; top: 8px; right: 8px;
  opacity: 0; transition: opacity 0.15s;
}
.tpl-card:hover button.tpl-del,
.tpl-card:focus-within button.tpl-del { opacity: 1; }
#dlg-reference { max-width: 460px; }
#dlg-reference input[type="file"] { font-size: 13px; }

/* 버튼 라벨은 절대 줄바꿈하지 않는다 — "내 작업"이 두 줄이 되면 못 읽는다.
   대신 폭이 모자라면 아래 미디어쿼리에서 햄버거 메뉴로 접는다 */
.header-actions { display: flex; gap: 6px; align-items: center; }
.header-actions .ghost { padding: 6px 10px; font-size: 13px; white-space: nowrap; }
.header-actions #who { white-space: nowrap; }
#btn-menu { display: none; font-size: 18px; padding: 5px 12px; line-height: 1; }

/* 버튼 전부를 한 줄에 못 놓는 폭 — 햄버거로 접는다 (모달식 펼침) */
@media (max-width: 1080px) {
  header { position: relative; }
  #btn-menu { display: inline-block; }
  .header-actions {
    display: none;
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
    flex-direction: column; align-items: stretch;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 10px; box-shadow: 0 10px 28px rgba(40, 36, 26, 0.18); min-width: 200px;
  }
  .header-actions.open { display: flex; }
  .header-actions .ghost { text-align: left; }
  .header-actions #who { padding: 4px 2px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
}

/* ---- 레퍼런스 다이얼로그 ---- */
.mode-tabs { display: flex; gap: 6px; margin: 4px 0 14px; }
.mode-tab {
  flex: 1; padding: 8px; font-size: 14px; border-radius: 8px;
  border: 1px solid #E4DFD3; background: #FAF8F3; cursor: pointer;
}
.mode-tab.on { background: #1F3D34; color: #FFF; border-color: #1F3D34; font-weight: 600; }
.ref-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.ref-row select { flex: 1; margin: 0; min-width: 0; }
.ref-row input[type="number"] { width: 62px; margin: 0; text-align: right; }
.ref-row span { font-size: 12px; color: #8A8578; }

/* ---- 폰트 안내 ---- */
.hint.warn { color: #A6501E; white-space: pre-line; }
#font-help summary { font-size: 13px; cursor: pointer; color: #5A6B60; margin-bottom: 6px; }
#font-help ol { margin: 4px 0 4px 18px; padding: 0; }
#font-help li { margin-bottom: 4px; }
#font-help code {
  font-size: 11px; background: #F2EFE7; padding: 2px 5px;
  border-radius: 4px; word-break: break-all;
}

/* ---- 트렌드 스냅샷 ---- */
#ref-meta summary { font-size: 13px; cursor: pointer; color: #5A6B60; margin: 8px 0; }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.meta-grid label { font-size: 12px; margin: 0; }
.meta-grid input { margin-top: 2px; width: 100%; box-sizing: border-box; }  /* 셀 밖으로 안 넘치게 */
.rank-badge {
  display: inline-block; background: #1F3D34; color: #FFF;
  font-size: 11px; font-weight: 700; padding: 2px 7px;
  border-radius: 5px; margin-right: 6px; vertical-align: middle;
}
.tpl-stats { font-size: 12px; color: #8A7A2E; margin-top: 6px; }

/* ---- 템플릿 추천 (fit 정렬 1등) ---- */
.rec-badge {
  display: inline-block; background: var(--foil); color: #FFF;
  font-size: 11px; font-weight: 700; padding: 2px 7px;
  border-radius: 5px; margin-right: 6px; vertical-align: middle;
}
.tpl-card.recommended { border-color: var(--foil); box-shadow: 0 0 0 1px var(--foil); }
/* 선택 표시가 추천 표시를 이긴다 — 추천 카드를 클릭했는데 금색 그대로면
   "선택이 안 됐나?"로 헷갈린다. 추천임은 ★배지가 계속 말해준다 */
.tpl-card.recommended.selected { border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.tpl-reason { font-size: 12.5px; font-weight: 500; color: var(--teal-dark); margin: 5px 0 0; }

/* ---- 이중 자막 ---- */
.lang-toggle { display: flex; align-items: center; gap: 12px; }
.lang-toggle .check { margin: 0; font-size: 13px; white-space: nowrap; }
.text-field { margin-bottom: 12px; }
.text-field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.lang-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.lang-row input { flex: 1; margin: 0; }
.lang-tag {
  flex: 0 0 52px; font-size: 11px; color: #8A8578;
  text-align: right; white-space: nowrap;
}

/* 템플릿 적합도 — 고르기 전에 이 촬영본으로 만들 수 있는지 보여준다 */
.fit-badge { margin-right: .4rem; font-size: .95em; }
.tpl-card.fit-empty { opacity: .62; }
.tpl-fit {
  margin-top: .35rem; font-size: .78rem; line-height: 1.45;
  color: var(--muted, #8a8a8a);
}
.tpl-fit.partial { color: var(--foil); }
.tpl-fit.empty   { color: var(--danger); }

/* 템플릿 목록 — 촬영 전에 "뭘 찍어야 하나"를 보는 화면 */
dialog.wide { max-width: 720px; width: 92vw; }
.tpl-detail {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: .9rem 1rem; margin-bottom: .8rem; background: var(--card);
}
.tpl-detail h3 { margin: 0 0 .25rem; font-size: 1rem; display: flex;
  align-items: center; gap: .45rem; flex-wrap: wrap; }
.tpl-detail .hint { margin: .2rem 0; }
.src-tag {
  font-size: .68rem; padding: .1rem .4rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); font-weight: 400;
}
.slot-table { width: 100%; border-collapse: collapse; margin: .55rem 0 .35rem; font-size: .8rem; }
.slot-table th {
  text-align: left; font-weight: 500; color: var(--muted);
  border-bottom: 1px solid var(--line); padding: .25rem .4rem;
}
.slot-table td { padding: .3rem .4rem; border-bottom: 1px solid var(--line); }
.slot-table tr:last-child td { border-bottom: 0; }
.slot-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.slot-table .slot-id { font-weight: 500; }
.slot-table .slot-id em { font-weight: 400; color: var(--muted); font-style: normal; }
.slot-table tr.optional { color: var(--muted); }

/* 촬영 가이드(콘티) — 폰 메모로 복사해 촬영장에 들고 가는 체크리스트 */
.tpl-guide {
  margin: .55rem 0 .3rem;
  background: var(--porcelain); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .7rem .9rem .55rem;
}
.tpl-guide pre {
  white-space: pre-wrap; font-family: inherit; font-size: .82rem; line-height: 1.6;
  margin: 0 0 .4rem;
}
.g-head { display: flex; align-items: center; gap: 10px; margin-bottom: .3rem; }
.g-head strong { font-size: .88rem; }
.g-head button { margin-left: auto; }
.g-note { font-size: .74rem; color: var(--muted); margin: .1rem 0; }
.g-item { border-top: 1px solid var(--line); padding: .5rem 0 .45rem; margin-top: .35rem; }
.g-item > label {
  display: flex; gap: 9px; align-items: baseline; cursor: pointer;
  margin: 0; font-size: .84rem; flex-wrap: wrap;
}
.g-item > label input { margin: 0; }
.g-detail { color: var(--muted); font-size: .76rem; }
.g-item.done > label { text-decoration: line-through; opacity: .5; }
.g-sub { margin: .2rem 0 0 27px; font-size: .76rem; color: var(--muted); }
.g-sub label { display: flex; gap: 7px; align-items: baseline; cursor: pointer; margin: 0; }
.g-sub label.done { text-decoration: line-through; opacity: .6; }
/* 원본영상 링크 — 카드 전체가 클릭(펼침)이라, 링크는 호버 시 확실히 다르게 보여야
   "지금 누르면 카드가 아니라 링크"임이 구분된다 */
.sum-link {
  margin-left: auto; font-size: 12px;
  padding: 3px 9px; border-radius: 999px; border: 1px solid transparent;
  transition: background .12s, color .12s;
}
.sum-link:hover {
  background: var(--teal); color: #fff !important;
  border-color: var(--teal); text-decoration: none;
}
/* 링크에 올라가 있는 동안엔 카드 호버 효과(초록 테두리)를 끈다 — 행동이 하나만 강조되게 */
.home-tpl:hover:has(.sum-link:hover) { border-color: var(--line); }
button.tiny.on { background: var(--teal); color: #fff; border-color: var(--teal); }

/* 검수: AI가 자신 없어한 컷 표시 + 평가 셋 */
.unsure {
  display: inline-block; width: 16px; height: 16px; line-height: 16px;
  text-align: center; border-radius: 50%; margin-left: 4px;
  background: var(--danger); color: #FFF; font-size: 11px; font-weight: 700;
}
#sort-unsure-wrap {
  font-size: 13px; margin-top: 6px;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
#sort-unsure-wrap .check { margin: 0; white-space: nowrap; }
#unsure-note { font-size: 12px; }
#btn-evalset { margin-left: 10px; }
#evalset-status { margin-top: 6px; }

/* 검수 카드의 구도 표시 — 같은 태그라도 구도가 다르면 다른 컷이다 */
.seg-look { font-size: .7rem; color: var(--muted); margin: .1rem 0 .25rem; }
/* 동작(AI)·움직임(ffmpeg) — 시술 컷에만. 매칭이 품질보다 먼저 보는 값이라 검수에서 같이 보인다 */
.seg-act { display: flex; align-items: center; gap: 6px; font-size: .7rem; margin: 0 0 .3rem; flex-wrap: wrap; }
.act-chip {
  font-size: .68rem; padding: 1px 7px; border-radius: 999px; border: 1px solid transparent;
  cursor: pointer; line-height: 1.5; font-family: inherit;
}
.act-chip.act-working { background: #DFF3EA; color: #1F6B4E; border-color: #B9E3CF; }
.act-chip.act-idle { background: #F1F1F1; color: #666; border-color: #DDD; }
.act-chip.act-none { background: #FFF; color: var(--muted); border-color: #DDD; }
.act-chip:hover { filter: brightness(.95); }
.motion { color: var(--muted); letter-spacing: 1px; }
.swap-cand.working { border-color: #B9E3CF; }
.swap-cand.working:hover { border-color: var(--teal); }

/* 배치 미리보기 스트립 — 컷 순서·길이·자막 위치를 만들기 전에 눈으로 확인 */
.strip { display: flex; gap: 3px; margin: .5rem 0 .9rem; align-items: stretch; }
.strip:empty { display: none; }
.strip-cell {
  position: relative; flex: 1 1 0; min-width: 26px;
  border-radius: 6px; overflow: hidden; background: var(--line);
  cursor: pointer;
}
.strip-cell:hover { outline: 2px solid var(--teal); outline-offset: -2px; }
.strip-cell.swapped { outline: 2px solid var(--foil); outline-offset: -2px; }

/* 컷 교체 패널 */
#swap-panel {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); padding: .7rem .85rem; margin: -0.4rem 0 .9rem;
}
.swap-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: .5rem; flex-wrap: wrap; }
.swap-head button { margin-left: auto; }
.swap-span { display: flex; gap: 6px; align-items: center; margin: 0 0 .55rem; flex-wrap: wrap; }
.swap-row { display: flex; gap: 8px; flex-wrap: wrap; }
.swap-cand {
  border: 1px solid var(--line); border-radius: 8px; background: var(--porcelain);
  padding: 4px; cursor: pointer; width: 96px; font-size: .68rem; color: var(--ink);
}
.swap-cand img { width: 100%; height: 54px; object-fit: cover; border-radius: 5px; display: block; margin-bottom: 3px; }
.swap-cand:hover { border-color: var(--teal); }
.src-link { display: inline-block; font-size: 12.5px; margin-top: 4px; color: var(--teal-dark); }

/* 첫 화면 템플릿 둘러보기 — 카드 그리드 (맨 위: 촬영 전 확인이 첫 동선이다).
   접힌 카드는 한 줄에 3~4개, 클릭하면 그 카드가 전체 폭으로 펼쳐진다 */
#home-templates { margin-bottom: 30px; }
#home-template-list {
  display: grid; gap: 10px;
  /* 성과 수치(조회·좋아요·반응도·게시일)까지 접힌 카드에 얹으므로 폭을 넉넉히 —
     한 줄에 2~3개면 충분하고, 좁혀서 수치가 줄바꿈 누더기가 되는 것보다 낫다 */
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.home-tpl {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card);
  display: flex; flex-direction: column;   /* summary가 카드 높이를 채우고 세로 중앙 정렬되게 */
}
.home-tpl:hover { border-color: var(--teal); }
.home-tpl[open] { grid-column: 1 / -1; }   /* 펼치면 그 줄 전체를 쓴다 */
.home-tpl summary {
  cursor: pointer; padding: .95rem .9rem .85rem;
  min-height: 128px;
  flex: 1;
  display: flex; flex-direction: column; gap: 9px;
  justify-content: center;                 /* 내용이 카드 세로 중앙에 오도록 */
  list-style: none;
}
.home-tpl summary::-webkit-details-marker { display: none; }
/* 제목을 한 줄로 고정해야 같은 줄 카드들의 막대가 같은 높이에 온다 —
   긴 이름은 …로 줄이고 전체 이름은 툴팁·펼친 상태에서 보여준다 */
.home-tpl .sum-name { display: flex; gap: 7px; align-items: baseline; min-width: 0; }
.home-tpl .sum-name strong {
  font-size: 14px; line-height: 1.35; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.home-tpl[open] .sum-name strong { white-space: normal; overflow: visible; }
.home-tpl summary .tpl-bar { margin: 0; }
/* 성과 스냅샷 — 인스타 사이드바처럼 세로 스택 (♡ 9 / 💬 0 / 🗓 날짜) */
.stats-icons { display: flex; flex-direction: column; gap: 3px; margin: 2px 0; }
.stats-icons .stat-chip {
  font-size: 12.5px; color: var(--ink); opacity: .78; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.home-tpl .sum-meta { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.home-tpl .sum-meta .hint { font-size: 11.5px; }
.home-tpl .tpl-detail { padding: 0 .9rem .8rem; border-top: 1px solid var(--line); }
.home-tpl .tpl-detail > p.hint { margin-top: .6rem; }
.strip-cell img { width: 100%; height: 76px; object-fit: cover; display: block; }
.strip-blank { height: 76px; }
.strip-dur {
  position: absolute; left: 0; bottom: 0; right: 0;
  font-size: .62rem; text-align: center; padding: 1px 0;
  background: rgba(0,0,0,.55); color: #fff;
}
.strip-text {
  position: absolute; top: 3px; right: 3px;
  font-size: .58rem; font-weight: 700; line-height: 1;
  background: var(--teal); color: #fff; border-radius: 3px; padding: 2px 3px;
}

/* 템플릿 리듬 막대 — 컷 개수·길이 비율을 한눈에. 레퍼런스 영상 대신 구조를 보여준다 */
.tpl-bar { display: flex; gap: 2px; height: 16px; margin: .5rem 0 .2rem; }
.tpl-bar .bar-seg {
  flex: 1 1 0; min-width: 3px; border-radius: 3px; background: var(--teal); opacity: .75;
}
.tpl-bar .bar-seg.optional { background: var(--line); opacity: 1; }
/* 자막 표시는 진한 테두리 — 금테였을 땐 애프터(금색 채움) 컷에서 안 보였다 */
.tpl-bar .bar-seg.has-text { box-shadow: inset 0 0 0 2px var(--ink); }

/* 리듬 막대 범례 — 실물과 같은 모양으로 보여준다 (글로 설명하는 것보다 확실하다).
   제목 · 역할 색 · 상태 표시를 구분선으로 나눈 정돈된 한 줄 카드 */
.bar-legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 13px;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; margin: .45rem 0 .8rem;
  font-size: 12px; color: var(--muted);
}
.legend-title { font-weight: 600; color: var(--ink); font-size: 12.5px; }
.legend-hint { color: var(--muted); }
.legend-sep { width: 1px; height: 15px; background: var(--line); }
.legend-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.bar-demo {
  display: inline-block; width: 20px; height: 11px; border-radius: 3px;
  background: var(--teal); opacity: .75; vertical-align: -1px;
}
.bar-demo.has-text { box-shadow: inset 0 0 0 2px var(--ink); opacity: 1; }
.bar-demo.optional { background: var(--line); opacity: 1; }
/* 역할 색 — app.js ROLE_COLORS와 동일해야 한다 (범례가 실물과 같아야 의미가 있다) */
.bar-demo.r-before  { background: #7A5C9E; opacity: 1; }
.bar-demo.r-process { background: #2E6E64; opacity: 1; }
.bar-demo.r-after   { background: #C29245; opacity: 1; }
.bar-demo.r-detail  { background: #A87A2F; opacity: 1; }
.bar-demo.r-product { background: #4A6FA5; opacity: 1; }
.slot-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px;
  margin-right: 7px; vertical-align: -1px; opacity: .8;
}

/* 미리보기 영상 — 세로 릴스라 폭을 제한해야 화면을 안 잡아먹는다 */
#preview-box { margin: .3rem 0 1rem; }
#preview-box video {
  width: 100%; max-width: 260px; border-radius: var(--radius);
  background: #000; display: block;
}
#preview-box .hint { margin-top: .4rem; max-width: 44rem; }

/* 템플릿 편집 폼 */
.tpl-edit label { display: block; margin-bottom: .5rem; font-size: .82rem; }
.tpl-edit label input[type="text"], .tpl-edit label select { margin-left: .4rem; }
.tpl-edit .slot-table input[type="number"] { width: 3.4rem; padding: .12rem .25rem; font-size: .78rem; }
.tpl-edit .e-each-label { font-size: .7rem; margin: 3px 0 0; display: flex; gap: 4px; align-items: center; }
.tpl-edit .e-hold-label { font-size: .7rem; margin: 3px 0 0; display: flex; gap: 3px; align-items: center; color: var(--muted); }
.tpl-edit .e-hold { width: 2.9rem; padding: .12rem .25rem; font-size: .74rem; }
.tpl-edit .slot-table select { font-size: .74rem; padding: .12rem; max-width: 6.4rem; }
/* 받는 단계 선택 — 슬롯 이름 아래 한 줄 통째로, 라벨이 잘리면 뭔지 알 수 없다 */
.tpl-edit .slot-table .e-phase { display: block; max-width: 8.5rem; margin-top: 3px; }
.tpl-edit .slot-table .e-rowbtns { white-space: nowrap; }
.tpl-edit .e-add { margin: 2px 0 6px; }

.strip-removed { flex-basis: 100%; display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.caption-pos-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; font-size: 13px; }

/* ---- 전환 효과 데모 — CapCut 효과의 CSS 근사 (0~45% A장면 / 45~60% 전환 / 60~100% B장면) ---- */
#dlg-fx { width: 340px; }
.fx-stage {
  position: relative; width: 100%; aspect-ratio: 16 / 10;
  border-radius: 10px; overflow: hidden; background: #111;
}
.fx-scene {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; color: #fff; letter-spacing: .02em;
}
.fx-a { background: linear-gradient(135deg, #6C5CE7, #4834A4); }
.fx-b { background: linear-gradient(135deg, #C29245, #8A6320); opacity: 0; }
.fx-white { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
#fx-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.fx-opt.on { border-color: var(--teal); color: var(--teal-dark); font-weight: 600; }

/* 컷 — 효과 없이 바로 */
.fx-cut .fx-b { animation: fxCutB 1.8s steps(1) infinite; }
@keyframes fxCutB { 0%, 49% { opacity: 0; } 50%, 100% { opacity: 1; } }

/* 플래시 — 흰 화면이 번쩍 */
.fx-Flash .fx-b { animation: fxCutB 1.8s steps(1) infinite; }
.fx-Flash .fx-white { animation: fxFlash 1.8s infinite; }
@keyframes fxFlash { 0%, 42% { opacity: 0; } 50% { opacity: 1; } 64%, 100% { opacity: 0; } }

/* 스냅 줌 — 확 커지며 넘어감 (방사형 블러 느낌) */
.fx-Snap_Zoom .fx-a { animation: fxSnapA 1.8s infinite; }
.fx-Snap_Zoom .fx-b { animation: fxSnapB 1.8s infinite; }
@keyframes fxSnapA {
  0%, 40% { transform: scale(1); filter: blur(0); opacity: 1; }
  55%, 100% { transform: scale(1.9); filter: blur(5px); opacity: 0; }
}
@keyframes fxSnapB {
  0%, 48% { opacity: 0; transform: scale(1.6); filter: blur(5px); }
  62%, 100% { opacity: 1; transform: scale(1); filter: blur(0); }
}

/* 줌 — 부드럽게 커지며 교차 */
.fx-Zoom_Transition .fx-a { animation: fxZoomA 1.8s infinite; }
.fx-Zoom_Transition .fx-b { animation: fxZoomB 1.8s infinite; }
@keyframes fxZoomA {
  0%, 38% { transform: scale(1); opacity: 1; }
  62%, 100% { transform: scale(1.2); opacity: 0; }
}
@keyframes fxZoomB {
  0%, 40% { transform: scale(0.9); opacity: 0; }
  64%, 100% { transform: scale(1); opacity: 1; }
}

/* 스와이프 — 옆으로 밀려나가며 다음 장면이 들어옴 */
.fx-Swipe_Left .fx-a { animation: fxSwipeA 1.8s infinite; }
.fx-Swipe_Left .fx-b { animation: fxSwipeB 1.8s infinite; }
@keyframes fxSwipeA { 0%, 42% { transform: translateX(0); } 60%, 100% { transform: translateX(-105%); } }
@keyframes fxSwipeB {
  0%, 42% { transform: translateX(105%); opacity: 1; }
  60%, 100% { transform: translateX(0); opacity: 1; }
}

/* 셰이크 — 흔들리며 넘어감 */
.fx-Shake_down .fx-a { animation: fxShakeA 1.8s infinite; }
.fx-Shake_down .fx-b { animation: fxShakeB 1.8s infinite; }
@keyframes fxShakeA {
  0%, 40% { transform: translateY(0); opacity: 1; }
  44% { transform: translateY(9px); }
  48% { transform: translateY(-7px); }
  52% { transform: translateY(5px); opacity: 1; }
  53%, 100% { opacity: 0; }
}
@keyframes fxShakeB {
  0%, 52% { opacity: 0; transform: translateY(-6px); }
  56% { opacity: 1; transform: translateY(8px); }
  60% { transform: translateY(-5px); }
  64%, 100% { transform: translateY(0); opacity: 1; }
}

/* 글리치 — 지직거리며 조각남 */
.fx-Signal_Glitch_2 .fx-a { animation: fxGlitchA 1.8s steps(1) infinite; }
.fx-Signal_Glitch_2 .fx-b { animation: fxGlitchB 1.8s steps(1) infinite; }
@keyframes fxGlitchA {
  0%, 40% { opacity: 1; transform: none; filter: none; clip-path: none; }
  44% { transform: translateX(-8px); clip-path: inset(10% 0 55% 0); filter: hue-rotate(90deg); }
  48% { transform: translateX(6px); clip-path: inset(50% 0 15% 0); filter: invert(1); }
  52%, 100% { opacity: 0; }
}
@keyframes fxGlitchB {
  0%, 46% { opacity: 0; }
  50% { opacity: 1; transform: translateX(7px); clip-path: inset(30% 0 30% 0); filter: hue-rotate(-60deg); }
  54% { transform: translateX(-5px); clip-path: inset(0 0 65% 0); filter: none; }
  58%, 100% { opacity: 1; transform: none; clip-path: none; filter: none; }
}

/* 휩 — 카메라를 휙 돌린 듯한 세로 쓸림 */
.fx-Whip_Tear .fx-a { animation: fxWhipA 1.8s infinite; }
.fx-Whip_Tear .fx-b { animation: fxWhipB 1.8s infinite; }
@keyframes fxWhipA {
  0%, 42% { transform: translateY(0); filter: blur(0); }
  58%, 100% { transform: translateY(-120%); filter: blur(6px); }
}
@keyframes fxWhipB {
  0%, 42% { transform: translateY(120%); filter: blur(6px); opacity: 1; }
  58%, 100% { transform: translateY(0); filter: blur(0); opacity: 1; }
}

.invite-row { display: flex; gap: 6px; align-items: center; }
.invite-row input { flex: 1; }
.invite-actions { display: flex; gap: 6px; margin-top: 5px; }

/* 템플릿 분류 헤더 — grid(#home-template-list)와 flex(.tpl-cards) 양쪽에서 한 줄을 통째로 차지 */
.tpl-group-head {
  grid-column: 1 / -1; flex-basis: 100%;
  font-size: .78rem; font-weight: 600; color: var(--muted); letter-spacing: .03em;
  margin: 8px 0 0; padding-bottom: 4px; border-bottom: 1px solid var(--line);
}

/* 비밀번호 입력 + 눈 아이콘 — 아이콘이 입력칸 오른쪽 끝 안쪽에 겹친다 */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { width: 100%; box-sizing: border-box; padding-right: 2.4rem; }
.pw-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; cursor: pointer; font-size: 1rem;
  padding: 2px 4px; opacity: .55; line-height: 1;
}
.pw-eye:hover { opacity: 1; }
.tpl-edit .slot-table td { vertical-align: middle; }
.tpl-edit .dlg-actions { margin-top: .6rem; }
.tpl-edit .e-meta { margin: 4px 0 14px; }
.tpl-edit .e-meta summary { font-size: 12.5px; color: var(--muted); cursor: pointer; margin-bottom: 6px; }
.tpl-edit .e-meta label { font-weight: 400; }

/* ---- 관리자 사용자 목록 ---- */
#admin-section { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
#admin-users { list-style: none; padding: 0; margin: 8px 0 0; }
.admin-user {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.admin-user:last-child { border-bottom: 0; }

/* ---- 모바일 대응 — 폰에서 촬영한 영상을 폰에서 바로 올리는 흐름 ---- */
@media (max-width: 700px) {
  body { padding: 16px 12px 60px; }
  /* 헤더는 로고 + 햄버거 한 줄 유지 — 메뉴는 1080px 미디어쿼리의 펼침 패널이 담당 */
  /* 홈 카드가 리듬 막대·성과 스택까지 품게 되면서 2열(~170px)은 누더기 — 1열로 시원하게 */
  #home-template-list { grid-template-columns: 1fr; }
  .field-group.row { flex-wrap: wrap; }
  dialog { width: calc(100vw - 20px); max-width: none; box-sizing: border-box; }
  #dlg-fx { width: calc(100vw - 20px); }   /* id 지정폭(340px)이 위 규칙을 이겨버린다 */
  /* 표는 가로 스크롤 — 화면을 깨느니 밀어서 보게 한다 */
  .tpl-detail, .tpl-edit { overflow-x: auto; }
  .slot-table { min-width: 640px; }
  .swap-row { overflow-x: auto; flex-wrap: nowrap; }
  .strip { overflow-x: auto; }
  /* 스트립 컷은 손가락으로 눌러야 한다 — 슬리버가 되느니 옆으로 민다 */
  .strip-cell { min-width: 44px; }
  /* 검수 그리드는 2열 유지 — 1열 큰 썸네일은 스크롤이 한없이 길어진다 */
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  /* 컷 조정 패널 — 미리보기 영상을 위로, 설명을 아래로 세로 배치 */
  .swap-preview-wrap { flex-direction: column; align-items: stretch; }
  .swap-preview { max-width: 100%; height: 240px; }
  /* 직원 관리 행 — 이름·사용량·버튼이 한 줄에 안 들어가면 줄바꿈 */
  .admin-user { flex-wrap: wrap; }
  .tpl-cards { flex-direction: column; }   /* 드래프트 템플릿 카드도 1열 */
  /* iOS는 16px 미만 입력칸에 포커스하면 화면을 강제 확대한다 — 확대 자체를 막는다
     (탭할 때마다 줌돼서 레이아웃이 깨져 보이는 주범. 조밀한 표는 어차피 가로 스크롤) */
  input, select, textarea { font-size: 16px !important; }
  /* 자막 문구 헤더(밀도·언어·톤·AI 버튼)가 폰 폭을 넘는다 — 줄바꿈 허용 */
  .label-row { flex-wrap: wrap; }
  .lang-toggle { flex-wrap: wrap; gap: 8px 10px; }
  /* 직접 입력 슬롯 행 — 단계 셀렉트가 한 줄을 통째로, 숫자들은 다음 줄 */
  .ref-row { flex-wrap: wrap; }
  .ref-row select { flex: 1 1 100%; }
  .legend-sep { display: none; }           /* 범례가 줄바꿈되면 구분선만 떠 보인다 */
  #file-list li { gap: 8px; }
  #file-list li span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* 긴 다이얼로그(템플릿 목록 등)는 안에서 스크롤 — 폰 주소창 변동(dvh) 대응 */
  dialog { max-height: calc(100dvh - 20px); overflow-y: auto; }
}

/* ---- 내 작업 대시보드 ---- */
#jobs-grid {
  display: grid; gap: 12px; margin-top: 10px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.job-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); overflow: hidden; display: flex; flex-direction: column;
}
.job-thumb { position: relative; aspect-ratio: 16/9; background: #E5E2DA; }
.job-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.job-status {
  position: absolute; top: 7px; left: 7px;
  font-size: 11px; font-weight: 700; color: #fff;
  padding: 2px 8px; border-radius: 999px; background: var(--muted);
}
.st-tagged { background: var(--teal); }
.st-analyzed { background: #5E8FA0; }
.st-analyzing, .st-tagging { background: var(--foil); }
.st-uploaded { background: #8A8F8C; }
.st-error { background: var(--danger); }
.job-body { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.job-body strong {
  font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.job-body .hint { font-size: 11.5px; }
.job-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; }
.job-actions .primary.tiny { padding: 4px 10px; font-size: 12.5px; }
#jobs-stats { margin: 0 0 4px; }
.job-actions { flex-wrap: wrap; }
.job-actions a.dl {
  display: inline-block; text-decoration: none; font-size: 12px;
  padding: 4px 9px; line-height: 1.3;
}
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; }
.dlg-head h2 { margin-bottom: 4px; }
.dlg-x {
  background: none; border: none; font-size: 17px; color: var(--muted);
  padding: 2px 8px; line-height: 1;
}
.dlg-x:hover { color: var(--ink); }
.strip-cell.dragging { opacity: .35; }
.strip-cell.drop-target { outline: 2px dashed var(--foil); outline-offset: -2px; }
.swap-span strong { font-size: 13px; min-width: 3.2em; text-align: center; }

/* ---- AI 카피: 톤 선택 + 훅 후보 ---- */
#copy-tone { width: auto; max-width: 9.5em; display: inline-block; font-size: 12.5px; padding: 4px 6px; }
#hook-options { margin: -6px 0 14px; }
.hook-opt-row { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; margin-top: 6px; }
.hook-opt { font-size: 12px; max-width: 100%; text-align: left; }
.hook-opt.on { border-color: var(--teal); color: var(--teal); font-weight: 600; }
.swap-preview-wrap { display: flex; align-items: flex-end; gap: 10px; margin: 0 0 .6rem; }
.swap-preview {
  height: 210px; border-radius: 8px; background: #000; display: block; max-width: 45%;
}
