:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #dbe3ef;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #eff6ff;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  background: linear-gradient(180deg, #f7f9fc 0%, #eef3f9 100%);
  color: var(--text);
}

img {
  max-width: 100%;
  display: block;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
  outline: none;
  transition: 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #8fb3ff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

textarea {
  resize: vertical;
  min-height: 110px;
}

small {
  display: inline-block;
  margin-top: 8px;
  color: var(--muted);
}

.container {
  width: min(1440px, calc(100% - 28px));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(219, 227, 239, 0.85);
}

.topbar-inner {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-badge {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 1.05rem;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  box-shadow: 0 14px 34px rgba(37, 99, 235, 0.22);
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.1;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.top-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 24px;
  padding: 24px 0 42px;
  align-items: start;
}

.panel-card {
  background: var(--card);
  border: 1px solid rgba(219, 227, 239, 0.8);
  box-shadow: var(--shadow);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  display: inline-flex;
  padding: 7px 12px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.8rem;
  margin-bottom: 12px;
}

.hero-card h2 {
  margin: 0 0 8px;
  font-size: clamp(1.4rem, 2vw, 2rem);
}

.hero-card p {
  margin: 0;
  color: var(--muted);
  max-width: 700px;
}

.autosave-pill {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid var(--line);
  color: #0f172a;
  font-weight: 600;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.12);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.section-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.template-card {
  display: block;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: #fff;
  cursor: pointer;
  transition: 0.2s ease;
}

.template-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
}

.template-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.template-card input {
  display: none;
}

.template-preview {
  height: 155px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid #dfe7f1;
  margin-bottom: 12px;
  background: #fff;
  position: relative;
}

.classic-preview {
  display: grid;
  grid-template-columns: 32% 1fr;
}

.mini-sidebar {
  background: linear-gradient(180deg, #173b71, #2457a8);
}

.mini-main {
  padding: 10px;
}

.modern-top {
  height: 38px;
  background: linear-gradient(90deg, #111827, #2563eb);
}

.modern-body,
.exec-body,
.ats-body,
.minimal-body,
.elegant-body,
.compact-body {
  padding: 12px;
}

.exec-header {
  padding: 12px;
  background: linear-gradient(90deg, #1f2937, #374151);
}

.ats-head {
  padding: 12px 12px 6px;
}

.minimal-strip {
  height: 12px;
  background: linear-gradient(90deg, #cbd5e1, #94a3b8);
}

.bold-preview {
  display: grid;
  grid-template-columns: 28% 1fr;
}

.bold-left {
  background: linear-gradient(180deg, #111827, #2563eb);
}

.bold-right {
  padding: 12px;
}

.elegant-top {
  padding: 12px;
  background: linear-gradient(90deg, #f8fafc, #e2e8f0);
}

.compact-head {
  height: 28px;
  background: linear-gradient(90deg, #0f172a, #334155);
}

.mini-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.mini-block {
  margin-top: 10px;
}

.mini-line {
  height: 8px;
  border-radius: 999px;
  background: #dbe5f0;
  margin-bottom: 8px;
}

.mini-line.dark {
  background: #1f2937;
}

.w-100 { width: 100%; }
.w-90 { width: 90%; }
.w-85 { width: 85%; }
.w-80 { width: 80%; }
.w-75 { width: 75%; }
.w-70 { width: 70%; }
.w-65 { width: 65%; }
.w-60 { width: 60%; }
.w-55 { width: 55%; }
.w-50 { width: 50%; }
.w-45 { width: 45%; }
.w-40 { width: 40%; }
.w-35 { width: 35%; }
.w-30 { width: 30%; }

.template-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.template-info strong {
  font-size: 0.98rem;
}

.template-info span {
  color: var(--muted);
  font-size: 0.9rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.tag-input-wrap {
  display: flex;
  gap: 10px;
}

.tags-box,
.preview-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 24px;
}

.tag-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #eff6ff, #f5f3ff);
  color: #1e3a8a;
  border: 1px solid #d8e5ff;
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

.tag-item button {
  background: transparent;
  color: #1e40af;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

.dynamic-container {
  display: grid;
  gap: 14px;
}

.dynamic-block {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: #fbfdff;
}

.block-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.block-top h4 {
  margin: 0;
  font-size: 1rem;
}

.block-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.check-line {
  margin: 2px 0 14px;
}

.check-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
}

.check-item input {
  width: 18px;
  height: 18px;
  padding: 0;
}

.preview-toolbar {
  position: sticky;
  top: 96px;
  z-index: 5;
  background: #ffffffd9;
  backdrop-filter: blur(8px);
  padding: 16px 18px;
  border: 1px solid rgba(219, 227, 239, 0.82);
  box-shadow: var(--shadow);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.preview-toolbar h3 {
  margin: 0;
}

.preview-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.cv-preview-wrap {
  overflow: hidden;
  border-radius: 24px;
  width: 100%;
}

.cv-preview {
  background: #e9eef6;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(219, 227, 239, 0.7);
  width: 100%;
  overflow: hidden;
}

.cv-shell {
  width: 100%;
  max-width: 900px;
  min-height: auto;
  margin: 0 auto;
  background: #fff;
  color: #111827;
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.16);
  overflow: hidden;
  aspect-ratio: 210 / 297;
}

.template-classic .cv-shell {
  display: grid;
  grid-template-columns: 31% 1fr;
}

.cv-sidebar {
  background: #173b71;
  color: #fff;
  padding: 28px 22px;
}

.cv-main {
  padding: 28px 28px 26px;
}

.photo-wrap {
  width: 120px;
  height: 120px;
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 24px;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.15);
  display: grid;
  place-items: center;
}

.photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.photo-wrap.has-image img {
  display: block;
}

.photo-wrap.has-image .photo-fallback {
  display: none;
}

.photo-fallback {
  color: rgba(255, 255, 255, 0.8);
  font-weight: 700;
  font-size: 0.95rem;
}

.cv-side-section {
  margin-bottom: 22px;
}

.cv-side-section h4 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #dbeafe;
}

.cv-side-section p {
  margin: 0 0 10px;
  color: rgba(255, 255, 255, 0.94);
  font-size: 0.93rem;
  line-height: 1.55;
  word-break: break-word;
}

.preview-tags {
  gap: 8px;
}

.preview-tags .tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.cv-header {
  margin-bottom: 22px;
}

.cv-header h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.08;
  color: #0f172a;
}

.cv-header h2 {
  margin: 8px 0 0;
  font-size: 1rem;
  font-weight: 600;
  color: #2563eb;
}

.cv-section {
  margin-bottom: 22px;
  break-inside: avoid;
}

.cv-section h3 {
  margin: 0 0 12px;
  font-size: 0.98rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #0f172a;
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 8px;
}

.cv-section p {
  margin: 0;
  color: #374151;
  line-height: 1.65;
  font-size: 0.95rem;
}

.preview-item {
  margin-bottom: 16px;
  break-inside: avoid;
}

.preview-item:last-child {
  margin-bottom: 0;
}

.preview-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 6px;
}

.preview-item h4 {
  margin: 0;
  font-size: 1rem;
  color: #111827;
}

.preview-item .sub {
  display: block;
  margin-top: 4px;
  color: #2563eb;
  font-weight: 600;
  font-size: 0.92rem;
}

.preview-date {
  font-size: 0.87rem;
  color: #6b7280;
  white-space: nowrap;
  font-weight: 600;
}

.preview-item p {
  color: #374151;
  font-size: 0.93rem;
  line-height: 1.6;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  font-weight: 700;
  transition: 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.2);
}

.btn-secondary {
  background: #eef4ff;
  color: var(--primary);
}

.btn-ghost {
  background: #fff;
  color: #0f172a;
  border: 1px solid var(--line);
}

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
}

.btn-small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.88rem;
}

.empty-note {
  color: #94a3b8;
  font-style: italic;
}

.hidden {
  display: none !important;
}

/* MODERN */
.template-modern .cv-shell,
.template-minimal .cv-shell,
.template-elegant .cv-shell,
.template-compact .cv-shell {
  display: block;
}

.template-modern .cv-sidebar,
.template-minimal .cv-sidebar,
.template-elegant .cv-sidebar,
.template-compact .cv-sidebar {
  background: #fff;
  color: #111827;
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 22px;
  border-bottom: 1px solid #e5e7eb;
  padding: 24px 28px;
}

.template-modern .photo-wrap,
.template-minimal .photo-wrap,
.template-elegant .photo-wrap,
.template-compact .photo-wrap {
  margin: 0;
  border-radius: 22px;
  border: 0;
  background: #eef2ff;
}

.template-modern .photo-fallback,
.template-minimal .photo-fallback,
.template-elegant .photo-fallback,
.template-compact .photo-fallback {
  color: #4338ca;
}

.template-modern .cv-side-section,
.template-minimal .cv-side-section,
.template-elegant .cv-side-section,
.template-compact .cv-side-section {
  margin-bottom: 0;
}

.template-modern .cv-side-section h4,
.template-minimal .cv-side-section h4,
.template-elegant .cv-side-section h4,
.template-compact .cv-side-section h4 {
  color: #0f172a;
}

.template-modern .cv-side-section p,
.template-minimal .cv-side-section p,
.template-elegant .cv-side-section p,
.template-compact .cv-side-section p {
  color: #374151;
}

.template-modern .preview-tags .tag-pill,
.template-minimal .preview-tags .tag-pill,
.template-elegant .preview-tags .tag-pill,
.template-compact .preview-tags .tag-pill {
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid #dfe3ff;
}

/* EXECUTIVE */
.template-executive .cv-shell {
  display: block;
}

.template-executive .cv-sidebar {
  background: linear-gradient(90deg, #111827, #1f2937);
  padding: 26px 28px;
  display: grid;
  grid-template-columns: 120px 1fr 1fr;
  gap: 24px;
  align-items: center;
}

.template-executive .cv-main {
  padding: 30px;
}

/* ATS */
.template-ats .cv-shell {
  display: block;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
}

.template-ats .cv-sidebar {
  background: #fff;
  color: #111827;
  padding: 18px 30px 0;
  border-bottom: none;
}

.template-ats .photo-wrap {
  display: none !important;
}

.template-ats .cv-side-section {
  margin-bottom: 12px;
}

.template-ats .cv-side-section h4 {
  color: #111827;
  border-bottom: 1px solid #d1d5db;
  padding-bottom: 6px;
}

.template-ats .cv-side-section p {
  color: #111827;
}

.template-ats .preview-tags .tag-pill {
  background: #fff;
  color: #111827;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
}

.template-ats .cv-main {
  padding: 12px 30px 30px;
}

.template-ats .cv-header h2,
.template-ats .preview-item .sub,
.template-ats .preview-date,
.template-ats .cv-section p {
  color: #111827;
}

.template-ats .cv-section h3 {
  border-bottom: 1px solid #111827;
}

/* BOLD */
.template-bold .cv-shell {
  display: grid;
  grid-template-columns: 34% 1fr;
}

.template-bold .cv-sidebar {
  background: linear-gradient(180deg, #0f172a, #2563eb);
}

.template-bold .preview-tags .tag-pill {
  background: rgba(255, 255, 255, 0.18);
}

/* ELEGANT */
.template-elegant .cv-header {
  padding-bottom: 10px;
  border-bottom: 1px solid #d1d5db;
}

.template-elegant .cv-header h1 {
  font-size: 2.1rem;
}

.template-elegant .cv-header h2 {
  color: #6b7280;
}

/* COMPACT */
.template-compact .cv-main {
  padding: 22px 24px;
}

.template-compact .cv-section {
  margin-bottom: 16px;
}

.template-compact .cv-section h3 {
  font-size: 0.9rem;
}

@page {
  size: A4;
  margin: 10mm;
}

@media print {
  html,
  body {
    background: #fff;
    margin: 0;
    padding: 0;
  }

  .topbar,
  .editor-panel,
  .preview-toolbar {
    display: none !important;
  }

  .app-shell {
    display: block;
    padding: 0;
    margin: 0;
  }

  .preview-panel {
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .cv-preview-wrap {
    overflow: visible !important;
    border-radius: 0;
  }

  .cv-preview {
    padding: 0;
    border: 0;
    background: #fff;
    box-shadow: none;
  }

  .cv-shell {
    width: 190mm;
    min-height: 277mm;
    max-width: none;
    aspect-ratio: auto;
    box-shadow: none;
    margin: 0 auto;
    page-break-inside: avoid;
  }

  .cv-section,
  .preview-item,
  .cv-side-section {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .template-classic .cv-shell,
  .template-bold .cv-shell {
    display: grid;
  }
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .preview-toolbar {
    position: static;
  }
}

@media (max-width: 820px) {
  .template-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .hero-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 0;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions .btn {
    flex: 1;
  }

  .tag-input-wrap {
    flex-direction: column;
  }

  .cv-preview {
    padding: 10px;
  }

  .cv-shell {
    width: 100%;
    max-width: 100%;
    min-height: auto;
    aspect-ratio: auto;
  }

  .template-classic .cv-shell,
  .template-bold .cv-shell,
  .template-modern .cv-sidebar,
  .template-minimal .cv-sidebar,
  .template-elegant .cv-sidebar,
  .template-compact .cv-sidebar,
  .template-executive .cv-sidebar {
    display: block;
  }

  .cv-sidebar,
  .cv-main,
  .template-modern .cv-sidebar,
  .template-minimal .cv-sidebar,
  .template-elegant .cv-sidebar,
  .template-compact .cv-sidebar,
  .template-executive .cv-sidebar {
    padding: 22px 18px;
  }

  .photo-wrap {
    margin-bottom: 18px;
  }

  .preview-item-head {
    flex-direction: column;
    gap: 4px;
  }

  .preview-date {
    white-space: normal;
  }
}

.site-footer {
  margin-top: 24px;
  padding: 0 0 24px;
}

.footer-inner {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(219, 227, 239, 0.95);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  border-radius: 22px;
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  flex-wrap: wrap;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.footer-brand-badge {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.2);
  flex-shrink: 0;
}

.footer-copy {
  margin: 0;
  font-weight: 700;
  color: #0f172a;
  font-size: 0.96rem;
}

.footer-sub {
  display: inline-block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
}

.footer-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-link-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.92rem;
  color: #0f172a;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border: 1px solid var(--line);
  transition: 0.2s ease;
}

.footer-link-pill:hover {
  transform: translateY(-1px);
  color: var(--primary);
  border-color: #bfd3ff;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.08);
}

@media (max-width: 820px) {
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .footer-links {
    width: 100%;
  }

  .footer-link-pill {
    flex: 1 1 auto;
  }
}