/* 카드뉴스 만들기 — 화면 (카드 디자인은 js/render.js) */
:root {
  --bg: #F6F7F9;
  --panel: #FFFFFF;
  --ink: #15171C;
  --ink2: #4A505C;
  --line: #DADDE3;
  --pri: #1F5BFF;
  --pri-ink: #FFFFFF;
  --ok: #0E7A4F;
  --stop: #C62828;
  --check: #B85C00;
  --tip: #5B6270;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 130px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: CardnewsSans, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 17px; line-height: 1.55; word-break: keep-all; overflow-wrap: anywhere;
}
h2 { font-size: 24px; margin: 8px 0 14px; line-height: 1.3; }
h3 { font-size: 19px; margin: 0 0 10px; }
h3 i, .lab i { font-style: normal; font-weight: 500; color: var(--tip); font-size: 15px; }
small, .note { display: block; color: var(--ink2); font-size: 15px; margin-top: 6px; }
.lead { margin: 0 0 14px; color: var(--ink2); }
[hidden] { display: none !important; }

/* 위쪽 단계 표시 */
.top { position: sticky; top: 0; z-index: 10; background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 16px 8px; }
.brand { font-weight: 800; font-size: 18px; margin-bottom: 6px; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.step-btn { display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 44px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; font: inherit; font-size: 15px; color: var(--tip); padding: 4px 4px; cursor: pointer; white-space: nowrap; min-width: 0; }
@media (max-width: 420px) { .step-btn { font-size: 14px; gap: 4px; } .step-btn b { width: 22px; height: 22px; font-size: 13px; } .brand { font-size: 16px; margin-bottom: 4px; } }
.step-btn b { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; align-items: center; justify-content: center; background: var(--line); color: var(--ink); font-size: 14px; flex: none; }
.step-btn.on { border-color: var(--pri); color: var(--ink); font-weight: 700; }
.step-btn.on b { background: var(--pri); color: var(--pri-ink); }
.step-btn.done b { background: var(--ok); color: #fff; }
.step-btn:disabled { opacity: .45; cursor: default; }

main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 40px; }
.card-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }

/* 버튼 */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 8px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: #9AA1AD; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--pri); border-color: var(--pri); color: var(--pri-ink); }
.btn.big { width: 100%; min-height: 56px; font-size: 18px; margin: 6px 0; }
.btn.sm { min-height: 40px; padding: 4px 12px; font-size: 15px; border-radius: 10px; }
.btn.round { width: 48px; padding: 0; border-radius: 50%; font-size: 24px; }
.btn.link { border: 0; background: none; color: var(--pri); text-decoration: underline; width: 100%; margin-top: 6px; }
.btn.danger { color: var(--stop); }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.row.small { gap: 6px; margin: 0; }

/* 입력 */
.field { display: block; margin-bottom: 16px; }
.lab { display: block; font-weight: 700; margin-bottom: 6px; }
.lab em { font-style: normal; color: var(--pri); font-size: 14px; margin-left: 4px; }
input[type=text], textarea { width: 100%; font: inherit; font-size: 17px; padding: 12px 14px; border: 1px solid #BFC5CF; border-radius: 12px; background: #fff; color: var(--ink); }
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, .btn:focus-visible, .step-btn:focus-visible { outline: 3px solid rgba(31,91,255,.35); outline-offset: 1px; }
.count { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 800; }
.count output { min-width: 28px; text-align: center; }
.check-row { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.check-row input { width: 22px; height: 22px; }
.err { color: var(--stop); font-weight: 700; }
.ok { color: var(--ok); font-weight: 700; margin: 4px 0; }

/* 예시 */
.example-list { display: grid; gap: 8px; }
.example-list .btn { justify-content: flex-start; text-align: left; flex-direction: column; align-items: flex-start; min-height: 64px; }
.example-list .btn span { font-weight: 500; font-size: 14px; color: var(--ink2); }

/* 글 받기 단계 */
.howto { list-style: none; padding: 0; margin: 0; }
.how { display: flex; gap: 12px; background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.how.active { border-color: var(--pri); }
.how.done { border-color: var(--ok); }
.how-num { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--line); display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 18px; }
.how.active .how-num { background: var(--pri); color: #fff; }
.how.done .how-num { background: var(--ok); color: #fff; }
.how-body { flex: 1; min-width: 0; }
.how h3 { margin-top: 4px; }
details summary { cursor: pointer; color: var(--pri); font-weight: 700; min-height: 40px; display: flex; align-items: center; }
#promptText { font-size: 14px; margin-top: 6px; }
.msg { border-radius: 12px; padding: 12px 14px; margin-top: 10px; font-size: 16px; }
.msg.good { background: #E7F6EE; color: #0B5D3B; }
.msg.bad { background: #FDECEC; color: #8E1C1C; }
.msg.part { background: #FFF4E0; color: #7A4300; }
.msg ul { margin: 6px 0 0; padding-left: 20px; }

/* 고치기 */
.edit-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.preview-col, .edit-col { min-width: 0; }
.strip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; scroll-snap-type: x mandatory; }
.thumb { position: relative; flex: none; width: 92px; padding: 0; border: 3px solid transparent; border-radius: 10px; background: none; cursor: pointer; scroll-snap-align: start; }
.thumb canvas { display: block; width: 100%; height: auto; border-radius: 7px; }
.thumb.on { border-color: var(--pri); }
.thumb .no { position: absolute; left: 4px; top: 4px; background: rgba(0,0,0,.65); color: #fff; font-size: 12px; font-weight: 800; border-radius: 6px; padding: 0 5px; }
.thumb .dot { position: absolute; right: 4px; top: 4px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; }
.thumb .dot.stop { background: var(--stop); }
.thumb .dot.check { background: var(--check); }
.preview-wrap { position: relative; }
/* 휴대폰에서는 화면 높이의 58%까지만: 아래 편집 칸이 바로 보이게 */
#preview { width: auto; max-width: 100%; height: auto; max-height: 58vh; aspect-ratio: 4 / 5; margin: 0 auto; display: block; border-radius: 12px; background: #222; touch-action: pan-y; box-shadow: 0 2px 14px rgba(0,0,0,.12); }
#preview.can-drag { cursor: grab; touch-action: none; }
/* 휴대폰에서 편집 칸으로 내려가면 단계 표시줄 바로 아래에 작은 미리보기 띠 (누르면 큰 미리보기로).
   입력 칸 위에 떠서 글을 가리지 않게 화면 폭 전체의 띠로 둔다 */
.mini { position: fixed; left: 0; right: 0; top: 96px; z-index: 9; display: flex; align-items: center; gap: 12px; padding: 6px 16px; border: 0; border-bottom: 1px solid var(--line); background: var(--panel); box-shadow: 0 4px 10px rgba(0,0,0,.08); font: inherit; font-size: 15px; color: var(--ink); text-align: left; cursor: pointer; }
.mini canvas { width: 52px; height: auto; border-radius: 6px; flex: none; }
.mini span { flex: 1; font-weight: 700; }
.mini b { color: var(--pri); font-size: 14px; }
@media (min-width: 900px) { .mini { display: none !important; } }
@media (max-width: 899px) { html { scroll-padding-top: 200px; } } /* 입력 칸이 위쪽 띠 밑으로 숨지 않게 */
.hint { font-size: 14px; color: var(--tip); margin: 6px 0 0; }
.checks { list-style: none; padding: 0; margin: 10px 0 0; }
.checks li { display: flex; gap: 8px; padding: 8px 10px; border-radius: 10px; margin-bottom: 6px; background: #F1F3F6; font-size: 15px; }
.checks li b { flex: none; font-size: 13px; border-radius: 6px; padding: 1px 7px; color: #fff; height: fit-content; margin-top: 2px; }
.checks li.stop b { background: var(--stop); }
.checks li.check b { background: var(--check); }
.checks li.tip b { background: var(--tip); }
.checks li.none { background: #E7F6EE; color: #0B5D3B; }
.checks li button { margin-left: auto; flex: none; }
/* 좁은 화면(아이폰 SE 등): '고치기' 버튼을 문장 아래로 내려 문장이 좁게 꺾이지 않게 */
@media (max-width: 420px) {
  .checks li { flex-wrap: wrap; }
  .checks li span { flex: 1 1 calc(100% - 60px); }
  .checks li button { margin-left: auto; }
}
.tpl-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tpl { padding: 6px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.tpl canvas { width: 100%; height: auto; display: block; border-radius: 6px; margin-bottom: 4px; }
.tpl.on { border-color: var(--pri); }
.accent-list { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.accent { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 4px 12px 4px 6px; border: 2px solid var(--line); border-radius: 999px; background: #fff; font: inherit; font-size: 15px; cursor: pointer; }
.accent i { width: 28px; height: 28px; border-radius: 50%; display: block; }
.accent.on { border-color: var(--ink); font-weight: 800; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: -6px 0 16px; font-size: 14px; color: var(--tip); }
.chip { min-height: 36px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; }
.chip:hover { border-color: var(--pri); }
.backdrop-row { margin-top: 12px; }
/* PC에서 카드 글자를 눌러 칸으로 왔을 때 잠깐 강조 */
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px rgba(31,91,255,.55); } 100% { box-shadow: 0 0 0 4px rgba(31,91,255,0); } }
.pc-only { display: none; }
@media (min-width: 900px) and (pointer: fine) { .pc-only { display: block; } }
.backdrop-row .lab { font-size: 15px; margin-bottom: 4px; }
.bd.on { border-color: var(--ink); background: #EEF1F6; }
.editor-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 12px; }
.editor-head h3 { margin: 0; }
.photo-box { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.photo-ctl { margin-top: 8px; }
.photo-ctl .row { margin-bottom: 10px; }
.ai-photo { margin: 8px 0; }
.ai-photo .note { margin: 4px 0 8px; }
.scene { font-size: 15px; color: var(--tip); background: #F1F3F6; border-radius: 10px; padding: 8px 10px; }
.retry { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 6px; }
.retry ol { padding-left: 20px; margin: 6px 0; font-size: 15px; }
.retry textarea { margin: 6px 0; }
#notesBox { margin-top: 12px; }
#notesList { margin: 4px 0 0; padding-left: 20px; color: var(--check); font-size: 15px; }

/* 저장 */
.state { font-weight: 700; }
.dl-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin: 12px 0; }
.dl-list a { display: block; text-decoration: none; color: var(--ink); font-size: 13px; font-weight: 700; text-align: center; }
.dl-list img { width: 100%; height: auto; display: block; border-radius: 8px; border: 1px solid var(--line); margin-bottom: 4px; }
.tips { font-size: 15px; color: var(--ink2); padding-left: 20px; }

/* 시험 정보 (?check=1) */
.diag table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0; }
.diag th, .diag td { text-align: left; vertical-align: top; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.diag th { width: 42%; font-weight: 700; }
.diag td { word-break: break-all; }
.diag tr.y td { color: var(--ok); }
.diag tr.n td { color: var(--stop); font-weight: 700; }

.foot { max-width: 1180px; margin: 0 auto; padding: 0 16px 90px; font-size: 14px; color: var(--tip); }
.save-state { font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 20; display: flex; gap: 10px; align-items: center; max-width: calc(100% - 32px); background: #15171C; color: #fff; padding: 10px 14px; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 15px; }
.toast .btn { min-height: 36px; background: #fff; }

/* PC: 미리보기 왼쪽 고정, 편집 오른쪽 */
@media (min-width: 900px) {
  .edit-layout { grid-template-columns: minmax(360px, 460px) 1fr; align-items: start; }
  .preview-col { position: sticky; top: 112px; }
  #preview { width: 100%; max-height: none; }
  .form, .howto, #step2 > .lead, #step2 > h2, #step2 > .btn.link { max-width: 720px; }
  #step1 > * { max-width: 720px; }
  .example-list { grid-template-columns: repeat(3, 1fr); }
  .btn.big { width: auto; min-width: 280px; }
  .btn.link { width: auto; }
}
