/* AI 로 만들기 (2026-09-25) - aipop.js 전용. 🔴 `.aipop-*` 와 `#aipop-*` 밖을 건드리지 않는다.
   (같은 때 다른 작업이 style.css 의 모바일 전수 개선을 하고 있다. 겹치지 않게 범위를 여기로 좁혔다.) */

/* ---- 입구 (만들기 창 맨 위 큰 카드) ---- */
#edit-banner:not(.hidden) ~ .aipop-entry-card { display: none; }
.aipop-entry-card { padding: 0; overflow: hidden; }
/* 템플릿 화면 머리의 같은 카드 - 탭 위에 한 칸 띄운다 */
#aipop-card-layouts { margin: 0 0 16px; }
/* 만들기 창에서 AI 카드 밑, 예전 상품 POP 양식이 보조 입구라는 한 줄 (2026-09-25) */
.create-alt-head { margin: 8px 4px 12px; font-size: 16px; line-height: 24px; font-weight: 600; color: var(--text-sub, #555); }
#edit-banner:not(.hidden) ~ .create-alt-head { display: none; }
.aipop-entry { display: flex; align-items: center; gap: 16px; width: 100%; min-height: 88px; padding: 20px; border: 0;
  background: var(--primary-soft, #eef4ff); color: var(--text, #111); text-align: left; cursor: pointer; font: inherit; }
.aipop-entry:hover { background: var(--primary-light, #dbe7ff); }
.aipop-entry:focus-visible { outline: 3px solid var(--primary, #2563eb); outline-offset: -3px; }
.aipop-entry strong { display: block; font-size: 20px; line-height: 28px; margin-bottom: 4px; }
.aipop-entry-hint { display: block; font-size: 16px; line-height: 24px; color: var(--text-sub, #555); }
.aipop-entry-icon { flex: 0 0 auto; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px;
  background: var(--brand-grad, #2563eb); color: #fff; font-size: 24px; line-height: 1; }

/* ---- 창 ---- */
body.aipop-open { overflow: hidden; }
.aipop-dialog { padding: 0; border: 0; border-radius: 16px; width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  background: var(--bg, #fff); color: var(--text, #111); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); overflow: hidden; }
.aipop-dialog::backdrop { background: rgba(15, 18, 30, .55); }
.aipop-sheet { display: flex; flex-direction: column; max-height: calc(100dvh - 48px); margin: 0; }
.aipop-head { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--divider, #eee); }
.aipop-head h2 { flex: 1 1 auto; margin: 0; font-size: 20px; line-height: 28px; }
.aipop-x { flex: 0 0 auto; width: 48px; height: 48px; border: 0; border-radius: 12px; background: transparent; color: inherit;
  font-size: 24px; line-height: 1; cursor: pointer; }
.aipop-x:hover { background: var(--surface, #eee); }
.aipop-body { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 20px 8px; overscroll-behavior: contain; }
.aipop-lead { margin: 0 0 16px; font-size: 16px; line-height: 24px; color: var(--text-sub, #555); }
.aipop-foot { flex: 0 0 auto; padding: 12px 20px calc(16px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--divider, #eee);
  background: var(--bg, #fff); }
.aipop-say { margin: 0 0 8px; min-height: 22px; font-size: 16px; line-height: 24px; color: var(--text-sub, #555); text-align: center; }
.aipop-say.warn { color: var(--warn-text, #9a3412); font-weight: 600; }
.aipop-go { display: block; width: 100%; min-height: 56px; border: 0; border-radius: 14px; background: var(--primary, #2563eb); color: #fff;
  font: inherit; font-size: 18px; font-weight: 700; cursor: pointer; }
.aipop-go:hover:not(:disabled) { background: var(--primary-hover, #1d4ed8); }
.aipop-go:disabled { background: var(--surface, #ddd); color: var(--text-disabled, #999); cursor: default; }

/* 글 칸 - 창의 중심(2026-10-03). 사진 · 파일 · 링크는 이 칸 아래쪽에 붙는 첨부다(채팅 입력창 모양). */
.aipop-compose { display: flex; flex-direction: column; margin: 0 0 12px; border: 1px solid var(--line, #ccc); border-radius: 16px;
  background: var(--bg, #fff); overflow: hidden; }
.aipop-compose:focus-within { border-color: var(--primary, #2563eb); box-shadow: 0 0 0 3px var(--primary-soft, #eef4ff); }
.aipop-compose.over { border-color: var(--primary, #2563eb); background: var(--primary-soft, #eef4ff); }
.aipop-text { display: block; width: 100%; box-sizing: border-box; min-height: 168px; max-height: 40dvh; padding: 16px; border: 0; outline: 0; resize: vertical;
  background: transparent; color: var(--text, #111); font: inherit; font-size: 17px; line-height: 26px; }
.aipop-text::placeholder { color: var(--text-hint, #888); }
.aipop-atts { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 12px 12px; }
.aipop-att { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 44px; padding: 4px 4px 4px 8px; box-sizing: border-box;
  border: 1px solid var(--line, #ddd); border-radius: 12px; background: var(--page, #f5f5f7); font-size: 14px; line-height: 20px; }
.aipop-att-photo { padding-left: 4px; }
.aipop-att img { display: block; width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: #111; }
.aipop-att-ic { display: grid; place-items: center; flex: none; width: 24px; height: 24px; color: var(--primary, #2563eb); }
.aipop-att-ic svg { width: 20px; height: 20px; }
.aipop-att-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.aipop-att-x { flex: none; width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--text-sub, #555);
  font: inherit; font-size: 14px; cursor: pointer; }
.aipop-att-x:hover { background: var(--surface, #e5e5ea); }
.aipop-linkrow { display: flex; gap: 8px; padding: 0 12px 12px; }
.aipop-linkrow input { flex: 1 1 auto; min-width: 0; box-sizing: border-box; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line, #ccc);
  border-radius: 12px; background: var(--bg, #fff); color: var(--text, #111); font: inherit; font-size: 16px; line-height: 24px; }
.aipop-linkrow .aipop-btn { flex: none; }
.aipop-tools { display: flex; gap: 4px; padding: 6px 8px; border-top: 1px solid var(--divider, #eee); background: var(--page, #fafafa); }
.aipop-tool { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent;
  color: var(--text, #111); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.aipop-tool:hover { background: var(--surface, #e9e9ee); }
.aipop-tool:focus-within, .aipop-tool:focus-visible { outline: 2px solid var(--primary, #2563eb); outline-offset: -2px; }
.aipop-tool svg { width: 22px; height: 22px; color: var(--primary, #2563eb); flex: none; }
.aipop-dialog .hidden { display: none !important; }
.aipop-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 16px; border: 1px solid var(--line, #ccc);
  border-radius: 12px; background: var(--bg, #fff); color: var(--text, #111); font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; }
.aipop-btn:hover { background: var(--surface, #eee); }
.aipop-btn-soft { background: var(--page, #f5f5f7); }
.aipop-btn-main { border-color: var(--primary, #2563eb); background: var(--primary, #2563eb); color: #fff; }
.aipop-btn-main:hover { background: var(--primary-hover, #1d4ed8); }
.aipop-field { display: block; margin: 0 0 12px; }
.aipop-label { display: block; margin: 0 0 6px; font-size: 16px; line-height: 24px; font-weight: 600; }
.aipop-check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: -4px 0 16px; font-size: 16px; line-height: 24px; cursor: pointer; }
.aipop-check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--primary, #2563eb); }
.aipop-check.hidden { display: none; }
.aipop-field input[type=text], .aipop-field input[type=url] { width: 100%; box-sizing: border-box; min-height: 52px; padding: 12px 14px; border: 1px solid var(--line, #ccc);
  border-radius: 12px; background: var(--bg, #fff); color: var(--text, #111); font: inherit; font-size: 16px; line-height: 24px; }
.aipop-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 20px; }
.aipop-chip { min-height: 40px; padding: 0 14px; border: 1px solid var(--line, #ccc); border-radius: 999px; background: var(--bg, #fff);
  color: var(--text-sub, #555); font: inherit; font-size: 14px; line-height: 22px; cursor: pointer; }
.aipop-chip:hover { background: var(--surface, #eee); }
.aipop-seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.aipop-seg button { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px; border: 2px solid var(--line, #ccc);
  border-radius: 12px; background: var(--bg, #fff); color: var(--text, #111); font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; }
.aipop-seg button.on { border-color: var(--primary, #2563eb); background: var(--primary-soft, #eef4ff); }
.aipop-tv { display: inline-block; border: 2px solid currentColor; border-radius: 3px; }
.aipop-tv-l { width: 26px; height: 16px; }
.aipop-tv-p { width: 14px; height: 24px; }
.aipop-note { display: block; margin: 6px 0 0; font-size: 14px; line-height: 20px; color: var(--text-hint, #777); }

/* 폰 - 화면 전체를 덮는 시트. 머리와 바닥은 붙어 있고 가운데만 굴러간다. */
@media (max-width: 640px) {
  .aipop-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .aipop-sheet { height: 100dvh; max-height: 100dvh; }
  .aipop-head { padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 8px 16px; }
  .aipop-body { padding: 16px 16px 8px; }
  .aipop-foot { padding-left: 16px; padding-right: 16px; }
  .aipop-text { min-height: 176px; }
}

/* ---- 만드는 중 카드 줄 ---- */
.aipop-strip { margin: 0 0 16px; }
.aipop-strip.hidden { display: none; }
.aipop-strip-head h2 { margin: 0 0 8px; font-size: 18px; line-height: 28px; }
.aipop-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.aipop-card { display: flex; gap: 12px; padding: 12px; border: 1px solid var(--line, #ddd); border-radius: var(--radius-card, 12px);
  background: var(--bg, #fff); color: var(--text, #111); min-width: 0; }
.aipop-card.aipop-done { border-color: var(--primary, #2563eb); }
.aipop-card.aipop-failed { border-color: var(--badge-danger-bg, #fecaca); }
.aipop-thumb { position: relative; flex: 0 0 auto; width: 88px; height: 88px; border-radius: 10px; overflow: hidden; background: var(--surface, #eee); }
.aipop-thumb img { width: 100%; height: 100%; object-fit: cover; }
/* 완성 카드는 결과 화면(16:9 · 9:16)이 잘리지 않게 담는다 */
.aipop-card.aipop-done .aipop-thumb { width: 128px; height: 72px; background: #111; align-self: flex-start; }
.aipop-card.aipop-done .aipop-thumb img { object-fit: contain; }
.aipop-more { margin-top: 8px; }
.aipop-card.aipop-active .aipop-thumb img { filter: saturate(.6) brightness(.8); }
.aipop-spin { position: absolute; inset: 0; margin: auto; width: 32px; height: 32px; border: 3px solid rgba(255, 255, 255, .45);
  border-top-color: #fff; border-radius: 50%; animation: aipop-spin 1s linear infinite; }
@keyframes aipop-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .aipop-spin { animation-duration: 3s; } }
.aipop-cbody { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 auto; }
.aipop-cbody strong { font-size: 16px; line-height: 22px; }
.aipop-muted { font-size: 14px; line-height: 20px; color: var(--text-sub, #555); }
.aipop-steps { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }
.aipop-steps li { flex: 1 1 0; height: 6px; border-radius: 3px; background: var(--surface, #e5e5e5); }
.aipop-steps li.done { background: var(--primary, #2563eb); }
.aipop-steps li.now { background: var(--primary-light, #93c5fd); }
.aipop-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.aipop-acts .aipop-btn { min-height: 44px; font-size: 14px; line-height: 22px; padding: 0 14px; }
@media (max-width: 640px) {
  .aipop-cards { grid-template-columns: 1fr; }
}

/* 무료 AI 남은 횟수 한 줄 + 다 쓴 뒤 안내 (2026-10-03) */
.aipop-free { margin: 6px 0 12px; font-size: 13px; line-height: 18px; color: var(--text-sub, #555); text-align: left; }
.aipop-upsell { margin: 10px 0 14px; padding: 12px 14px; border: 1px solid var(--divider, #eee); border-radius: 12px; background: var(--surface-2, #f7f7f8); }
.aipop-upsell p { margin: 0 0 10px; font-size: 15px; line-height: 22px; font-weight: 600; }
.aipop-upsell .aipop-btn { min-height: 44px; }
.aipop-flash { outline: 2px solid var(--accent, #2563eb); outline-offset: 2px; border-radius: 12px; }
