/* ── Itdasy 작업실 화면 ─────────────────────────────────────────
   §5.9 슬롯 편집 풀스크린 + 슬롯카드 + 패널 바텀시트
   의존: tokens.css (vars), components.css (btn-*), details.css (dt-*)
   ────────────────────────────────────────────────────────────── */

/* ══ Step3: 슬롯 카드 (가로 스크롤 트레이) ═════════════════════ */

.ws-slot-card {
  width: 100%;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border, rgba(15,20,25,0.08));
  border-radius: var(--r-lg);
  padding: 10px;
  user-select: none;
  position: relative;
  transition: border-color 0.15s;
}
.ws-slot-card:active { border-color: var(--accent, #D58A95); }

.ws-slot-card--done {
  border-color: var(--accent, #D58A95);
}

.ws-slot-card__del {
  position: absolute;
  top: 6px; right: 6px;
  z-index: 2;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  color: var(--text-subtle);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.ws-slot-card__thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
}

.ws-slot-card__thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.ws-slot-card__thumb-count {
  position: absolute;
  bottom: 4px; right: 4px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 9px;
  color: #fff;
  font-weight: 700;
}

.ws-slot-card__empty {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--r-md);
  border: 2px dashed rgba(213,138,149, 0.35);
  background: rgba(213,138,149, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-subtle);
}

.ws-slot-card__meta {
  margin-top: 6px;
  text-align: center;
}

.ws-slot-card__name {
  font-size: 11px;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.ws-slot-card__count {
  font-size: 11px;
  color: var(--text-subtle);
  margin-top: 2px;
}

/* ══ Step3: 슬롯 편집 툴바 ════════════════════════════════════ */

/* 2026-04-24 — 슬롯 편집 옵션 툴바(배경/B/A/요소).
   #slotPopup 이 fixed 오버레이로 승격됐으므로 absolute 가 팝업 기준으로 동작.
   padding-bottom 은 안전영역 + 14px 만 (style-polish.css 가 #slotToolbar 에 추가 확장). */
.ws-toolbar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 10px calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-wrap: wrap;            /* [PR-2] 활성 헤더(풀폭 첫 행) + 버튼 6개 1행 */
  gap: 6px;
  z-index: 2;
  overflow-x: hidden;
}

/* [PR-2] 활성(편집 대상) 사진 컨텍스트 헤더 — 툴바 첫 행 풀폭 */
.ws-active-ctx {
  flex: 0 0 100%;
  order: -1;
  font-size: 11px;
  font-weight: 700;
  color: var(--brand-strong, var(--accent));
  padding: 2px 2px 4px;
  line-height: 1.2;
}
.ws-active-ctx:empty { display: none; }

.ws-toolbar__btn {
  flex: 1;
  min-width: 60px;
  padding: 10px 6px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  font-family: inherit;
  line-height: 1;
}

.ws-toolbar__btn:active {
  background: var(--surface-2);
}

.ws-toolbar__btn--active {
  border-color: var(--brand);
  background: var(--brand-bg);
  color: var(--brand-strong);
}

/* ══ Step4: 패널 바텀시트 껍데기 ════════════════════════════════ */

.ws-panel {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 9100;
  background: rgba(0, 0, 0, 0.5);
  align-items: flex-end;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}

.ws-panel--open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  transition: opacity .22s ease, transform .22s ease, visibility 0s linear 0s;
}

@media (prefers-reduced-motion: reduce) {
  .ws-panel,
  .ws-panel--open {
    transition: none;
  }
}

.ws-panel__sheet {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.ws-panel__sheet--sm  { max-height: 55vh; }
.ws-panel__sheet--md  { max-height: 75vh; }
.ws-panel__sheet--lg  { max-height: 85vh; }

.ws-panel__hdr {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.ws-panel__title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ws-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.ws-panel__close {
  /* [2026-06-10] 32px → 40px — 터치 타겟 확대 (고령 사용자/실수탭 방지) */
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: none;
  border-radius: 50%;
  color: var(--text-subtle);
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
}

/* reviewEditor / elementEditor — 풀스크린 다크 편집기 */
.ws-editor {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9200;
  background: #000;
  flex-direction: column;
}

.ws-editor--open {
  display: flex;
}

/* ── [PR-E1] 전후 Before/After 선택 패널 (슬롯 팝업 내부 슬라이드업) ── */
.ba-select-panel {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: flex-end;
  background: rgba(0,0,0,0.35);
}
.ba-select-panel[hidden] { display: none; }
.ba-select-sheet {
  width: 100%; background: #fff;
  border-radius: 18px 18px 0 0;
  padding: 16px 14px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 30px rgba(0,0,0,0.18);
  animation: ba-select-up 220ms ease-out;
}
@keyframes ba-select-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.ba-select-hd { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.ba-select-ttl strong { display: block; font-size: 16px; font-weight: 800; color: #1f2430; }
.ba-select-ttl span { display: block; font-size: 12px; color: #6b7280; margin-top: 3px; }
.ba-select-x { background: #f2f4f6; border: none; width: 32px; height: 32px; border-radius: 50%; color: #4e5968; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ba-select-strip { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 14px; scrollbar-width: none; }
.ba-select-strip::-webkit-scrollbar { display: none; }
.ba-card { position: relative; flex: 0 0 auto; width: 84px; height: 84px; border-radius: 12px; overflow: hidden; padding: 0; border: 2px solid transparent; background: #eceef1; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ba-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ba-card.on { border-color: #6b5cff; box-shadow: 0 0 0 2px rgba(107,92,255,0.22); }
.ba-badge { position: absolute; top: 4px; left: 4px; font-size: 9px; font-weight: 800; color: #fff; padding: 2px 7px; border-radius: 999px; }
.ba-badge--before { background: rgba(100,149,237,0.95); }
.ba-badge--after { background: rgba(213,138,149,0.95); }
.ba-select-cta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ba-cta { height: 44px; border-radius: 12px; border: 1px solid var(--border, rgba(15,20,25,0.12)); background: #f7f8fa; font-size: 13px; font-weight: 700; color: #1f2430; cursor: pointer; font-family: inherit; }
.ba-cta:active { transform: scale(0.98); }
.ba-cta--primary { grid-column: 1 / -1; background: #191f28; color: #fff; border: none; }
.ba-cta--primary:disabled { background: #c8ccd2; color: #fff; cursor: not-allowed; transform: none; }

/* ══ [C-lite 디자인 매칭] 첨부 이미지 기준 라이트 폴리싱 (CSS only, 로직 불변) ══ */
#slotPopup, #photoEditorSheet.pe-inline {
  --ws-clite-bg: #f7f8fb;
  --ws-clite-surface: #fff;
  --ws-clite-border: #e8eaf0;
  --ws-clite-text: #111827;
  --ws-clite-text-soft: #374151;
  --ws-clite-muted: #6b7280;
  --ws-clite-accent: #5b7cfa;
  --ws-clite-accent-2: #6c63ff;
  --ws-clite-accent-soft: rgba(91, 124, 250, 0.12);
  --ws-clite-accent-ring: rgba(91, 124, 250, 0.35);
}
/* 슬롯 팝업 — 밝은 톤 */
#slotPopup { background: var(--ws-clite-bg); }
/* 상단바 */
#slotPopup .dt-hdr { background: var(--ws-clite-surface); border-bottom: 1px solid rgba(232,234,240,0.8); }
#slotPopup .dt-title { font-size: 15px; font-weight: 750; color: var(--ws-clite-text); letter-spacing: -0.03em; }
#slotPopup .dt-back { border-radius: 14px; background: #f3f4f6; border: 1px solid var(--ws-clite-border); color: var(--ws-clite-text-soft); }
/* 헤더 보조 '잇비' 버튼 (하단에서 이전) */
#slotPopup .slot-itbi-hd {
  width: 36px; height: 36px; border-radius: 12px; flex-shrink: 0;
  background: #f3f4f6; border: 1px solid var(--ws-clite-border);
  color: var(--ws-clite-accent-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
#slotPopup .slot-itbi-hd:active { transform: scale(0.96); background: var(--ws-clite-accent-soft); }
/* 하단 메뉴 — 아이콘+라벨, 보더리스, accent active */
#slotPopup .ws-toolbar {
  background: rgba(255,255,255,0.97); border-top: 1px solid var(--ws-clite-border);
  gap: 0; padding: 6px 6px calc(8px + env(safe-area-inset-bottom, 0px)); backdrop-filter: blur(12px);
}
#slotPopup .ws-toolbar__btn {
  flex: 1; min-width: 0; border: 0; background: transparent; border-radius: 14px;
  color: #4b5563; font-size: 10.5px; font-weight: 700; letter-spacing: -0.04em; gap: 3px; padding: 7px 2px;
}
#slotPopup .ws-toolbar__btn svg, #slotPopup .ws-toolbar__btn .ic { width: 19px; height: 19px; }
#slotPopup .ws-toolbar__btn:active { transform: scale(0.96); background: var(--ws-clite-accent-soft); }
#slotPopup .ws-toolbar__btn--active { color: var(--ws-clite-accent); background: var(--ws-clite-accent-soft); border: 0; }
#slotPopup .ws-active-ctx { color: var(--ws-clite-muted); font-weight: 700; }

/* ══ [PR-Design-2] 슬롯 기본 화면: 상단 스트립 + 중앙 큰 메인 ══ */
#slotPopup .ws-strip { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 10px; scrollbar-width: none; }
#slotPopup .ws-strip::-webkit-scrollbar { display: none; }
#slotPopup .ws-strip-thumb {
  position: relative; flex: 0 0 64px; width: 64px; height: 64px;
  border-radius: 12px; overflow: hidden; padding: 0; cursor: pointer;
  border: 2px solid transparent; background: #f3f4f6;
  transition: border-color .16s, box-shadow .16s, transform .16s;
}
#slotPopup .ws-strip-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
#slotPopup .ws-strip-thumb.is-active { border-color: #5b7cfa; box-shadow: 0 0 0 2px rgba(91,124,250,0.30); }
#slotPopup .ws-strip-thumb:active { transform: scale(0.97); }
#slotPopup .ws-strip-num { position: absolute; left: 4px; top: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: rgba(17,24,39,0.72); color: #fff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
#slotPopup .ws-strip-check { position: absolute; right: 4px; top: 4px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,0.32); color: #fff; font-size: 11px; line-height: 1; display: flex; align-items: center; justify-content: center; }
#slotPopup .ws-strip-check.on { background: #5b7cfa; }
#slotPopup .ws-strip-ba { position: absolute; left: 4px; bottom: 4px; font-size: 8px; font-weight: 800; color: #fff; padding: 1px 5px; border-radius: 999px; }
#slotPopup .ws-strip-ba.before { background: rgba(100,149,237,0.92); }
#slotPopup .ws-strip-ba.after { background: rgba(213,138,149,0.92); }
#slotPopup .ws-strip-add { flex: 0 0 64px; width: 64px; height: 64px; border-radius: 12px; border: 1.5px dashed #d1d5db; background: #f5f6f8; color: #9ca3af; display: flex; align-items: center; justify-content: center; cursor: pointer; }
#slotPopup .ws-strip-add:active { transform: scale(0.97); }
/* 중앙 큰 active 미리보기 */
#slotPopup .ws-main {
  position: relative; margin: 2px 0 12px; border-radius: 20px; overflow: hidden;
  background: #f1f3f7; border: 1px solid var(--ws-clite-border, #e8eaf0);
  box-shadow: 0 10px 28px rgba(15,23,42,0.08);
  display: flex; align-items: center; justify-content: center;
  min-height: 46vh; max-height: 58vh;
}
#slotPopup .ws-main-img { width: 100%; height: 100%; max-height: 58vh; object-fit: contain; display: block; }
#slotPopup .ws-main-empty { color: #9ca3af; font-size: 13px; padding: 48px 12px; }
#slotPopup .ws-main-pill { position: absolute; right: 12px; top: 12px; min-width: 44px; height: 30px; padding: 0 11px; border-radius: 999px; background: rgba(17,24,39,0.66); color: #fff; font-size: 13px; font-weight: 750; display: inline-flex; align-items: center; justify-content: center; backdrop-filter: blur(8px); }
#slotPopup .ws-main-undo { position: absolute; right: 12px; bottom: 12px; width: 38px; height: 38px; border-radius: 999px; background: rgba(255,255,255,0.92); border: 1px solid rgba(232,234,240,0.9); box-shadow: 0 8px 20px rgba(15,23,42,0.12); color: #111827; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
#slotPopup .ws-main-undo:active { transform: scale(0.94); }
/* 완료 버튼 — 슬롯 팝업 내부만 다크 네이비(전역 btn-primary 불변) */
#slotPopup .dt-hdr .btn-primary { background: #111827 !important; color: #fff !important; border-radius: 16px !important; box-shadow: none !important; }
@media (width <= 430px) {
  #slotPopup .ws-strip-thumb, #slotPopup .ws-strip-add { flex-basis: 60px; width: 60px; height: 60px; }
}
