/* 블로그 관리 화면 */
* { box-sizing: border-box; }
:root { --navy: #0a1d38; --blue: #1f6fc4; --blue-d: #1659a6; --ink: #0e1726; --body: #3b4658; --muted: #6b778a; --line: #e3e8ef; --soft: #f4f7fb; --red: #c62828; }
body { margin: 0; background: var(--soft); color: var(--body); font-family: "Pretendard Variable", Pretendard, -apple-system, "Malgun Gothic", sans-serif; line-height: 1.6; word-break: keep-all; }
.bar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; background: var(--navy); color: #fff; }
.bar .brand { color: #fff; font-weight: 800; font-size: 18px; text-decoration: none; }
.bar-right { display: flex; gap: 8px; align-items: center; }
.bar-links { display: flex; gap: 8px; align-items: center; margin-right: auto; }
@media (max-width: 520px) { .bar { padding: 10px 12px; gap: 8px; flex-wrap: wrap; } .bar-links { flex-wrap: wrap; order: 3; width: 100%; margin-right: 0; } .bar .brand { font-size: 15px; } }
main { max-width: 860px; margin: 0 auto; padding: 24px 16px 120px; }
.center { padding: 80px 0; text-align: center; }
.muted { color: var(--muted); }
h1 { margin: 0 0 18px; font-size: 24px; color: var(--ink); }
.card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin-bottom: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--body); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #c4cfdd; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-d); }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.35); color: #fff; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }

/* 목록 */
.plist { display: grid; gap: 10px; }
.pitem { display: grid; grid-template-columns: 72px 1fr auto; gap: 14px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.pitem .th { width: 72px; height: 56px; border-radius: 8px; background: var(--soft) center / cover no-repeat; }
.pitem .t { font-weight: 700; color: var(--ink); }
.pitem .s { font-size: 13px; color: var(--muted); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; margin-right: 6px; }
.badge.pub { background: #e3f5ea; color: #1b7a3e; }
.badge.draft { background: #fff1e5; color: #c25b00; }
.acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* 입력 */
label.f { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 700; color: var(--ink); }
label.f .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
input[type=text], select, textarea { display: block; width: 100%; margin-top: 6px; padding: 11px 12px; border: 1px solid #cfd8e3; border-radius: 10px; background: #fff; font: inherit; font-size: 16px; color: var(--ink); }
textarea { resize: vertical; min-height: 84px; line-height: 1.6; field-sizing: content; } /* 높이는 글 줄 수에 맞춤 (미지원 브라우저는 auto-grow.js) */
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31,111,196,.35); border-color: var(--blue); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
details.card > summary { cursor: pointer; font-weight: 700; color: var(--ink); }
details.card[open] > summary { margin-bottom: 14px; }

/* 블록 */
.block { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 14px; }
.block-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 800; color: var(--ink); }
.photos { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.ph { position: relative; width: 112px; height: 84px; border-radius: 10px; overflow: hidden; background: var(--soft); border: 1px solid var(--line); }
.ph img { width: 100%; height: 100%; object-fit: cover; }
.ph button { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; font-size: 15px; line-height: 1; cursor: pointer; }
.add-photo { display: grid; place-items: center; width: 112px; height: 84px; border-radius: 10px; border: 2px dashed #b9c6d6; color: var(--blue); font-weight: 700; font-size: 14px; cursor: pointer; text-align: center; }
.add-photo input { display: none; }
.add-photo.busy { opacity: .6; pointer-events: none; }
.add-block { width: 100%; padding: 14px; border: 2px dashed #b9c6d6; background: transparent; border-radius: 14px; color: var(--blue); font: inherit; font-weight: 800; cursor: pointer; }

/* 아래 고정 줄 */
.actions { position: fixed; inset: auto 0 0 0; z-index: 25; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(8px); }
.problems { margin: 0 0 14px; padding: 12px 16px; border-radius: 12px; background: #fff3f3; border: 1px solid #f2c4c4; color: var(--red); font-size: 14px; }
.problems ul { margin: 4px 0 0; padding-left: 18px; }

/* 미리보기 */
.modal { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; background: rgba(10,29,56,.6); }
.modal .mh { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); font-weight: 800; color: var(--ink); }
.modal iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.modal .mb { flex: 1; overflow: auto; background: #fff; padding: 16px; }
.err { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.err b { color: var(--ink); }
/* 네이버용 복사 */
.nv { max-width: 760px; margin: 0 auto; }
.nv ol { margin: 0 0 14px; padding: 12px 16px 12px 34px; border-radius: 12px; background: var(--soft); font-size: 14.5px; }
.nv .row { margin-bottom: 10px; }
.nv > .muted { font-size: 13px; }
.nv-warn { margin: 0 0 14px; padding: 10px 14px; border-radius: 12px; background: #fff1e5; color: #8a4300; font-size: 14px; }
.nv-view { padding: 14px; border: 1px dashed #b9c6d6; border-radius: 12px; overflow-wrap: anywhere; }
.nv-view h2 { margin: 0 0 12px; font-size: 19px; color: var(--ink); }
.nv-view img { max-width: 100%; height: auto; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 50; max-width: 90vw; padding: 11px 18px; border-radius: 12px; background: #172033; color: #fff; font-size: 14.5px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.bad { background: var(--red); }
/* 결과 팝업 (AI 성공·실패) */
.dlg { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: rgba(10,29,56,.6); }
.dlg-box { width: 100%; max-width: 440px; max-height: 90vh; overflow: auto; padding: 24px 22px 18px; border-radius: 18px; background: #fff; border-top: 6px solid var(--blue); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.dlg-box.bad { border-top-color: var(--red); }
.dlg-box.wait { border-top-color: #d99100; }
.dlg-box h2 { margin: 0 0 14px; font-size: 19px; color: var(--ink); }
.dlg-box dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 14px; font-size: 14.5px; }
.dlg-box dt { color: var(--muted); white-space: nowrap; }
.dlg-box dd { margin: 0; color: var(--ink); word-break: keep-all; overflow-wrap: anywhere; }
.dlg-box p { margin: 0 0 8px; font-size: 14.5px; line-height: 1.6; color: var(--body); word-break: keep-all; }
.dlg-btns { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.dlg-btns .btn { min-width: 100px; }
@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
  .pitem { grid-template-columns: 56px 1fr; }
  .pitem .acts { grid-column: 1 / -1; justify-content: flex-start; }
  .pitem .th { width: 56px; height: 44px; }
}

/* 드래그앤드롭·안내 */
.tipbox { margin: 0 0 14px; padding: 12px 16px; border-radius: 12px; background: #eef5fc; border: 1px solid #d6e6f6; font-size: 14px; color: var(--body); }
.block.dragover, .add-block.dragover { outline: 3px dashed var(--blue); outline-offset: -3px; background: #eef5fc; }
.add-block small { display: block; margin-top: 2px; font-weight: 500; color: var(--muted); }
.add-photo small { display: block; margin-top: 2px; font-size: 11.5px; font-weight: 500; color: var(--muted); }
.ph img { cursor: zoom-in; }
.ph-x, .ph-m { position: absolute; width: 26px; height: 26px; border: 0; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; }
.ph-x { top: 4px; right: 4px; }
.ph-m { bottom: 4px; right: 4px; }
.ph button { top: auto; right: auto; } /* 예전 규칙 무효화 */
.ph .ph-x { top: 4px; right: 4px; }
.ph .ph-m { bottom: 4px; right: 4px; }

/* 가리기 화면 */
.modal.editor { z-index: 60; background: #0b1220; }
.modal.editor .mh { flex-wrap: wrap; gap: 8px; }
.modal.editor .mt { font-weight: 800; }
.modal.editor .stage { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; background: #0b1220; }
.modal.editor canvas { touch-action: none; cursor: crosshair; background: #000; }
.modal.editor .tip { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: #fff; font-size: 13.5px; color: var(--body); }

/* 크게 보기 */
.modal.viewer { z-index: 50; background: #0b1220; }
.viewer .vbody { flex: 1; display: flex; min-height: 0; }
.viewer .vimg { position: relative; flex: 1; min-width: 0; display: grid; place-items: center; background: #0b1220; padding: 8px; }
.viewer .vimg img { position: absolute; inset: 8px; width: calc(100% - 16px); height: calc(100% - 16px); object-fit: contain; }
.viewer .vside { width: 360px; padding: 16px; overflow: auto; background: #fff; border-left: 1px solid var(--line); }
.viewer .vside textarea { min-height: 180px; }
.vnav { position: absolute; z-index: 1; top: 50%;transform: translateY(-50%); width: 44px; height: 64px; border: 0; border-radius: 10px; background: rgba(255,255,255,.16); color: #fff; font-size: 30px; cursor: pointer; }
.vnav:hover { background: rgba(255,255,255,.28); }
.vnav:disabled { opacity: .25; cursor: default; }
.vnav.prev { left: 10px; } .vnav.next { right: 10px; }
@media (max-width: 760px) {
  .viewer .vbody { flex-direction: column; }
  .viewer .vimg { flex: 1 1 52%; }
  .viewer .vside { width: auto; flex: 0 0 auto; max-height: 44%; border-left: 0; border-top: 1px solid var(--line); }
  .viewer .vside textarea { min-height: 96px; }
  .vnav { width: 36px; height: 52px; font-size: 24px; }
}

/* AI 글 만들기 */
.aibox { margin: 0 0 14px; padding: 16px 18px; border-radius: 14px; background: linear-gradient(135deg, #f1f6ff, #eaf1fb); border: 1px solid #cfdcf0; }
.aibox select { display: inline-block; width: auto; margin: 0; padding: 9px 12px; font-size: 15px; }
.aibox .chk { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink); }
.ainote { margin-top: 12px; padding: 10px 14px; border-radius: 10px; background: #fff8e6; border: 1px solid #f1dda0; color: #6e5200; font-size: 14px; }
.aitext textarea { background: #f6faff; border-color: #bcd2ee; }

/* AI 글 길이 고르기 */
.lens { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 10px; }
.blocklen { margin-top: 10px; }
.lenctl { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--ink); }
.lenctl label { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.lenctl select { display: inline-block; width: auto; margin: 0; padding: 8px 10px; font-size: 15px; }
.lenctl input[type=number] { width: 90px; padding: 7px 10px; border: 1px solid #cfd8e3; border-radius: 10px; background: #fff; font: inherit; font-size: 16px; color: var(--ink); }
.lenctl [hidden] { display: none; }
.count { font-weight: 600; }
.count.short { color: var(--red); }

/* 사진 올리는 중 로딩 칸 */
.ph.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 6px; text-align: center; font-size: 12px; line-height: 1.3; color: var(--blue-d, #1659a6); background: #eef5fc; border: 1px dashed #9db9d9; }
.ph.loading .spin { width: 24px; height: 24px; border: 3px solid #c3d6ee; border-top-color: var(--blue); border-radius: 50%; animation: bspin .8s linear infinite; }
@keyframes bspin { to { transform: rotate(360deg); } }
.actions .btn.loading, .aibox .btn.loading, .block .btn.loading { opacity: 1; cursor: progress; }
.actions .btn.loading::before, .aibox .btn.loading::before, .block .btn.loading::before { content: ''; display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: bspin .7s linear infinite; }

/* 사진 배치 선택 */
.layoutrow { margin: 0 0 12px; padding: 8px 12px; border-radius: 10px; background: #f6f9fd; border: 1px solid var(--line); gap: 12px; }
.layoutrow select { display: inline-block; width: auto; margin: 0 0 0 6px; padding: 7px 10px; font-size: 14.5px; }
.layoutrow .chk { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink); }

/* AI에게 맡기기: 진행 상태·결과 */
.jobbox{display:flex;gap:12px;align-items:center;justify-content:space-between;flex-wrap:wrap;margin-top:10px;padding:12px 14px;border-radius:10px;border:1px solid #bcd7f0;background:#fff;color:#22313f;font-size:14px;line-height:1.7}
.jobbox>div{flex:1;min-width:220px}
.jobbox.ok{border-color:#a8d8b4;background:#f1faf3}
.jobbox.bad{border-color:#f0c2bc;background:#fdf3f2}
.badge.job-run{background:#fff3d6;color:#8a5a00}
.badge.job-ok{background:#dcf3e2;color:#1d6b35}
.badge.job-bad{background:#fde3e0;color:#a52b1d}

/* 대표＋작은 사진 배치: 대표 사진 표시와 "대표로" 버튼 */
.ph .ph-s { position: absolute; bottom: 4px; left: 4px; width: 26px; height: 26px; border: 0; border-radius: 50%; background: rgba(0,0,0,.65); color: #ffd75e; font-size: 14px; line-height: 1; cursor: pointer; }
.wmbar { margin: 0 0 14px; }
.wmbar details { margin: 0 0 8px; }
.wmbar summary { cursor: pointer; font-size: 14px; }
.wmbar summary .muted { font-size: 12px; margin-left: 6px; }
.wmbar details[open] summary { margin-bottom: 12px; }
.wmbar canvas { display: block; width: 100%; max-width: 420px; height: auto; margin-top: 4px; border-radius: 10px; }
.ph .ph-main { position: absolute; bottom: 4px; left: 4px; padding: 3px 8px; border-radius: 999px; background: #1d6fd0; color: #fff; font-size: 11px; font-weight: 700; pointer-events: none; }
