/* Zero Church 페이지 레이아웃. 색·곡률·모션은 JDS 토큰만 참조한다 */
/* 스크롤바 트랙도 배경색으로 맞춘다. 서랍·대화상자가 열려 스크롤바가 사라지면 menubar.js가 잰 폭만큼 오른쪽을 채운다 */
html { background: var(--bg); scrollbar-color: var(--bd-2) var(--bg); transition: background-color var(--ms-3) var(--ease); }
html:has(dialog.jds-ov[open]) { padding-inline-end: var(--sbw, 0px); }
.wrap { --max-w: 760px; padding-block: var(--s8) var(--s20); }
.wrap--wide { --max-w: 1180px; }
.page { display: grid; gap: var(--s8); }
.page > * { min-width: 0; margin-block-start: 0; }
.intro { display: grid; gap: var(--s2); }
.intro > * { margin-block-start: 0; }
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2); }
.bar > * { margin: 0; }
.input-row { display: flex; gap: var(--s2); }
.input-row > input { flex: 1; min-width: 0; }
.input-row > * { margin: 0; }

/* 메이커 단계 머리: 단계 이름 + n / 3 + 진행 막대(JDS .prog) */
.wz-head { display: grid; gap: var(--s3); }
.wz-head > * { margin: 0; }
.wizard-step > * { min-width: 0; margin-block-start: 0; }
/* 단계 이동 줄: 긴 편집기 아래로 묻히지 않게 화면 아래에 붙인다 */
.wz-nav {
    position: sticky; bottom: 0; z-index: 5;
    display: flex; align-items: center; gap: var(--s2);
    padding-block: var(--s3) max(var(--s3), env(safe-area-inset-bottom));
    background: var(--bg); border-top: 1px solid var(--bd);
}
.wz-nav > * { margin: 0; }
.wz-nav .grow { flex: 1; }

.field-line > :is(input, .jds-trigger, .jds-box) { width: 160px; flex: 0 0 auto; }
.field-line > input.grow { width: auto; flex: 1; }
.opt { position: relative; }
.opt:has(.hint) { text-decoration: underline dotted var(--bd-2); text-underline-offset: 3px; }
.hint {
    position: absolute; left: 0; top: calc(100% + var(--s2)); z-index: 10;
    width: max-content; max-width: 240px; padding: 5px 8px; border-radius: 7px;
    background: var(--tx); color: var(--bg); font-size: 12px; line-height: 1.4;
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity var(--fx) var(--ease-fx);
}
.opt:hover .hint, .field-line:focus-within .hint { opacity: 1; visibility: visible; }

#previewFrame { width: 100%; height: 100px; background: var(--sf); }

/* 가사 수정 편집기 (2단계). 화면을 채우도록 높이를 잡는다 */
.ed-big { width: 100%; min-height: calc(100dvh - 320px); font-size: 16px; line-height: 1.7; }

/* 콘티 불러오기 탭의 목록 */
.ly-conti-list { display: grid; gap: var(--s2); }
.ly-conti-row { display: flex; align-items: flex-start; gap: var(--s3); cursor: pointer; }
.ly-conti-row > .stack { min-width: 0; }

/* 라이브러리 항목 한 줄 */
.lib-item { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); }
.lib-item > .stack { min-width: 0; }
.lib-name { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }

/* 홈 */
.tools { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.tool .row { justify-content: space-between; }
.tool .t-card { display: inline-flex; align-items: center; gap: var(--s2); }

@media (max-width: 639.98px) {
    /* 끝 버튼이 글 없는 아이콘이면 입력칸 옆에 한 줄로 둔다. 글자 버튼이 있을 때만 세로로 쌓는다 */
    .input-row:not(:has(> .btn--icon:last-child)) { flex-direction: column; }
    .tools { grid-template-columns: minmax(0, 1fr); }
}

/* 계정 입력 오류 한 줄 (aria-describedby로 입력칸과 이어진다) */
.field-err { font-size: 13px; line-height: 1.45; color: var(--err); }

/* 앱 바에는 메뉴 탭이 없다. 메뉴는 ≡ 드로어에만 있다 */

/* 본문으로 건너뛰기: 평소엔 화면 밖, 키보드 포커스를 받으면 보인다 */
.skip-link {
    position: fixed; left: var(--s4); top: var(--s2); z-index: 100;
    padding: var(--s2) var(--s4); border-radius: var(--r-sm);
    background: var(--sf); color: var(--tx); border: 1px solid var(--bd-2);
    transform: translateY(-200%); transition: transform var(--fx) var(--ease-fx);
}
.skip-link:focus { transform: none; }
main[tabindex="-1"]:focus { outline: none; }

/* 단계 스테퍼: 번호 원 + 이름, 단계 사이는 가는 선. 640px 미만은 현재 단계 이름만 보인다 */
.stepper { display: flex; align-items: center; margin: 0; padding: 0; list-style: none; min-width: 0; }
.stepper * { margin: 0; }
.stepper > li { position: relative; display: flex; align-items: center; gap: var(--s2); min-width: 0; flex: 0 0 auto; }
.stepper > li:not(:last-child) { flex: 1 1 auto; }
.stepper > li:not(:last-child)::after { content: ""; flex: 1 1 auto; min-width: var(--s4); height: 1px; margin-inline: var(--s1); background: var(--bd); }
.stepper button { display: inline-flex; align-items: center; gap: var(--s2); min-height: 40px; padding: 0; border: 0; background: none; color: var(--tx-2); font: inherit; cursor: pointer; }
.stepper button:hover .stepper-name { color: var(--tx); }
.stepper-dot { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--bd-2); font-size: 13px; font-weight: 600; color: var(--tx-2); }
.stepper-name { font-size: 14px; font-weight: 550; white-space: nowrap; color: var(--tx-2); }
.stepper li.is-ahead .stepper-dot, .stepper li.is-ahead .stepper-name { color: var(--tx-3); }
.stepper li[aria-current="step"] .stepper-dot { background: var(--sky-a); border-color: var(--sky-a); color: var(--bg); }
.stepper li[aria-current="step"] .stepper-name { color: var(--tx); }
.stepper li.is-done .stepper-dot { background: var(--sky-soft); border-color: var(--sky-a); color: var(--tx); }
@media (max-width: 639.98px) {
    .stepper li:not([aria-current]) .stepper-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .stepper li:not(:last-child) { flex: 1 1 auto; }
}

/* 단계 이동 줄이 있는 화면에서는 알림이 "다음" 버튼을 가리지 않게 그 위에 띄운다 */
body:has(.wz-nav) .toast { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 72px); }

/* data-tip 이름표는 JDS(bundle.js)가 그린다. 여기서는 기준 자리만 잡는다 (이름표 CSS를 두면 두 번 뜬다) */
[data-tip] { position: relative; }

/* 토스트: 편집 화면과 넓은 화면에서는 아래 가운데. 가운데 맞춤은 translate로 해 JDS의 transform과 겹치지 않게 한다 */
body:has(.sl) .toast { left: 50%; right: auto; translate: -50% 0; max-width: min(360px, calc(100vw - 32px)); }
@media (min-width: 1024px) { .toast { left: 50%; right: auto; translate: -50% 0; max-width: min(360px, calc(100vw - 32px)); } }
/* 계정 입력 폼은 읽기 편한 너비로 */
#acct_forms, #acct_signed { max-width: 420px; }

/* 가사 PPT 머리: 넓으면 저장 상태가 제목 줄 오른쪽, 좁으면 부제 아래 */
.mk-head { grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; column-gap: var(--s4); }
#mk_saved { grid-column: 2; grid-row: 1; justify-self: end; }
#mk_saved[data-tone="err"] { color: var(--err); }
@media (max-width: 639.98px) {
    .mk-head { grid-template-columns: minmax(0, 1fr); }
    #mk_saved { grid-column: auto; grid-row: auto; justify-self: start; }
}
/* 아래 막대의 다운로드는 좁은 화면 전용 (넓은 화면은 작업 막대에 있다) */
@media (min-width: 1024px) { .wz-nav > #mk_dl { display: none; } }

/* 계정 폼: 버튼은 폼 폭 전체, 다른 탭으로 가는 작은 링크 */
#panel_login .btn, #panel_signup .btn { width: 100%; }
.acct-switch { margin: 0; text-align: center; }
.link-btn { display: inline; min-height: 40px; padding: 0 var(--s1); border: 0; background: none; color: var(--link); font: inherit; cursor: pointer; }

/* 머리 도움말 버튼: 앱 바 메뉴가 보이는 넓은 화면에서만 (좁은 화면은 서랍 메뉴에 있다) */
.appbar-help { display: none; }
@media (min-width: 1024px) { .appbar-help { display: inline-flex; } }

/* 앱 바 제목은 글자 폭만큼만 누른다 (JDS는 빈 칸까지 채워 빈 바 전체가 홈 링크가 된다) */
.appbar-title { flex: 0 1 auto; margin-inline-end: auto; }

/* 3단계 편집기로 들어가면 편집기 위가 앱 머리 바로 아래에 오게 한다 */
#slides_root .sl { scroll-margin-top: calc(var(--head-h, 56px) + 8px); }

/* 단계 본문과 아래 고정 막대를 한 묶음으로 둔다: 막대가 단계 글 위에 겹치는 것은 의도한 모양 */
.wz-body { display: grid; gap: 0; min-width: 0; }
.wz-body > * { min-width: 0; margin-block-start: 0; }
/* 정렬 상자는 JDS가 옆에 만든 버튼으로 다시 그려지므로, 원래 상자가 숨겨지면 그 버튼도 숨긴다 */
#sort[hidden] + .jds-trigger { display: none; }

/* 경계 없는 클릭 요소의 호버·현재 표시: 배경 대신 글 아래 2px 막대.
   막대는 ::before를 쓴다(::after는 버튼 로딩 링이 쓴다). 호버하면 왼쪽에서 그려지고,
   벗어나면 오른쪽으로 사라진다. 현재 페이지는 막대가 늘 보인다. 아이콘 버튼은 아이콘 아래 16px 막대 */
:is(.btn--ghost, .link-btn, .menu-item, .drawer-nav .mi-t, .ed-act) { position: relative; }
:is(.btn--ghost, .link-btn, .menu-item, .drawer-nav .mi-t, .ed-act)::before {
    content: ""; position: absolute; left: var(--ul-x, 0); right: var(--ul-x, 0); bottom: var(--ul-b, 5px);
    height: 2px; border-radius: 1px; background: var(--sky);
    transform: scaleX(0); transform-origin: right center; pointer-events: none;
    transition: transform .2s ease;
}
.btn--ghost:not(.btn--icon) { --ul-x: 14px; }
.btn--ghost.btn--sm:not(.btn--icon) { --ul-x: 10px; --ul-b: 3px; }
.btn--ghost.btn--icon { --ul-b: 6px; }
.btn--ghost.btn--icon::before, .ed-act::before { left: 50%; right: auto; width: 16px; translate: -50% 0; transform-origin: center; }
.ed-act { --ul-b: 3px; }
.link-btn { --ul-x: var(--s1); --ul-b: -3px; }
.menu-item { --ul-x: 10px; --ul-b: 7px; width: fit-content; }
/* 드로어 항목: 아이콘과 글(.mi-t)을 .mi로 묶고, 막대는 글 span에만 그어 아이콘 아래로 뻗지 않게 한다 */
.drawer-nav .mi { display: inline-flex; align-items: center; gap: var(--s3); min-width: 0; }
.drawer-nav .mi-t { --ul-x: 0; --ul-b: -4px; min-width: 0; }
.drawer-nav .mi-t::before { transition: transform var(--fx) var(--ease-fx); }

@media (hover: hover) {
    :is(.btn--ghost:not(.btn--icon), .link-btn, .menu-item):hover::before { transform: scaleX(1); transform-origin: left center; }
    :is(.btn--ghost.btn--icon, .ed-act):hover::before { transform: scaleX(1); }
    .drawer-nav :is(a, button):hover .mi-t::before { transform: scaleX(1); transform-origin: left center; }
}
.menu-item[aria-current="page"]::before, .menu-item[aria-selected="true"]::before,
.drawer-nav [aria-current="page"] .mi-t::before { transform: scaleX(1); transform-origin: left center; }
@media (prefers-reduced-motion: reduce) {
    :is(.btn--ghost, .link-btn, .menu-item, .drawer-nav .mi-t, .ed-act)::before { transition: none; }
}

/* 배경 호버·강조 없음: 위 막대가 대신한다. 테두리 있는 버튼(.btn, .btn--pri)은 그대로 둔다.
   서랍 호버는 JDS 규칙과 같은 선택자로 덮는다(뒤에 오므로 이긴다) */
@media (hover: hover) and (pointer: fine) {
    .btn--ghost:hover:not(:disabled):not([aria-busy="true"]) { background: transparent; }
    .menu-item:hover, .menu-item[aria-selected="true"]:hover, .menu-item[aria-current="page"]:hover { background: transparent; }
    .drawer-nav :is(a, button):hover:not([aria-current="page"]) { background: transparent; color: var(--tx); }
}
.btn--ghost:active:not(:disabled):not([aria-busy="true"]), .menu-item:active, .drawer-nav :is(a, button):active { background: transparent; }
.drawer-nav [aria-current="page"] { background: transparent; font-weight: 600; color: var(--tx); }
.drawer-nav [aria-current="page"] :is(.ic, .jds-ic) { color: var(--sky-a); }

/* 글 선택·끌기 금지. 입력칸·편집 영역·고를 수 있는 본문 글(.bb-verse)만 글을 고르고 I자 커서를 쓴다. select는 손가락 커서를 그대로 둔다 */
body { -webkit-user-select: none; user-select: none; cursor: default; }
input, textarea, select, .bb-verse, [contenteditable="true"], [contenteditable="true"] * { -webkit-user-select: text; user-select: text; }
input, textarea, [contenteditable="true"], [contenteditable="true"] * { cursor: auto; }
/* 이미지·아이콘·버튼·링크·슬라이드 그림은 끌 수 없다. draggable="true"로 일부러 끄는 항목(슬라이드·예배·콘티 정렬)은 제외.
   .bb-verse는 role="button"이지만 본문 글이라 끌기를 막지 않는다 */
:is(img, svg, i, button, a, .btn, [role="button"]:not(.bb-verse), .sl-slide):not([draggable="true"]) { -webkit-user-drag: none; }

/* 컨테이너 포커스 없음: 목록·격자 자체에는 포커스 링을 두지 않는다. 항목(썸네일, 카드)의 포커스 링은 그대로 */
[role="listbox"]:is(:focus, :focus-visible), [role="grid"]:is(:focus, :focus-visible),
.lib-grid:is(:focus, :focus-visible), .bb-text:is(:focus, :focus-visible), .ly-conti-list:is(:focus, :focus-visible) {
    outline: none; box-shadow: none;
}

/* 본문 링크(홈 도구 링크, 라이브러리 항목 이름, .ul-link): 글자 밑줄 대신 호버 때 글 아래 막대 */
:is(.lp-links a, .lib-name, .ul-link) { position: relative; --ul-x: 0; --ul-b: -4px; }
:is(.lp-links a, .lib-name, .ul-link)::before {
    content: ""; position: absolute; left: var(--ul-x); right: var(--ul-x); bottom: var(--ul-b);
    height: 2px; border-radius: 1px; background: var(--sky);
    transform: scaleX(0); transform-origin: right center; pointer-events: none;
    transition: transform .2s ease;
}
@media (hover: hover) {
    :is(.lp-links a, .lib-name, .ul-link):hover::before { transform: scaleX(1); transform-origin: left center; }
}
@media (prefers-reduced-motion: reduce) {
    :is(.lp-links a, .lib-name, .ul-link)::before { transition: none; }
}

.lib-name { --ul-b: 0px; }

/* .btn이 display를 덮으므로 숨김 상태를 따로 준다 */
#downloadBtn[hidden] { display: none; }

/* 도구 화면 (1024px 이상, 높이 700px 이상): 머리 아래 한 화면에 맞춘다. 페이지는 스크롤하지 않고,
   넘치는 목록(.fl)과 파일 표(.tbl-wrap)만 그 칸 안에서 스크롤한다. 목록을 감싼 칸도 줄 수 있게 min-height를 0으로 둔다.
   구슬 레이스는 #race 칸을 쓴다(그 소스는 고치지 않고 여기서 맞춘다). 도움말(.doc-page)과 좁은 화면은 문서 스크롤을 그대로 둔다 */
@media (min-width: 1024px) and (min-height: 700px) {
    main.page:not(.doc-page):has(> #root, > #race) {
        height: calc(100dvh - var(--head-h));
        grid-template-rows: auto minmax(0, 1fr);
        gap: var(--s4); padding-block: var(--s4);
    }
    main.page:not(.doc-page):has(> #root, > #race) > :is(#root, #race),
    main.page:not(.doc-page):has(> #root, > #race) :is(#root, #race) :is(div, section):has(.fl, .tbl-wrap) {
        display: flex; flex-direction: column; min-height: 0;
    }
    main.page:not(.doc-page):has(> #root, > #race) .fl,
    main.page:not(.doc-page):has(> #root, > #race) .tbl-wrap { flex: 0 1 auto; min-height: 0; overflow: auto; }
    main.page:not(.doc-page):has(> #root, > #race) .tbl-wrap thead th { position: sticky; top: 0; background: var(--sf); }
    main.page:not(.doc-page):has(> #root, > #race) .file-zone { min-height: 96px; }
}
