/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Noto Sans KR', sans-serif;
  background: #0a160a;
  color: #e8f0e8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   APP HEADER
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 22, 10, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(74, 163, 74, 0.2);
  padding: 14px 32px;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1600px;
  margin: 0 auto;
}

.header-logo {
  height: 28px;
  object-fit: contain;
  opacity: 0.95;
}

.header-text h1 {
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.header-text span {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ============================================================
   APP BODY LAYOUT
   ============================================================ */
.app-body {
  display: flex;
  gap: 0;
  flex: 1;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 24px;
  gap: 24px;
  align-items: flex-start;
}

/* ============================================================
   FORM PANEL (LEFT)
   ============================================================ */
.form-panel {
  flex: 0 0 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(74,163,74,0.3) transparent;
}

.form-panel::-webkit-scrollbar {
  width: 4px;
}
.form-panel::-webkit-scrollbar-track { background: transparent; }
.form-panel::-webkit-scrollbar-thumb {
  background: rgba(74,163,74,0.3);
  border-radius: 2px;
}

/* ── Form Card ── */
.form-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 20px;
  transition: border-color 0.2s;
}

.form-card:hover {
  border-color: rgba(74,163,74,0.25);
}

.form-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 18px;
}

.form-card-icon {
  font-size: 15px;
}

.auto-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  background: rgba(74,163,74,0.2);
  color: #6dc96d;
  border: 1px solid rgba(74,163,74,0.3);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ── Form Groups ── */
.form-group {
  margin-bottom: 14px;
}

.form-group:last-of-type {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

input[type="text"],
input[type="url"],
input[type="number"],
input[type="date"] {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: 'Noto Sans KR', sans-serif;
  color: #ffffff;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="date"]:focus {
  border-color: rgba(74,163,74,0.6);
  background: rgba(74,163,74,0.08);
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

input::placeholder {
  color: rgba(255,255,255,0.25);
}

.input-with-unit {
  display: flex;
  align-items: center;
  gap: 0;
}

.input-with-unit input {
  border-radius: 10px 0 0 10px;
  flex: 1;
}

.unit {
  background: rgba(74,163,74,0.15);
  border: 1px solid rgba(255,255,255,0.1);
  border-left: none;
  border-radius: 0 10px 10px 0;
  padding: 10px 12px;
  font-size: 13px;
  color: #6dc96d;
  font-weight: 600;
  white-space: nowrap;
}

.form-hint {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  margin-top: 5px;
  font-family: monospace;
}

/* ── Reset Button ── */
.btn-reset {
  width: 100%;
  margin-top: 14px;
  padding: 9px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: rgba(255,255,255,0.45);
  font-size: 12px;
  font-family: 'Noto Sans KR', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-reset:hover {
  border-color: rgba(74,163,74,0.4);
  color: #6dc96d;
  background: rgba(74,163,74,0.06);
}

/* ── Background Selector ── */
.bg-selector {
  display: flex;
  gap: 12px;
}

.bg-option {
  flex: 1;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.bg-option input[type="radio"] {
  display: none;
}

.bg-thumb {
  width: 100%;
  height: 90px;
  border-radius: 10px;
  background-size: cover;
  background-position: center;
  border: 2.5px solid transparent;
  transition: border-color 0.2s, transform 0.2s;
  position: relative;
}

.bg-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: rgba(0,0,0,0.15);
  transition: background 0.2s;
}

.bg-option input:checked + .bg-thumb {
  border-color: #4CAF50;
  transform: scale(1.02);
}

.bg-option input:checked + .bg-thumb::after {
  background: transparent;
}

.bg-option span {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  font-weight: 500;
}

.bg-option input:checked ~ span {
  color: #6dc96d;
  font-weight: 700;
}

/* ── Download Button ── */
.btn-download {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #2d7d32, #43a047);
  border: none;
  border-radius: 14px;
  color: white;
  font-size: 15px;
  font-weight: 700;
  font-family: 'Noto Sans KR', sans-serif;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(67,160,71,0.35);
  letter-spacing: -0.01em;
}

.btn-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(67,160,71,0.5);
  background: linear-gradient(135deg, #388e3c, #4caf50);
}

.btn-download:active {
  transform: translateY(0);
}

.btn-download:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ============================================================
   PREVIEW PANEL (RIGHT)
   ============================================================ */
.preview-panel {
  flex: 1;
  min-width: 0;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.preview-header h2 {
  font-size: 14px;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.preview-size-badge {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 3px 10px;
  border-radius: 999px;
  font-family: monospace;
}

.preview-wrapper {
  width: 100%;
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background: #111;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

/* ============================================================
   CERTIFICATE  (native 951 × 1350px — scaled via JS)
   ============================================================ */
.certificate {
  width: 951px;
  height: 1350px;
  position: relative;
  overflow: hidden;
  background: #1a3a1a;
  font-family: 'Noto Sans KR', sans-serif;
  transform-origin: top left;
}

/* ── Background Image Area ── */
.cert-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 45%;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

/* ── QR Code Box ── */
.cert-qr-box {
  position: absolute;
  top: 26px;
  right: 26px;
  width: 128px;
  height: 128px;
  background: #ffffff;
  padding: 8px;
  z-index: 20;
  border-radius: 4px;
}

.cert-qr-box canvas,
.cert-qr-box img {
  width: 112px !important;
  height: 112px !important;
  display: block;
}

/* ── Green Dome ── */
.cert-dome {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 63%;
  background: #2B5C28;
  border-radius: 50% 50% 0 0 / 8% 8% 0 0;
  padding: 95px 80px 52px;
  display: flex;
  flex-direction: column;
}

/* ── Certificate Title ── */
.cert-title {
  font-size: 52px;
  font-weight: 900;
  color: #ffffff;
  text-align: center;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
  line-height: 1.1;
}

/* ── Subtitle ── */
.cert-subtitle {
  font-size: 24px;
  font-weight: 400;
  color: rgba(255,255,255,0.92);
  text-align: center;
  line-height: 1.7;
  margin-bottom: 36px;
}

/* ── Table ── */
.cert-table {
  flex: 1;
}

.cert-divider {
  height: 1px;
  background: rgba(255,255,255,0.22);
}

.cert-row {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  padding: 26px 0;
}

.cert-label {
  font-size: 21px;
  font-weight: 700;
  color: #ffffff;
  min-width: 190px;
  flex-shrink: 0;
  line-height: 1.4;
}

.cert-value {
  font-size: 21px;
  font-weight: 400;
  color: #ffffff;
  line-height: 1.4;
}

/* ── Effects List ── */
.cert-effects {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.cert-effect {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 21px;
  color: #ffffff;
  line-height: 1.4;
}

.cert-check {
  width: 30px;
  height: 30px;
  background: #4CAF50;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
  flex-shrink: 0;
}

/* ── Footer ── */
.cert-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding-top: 36px;
  font-size: 24px;
  font-weight: 400;
  color: #ffffff;
}

.cert-logo {
  height: 38px;
  object-fit: contain;
  /* 로고가 흰색이라 배경에 잘 보임 */
}

/* ============================================================
   DOWNLOAD OVERLAY (생성 중 표시)
   ============================================================ */
.generating-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 16px;
}

.generating-overlay p {
  color: white;
  font-size: 16px;
  font-weight: 600;
  font-family: 'Noto Sans KR', sans-serif;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: #4CAF50;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
