/* 예배 준비 도우미. 색과 간격은 JDS 토큰만 참조한다 */
[hidden] { display: none !important; }

/* 1단계: 순서 목록. 넓으면 한 줄, 640px 미만에서는 줄을 나눈다 */
.wo-list { display: grid; gap: var(--s3); list-style: none; margin: 0; padding: 0; }
.wo-list > li { margin: 0; }
.wo-item { display: grid; align-items: center; gap: var(--s2); padding: var(--s3); }
.wo-item > * { min-width: 0; margin: 0; }
.wo-item.is-dragging { opacity: .5; }
.wo-item.is-drop-before { box-shadow: inset 0 2px 0 var(--sky-a); }
.wo-item.is-drop-after { box-shadow: inset 0 -2px 0 var(--sky-a); }
.wo-grip { cursor: grab; color: var(--tx-3); }
.wo-no { display: flex; align-items: center; justify-content: center; gap: var(--s2); min-width: 2.5rem; color: var(--tx-2); font-variant-numeric: tabular-nums; }
.wo-type { min-width: 0; }
.wo-type > select { width: 100%; }
.wo-link { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
/* 연결한 PPT 이름은 한 줄에 두고 길면 말줄임 */
.wo-linked { display: inline-flex; align-items: center; gap: var(--s1); max-width: 100%; min-width: 0; }
.wo-linked > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wo-acts { display: flex; gap: var(--s2); }
/* 좁으면 첫 줄은 손잡이·번호·버튼, 나머지 입력칸은 그 아래 전체 너비로 */
@media (max-width: 639.98px) {
    .wo-item { grid-template-columns: auto 3.5rem minmax(0, 1fr); }
    .wo-grip { grid-row: 1; grid-column: 1; }
    .wo-no { grid-row: 1; grid-column: 2; justify-content: flex-start; }
    .wo-acts { grid-row: 1; grid-column: 3; justify-self: end; }
    .wo-type { grid-row: 2; grid-column: 2 / 4; }
    .wo-name { grid-row: 3; grid-column: 2 / 4; }
    .wo-person { grid-row: 4; grid-column: 2 / 4; }
    .wo-link { grid-row: 5; grid-column: 2 / 4; }
}
/* 640~1023px: 입력칸이 좁아지지 않게 연결·이동 버튼을 둘째 줄로 내린다 */
@media (min-width: 640px) and (max-width: 1023.98px) {
    .wo-item { grid-template-columns: auto auto 9rem minmax(0, 1.2fr) minmax(0, 1fr); }
    .wo-link { grid-row: 2; grid-column: 3 / 5; }
    .wo-acts { grid-row: 2; grid-column: 5; justify-self: end; }
}
@media (min-width: 1024px) {
    .wo-item { grid-template-columns: auto auto 9rem minmax(0, 1.2fr) minmax(0, 1fr) auto auto; }
}

/* 1단계: 순서 틀 줄. 고르는 상자는 넓게, 버튼은 옆에 둔다 */
.wo-preset { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s2); }
.wo-preset-pick { flex: 1 1 14rem; min-width: 0; }
/* 순서 틀의 "기본 순서"는 빈 값이지만 고른 값이므로 흐리게 보이지 않게 한다 */
.wo-preset .jds-val.is-empty { color: var(--tx); }

/* 종류별 색 점(1단계 번호 옆, 3단계 묶음 머리). 색은 JDS 토큰만 쓴다 */
.tone-dot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--tx-3); }
.tone-dot[data-tone="sky"] { background: var(--p-sky); }
.tone-dot[data-tone="lime"] { background: var(--p-lime); }
.tone-dot[data-tone="violet"] { background: var(--p-lavender); }

/* 연결할 PPT 고르기 대화상자의 한 줄 */
.wo-pick { display: grid; gap: var(--s1); width: 100%; text-align: left; font: inherit; color: var(--tx); cursor: pointer; }

/* 2단계: 디자인 */
.dz-grid { display: grid; gap: var(--s6); align-items: start; }
.dz-grid > * { min-width: 0; }
.dz-lays { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
@media (min-width: 640px) { .dz-lays { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.dz-lay {
    display: grid; justify-items: center; gap: var(--s2); padding: var(--s2);
    min-height: 44px; font-size: 13px; color: var(--tx);
    background: var(--sf); border: 1px solid var(--bd); border-radius: var(--r-sm); cursor: pointer;
}
.dz-lay[aria-checked="true"] { background: var(--sky-soft); border-color: var(--sky-a); }
.dz-lay-ic { position: relative; display: block; width: 44px; height: 30px; background: var(--sf-2); border: 1px solid var(--bd-2); border-radius: 4px; }
.dz-lay-ic::after { content: ""; position: absolute; background: var(--tx-2); border-radius: 2px; }
.dz-lay-ic[data-l="split"]::before, .dz-lay-ic[data-l="full"]::before, .dz-lay-ic[data-l="lower"]::before { content: ""; position: absolute; background: var(--tx-2); border-radius: 2px; }
.dz-lay-ic[data-l="center"]::after { left: 25%; top: 40%; width: 50%; height: 20%; }
.dz-lay-ic[data-l="bottom"]::after { left: 15%; right: 15%; bottom: 10%; height: 20%; }
.dz-lay-ic[data-l="left"]::after { left: 15%; top: 35%; width: 60%; height: 40%; }
.dz-lay-ic[data-l="right"]::after { right: 15%; top: 35%; width: 60%; height: 40%; }
.dz-lay-ic[data-l="top"]::after { left: 15%; right: 15%; top: 20%; height: 40%; }
.dz-lay-ic[data-l="split"]::before { left: 12%; top: 35%; width: 28%; height: 30%; }
.dz-lay-ic[data-l="split"]::after { left: 45%; top: 15%; width: 45%; height: 70%; }
.dz-lay-ic[data-l="full"]::after { left: 12%; right: 12%; top: 14%; height: 52%; }
.dz-lay-ic[data-l="full"]::before { left: 12%; right: 12%; bottom: 12%; height: 10%; }
.dz-lay-ic[data-l="lower"]::before { left: 12%; top: 12%; width: 45%; height: 10%; }
.dz-lay-ic[data-l="lower"]::after { left: 12%; right: 12%; bottom: 12%; height: 35%; }
.dz-bgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: var(--s2); }
.dz-bg { padding: 0; min-height: 44px; overflow: hidden; background: none; border: 1px solid var(--bd); border-radius: var(--r-xs); cursor: pointer; }
.dz-bg img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.dz-card { display: grid; gap: var(--s4); }
.dz-card > .stack { min-width: 0; }
.dz-card-prev { min-width: 0; }
/* 2단계 미리보기: 본문 슬라이드와 표지를 나란히 두어 화면을 다 차지하지 않게 한다 */
#dz_prev { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
#dz_prev > * { margin: 0; min-width: 0; }
@media (min-width: 640px) {
    .dz-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}
@media (min-width: 1024px) {
    .dz-grid { grid-template-columns: minmax(0, 1fr) 340px; }
    .dz-grid > :first-child { position: sticky; top: calc(var(--head-h, 56px) + var(--s4)); }
}

/* 슬라이드 미리보기 (2·3단계). 글자 크기는 슬라이드 폭(--den)에 비례한다 */
.ws-slide { position: relative; width: 100%; overflow: hidden; container-type: inline-size; border: 1px solid var(--bd); border-radius: var(--r-xs); background-size: cover; background-position: center; background-repeat: no-repeat; }
.ws-box { position: absolute; display: flex; flex-direction: column; white-space: pre-line; overflow: hidden; line-height: 1.35; font-size: calc(var(--fs) * 1.333 * 100cqw / var(--den)); }
.ws-pic { position: absolute; object-fit: fill; }

/* 3단계 편집기: 항목 목록 | 무대 | 편집칸. 1024px 미만은 목록(가로 카드) → 무대 → 편집칸 한 열 */
.sl-body.ws-editor { grid-template-columns: minmax(0, 1fr); gap: var(--s4); align-items: start; }
.sl-body.ws-editor > * { min-width: 0; }
.sl-body.ws-editor > .ws-list, .sl-body.ws-editor > .ws-stage, .sl-body.ws-editor > .ws-opts { grid-column: 1; grid-row: auto; position: static; }
.sl-body.ws-editor > .ws-list { gap: var(--s2); }
.ws-list > .t-card + * { margin-block-start: 0; }
.sl-view.ws-list { grid-template-columns: minmax(0, 1fr); }
.sl-view.ws-list > * { min-width: 0; max-width: 100%; }
.sl-thumbs.ws-groups { display: flex; align-items: stretch; gap: var(--s2); max-height: none; overflow-x: auto; padding: 2px; }
.sl-thumbs.ws-groups:focus, .sl-thumbs.ws-groups:focus-visible { outline: none; }
.ws-group { flex: 0 0 min(220px, 72vw); min-height: 40px; display: grid; align-content: start; gap: var(--s2); padding: var(--s2); border: 1px solid var(--bd); border-radius: var(--r-sm); cursor: pointer; }
.ws-group[aria-selected="true"] { background: var(--sky-soft); border-color: var(--sky-a); }
.ws-group:focus-visible { outline: 2px solid var(--sky-a); outline-offset: 2px; }
.ws-groups > *, .ws-group > * { margin: 0; }
.ws-group-head { display: flex; align-items: center; gap: var(--s2); margin: 0; font-weight: 600; color: var(--tx); }
.ws-group-head > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.ws-thumbs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.ws-thumb { min-width: 0; border-radius: var(--r-xs); cursor: pointer; }
.ws-thumb.is-cur { outline: 2px solid var(--sky-a); outline-offset: 2px; }

/* 무대: 머리 줄 아래 현재 슬라이드. 높이는 --ws-h를 넘지 않게 폭을 비율로 정한다 */
.ws-stage { --ws-h: clamp(200px, calc(100dvh - 400px), 62dvh); display: grid; gap: var(--s3); align-content: start; }
/* 머리: [항목 · n / N장] [전체 n / N] */
.ws-stage-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: var(--s1) var(--s3); }
.ws-stage-head > * { margin: 0; }
.ws-stage-title { font-weight: 600; color: var(--tx); }
.ws-stage-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "frame frame" "prev next"; align-items: center; gap: var(--s2); }
.ws-stage-row > * { margin: 0; min-width: 0; }
.ws-frame { grid-area: frame; }
.ws-frame > .ws-slide { width: min(100%, calc(var(--ws-h) * var(--ar, 1.7778))); margin-inline: auto; }
.ws-nav { grid-area: prev; justify-self: start; width: 44px; min-width: 44px; height: 44px; min-height: 44px; padding: 0; justify-content: center; }
.ws-next { grid-area: next; justify-self: end; }
@media (min-width: 640px) {
    .ws-stage-row { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "prev frame next"; }
}
/* 아래 막대의 다운로드는 1024px 미만 전용. 넓은 화면은 위 막대의 #ws_dl을 쓴다 */
@media (min-width: 1024px) { .wz-nav > #ws_dl_nav { display: none; } }
@media (max-width: 1023.98px) { body:has(#ws_dl_nav:not([hidden])) #ws_dl { display: none; } }
/* 편집기 머리가 앱 머리 아래 바로 오도록 */
#slides_root > .sl { scroll-margin-top: calc(var(--head-h, 56px) + 8px); }
/* 작업 막대는 가사 PPT 메이커와 같은 모양: 왼쪽 [파일명(최대 360px)][.pptx][장 수], 오른쪽 [다운로드] */
.sl:has(.ws-editor) > .sl-top { align-items: center; position: sticky; top: var(--head-h, 56px); z-index: 4; background: var(--bg); padding-block: var(--s2); }
.sl:has(.ws-editor) .sl-top__file { display: flex; flex: 0 1 auto; align-items: center; gap: var(--s2); min-width: 0; }
.sl:has(.ws-editor) .sl-top__file #ws_file { flex: 0 1 240px; width: 240px; max-width: 360px; min-width: 0; }
.sl:has(.ws-editor) .sl-top__file #ws_count { white-space: nowrap; }
.sl:has(.ws-editor) .sl-top__act { display: flex; align-items: center; gap: var(--s2); margin-inline-start: auto; }
@media (max-width: 639px) {
    .sl:has(.ws-editor) .sl-top__file { flex: 1 1 0; }
    .sl:has(.ws-editor) .sl-top__file #ws_file { flex: 1 1 0; width: auto; max-width: none; }
    .sl:has(.ws-editor) #ws_count { display: none; }
    .sl:has(.ws-editor) .sl-top__act { margin-inline-start: 0; }
}
@media (min-width: 1024px) {
    .sl-body.ws-editor { grid-template-columns: 240px minmax(0, 1fr) 300px; }
    .sl-body.ws-editor > .ws-list { grid-column: 1; grid-row: 1; position: sticky; top: calc(var(--head-h, 56px) + var(--s4)); max-height: calc(100dvh - var(--head-h, 56px) - 200px); overflow-y: auto; }
    .sl-body.ws-editor > .ws-stage { grid-column: 2; grid-row: 1; }
    .sl-body.ws-editor > .ws-opts { grid-column: 3; grid-row: 1; }
    .sl-thumbs.ws-groups { display: grid; grid-template-columns: minmax(0, 1fr); overflow: visible; }
    .ws-group { flex: none; }
}
