/* ===== CSS Variables ===== */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --accent: #1e3a5f;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 8px;
  --form-width: 40%;
  --preview-width: 60%;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d27;
  --text: #e8eaed;
  --text-muted: #9ca3af;
  --border: #2d3348;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

body {
  font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Header ===== */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.site-title a { color: inherit; text-decoration: none; }

.site-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.progress-wrap { min-width: 200px; }

.progress-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

.btn-icon {
  background: var(--border);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.2s;
}

.btn-icon:hover { background: var(--primary); }

.template-switcher {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.template-switcher .label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.tpl-btn {
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
  color: var(--text);
}

.tpl-btn:hover { border-color: var(--primary); }
.tpl-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.sidebar-color-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.sidebar-color-wrap input[type="color"] {
  width: 32px;
  height: 32px;
  border: none;
  cursor: pointer;
  border-radius: 4px;
}

.action-bar {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  border: none;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--accent); color: #fff; }
.btn-secondary:hover { opacity: 0.9; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.privacy-notice {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* ===== Ad Slots ===== */
.ad-slot {
  background: var(--border);
  color: var(--text-muted);
  text-align: center;
  font-size: 0.75rem;
  border: 1px dashed var(--text-muted);
  margin: 0.75rem 0;
}

.ad-banner {
  height: 90px;
  line-height: 90px;
  width: 100%;
}

.ad-square {
  height: 250px;
  line-height: 250px;
  max-width: 300px;
  margin: 1rem auto;
}

/* ===== Cross Link ===== */
.cross-link-banner {
  background: linear-gradient(135deg, #1e3a5f, #2563eb);
  padding: 0.75rem 1.5rem;
  text-align: center;
}

.cross-link-banner a {
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
}

.cross-link-banner a:hover { text-decoration: underline; }

/* ===== Mobile Tabs ===== */
.mobile-tabs {
  display: none;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 0.75rem;
  border: none;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ===== Main Layout ===== */
.main-layout {
  display: flex;
  min-height: calc(100vh - 200px);
}

.form-panel {
  width: var(--form-width);
  padding: 1rem 1.5rem;
  overflow-y: auto;
  max-height: calc(100vh - 180px);
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.preview-panel {
  width: var(--preview-width);
  padding: 1.5rem;
  overflow-y: auto;
  background: var(--bg);
  display: flex;
  justify-content: center;
}

.preview-wrapper {
  width: 100%;
  max-width: 210mm;
}

/* ===== Form Sections ===== */
.form-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-check {
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: color 0.2s;
}

.section-check.done { color: var(--success); }

.btn-add {
  margin-left: auto;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.btn-add:hover { opacity: 0.9; }

.field-grid {
  display: grid;
  gap: 0.75rem;
}

.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text-muted);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="number"],
.field input[type="file"],
.field select,
.field textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}

.field input:disabled { opacity: 0.5; }

.field textarea { resize: vertical; min-height: 60px; }

.date-row {
  display: flex;
  gap: 0.5rem;
}

.date-row input { flex: 1; }

.radio-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.radio-row label {
  font-size: 0.85rem;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
}

.req { color: #ef4444; }

.photo-preview {
  width: 70px;
  height: 90px;
  border: 1px dashed var(--border);
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg);
}

.photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-placeholder {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
}

/* ===== Dynamic Lists ===== */
.dynamic-list { display: flex; flex-direction: column; gap: 0.75rem; }

.dynamic-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  position: relative;
}

.dynamic-item.dragging { opacity: 0.5; }

.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 1rem;
  user-select: none;
  padding: 0 0.25rem;
}

.item-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.item-header .item-num {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-remove {
  margin-left: auto;
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 0.8rem;
}

.item-fields {
  display: grid;
  gap: 0.5rem;
}

.item-fields .mini-field label {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 2px;
}

.item-fields .mini-field input,
.item-fields .mini-field select,
.item-fields .mini-field textarea {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.8rem;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

.item-fields .row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.item-fields .row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
}

/* ===== Skills Tags ===== */
.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.skill-tag {
  background: var(--primary);
  color: #fff;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
}

.char-count {
  float: right;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--text-muted);
}

.conditional-fields {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

/* ===== Resume Preview (A4) ===== */
.resume-a4 {
  width: 210mm;
  min-height: 297mm;
  background: #fff;
  color: #000;
  box-shadow: var(--shadow);
  margin: 0 auto;
  padding: 15mm 18mm;
  font-size: 10pt;
  line-height: 1.5;
  position: relative;
}

/* Template A - Standard */
.tpl-a .resume-title {
  text-align: center;
  font-size: 22pt;
  font-weight: bold;
  letter-spacing: 0.5em;
  margin-bottom: 12px;
  font-family: 'Batang', 'Malgun Gothic', serif;
}

.tpl-a .basic-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.tpl-a .basic-info-table {
  flex: 1;
  border-collapse: collapse;
  width: calc(100% - 90px);
}

.tpl-a .basic-info-table td {
  border: 1px solid #000;
  padding: 4px 8px;
  font-size: 9pt;
}

.tpl-a .basic-info-table .label-cell {
  background: #f0f0f0;
  width: 70px;
  font-weight: bold;
  text-align: center;
}

.tpl-a .photo-box {
  width: 70px;
  height: 90px;
  border: 1px solid #000;
  margin-left: 10px;
  overflow: hidden;
  flex-shrink: 0;
}

.tpl-a .photo-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tpl-a .section-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
}

.tpl-a .section-table th,
.tpl-a .section-table td {
  border: 1px solid #000;
  padding: 3px 6px;
  font-size: 9pt;
  text-align: center;
}

.tpl-a .section-table th {
  background: #f0f0f0;
  font-weight: bold;
}

.tpl-a .section-table td.left { text-align: left; }

.tpl-a .section-heading {
  font-weight: bold;
  font-size: 10pt;
  margin: 8px 0 4px;
  border-bottom: 1px solid #000;
  padding-bottom: 2px;
}

.tpl-a .cover-text {
  font-size: 9pt;
  margin-bottom: 6px;
  white-space: pre-wrap;
}

.tpl-a .cover-text strong { display: block; margin-bottom: 2px; }

/* Template B - Clean */
.tpl-b {
  display: flex;
  padding: 0 !important;
  min-height: 297mm;
}

.tpl-b .sidebar {
  width: 35mm;
  padding: 15mm 8mm;
  color: #fff;
  flex-shrink: 0;
}

.tpl-b .sidebar .sb-name {
  font-size: 14pt;
  font-weight: bold;
  margin-bottom: 4px;
  word-break: keep-all;
}

.tpl-b .sidebar .sb-hanja {
  font-size: 9pt;
  opacity: 0.8;
  margin-bottom: 12px;
}

.tpl-b .sidebar .sb-section {
  margin-bottom: 12px;
}

.tpl-b .sidebar .sb-section h4 {
  font-size: 8pt;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.7;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.3);
  padding-bottom: 2px;
}

.tpl-b .sidebar .sb-section p,
.tpl-b .sidebar .sb-section li {
  font-size: 8pt;
  line-height: 1.6;
}

.tpl-b .sidebar .sb-photo {
  width: 60px;
  height: 77px;
  margin-bottom: 12px;
  overflow: hidden;
  border-radius: 4px;
}

.tpl-b .sidebar .sb-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tpl-b .main-content {
  flex: 1;
  padding: 15mm 15mm 15mm 12mm;
}

.tpl-b .mb-section {
  margin-bottom: 14px;
}

.tpl-b .mb-section h3 {
  font-size: 11pt;
  font-weight: bold;
  color: var(--sidebar-color, #1e3a5f);
  margin-bottom: 6px;
  padding-bottom: 3px;
  border-bottom: 2px solid var(--sidebar-color, #1e3a5f);
}

.tpl-b .mb-entry {
  margin-bottom: 8px;
}

.tpl-b .mb-entry .entry-head {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  font-size: 9.5pt;
}

.tpl-b .mb-entry .entry-sub {
  font-size: 8.5pt;
  color: #555;
}

.tpl-b .mb-entry .entry-desc {
  font-size: 8.5pt;
  color: #333;
  margin-top: 2px;
  white-space: pre-wrap;
}

.tpl-b .skill-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tpl-b .skill-pill {
  background: #eef2ff;
  color: var(--sidebar-color, #1e3a5f);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 8pt;
}

/* Template C - Two Column */
.tpl-c .c-header {
  text-align: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid #333;
}

.tpl-c .c-header .c-name {
  font-size: 20pt;
  font-weight: bold;
}

.tpl-c .c-header .c-contact {
  font-size: 9pt;
  color: #555;
  margin-top: 4px;
}

.tpl-c .c-columns {
  display: flex;
  gap: 12mm;
}

.tpl-c .c-left {
  width: 38%;
  flex-shrink: 0;
}

.tpl-c .c-right {
  flex: 1;
}

.tpl-c .c-section {
  margin-bottom: 12px;
}

.tpl-c .c-section h3 {
  font-size: 10pt;
  font-weight: bold;
  background: #333;
  color: #fff;
  padding: 3px 8px;
  margin-bottom: 6px;
}

.tpl-c .c-section .c-item {
  margin-bottom: 6px;
  font-size: 8.5pt;
}

.tpl-c .c-section .c-item .c-item-title {
  font-weight: bold;
}

.tpl-c .c-section .c-item .c-item-meta {
  color: #666;
  font-size: 8pt;
}

.tpl-c .c-photo {
  width: 70px;
  height: 90px;
  border: 1px solid #ccc;
  margin-bottom: 8px;
  overflow: hidden;
}

.tpl-c .c-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tpl-c .cover-block {
  font-size: 8.5pt;
  margin-bottom: 8px;
}

.tpl-c .cover-block strong {
  display: block;
  font-size: 9pt;
  margin-bottom: 2px;
}

.tpl-c .cover-block p {
  white-space: pre-wrap;
  color: #333;
}

/* ===== FAQ ===== */
.faq-section {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.faq-section h2 {
  font-size: 1.3rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.faq-item {
  margin-bottom: 1.25rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.faq-item h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.faq-item p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ===== Footer ===== */
.site-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.site-footer p { margin-bottom: 0.25rem; }

/* ===== Privacy Page ===== */
.privacy-content {
  max-width: 700px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.privacy-content h1 { font-size: 1.5rem; margin-bottom: 0.5rem; }
.privacy-content h2 { font-size: 1.1rem; margin: 1.5rem 0 0.5rem; }
.privacy-content p, .privacy-content li {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
}
.privacy-content ul { padding-left: 1.5rem; margin: 0.5rem 0; }

/* ===== Modals ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal h3 { margin-bottom: 0.75rem; }
.modal p, .modal li { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.modal ul { padding-left: 1.25rem; margin-bottom: 1rem; }
.modal .btn { margin-right: 0.5rem; margin-top: 0.5rem; }

.checklist { list-style: none; padding: 0; }
.checklist li { margin-bottom: 0.5rem; }
.checklist label { font-size: 0.85rem; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  z-index: 2000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: opacity 0.3s;
}

.toast[hidden] { display: none; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .mobile-tabs { display: flex; }

  .main-layout { flex-direction: column; }

  .form-panel,
  .preview-panel {
    width: 100%;
    max-height: none;
  }

  .form-panel { display: none; border-right: none; }
  .preview-panel { display: none; }

  .form-panel.active,
  .preview-panel.active { display: block; }

  .resume-a4 {
    width: 100%;
    min-height: auto;
    padding: 10mm;
    font-size: 8pt;
  }

  .header-top { flex-direction: column; }
  .progress-wrap { width: 100%; }

  .tpl-b { flex-direction: column; }
  .tpl-b .sidebar { width: 100%; }

  .tpl-c .c-columns { flex-direction: column; }
  .tpl-c .c-left { width: 100%; }
}