/* 카드뉴스 메이커 — pure CSS (no framework) */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #f2f4f6;
  --card: #ffffff;
  --ink: #191f28;
  --sub: #6b7684;
  --line: #e5e8eb;
  --primary: #2563eb;
  --primary-dark: #1e50c8;
  --yellow: #ffd400;
  --radius: 16px;
}
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Pretendard Variable', Pretendard, 'Malgun Gothic', '맑은 고딕', sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
.hidden { display: none !important; }

.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; padding-bottom: 84px; }

/* ── 상단바 ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 12px 20px;
}
.brand { font-size: 17px; font-weight: 800; letter-spacing: -0.3px; }
.brand b { color: var(--primary); }
.brand-sub { font-size: 12px; color: var(--sub); }

.wrap { flex: 1; padding: 16px 16px 24px; display: flex; flex-direction: column; gap: 14px; }

/* ── 히어로 ── */
.hero { padding: 14px 4px 2px; }
.hero h1 { font-size: 23px; font-weight: 800; line-height: 1.35; letter-spacing: -0.5px; }
.hero em { font-style: normal; color: var(--primary); }

/* ── 패널 ── */
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.panel-title { font-size: 15px; font-weight: 700; letter-spacing: -0.2px; }
.panel-title .muted { font-size: 12px; font-weight: 400; color: var(--sub); margin-left: 4px; }
.muted { color: var(--sub); font-weight: 400; }

textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 12px; font: inherit; font-size: 14.5px; color: var(--ink);
  resize: vertical; background: #fafbfc; outline: none;
}
textarea:focus { border-color: var(--primary); background: #fff; }

.field-label { font-size: 13px; font-weight: 600; color: var(--ink); margin-top: 4px; }
.hint { font-size: 12.5px; color: var(--sub); text-align: center; }
.hint.small { text-align: left; margin-top: 2px; }

/* ── 버튼 ── */
.btn {
  font: inherit; font-size: 14px; font-weight: 600;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 12px; padding: 11px 16px; cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s;
}
.btn:active { transform: scale(.97); }
.btn.small { padding: 8px 13px; font-size: 13px; border-radius: 10px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.primary:disabled, .btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: transparent; color: var(--sub); }
.btn.big { width: 100%; padding: 15px; font-size: 16px; }
.row-btns { display: flex; gap: 8px; }
.row-btns .btn { flex: 1; }

/* ── 선택 카드 (그림 모양/느낌) ── */
.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice-grid.two { grid-template-columns: repeat(2, 1fr); }
.choice {
  font: inherit; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 14px; background: #fff;
  padding: 12px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.choice b { font-size: 13.5px; }
.choice small { font-size: 11px; color: var(--sub); }
.choice.active { border-color: var(--primary); background: #f0f5ff; box-shadow: 0 0 0 1px var(--primary) inset; }
.shape-demo { display: block; width: 34px; height: 34px; border: 2px solid #98a4b3; border-radius: 6px; background: #e9edf2; }
.choice.active .shape-demo { border-color: var(--primary); background: #cfe0ff; }
.shape-169 { width: 40px; height: 24px; }
.shape-11  { width: 30px; height: 30px; }
.shape-916 { width: 22px; height: 38px; }
.feel-photo { width: 38px; height: 38px; background: linear-gradient(135deg, #9ec3ff 0%, #d7e6ff 55%, #ffd9a8 100%); border: none; }
.feel-draw  { width: 38px; height: 38px; background: repeating-linear-gradient(45deg, #ffe2b8 0 6px, #ffd08a 6px 12px); border: none; }

/* ── 세그먼트(토글) 버튼 ── */
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1.5px solid var(--line); background: #fff; color: var(--sub);
  border-radius: 999px; padding: 8px 14px; flex: 1; min-width: 72px;
  transition: all .15s;
}
.seg button.active { border-color: var(--ink); color: var(--ink); background: #f3f5f7; }
.seg button:disabled { opacity: .4; cursor: default; }
.seg button:disabled.active { opacity: .9; }

/* ── 슬라이더 ── */
.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--primary); }
.slider-row span { font-size: 12.5px; color: var(--sub); min-width: 44px; text-align: right; }

/* ── 제목 목록 ── */
.title-list { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.title-list li {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 13px;
  font-size: 14px; cursor: pointer; background: #fff; transition: all .15s;
}
.title-list li:hover { border-color: #b9c6e4; }
.title-list li.active { border-color: var(--primary); background: #f0f5ff; font-weight: 700; }
.title-list li .tag {
  display: inline-block; font-size: 10.5px; font-weight: 700; color: var(--primary);
  background: #e3ecff; border-radius: 6px; padding: 1px 6px; margin-bottom: 3px;
}

/* ── 미리보기 ── */
.card-preview {
  position: relative; width: 100%; border-radius: 12px; overflow: hidden;
  background: #eceff3; min-height: 120px;
}
.card-preview img { display: block; width: 100%; }
.img-loading {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px;
  align-items: center; justify-content: center;
  background: #eceff3; color: var(--sub); font-size: 13.5px; font-weight: 600;
}
.overlay-dim {
  position: absolute; left: 0; right: 0; pointer-events: none;
}
.dim-bottom { top: 40%; bottom: 0; background: linear-gradient(to top, rgba(0,0,0,.72) 0%, rgba(0,0,0,.35) 50%, rgba(0,0,0,0) 100%); }
.dim-top { top: 0; bottom: 40%; background: linear-gradient(to bottom, rgba(0,0,0,.72) 0%, rgba(0,0,0,.35) 50%, rgba(0,0,0,0) 100%); }
.dim-middle { top: 0; bottom: 0; background: rgba(0,0,0,.38); }

.overlay-wrap {
  position: absolute; left: 0; right: 0;
  padding: 5%;
  display: flex; flex-direction: column; gap: 2%;
  pointer-events: none;
}
.overlay-wrap.pos-bottom { bottom: 0; }
.overlay-wrap.pos-top { top: 0; }
.overlay-wrap.pos-middle { top: 50%; transform: translateY(-50%); }
.overlay-text {
  font-weight: 800; letter-spacing: -0.3px; word-break: keep-all; overflow-wrap: break-word;
  line-height: 1.28; white-space: pre-wrap;
}
.overlay-body {
  font-weight: 500; word-break: keep-all; overflow-wrap: break-word;
  line-height: 1.45; white-space: pre-wrap;
}
.align-left { text-align: left; }
.align-center { text-align: center; }
.align-right { text-align: right; }
.c-white { color: #ffffff; text-shadow: 0 1px 8px rgba(0,0,0,.55); }
.c-yellow { color: var(--yellow); text-shadow: 0 1px 8px rgba(0,0,0,.55); }
.c-black { color: #111318; text-shadow: 0 1px 6px rgba(255,255,255,.45); }

.img-tools { display: flex; gap: 8px; }
.img-tools .btn { flex: 1; }

/* ── 카드 칩 (여러 장) ── */
.card-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.card-chips .chip {
  font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer;
  border: 1.5px solid var(--line); background: #fff; color: var(--sub);
  border-radius: 999px; padding: 7px 13px; transition: all .15s;
}
.card-chips .chip.active { border-color: var(--primary); background: #f0f5ff; color: var(--primary); }
.card-chips .chip .mini { display: block; font-size: 10px; font-weight: 500; color: inherit; opacity: .75; }

/* ── 결과 상단 문구 ── */
.result-head {
  text-align: center; font-size: 15px; font-weight: 800; padding: 8px 0 2px;
}
.result-head.ok { color: #0e8345; }
.result-head.warn { color: #c25e00; }

/* ── 하단 액션바 (3단계) ── */
.actionbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  max-width: 560px; margin: 0 auto;
  background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  display: flex; gap: 8px;
}
.actionbar .btn { flex: 1; font-size: 13.5px; padding: 12px 6px; }
.actionbar .btn.ghost { border-color: transparent; }

/* ── 토스트 ── */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(12px);
  background: rgba(25,31,40,.92); color: #fff; font-size: 13.5px; font-weight: 600;
  border-radius: 999px; padding: 10px 18px; z-index: 60;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  max-width: 90%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── 로딩 오버레이 ── */
.loading {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(242,244,246,.96); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
}
.loading-box { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 20px; }
.loading-msg { font-size: 15.5px; font-weight: 700; max-width: 300px; }
.loading-sub { font-size: 12.5px; color: var(--sub); }

/* ── 스피너 ── */
.spin {
  display: inline-block; width: 22px; height: 22px; flex: none;
  border: 3px solid #d5dbe3; border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite;
}
.spin.big { width: 44px; height: 44px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 380px) {
  .hero h1 { font-size: 20px; }
  .actionbar .btn { font-size: 12.5px; }
}
