/* 카톡부고장 — Global Styles (Mobile-first) */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

:root {
  --bg: #f8f6f3;
  --bg-card: #ffffff;
  --bg-alt: #f5f3ef;
  --bg-hover: #f0ede8;
  --bg-active: #faf9f7;
  --text: #2c2c2c;
  --text-secondary: #666666;
  --text-muted: #706b63;
  --text-tertiary: #727272;
  --border: #e0ddd8;
  --border-focus: #2c2c2c;
  --primary: #2c2c2c;
  --primary-text: #ffffff;
  --error: #d32f2f;
  --error-bg: #fdecea;
  --success: #2e7d32;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: 'Malgun Gothic', '맑은 고딕', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.page-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px;
  min-height: 100vh;
}

/* Top navigation */
.top-nav {
  display: flex;
  align-items: center;
  margin: -8px -4px 16px;
}
.nav-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-size: 20px;
  color: var(--text);
  text-decoration: none;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}
.nav-back:active {
  background: var(--border);
}
.nav-title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
}
.nav-right {
  width: 36px;
}

/* Step indicator */
.step-indicator {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  margin-bottom: 24px;
  padding: 16px 0;
}
.step-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.step-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  background: var(--border);
  color: var(--text-muted);
  transition: all 0.2s;
}
.step-dot.active {
  background: var(--primary);
  color: var(--primary-text);
}
.step-dot.completed {
  background: var(--primary);
  color: var(--primary-text);
}
.step-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  transition: color 0.2s;
}
.step-label.active {
  color: var(--text);
  font-weight: 700;
}
.step-line {
  width: 36px;
  height: 2px;
  background: var(--border);
  transition: background 0.2s;
  margin-top: 16px;
}
.step-line.active {
  background: var(--primary);
}

/* Step title */
.step-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
  letter-spacing: -0.5px;
}

/* Form groups */
.form-group {
  margin-bottom: 28px;
}
.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.form-label .required {
  color: var(--error);
  margin-left: 2px;
}
.form-label .optional {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 12px;
  margin-left: 4px;
}

/* Inputs */
.form-input,
.form-select {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-card);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(44,44,44,0.08);
}
.form-input.error,
.form-select.error {
  border-color: var(--error);
}
.form-input::placeholder {
  color: var(--text-muted);
}
.form-textarea{resize:vertical;line-height:1.6}

/* Select arrow */
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* Date/Time row */
.form-row {
  display: flex;
  gap: 12px;
}
.form-row > * {
  flex: 1;
  min-width: 0;
}

/* Hint text */
.form-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* Error message */
.form-error {
  font-size: 13px;
  color: var(--error);
  margin-top: 4px;
  display: none;
}
.form-error.visible {
  display: block;
}

/* Autocomplete dropdown */
.autocomplete-wrapper {
  position: relative;
}
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  max-height: 240px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}
.autocomplete-list.open {
  display: block;
}
.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid var(--bg-hover);
}
.autocomplete-item:last-child {
  border-bottom: none;
}
.autocomplete-item:hover,
.autocomplete-item.highlighted {
  background: var(--bg-alt);
}
.autocomplete-item .region {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 8px;
}

/* Relation grid modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
}
.modal-overlay.open {
  display: flex;
}
.modal-content {
  background: var(--bg-card);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 20px 16px;
}
.modal-handle{width:32px;height:4px;background:var(--border);border-radius:2px;margin:0 auto 12px}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}
.modal-close {
  width: 44px;
  height: 44px;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.relation-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.relation-group-label {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 10px 0 4px;
  border-bottom: 1px solid #eee;
  margin-bottom: 2px;
}
.relation-group-label:first-child {
  padding-top: 0;
}
.relation-btn {
  padding: 10px 4px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: all 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.relation-btn:hover {
  background: var(--bg-alt);
}
.relation-btn:active {
  background: var(--primary);
  color: var(--primary-text);
}

/* Dynamic mourner/bank rows */
.dynamic-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dynamic-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.dynamic-row .form-input,
.dynamic-row .form-select {
  flex: 1;
}
.btn-remove-row {
  width: 36px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--error);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-add-row {
  width: 100%;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

/* PIN input */
.pin-group {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.pin-digit {
  width: 52px;
  height: 56px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-family: inherit;
  -webkit-text-security: disc;
}
.pin-digit:focus {
  outline: none;
  border-color: var(--border-focus);
}
.pin-digit.error {
  border-color: var(--error);
}
.pin-match-msg {
  text-align: center;
  font-size: 13px;
  margin-top: 8px;
}
.pin-match-msg.error { color: var(--error); }
.pin-match-msg.success { color: var(--success); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: transform 0.1s, opacity 0.15s;
  width: 100%;
}
.btn:active:not(:disabled) {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
.preview-edit-links {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.preview-edit-btn {
  flex: 1;
  min-width: 0;
  padding: 10px 0;
  min-height: 44px;
  font-size: 13px;
  color: var(--text-tertiary);
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.preview-edit-btn:active {
  background: var(--bg-card);
}

.consent-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
.consent-row input[type="checkbox"] {
  margin-top: 3px;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* ── Funeral Type Cards ── */
/* Gender buttons */
.gender-btns{display:flex;gap:8px}
.gender-btn{flex:1;padding:16px 12px;border:2px solid var(--border);border-radius:10px;background:var(--bg-card);cursor:pointer;font-size:15px;font-weight:600;font-family:inherit;color:var(--text);-webkit-tap-highlight-color:transparent;position:relative}
.gender-btn:active{transform:scale(0.97)}
.gender-btn.active{border-color:var(--text);background:var(--bg-active)}
.gender-btn.active::after{content:'\2713';position:absolute;top:4px;right:6px;font-size:11px;color:var(--text);font-weight:700}

.funeral-type-cards{display:flex;gap:8px}
.type-card{flex:1;padding:14px 8px;border:2px solid var(--border);border-radius:12px;background:var(--bg-card);cursor:pointer;text-align:center;font-family:inherit;position:relative;-webkit-tap-highlight-color:transparent}
.type-card:active{transform:scale(0.97)}
.type-card.active{border-color:var(--text);background:var(--bg-active)}
.type-icon{display:block;font-size:24px;margin-bottom:4px}
.type-name{display:block;font-size:13px;font-weight:700;color:var(--text)}
.type-badge{position:absolute;top:-8px;right:-4px;font-size:12px;background:var(--text);color:#fff;padding:2px 6px;border-radius:8px}
.type-notice{background:var(--bg-alt);border-radius:10px;padding:12px 14px;margin-bottom:16px}
.type-notice p{font-size:13px;color:var(--text-secondary);line-height:1.5;margin:0}
.type-notice .warn{color:#c44;font-size:12px;margin-top:6px;display:block}
.toggle-row{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:600;cursor:pointer;-webkit-tap-highlight-color:transparent}
.toggle-row input[type="checkbox"]{width:18px;height:18px;accent-color:var(--text)}

/* Example toggle & chips */
.btn-example-toggle{display:inline-block;margin-top:6px;padding:4px 0;border:none;background:none;font-size:13px;color:var(--text-muted);cursor:pointer;font-family:inherit;-webkit-tap-highlight-color:transparent}
.btn-example-toggle:active{opacity:0.6}
.example-list{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
.example-chip{padding:6px 12px;min-height:44px;border:1px solid var(--border);border-radius:16px;background:var(--bg-card);font-size:13px;font-family:inherit;color:var(--text);cursor:pointer;-webkit-tap-highlight-color:transparent;display:inline-flex;align-items:center}
.example-chip:active{background:var(--bg-hover)}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 32px;
}
.btn-row .btn {
  flex: 1;
}

/* Info text */
.info-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Success screen */
.success-screen {
  text-align: center;
  padding: 40px 0;
}
.success-screen .check-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.success-screen h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}
.success-screen .url-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 15px;
  word-break: break-all;
  margin: 20px 0;
  color: var(--primary);
}
.btn-kakao-main {
  display: block;
  width: 100%;
  padding: 18px 20px;
  border: none;
  border-radius: 12px;
  background: #FEE500;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  color: #191919;
  letter-spacing: -0.3px;
  margin-top: 24px;
  margin-bottom: 12px;
}
.btn-kakao-main:active { opacity: 0.85; }
.success-screen .share-btns {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.success-screen .share-btns .btn {
  flex: 1;
  font-size: 13px;
  padding: 10px 8px;
}

/* Emoji picker */
.emoji-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.emoji-opt {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.emoji-opt:active { transform: scale(0.95); }
.emoji-opt.selected {
  border-color: var(--primary);
  background: var(--bg-hover);
}

/* Theme picker */
.theme-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.theme-opt {
  padding: 14px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.theme-opt:active { transform: scale(0.97); }
.theme-opt.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}
.theme-opt .theme-preview {
  height: auto;
  min-height: 72px;
  border-radius: 4px;
  margin-bottom: 6px;
}
.theme-opt .theme-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Focus styles (keyboard accessibility) */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.form-input:focus-visible,
.form-select:focus-visible {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(44, 44, 44, 0.15);
}
.pin-digit:focus-visible {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(44, 44, 44, 0.15);
}
.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.type-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.emoji-opt:focus-visible,
.theme-opt:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Toast */
.toast-container{position:fixed;bottom:24px;left:50%;transform:translateX(-50%);z-index:9999;pointer-events:none;width:90%;max-width:400px}
.toast{background:var(--text);color:var(--primary-text);padding:12px 20px;border-radius:24px;font-size:14px;line-height:1.5;text-align:center;opacity:0;transform:translateY(12px);transition:opacity 0.25s,transform 0.25s;pointer-events:auto;margin-top:8px;box-shadow:0 4px 12px rgba(0,0,0,0.15)}
.toast.show{opacity:1;transform:translateY(0)}

/* Step transition animation */
.form-step{transition:opacity 0.2s ease,transform 0.2s ease}
.form-step.slide-in{opacity:0;transform:translateX(20px)}
.form-step.slide-in-reverse{opacity:0;transform:translateX(-20px)}

/* Utility */
.hidden { display: none !important; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
