/* QR 카드 생성기 — 스타일
   모바일 우선(390px), 가로 넘침 없음. 카드 미리보기는 3:4 캔버스. */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #f4f5fa;
  --sheet: #ffffff;
  --ink: #15171c;
  --ink-2: #5a6070;
  --ink-3: #8b91a1;
  --line: #e3e6ef;
  --line-2: #eef1f7;
  --brand: #4f46e5;
  --brand-2: #6d63f5;
  --brand-soft: #eceafd;
  --ok: #12a150;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 8px 24px rgba(20, 24, 40, .06);
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0 14px 40px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, p, ul { margin: 0; }

/* ---------- 헤더 ---------- */
.app-head { padding: 22px 2px 12px; }

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  flex: none;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--brand), #8b5cf6);
  color: #fff;
  font-size: 22px;
  box-shadow: 0 6px 16px rgba(79, 70, 229, .28);
}

.app-head h1 { font-size: 20px; font-weight: 800; letter-spacing: -.4px; }
.brand-sub { margin-top: 2px; font-size: 12.5px; color: var(--ink-3); letter-spacing: .1px; }

.privacy-badge {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #eef8f2;
  color: #1c7a4b;
  font-size: 12px;
  font-weight: 600;
  word-break: keep-all;
}

/* ---------- 광고 자리(코드 삽입 전까지 자리 차지 않음) ---------- */
.ad-slot { display: none; }

/* ---------- 탭 ---------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 5px;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 10px 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: -.3px;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.tab.is-on { background: var(--brand); color: #fff; box-shadow: 0 3px 10px rgba(79, 70, 229, .28); }

/* ---------- 패널 ---------- */
.panel, .design, .preview, .about {
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.panel[hidden] { display: none; }

.panel-head { margin-bottom: 14px; }
.panel-head h2 { font-size: 16.5px; font-weight: 800; letter-spacing: -.3px; }
.panel-head p { margin-top: 5px; font-size: 12.5px; color: var(--ink-2); line-height: 1.45; word-break: keep-all; }

/* ---------- 입력 ---------- */
.field { display: block; margin-bottom: 12px; min-width: 0; }

.lab {
  display: block;
  margin-bottom: 5px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
  letter-spacing: -.2px;
}

.req { color: var(--brand); font-size: 10.5px; font-weight: 700; vertical-align: 1px; }

input[type="text"], input[type="password"], input[type="tel"], input[type="email"], select, textarea {
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfcfe;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  line-height: 1.35;
  -webkit-appearance: none;
  appearance: none;
}

textarea { resize: vertical; min-height: 76px; }

select {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238b91a1' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row input { flex: 1 1 auto; }

.btn-ghost {
  flex: none;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.btn-ghost:active { background: var(--line-2); }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-grid .field { margin-bottom: 12px; }

.check-field .lab { visibility: visible; }
.check {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfcfe;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.check input { width: 17px; height: 17px; accent-color: var(--brand); margin: 0; }

.check-line { display: flex; align-items: flex-start; gap: 8px; margin: 2px 0 8px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.check-line input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }

.hint { font-size: 12px; color: var(--ink-3); line-height: 1.45; word-break: keep-all; }
.hint.center { text-align: center; }

/* ---------- 디자인 ---------- */
.sec-title { font-size: 15px; font-weight: 800; letter-spacing: -.3px; margin-bottom: 12px; }

.theme-row { display: flex; flex-wrap: wrap; gap: 7px; }

.theme {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px 7px 7px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-2);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -.3px;
  cursor: pointer;
}
.theme i {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, var(--c3) 0 22%, var(--c1) 23% 62%, var(--c2) 63% 100%);
  border: 1px solid rgba(0, 0, 0, .12);
  flex: none;
}
.theme.is-on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }

/* ---------- 미리보기 ---------- */
.canvas-wrap {
  border-radius: 14px;
  background: repeating-conic-gradient(#f0f2f8 0% 25%, #ffffff 0% 50%) 50% / 18px 18px;
  padding: 10px;
  border: 1px solid var(--line-2);
}

#cardCanvas {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
  margin: 0 auto;
  border-radius: 12px;
  box-shadow: 0 10px 26px rgba(20, 24, 40, .16);
  background: #fff;
}

.status { min-height: 18px; margin-top: 10px; font-size: 12.5px; font-weight: 600; color: var(--brand); text-align: center; word-break: keep-all; }
.status.is-warn { color: #c2410c; }

.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

.btn {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-radius: 13px;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.3px;
  cursor: pointer;
}

.btn-primary { background: linear-gradient(145deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 8px 20px rgba(79, 70, 229, .28); }
.btn-primary:active { transform: translateY(1px); }
.btn-line { background: #fff; border: 1.5px solid var(--line); color: var(--ink); }

/* ---------- 소개 / 푸터 ---------- */
.about ul { padding-left: 18px; margin-top: 2px; }
.about li { margin-bottom: 7px; font-size: 12.5px; color: var(--ink-2); line-height: 1.5; word-break: keep-all; }
.about b { color: var(--ink); }

.app-foot { padding: 6px 4px 0; text-align: center; font-size: 11px; color: var(--ink-3); }

/* ---------- PNG 저장 모달 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(12, 15, 26, .68);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.modal[hidden] { display: none; }

.modal-box {
  width: 100%;
  max-width: 380px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 16px;
  border-radius: 18px;
  background: #fff;
  text-align: center;
}
.modal-title { font-size: 15px; font-weight: 800; }
.modal-desc { margin: 4px 0 10px; font-size: 12.5px; color: var(--ink-2); word-break: keep-all; }
.modal-box img { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); }
.modal-actions { display: flex; gap: 8px; margin-top: 12px; }
.modal-actions .btn { padding: 12px; font-size: 14px; }

/* ---------- 인쇄 ---------- */
.print-only { display: none; }

@media print {
  @page { size: A4 portrait; margin: 16mm; }

  html, body { background: #fff !important; padding: 0 !important; }
  body > * { display: none !important; }

  .print-only {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 96vh;
  }
  .print-only img {
    width: 130mm;
    height: auto;
    border-radius: 4mm;
  }
}

@media (max-width: 340px) {
  .field-grid { grid-template-columns: 1fr; }
}
