/* ⑥ 카드 편집 — 공용 카드 HTML 모양(디자인 기준 6-1·6-2). 템플릿은 .t-이름 에서 변수만 바꾼다(6-3). */

.cn-card {
  /* 템플릿이 바꾸는 변수(기본값) */
  --cn-bg: #ffffff;
  --cn-fg: #1f2937;
  --cn-sub: #6b7280;
  --cn-accent: #8134af;
  --cn-accent-fg: #ffffff;
  --cn-accent-text: #8134af;
  --cn-accent-soft: rgba(129, 52, 175, 0.22);
  --cn-box-rgb: 255, 255, 255;
  --cn-box-alpha: 0;
  --cn-radius: 0px;
  --cn-pad-y: 56px;
  --cn-pad-x: 64px;
  --cn-line: 1;
  --cn-dim: 0;
  --cn-font: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;

  position: relative;
  width: 1080px;
  height: 1350px;
  overflow: hidden;
  background: var(--cn-bg);
  color: var(--cn-fg);
  font-family: var(--cn-font);
  word-break: keep-all;
  overflow-wrap: anywhere;
  box-sizing: border-box;
  text-align: left;
  line-height: 1.3;
}
.cn-card.r-45 { height: 1350px; }
.cn-card.r-11 { height: 1080px; }
.cn-card * { box-sizing: border-box; }

/* 사진 자리(모든 카드에 있다. 사진이 없을 때 모양은 템플릿이 정한다) */
.cn-photo { position: absolute; inset: 0; background-size: cover; background-position: center; display: none; }
.cn-photo::after { content: ""; position: absolute; inset: 0; background: rgba(0, 0, 0, var(--cn-dim)); }
.cn-card.has-photo .cn-photo { display: block; }

/* 계정 라벨·쪽 번호(카드 바깥 여백 72 px 안) */
.cn-label { position: absolute; left: 72px; top: 64px; font-size: 30px; font-weight: 600; color: var(--cn-sub); z-index: 2; white-space: nowrap; }
.cn-page { position: absolute; right: 72px; bottom: 64px; font-size: 28px; font-weight: 600; color: var(--cn-sub); z-index: 2; }

/* 글상자 */
.cn-box {
  position: absolute; left: 72px; right: 72px; top: 136px; bottom: 136px; z-index: 1;
  display: flex; flex-direction: column; gap: 32px;
  padding: var(--cn-pad-y) var(--cn-pad-x);
  border-radius: var(--cn-radius);
  background: rgba(var(--cn-box-rgb), var(--cn-box-alpha));
  overflow: hidden;
}
.cn-card [data-field] { margin: 0; white-space: pre-line; min-width: 0; } /* 원고 줄바꿈을 그대로 보인다 */
.cn-em { font-style: normal; color: var(--cn-accent-text); }

/* 표지 */
.cn-card[data-layout="cover"] .cn-box { justify-content: flex-end; }
.cn-kicker { align-self: flex-start; font-size: 34px; font-weight: 700; padding: 10px 28px; border-radius: 999px; background: var(--cn-accent); color: var(--cn-accent-fg); }
.cn-kicker:empty { display: none; }
.cn-card[data-layout="cover"] .cn-title { font-size: 104px; font-weight: 800; line-height: calc(1.2 * var(--cn-line)); }
.cn-sub { font-size: 40px; font-weight: 500; color: var(--cn-sub); line-height: calc(1.45 * var(--cn-line)); }
.cn-sub:empty { display: none; }

/* 목록 */
.cn-card[data-layout="list"] .cn-title { font-size: 72px; font-weight: 800; line-height: calc(1.25 * var(--cn-line)); }
.cn-items { list-style: none; margin: 0; padding: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 44px; }
.cn-item { display: grid; grid-template-columns: 68px 1fr; column-gap: 28px; row-gap: 8px; align-items: start; }
.cn-num { grid-row: 1 / 3; width: 68px; height: 68px; border-radius: 50%; background: var(--cn-accent); color: var(--cn-accent-fg); font-size: 34px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.cn-head { font-size: 44px; font-weight: 700; line-height: calc(1.3 * var(--cn-line)); padding-top: 6px; }
.cn-body { font-size: 36px; font-weight: 500; color: var(--cn-sub); line-height: calc(1.45 * var(--cn-line)); }
.cn-body:empty { display: none; }

/* 인용 */
.cn-card[data-layout="quote"] .cn-box { justify-content: center; }
.cn-mark { font-size: 220px; font-weight: 800; line-height: 0.8; height: 150px; color: var(--cn-accent-text); opacity: 0.25; }
.cn-card[data-layout="quote"] .cn-title { font-size: 32px; font-weight: 600; color: var(--cn-sub); line-height: calc(1.4 * var(--cn-line)); }
.cn-quote { font-size: 62px; font-weight: 700; line-height: calc(1.45 * var(--cn-line)); }

/* 숫자 */
.cn-card[data-layout="stat"] .cn-box { justify-content: center; }
.cn-card[data-layout="stat"] .cn-title { font-size: 56px; font-weight: 800; line-height: calc(1.3 * var(--cn-line)); }
.cn-number { font-size: 220px; font-weight: 800; line-height: 1; color: var(--cn-accent-text); letter-spacing: -0.02em; white-space: nowrap !important; }
.cn-desc { font-size: 40px; font-weight: 500; color: var(--cn-sub); line-height: calc(1.5 * var(--cn-line)); }

/* 마무리 */
.cn-card[data-layout="outro"] .cn-box { justify-content: center; }
.cn-card[data-layout="outro"] .cn-title { font-size: 80px; font-weight: 800; line-height: calc(1.25 * var(--cn-line)); }
.cn-cta { align-self: flex-start; margin-top: 16px !important; font-size: 36px; font-weight: 700; padding: 22px 44px; border-radius: 999px; background: var(--cn-accent); color: var(--cn-accent-fg); }
.cn-cta:empty { display: none; }

/* 편집할 때만 보이는 것(저장할 때 지운다, 6-4) */
.cn-badges { position: absolute; top: 20px; right: 20px; z-index: 5; display: flex; gap: 10px; }
.cn-badge { font-size: 26px; font-weight: 800; padding: 6px 18px; border-radius: 999px; }
.cn-badge.over { background: #ef4444; color: #ffffff; }
.cn-badge.long { background: #fde047; color: #713f12; }

/* ══ 템플릿(6-3) — 공용 HTML 은 그대로, 아래 변수와 몇 줄만 다르다 ══ */

/* 클린: 흰 바탕, 진한 글자, 포인트 = 브랜드 1, 강조는 형광펜 밑줄, 사진은 위쪽 38% 띠 */
.t-clean {
  --cn-bg: #ffffff;
  --cn-fg: #111827;
  --cn-sub: #4b5563;
  --cn-box-rgb: 255, 255, 255;
  --cn-box-alpha: 0;
  --cn-radius: 0px;
  --cn-pad-y: 56px;
  --cn-pad-x: 64px;
  --cn-line: 1;
  --cn-dim: 0;
  --cn-font: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
}
.t-clean .cn-em { color: inherit; background: linear-gradient(transparent 58%, var(--cn-accent-soft) 58%); padding: 0 4px; }
.t-clean.has-photo .cn-photo { inset: 0 0 auto 0; height: 38%; }
.t-clean.has-photo .cn-box { top: calc(38% + 24px); }

/* 블랙 임팩트: 바탕 #0b0b0f, 흰 글자, 포인트 #d4ff3a(형광 연두), 강조는 포인트 색 글자. 후킹 문구용 */
.t-impact {
  --cn-bg: #0b0b0f;
  --cn-fg: #ffffff;
  --cn-sub: #b9bdc9;
  --cn-box-rgb: 11, 11, 15;
  --cn-box-alpha: 0;
  --cn-radius: 0px;
  --cn-pad-y: 56px;
  --cn-pad-x: 64px;
  --cn-line: 1;
  --cn-dim: 0.45;
  --cn-font: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
}
.t-impact .cn-em { color: var(--cn-accent-text); }
.t-impact[data-layout="cover"] .cn-title { font-size: 112px; font-weight: 800; letter-spacing: -0.03em; line-height: calc(1.15 * var(--cn-line)); }
.t-impact[data-layout="list"] .cn-title, .t-impact[data-layout="outro"] .cn-title { letter-spacing: -0.02em; }
.t-impact .cn-mark { opacity: 0.6; }
.t-impact.has-photo .cn-box { --cn-box-alpha: 0.55; }

/* 매거진 포토: 사진이 카드 전체, 그 위 검은 막(--cn-dim), 흰 글상자 92%·모서리 28·카드 아래쪽.
   사진이 없으면 브랜드 1 → 브랜드 2 그라데이션. 포인트 = 브랜드 2 */
.t-photo {
  --cn-bg: #1f2937;
  --cn-fg: #111827;
  --cn-sub: #4b5563;
  --cn-box-rgb: 255, 255, 255;
  --cn-box-alpha: 0.92;
  --cn-radius: 28px;
  --cn-pad-y: 56px;
  --cn-pad-x: 64px;
  --cn-line: 1;
  --cn-dim: 0.25;
  --cn-font: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: linear-gradient(140deg, var(--cn-grad-a, #8134af), var(--cn-grad-b, #dd2a7b));
}
.t-photo .cn-photo { inset: 0; } /* background-size: cover = 사진을 잘라 꽉 채움(object-fit: cover 와 같다) */
.t-photo .cn-box { top: auto; bottom: 136px; max-height: calc(100% - 272px); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.18); }
.t-photo .cn-label, .t-photo .cn-page { color: rgba(255, 255, 255, 0.95); text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35); }
.t-photo .cn-em { color: var(--cn-accent-text); }
.t-photo .cn-items { flex: 0 0 auto; }

/* ── 화면에서 줄여 보이기(실제 크기는 그대로) ── */
.cn-frame { position: relative; width: 100%; overflow: hidden; border-radius: 10px; border: 1px solid var(--line, #e5e7eb); background: #f3f4f6; }
.cn-frame.r-45 { aspect-ratio: 4 / 5; }
.cn-frame.r-11 { aspect-ratio: 1 / 1; }
.cn-scale { position: absolute; left: 0; top: 0; transform-origin: 0 0; transform: scale(var(--cn-scale, 0.25)); }
.cn-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.cn-cell { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cn-cell .meta { display: flex; gap: 8px; align-items: center; font-size: 14px; }
@media (max-width: 960px) { .cn-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .cn-grid { grid-template-columns: 1fr; } }

.seg { display: inline-flex; border: 1px solid #d1d5db; border-radius: 12px; overflow: hidden; }
.seg button { min-height: 48px; padding: 0 18px; border: 0; background: #fff; font: inherit; font-weight: 600; color: #4b5563; cursor: pointer; }
.seg button[aria-pressed="true"] { background: #1f2937; color: #fff; }
.start-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.btn.is-later { color: #9ca3af; border-style: dashed; cursor: not-allowed; }
.cn-cell select { min-height: 40px; padding: 0 10px; border: 1px solid #d1d5db; border-radius: 10px; font: inherit; font-size: 14px; background: #fff; }
.cn-cell .warns { display: flex; flex-wrap: wrap; gap: 6px; }
.cn-cell .warns .badge { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.cn-cell .badge.auto { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }

/* ── 템플릿 고르기 칸 ── */
.theme-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.theme-opt { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 2px solid #e5e7eb; border-radius: 16px; background: #fff; font: inherit; color: #1f2937; text-align: left; cursor: pointer; }
.theme-opt[aria-checked="true"] { border: 3px solid transparent; padding: 11px; background: linear-gradient(#fff, #fff) padding-box, linear-gradient(45deg, #feda75, #fa7e1e, #d62976, #962fbf, #4f5bd5) border-box; }
.theme-opt b { font-weight: 800; font-size: 16px; }
.theme-opt small { font-size: 13px; color: #6b7280; line-height: 1.4; }
.theme-opt .cn-frame { pointer-events: none; }
@media (max-width: 520px) { .theme-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; } .theme-opt { padding: 8px; } .theme-opt small { display: none; } }

/* ── 13단계: 카드 위에서 고치기(편집할 때만 보이는 것 — 저장할 때 지운다, 6-4) ── */
.cn-badge.hint { background: rgba(17, 24, 39, 0.75); color: #fff; font-weight: 600; }
.is-editing .cn-card [data-field] { outline: 2px dashed transparent; outline-offset: 6px; border-radius: 6px; cursor: text; }
.is-editing .cn-card [data-field]:hover { outline-color: rgba(150, 47, 191, 0.45); }
.is-editing .cn-card [data-field].is-picked, .is-editing .cn-card [data-field]:focus { outline: 3px dashed #962fbf; }
.is-editing .cn-card [data-field]:empty::before { content: "（비어 있음）"; opacity: 0.4; }
.is-moving .cn-label, .is-moving .cn-page { outline: 3px dashed #962fbf; outline-offset: 8px; cursor: grab; touch-action: none; user-select: none; }
.is-moving .cn-label::after, .is-moving .cn-page::after { content: " ↔"; color: #962fbf; font-weight: 800; }
.is-moving .cn-card [data-field] { pointer-events: none; }
.cd-tools { position: sticky; top: 116px; z-index: 20; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 14px; border-radius: 14px; background: #111827; color: #f9fafb; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); }
.cd-tools .btn { min-height: 40px; padding: 0 14px; background: #1f2937; color: #f9fafb; border-color: #374151; }
.cd-tools .btn-ghost { background: transparent; }
.cd-tools-label { font-weight: 700; margin-right: 6px; }
.cd-a-val { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; }
.cd-color, .cd-font { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.cd-color input { width: 40px; height: 34px; border: 0; padding: 0; background: none; }
.cd-font select { min-height: 36px; border-radius: 8px; border: 0; padding: 0 8px; font: inherit; }
.cd-work { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 20px; align-items: start; }
.cd-panel { position: sticky; top: 130px; gap: 12px; }
.cd-panel hr { border: 0; border-top: 1px solid #e5e7eb; width: 100%; margin: 4px 0; }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; font-size: 14px; font-weight: 600; }
.slider input { grid-column: 1 / -1; width: 100%; }
.slider output { font-variant-numeric: tabular-nums; color: #6b7280; }
.cn-cell .photo-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.cn-cell .photo-btns .btn { min-height: 36px; padding: 0 12px; font-size: 14px; }
#cd-move[aria-pressed="true"] { background: #962fbf; color: #fff; border-color: #962fbf; }
@media (max-width: 960px) { .cd-work { grid-template-columns: 1fr; } .cd-panel { position: static; order: -1; } }

/* ── 14단계: 저장·카드 세트 ── */
#cd-set-name { min-height: 44px; padding: 0 12px; border: 1px solid #d1d5db; border-radius: 12px; font: inherit; width: 240px; max-width: 100%; }
.set-item { display: grid; grid-template-columns: 84px 1fr; gap: 14px; align-items: center; padding: 12px; }
.set-item.is-current { border: 2px solid #962fbf; padding: 11px; }
.set-item .cn-frame { width: 84px; }
.cn-cell.is-bad .cn-frame { outline: 4px solid #ef4444; outline-offset: 2px; }
