/* 모두의 퍼즐 — 그림 고르기·올리기 창 (public/js/jigsaw/picker.js). 색·글꼴·모서리는 style.css 토큰 그대로, 여기에는 이 창의 배치만 */
html.jp-lock, html.jp-lock body { overflow: hidden; }
.jp-overlay {
    position: fixed; inset: 0; z-index: var(--z-modal);
    background: rgba(0, 0, 0, 0.62);
    display: flex; align-items: center; justify-content: center;
    padding: clamp(0px, 3vmin, 32px);
}
.jp-overlay[hidden] { display: none; }
.jp-overlay.jp-only-layer > .jp-dialog { visibility: hidden; }
.jp-dialog {
    position: relative;
    width: min(1080px, 100%); height: min(860px, 100%);
    display: flex; flex-direction: column;
    background: var(--bg-card); color: var(--text-main);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2); font-family: var(--font-sans);
    overflow: hidden;
}
.jp-head, .jp-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.jp-head { padding: 14px clamp(12px, 2.5vw, 22px) 6px; }
.jp-head, .jp-tabs, .jp-cats, .jp-tools { flex-shrink: 0; }
.jp-title { margin: 0; font-size: clamp(1rem, 0.95rem + 0.3vw, 1.2rem); font-weight: 700; }
.jp-close {
    flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%;
    border: 1px solid var(--border-strong); background: transparent; color: var(--text-sub);
    font-size: 0.95rem; cursor: pointer;
}
.jp-close:hover { color: var(--text-main); border-color: var(--text-dim); }

.jp-tabs { display: flex; align-items: center; gap: 4px; padding: 0 clamp(12px, 2.5vw, 22px); border-bottom: 1px solid var(--border-dim); }
.jp-tab {
    padding: 10px 12px; background: none; border: none; border-bottom: 2px solid transparent;
    color: var(--text-sub); font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.jp-tab[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.jp-tab:hover { color: var(--text-main); }
.jp-up-open { margin-left: auto; white-space: nowrap; }

.jp-cats { display: flex; gap: 6px; overflow-x: auto; padding: 10px clamp(12px, 2.5vw, 22px) 0; scrollbar-width: thin; }
.jp-cats[hidden] { display: none; }
.jp-cats .filter-tab { flex: 0 0 auto; }
.jp-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; padding: 10px clamp(12px, 2.5vw, 22px); }
.jp-search { flex: 0 1 280px; min-width: 0; }
.jp-note { flex: 1 1 260px; font-size: 0.78rem; color: var(--text-dim); line-height: 1.5; }

.jp-body { flex: 1 1 auto; overflow-y: auto; padding: 0 clamp(12px, 2.5vw, 22px) 18px; }
.jp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(170px, 42vw), 1fr)); gap: clamp(8px, 1.2vw, 14px); }
@media (min-width: 2200px) { .jp-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); } }
.jp-loading, .jp-empty { grid-column: 1 / -1; padding: 40px 12px; text-align: center; color: var(--text-dim); font-size: 0.88rem; line-height: 1.8; }
.jp-empty .btn { margin-left: 6px; }
.jp-more { display: block; margin: 16px auto 0; }
.jp-more[hidden] { display: none; }

.jp-card { display: flex; flex-direction: column; min-width: 0; background: var(--bg-elev); border: 1px solid var(--border-dim); border-radius: var(--radius); overflow: hidden; }
.jp-card:hover { border-color: var(--border-strong); }
.jp-pick { display: flex; flex-direction: column; gap: 3px; padding: 0 0 8px; background: none; border: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.jp-thumb { position: relative; display: block; aspect-ratio: 3 / 2; background: var(--bg-input); overflow: hidden; }
.jp-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.jp-name { padding: 6px 10px 0; font-size: 0.86rem; font-weight: 600; color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jp-meta { padding: 0 10px; font-size: 0.74rem; color: var(--text-dim); display: flex; gap: 8px; flex-wrap: wrap; }
.jp-by { color: var(--text-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.jp-why { padding: 0 10px; font-size: 0.72rem; color: var(--warn); line-height: 1.4; }
.jp-card.is-off .jp-thumb img { opacity: 0.45; filter: grayscale(0.6); }
.jp-card.is-off .jp-pick { cursor: not-allowed; }
.jp-badge { position: absolute; left: 6px; top: 6px; padding: 2px 8px; border-radius: 999px; font-size: 0.7rem; font-weight: 700; background: rgba(0, 0, 0, 0.7); color: #fff; }
.jp-st-pending { color: var(--brand); }
.jp-st-hidden, .jp-st-rejected { color: var(--danger); }
.jp-acts { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 10px 10px; margin-top: auto; }
.jp-mini { padding: 3px 9px; font: inherit; font-size: 0.72rem; color: var(--text-sub); background: transparent; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; }
.jp-mini:hover { color: var(--text-main); border-color: var(--text-dim); }
.jp-mini-del:hover { color: var(--danger); border-color: var(--danger); }

/* 겹 창 — 올리기·신고 (배경을 눌러도 닫히지 않음) */
.jp-layer { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, 0.55); }
.jp-sheet {
    width: min(560px, 100%); max-height: 100%; overflow-y: auto; box-sizing: border-box;
    background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-2); padding: 16px clamp(14px, 3vw, 22px) 14px;
}
.jp-sheet-title { margin: 0; font-size: 1.02rem; font-weight: 700; }
.jp-sheet-head { margin-bottom: 10px; }
.jp-lead, .jp-hint { font-size: 0.8rem; color: var(--text-dim); line-height: 1.6; margin: 6px 0 10px; }
.jp-sheet-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.jp-sheet fieldset { border: 1px solid var(--border-dim); border-radius: var(--radius); padding: 8px 12px 10px; margin: 10px 0; min-width: 0; }
.jp-sheet legend { padding: 0 4px; font-size: 0.8rem; font-weight: 700; color: var(--text-sub); }
.jp-radio, .jp-check { display: flex; align-items: flex-start; gap: 8px; padding: 5px 0; font-size: 0.86rem; line-height: 1.5; color: var(--text-main); cursor: pointer; }
.jp-radio input, .jp-check input { margin-top: 3px; flex: 0 0 auto; accent-color: var(--brand); width: 16px; height: 16px; }
.jp-scope { display: flex; gap: 4px 18px; flex-wrap: wrap; }
.jp-scope legend { width: 100%; }
.jp-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: var(--text-sub); margin: 8px 0; }
.jp-field .form-input { width: 100%; box-sizing: border-box; }

.jp-drop {
    position: relative; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px;
    min-height: 120px; padding: 12px; border: 2px dashed var(--border-strong); border-radius: var(--radius);
    background: var(--bg-input); color: var(--text-sub); cursor: pointer; text-align: center; font-size: 0.88rem;
}
.jp-drop:hover, .jp-drop:focus-within { border-color: var(--brand); color: var(--text-main); }
.jp-file { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.jp-drop-img img { max-width: 100%; max-height: 180px; border-radius: var(--radius-sm); display: block; }
.jp-drop-img[hidden] { display: none; }
.jp-file-info { font-size: 0.8rem; color: var(--ok); margin: 6px 0 0; min-height: 1.2em; }
.jp-file-info.is-bad { color: var(--danger); }
.jp-grow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 6px 0 0; }
.jp-grow[hidden] { display: none; }
.jp-grow .jp-hint { margin: 0; }

.jp-progress { margin-top: 8px; }
.jp-progress[hidden] { display: none; }
.jp-bar { height: 8px; border-radius: 4px; background: var(--bg-input); overflow: hidden; }
.jp-bar > i { display: block; height: 100%; width: 0; background: var(--brand); transition: width 0.2s; }
.jp-progress.is-check .jp-bar > i { width: 100% !important; animation: jp-pulse 1.2s ease-in-out infinite; }
@keyframes jp-pulse { 50% { opacity: 0.45; } }
.jp-progress-text { display: block; margin-top: 4px; font-size: 0.78rem; color: var(--text-sub); }

.jp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.jp-overlay :focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.jp-pick:focus-visible { outline-offset: -2px; }

/* 휴대폰 — 화면 가득, 탭은 가로로 밀기 */
@media (max-width: 600px) {
    .jp-overlay { padding: 0; }
    .jp-dialog { height: 100%; border-radius: 0; border: none; }
    .jp-tabs { overflow-x: auto; }
    .jp-tab { padding: 10px 8px; font-size: 0.86rem; }
    .jp-up-open { padding: 6px 10px; font-size: 0.8rem; }
    .jp-search { flex-basis: 100%; }
    .jp-layer { padding: 0; align-items: flex-end; }
    .jp-sheet { border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 94%; }
}
@media (prefers-reduced-motion: reduce) {
    .jp-bar > i { transition: none; }
    .jp-progress.is-check .jp-bar > i { animation: none; }
}

/* 크게 보기 (고르기 창 카드 · 게임 중 완성 그림 미리보기) — 배경을 눌러도 안 닫힘 */
.jp-zoom { position: fixed; inset: 0; z-index: calc(var(--z-modal, 2000) + 20); display: flex; align-items: center; justify-content: center; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); background: rgba(0, 0, 0, 0.9); }
.jp-zoom[hidden] { display: none; }
.jp-zoom-fig { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 100%; max-height: 100%; }
.jp-zoom-fig img { display: block; max-width: min(96vw, 1800px); max-height: calc(100dvh - 120px); width: auto; height: auto; object-fit: contain; border-radius: var(--radius-sm, 6px); background: rgba(255, 255, 255, 0.04); }
.jp-zoom-fig figcaption { color: #eef0ec; font-size: 0.9rem; text-align: center; }
.jp-zoom-fig figcaption:empty { display: none; }
.jp-zoom-x { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 10px; min-width: 48px; min-height: 44px; padding: 8px 14px; font: inherit; font-size: 0.95rem; font-weight: 600; color: #fff; background: rgba(20, 20, 20, 0.75); border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 999px; cursor: pointer; }
.jp-zoom-x:hover { background: rgba(50, 50, 50, 0.9); }
.jp-zoom-x:focus-visible { outline: 2px solid var(--brand, #f3dcae); outline-offset: 2px; }
