* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  letter-spacing: var(--ls-normal);
  word-break: keep-all;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage { display: flex; height: 100vh; }
.stage__video {
  display: none;
  flex: 0 0 var(--video-col, 50%);
  background: #000;
  align-items: center;
  justify-content: center;
}
.stage__video video { width: 100%; height: 100%; object-fit: contain; }
.stage[data-compose='on'] .stage__video { display: flex; }

/* ---- 시트 */
.sheet {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px 28px;
}

/* 디자인시스템 슬라이드 헤더: 제목 + 1px 슬레이트 선 */
.head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-bottom: 12px; border-bottom: 1px solid var(--rule);
}

/* 오른쪽 위 안전 점검 상태. 완료되면 초록색으로 바뀐다 */
.status {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 999px;
  background: var(--surface);
  font-size: 13px; font-weight: 500; color: var(--text-tertiary);
  transition: background-color .4s var(--ease-out), border-color .4s var(--ease-out), color .4s var(--ease-out);
}
.status svg { width: 16px; height: 16px; }
.status b { font-weight: 700; color: var(--text-secondary); }
.status__count { font-family: var(--font-mono); font-size: 12px; font-variant-numeric: tabular-nums; }
/* 완료: 초록 바탕에 흰 글자. 넘어가는 순간 커졌다 돌아오고, 바깥으로 초록 테두리가 두 번 퍼진다 */
.status[data-done='true'] { background: var(--success); border-color: var(--success); color: #fff; box-shadow: 0 4px 14px rgba(22, 163, 74, .35); }
.status[data-done='true'] b { color: #fff; }
.status--pop { animation: status-pop .6s var(--ease-out), status-ring 1s ease-out 2; }
@keyframes status-pop { 0% { transform: scale(1); } 35% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes status-ring {
  from { box-shadow: 0 0 0 0 rgba(22, 163, 74, .55), 0 4px 14px rgba(22, 163, 74, .35); }
  to { box-shadow: 0 0 0 16px rgba(22, 163, 74, 0), 0 4px 14px rgba(22, 163, 74, .35); }
}

/* 프로젝트 정보, 사진 목록 소제목 */
.info { display: flex; flex-direction: column; gap: 14px; }
.project {
  display: grid; grid-template-columns: 1.5fr 1fr; gap: 6px 24px;
  padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13px; line-height: 20px;
}
.project div { display: flex; gap: 10px; min-width: 0; }
.project dt { flex: none; width: 52px; color: var(--text-label); font-weight: 500; }
.project dd { margin: 0; min-width: 0; color: var(--text-primary); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project .mono { font-family: var(--font-mono); font-size: 12px; font-weight: 500; }
.badge { padding: 1px 8px; border-radius: 999px; background: var(--accent-weak); color: var(--accent-text); font-size: 12px; font-weight: 600; }
.list { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.list__title { font-size: 18px; line-height: 26px; font-weight: 700; letter-spacing: var(--ls-tight); color: var(--text-primary); }
.list__meta { font-size: 13px; line-height: 20px; color: var(--text-tertiary); }
.list__meta .sep { margin: 0 6px; color: var(--text-faint); }
.list__meta .dot { margin: 0 8px; color: var(--text-faint); }
.list__meta b { font-weight: 600; color: var(--text-primary); }
.list__meta .mono { font-family: var(--font-mono); font-size: 12px; }
.dl {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-primary);
  font: 600 13px/1 var(--font-sans); letter-spacing: var(--ls-normal);
  cursor: pointer;
}
.dl svg { width: 16px; height: 16px; flex: none; }
.dl:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.dl--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.head__logo { display: block; height: 32px; width: auto; }
.head__title {
  font-size: 28px; line-height: 1.3; font-weight: 700;
  letter-spacing: var(--ls-tight);
  color: var(--accent);
}

/* ---- 표. 행 높이에서 사진 칸 너비를 계산해 실제 사진 비율과 맞춘다 */
.rows {
  flex: 1;
  min-height: 0;
  container-type: size;
  display: grid;
  grid-template-rows: repeat(var(--row-count, 4), minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.row {
  display: grid;
  grid-template-columns: calc(100cqh / var(--row-count, 4) * var(--photo-ratio, 0.75)) 1fr;
  min-height: 0;
  border-top: 1px solid var(--border);
  position: relative;
}
.row:first-child { border-top: 0; }

.photo {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: var(--surface-subtle);
  border-right: 1px solid var(--border);
}
.photo img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: var(--reveal, 0);
  transform: scale(calc(1.03 - 0.03 * var(--reveal, 0)));
}
.photo__wait {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
}
.photo__wait svg { width: 24px; height: 24px; }
.photo__upload {
  position: absolute; left: 14px; right: 14px; top: 50%;
  transform: translateY(-50%);
  display: none;
}
.photo[data-phase='uploading'] .photo__upload { display: block; }
.photo:not([data-phase='waiting']) .photo__wait { display: none; }
.bar { height: 4px; border-radius: 999px; background: var(--accent-weak); overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; background: var(--accent-bright); transform-origin: left; transform: scaleX(var(--p, 0)); }
.photo__name {
  position: absolute; left: 8px; right: 8px; bottom: 8px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(10, 14, 26, .6);
  color: #fff;
  font-family: var(--font-mono); font-size: 11px; line-height: 16px;
  text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: var(--reveal, 0);
}

/* 필드 */
.fields {
  display: grid;
  grid-template-columns: 104px 1fr;
  grid-template-rows: auto auto auto auto 1fr;
  min-height: 0;
}
.label, .value {
  display: flex; align-items: center;
  min-height: 0;
  padding: 0 16px;
  border-top: 1px solid var(--border);
  font-size: 14px; line-height: 20px;
}
.label:nth-child(1), .value:nth-child(2) { border-top: 0; }
.label {
  color: var(--text-label);
  font-weight: 500;
  background: var(--surface-subtle);
  border-right: 1px solid var(--border);
}
.value { color: var(--text-primary); font-weight: 600; height: 34px; }
.label--remarks, .value--remarks { height: auto; align-items: flex-start; padding-top: 10px; padding-bottom: 10px; }
.value--remarks { display: block; overflow: hidden; font-weight: 400; color: var(--text-secondary); line-height: 1.65; }
.value .mono { font-family: var(--font-mono); font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }

.caret {
  display: inline-block; width: 2px; height: 1.05em;
  margin-left: 1px; vertical-align: -0.15em;
  background: var(--accent-bright);
  animation: blink 1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.skeleton {
  display: inline-block; height: 10px; border-radius: 999px;
  background: linear-gradient(90deg, var(--fill) 0%, var(--accent-weak) 50%, var(--fill) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---- 조작 안내. 녹화할 때는 H로 숨긴다 */
.hud {
  position: fixed; right: 16px; bottom: 16px;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  font-size: 12px; color: var(--text-secondary);
}
.hud[hidden] { display: none; }
.hud__time { font-family: var(--font-mono); font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.hud kbd {
  font-family: var(--font-mono); font-size: 11px;
  padding: 1px 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px;
  color: var(--text-primary);
}

/* ---- PDF 저장(인쇄). A4 세로 한 장에 시트만 남긴다 */
@media print {
  @page { size: A4 portrait; margin: 10mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html, body { height: auto; overflow: visible; background: #fff; }
  .hud, .side, .stage__video, .list__actions { display: none !important; }
  .stage, body.clips .stage { position: static; transform: none; width: auto; height: 277mm; outline: 0; }
  .sheet { padding: 0; }
  .rows { box-shadow: none; }
  .caret { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .caret, .skeleton, .status--pop { animation: none; }
}

/* ---- 클립 모드(?clips=1). 가운데 960×1080 프레임만 영상에 남고, 바깥(양옆 버튼 포함)은 편집에서 잘라 낸다 */
body.clips { background: #2a2f38; }
body.clips .stage {
  position: fixed; left: var(--frame-x, 0); top: var(--frame-y, 0);
  width: 960px; height: 1080px;
  transform: scale(var(--frame-scale, 1)); transform-origin: 0 0;
  background: var(--bg);
  outline: 1px dashed rgba(255, 255, 255, .35); outline-offset: 2px;
}
.side {
  position: fixed; top: 50%; transform: translateY(-50%);
  width: calc((100vw - 960px * var(--frame-scale, 1)) / 2 - 32px); max-width: 360px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  color: #c9d1d9; font-size: 13px; text-align: center;
}
.side--left { left: 16px; }
.side--right { right: 16px; }
.side .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: pre-line; }
.side__play {
  width: 132px; height: 132px; border-radius: 50%;
  border: 0; background: var(--accent-bright); color: #fff;
  font-size: 52px; line-height: 1; padding-left: 10px; cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.side__play:disabled { background: #4b5563; cursor: default; }
.side__clip { font-size: 18px; font-weight: 700; color: #fff; }
.side__tools { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.side__tools button {
  background: #1f242c; color: #c9d1d9; border: 1px solid #3a414c; border-radius: 6px;
  padding: 5px 10px; font: 600 12px var(--font-sans); cursor: pointer;
}
.side__frame { color: #8b949e; font-size: 11px; }
.side__frame.warn { color: #f2cc60; }
