:root {
  --accent: #2563eb;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --panel: #ffffff;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 30;
  color: #fff;
  background: rgba(15, 23, 42, .96);
  border-bottom: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(16px);
}
.brand { color: white; text-decoration: none; font-weight: 800; font-size: 21px; letter-spacing: -.5px; }
.brand span { color: #60a5fa; }
.top-actions { display: flex; gap: 10px; }
.primary-btn, .ghost-btn, .small-btn, .file-btn {
  border: 0;
  border-radius: 12px;
  font-weight: 700;
  transition: .2s ease;
}
.primary-btn { background: #fff; color: #0f172a; padding: 11px 17px; }
.primary-btn:hover { transform: translateY(-1px); }
.ghost-btn { background: rgba(255,255,255,.08); color: white; padding: 11px 17px; }
.ghost-btn:hover { background: rgba(255,255,255,.14); }
.small-btn { color: white; background: var(--accent); padding: 9px 12px; }

.app-shell { display: grid; grid-template-columns: minmax(360px, 520px) 1fr; min-height: calc(100vh - 68px); }
.builder-panel { background: #fff; padding: 26px; border-right: 1px solid var(--line); overflow-y: auto; }
.intro-card {
  padding: 24px;
  border-radius: 22px;
  color: white;
  background: linear-gradient(145deg, #0f172a, #1e293b 65%, #1d4ed8);
  box-shadow: 0 18px 45px rgba(15,23,42,.16);
}
.eyebrow { display: inline-block; font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px; opacity: .75; font-weight: 800; }
.intro-card h1 { font-size: 28px; margin: 8px 0 10px; line-height: 1.1; letter-spacing: -.7px; }
.intro-card p { margin: 0; color: rgba(255,255,255,.76); line-height: 1.6; font-size: 14px; }

.section-tabs { display: flex; gap: 8px; overflow-x: auto; margin: 22px 0; padding-bottom: 4px; }
.tab { white-space: nowrap; border: 1px solid var(--line); color: #475569; background: #fff; border-radius: 999px; padding: 9px 13px; font-size: 13px; font-weight: 700; }
.tab.active { color: white; background: var(--ink); border-color: var(--ink); }

.form-section { display: none; animation: fade .18s ease; }
.form-section.active { display: block; }
@keyframes fade { from { opacity: .6; transform: translateY(4px);} }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.section-heading > div { display: flex; align-items: center; gap: 10px; }
.section-heading span { width: 28px; height: 28px; border-radius: 9px; background: #eff6ff; color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.section-heading h2 { margin: 0; font-size: 19px; }
.section-heading p { color: var(--muted); font-size: 12px; margin: 0; }

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: 1fr 1fr; }
label { display: flex; flex-direction: column; gap: 7px; color: #334155; font-size: 12px; font-weight: 700; margin-bottom: 14px; }
input, textarea {
  width: 100%;
  border: 1px solid #dbe3ee;
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px 13px;
  color: #0f172a;
  outline: none;
  transition: .15s ease;
  resize: vertical;
}
input:focus, textarea:focus { border-color: var(--accent); background: white; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent); }

.photo-row { display: flex; gap: 15px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 16px; margin-bottom: 16px; }
.photo-preview, .resume-photo { background: linear-gradient(145deg, var(--accent), #0f172a); color: white; display: grid; place-items: center; font-weight: 800; overflow: hidden; }
.photo-preview { width: 68px; height: 68px; border-radius: 16px; flex: 0 0 auto; }
.photo-preview img, .resume-photo img { width: 100%; height: 100%; object-fit: cover; }
.file-btn { display: inline-flex; align-items: center; color: white; background: var(--accent); padding: 8px 11px; margin: 0 6px 5px 0; font-size: 12px; }
.file-btn input { display: none; }
.text-btn { background: none; border: 0; color: #ef4444; font-weight: 700; font-size: 12px; }
.photo-row small { display: block; color: var(--muted); }

.repeater-list { display: grid; gap: 14px; }
.repeater-card { border: 1px solid var(--line); border-radius: 16px; padding: 15px; background: #fff; box-shadow: 0 4px 15px rgba(15,23,42,.03); }
.repeater-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 13px; }
.remove-item { border: 0; color: #ef4444; background: #fef2f2; border-radius: 9px; padding: 7px 10px; font-size: 11px; font-weight: 700; }

.template-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.template-card { padding: 16px 12px; border-radius: 14px; border: 1px solid var(--line); background: white; text-align: left; }
.template-card b, .template-card span { display: block; }
.template-card span { margin-top: 4px; font-size: 11px; color: var(--muted); }
.template-card.active { border: 2px solid var(--accent); background: color-mix(in srgb, var(--accent) 5%, white); }
.color-picker-wrap { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-top: 18px; }
.color-picker-wrap label { margin: 0; }
#accentColor { width: 70px; height: 42px; padding: 5px; }
.preset-colors { display: flex; gap: 8px; flex-wrap: wrap; }
.color-dot { width: 27px; height: 27px; border-radius: 50%; border: 3px solid white; outline: 1px solid #cbd5e1; }
.toggle-row { flex-direction: row; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 17px; margin-top: 17px; }
.toggle-row input { width: 20px; height: 20px; }

.preview-panel { padding: 24px; min-width: 0; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; color: #475569; font-size: 12px; margin: 0 auto 12px; max-width: 850px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; display: inline-block; margin-right: 6px; }
.save-status { color: #64748b; }
.paper-wrap { overflow: auto; padding-bottom: 60px; }
.resume {
  --resume-accent: var(--accent);
  width: 794px;
  min-height: 1123px;
  margin: 0 auto;
  background: white;
  box-shadow: 0 25px 70px rgba(15,23,42,.14);
  color: #172033;
}
.resume-header { display: flex; align-items: center; gap: 22px; padding: 42px 48px 30px; border-bottom: 1px solid #e8edf4; }
.resume-photo { width: 94px; height: 94px; border-radius: 24px; flex: 0 0 auto; }
.headline h1 { margin: 0; font-size: 34px; line-height: 1; letter-spacing: -1px; }
.headline h2 { margin: 9px 0 12px; color: var(--resume-accent); font-size: 16px; font-weight: 700; }
.contact-line { display: flex; flex-wrap: wrap; gap: 5px 14px; color: #64748b; font-size: 11px; }
.resume-body { display: grid; grid-template-columns: 235px 1fr; }
.resume-side { background: #f8fafc; padding: 30px 26px 40px 40px; min-height: 950px; }
.resume-main { padding: 30px 45px 45px; }
.resume-section { margin-bottom: 27px; }
.resume-section h3 { margin: 0 0 13px; text-transform: uppercase; letter-spacing: 1.2px; font-size: 11px; color: var(--resume-accent); }
.resume-section p { color: #445064; font-size: 12px; line-height: 1.7; margin: 0; white-space: pre-line; }
.tag-list { display: flex; gap: 7px; flex-wrap: wrap; }
.tag { background: white; border: 1px solid #e2e8f0; border-radius: 999px; padding: 6px 8px; font-size: 10px; }
.simple-list { padding-left: 15px; margin: 0; }
.simple-list li { margin-bottom: 7px; font-size: 11px; color: #445064; }
.timeline-item { position: relative; padding: 0 0 20px 17px; border-left: 1px solid #dbe3ee; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before { content: ''; position: absolute; left: -4px; top: 4px; width: 7px; height: 7px; background: var(--resume-accent); border-radius: 50%; }
.timeline-top { display: flex; justify-content: space-between; gap: 16px; }
.timeline-top b { font-size: 13px; }
.timeline-top span { font-size: 10px; color: #64748b; white-space: nowrap; }
.timeline-company { color: var(--resume-accent); font-size: 11px; font-weight: 700; margin: 4px 0 7px; }
.timeline-item p { font-size: 11px; line-height: 1.6; }
.paragraph-list p + p { margin-top: 10px; }

/* Classic */
.resume.classic { font-family: Georgia, 'Times New Roman', serif; }
.resume.classic .resume-header { display: block; text-align: center; padding-top: 48px; }
.resume.classic .resume-photo { margin: 0 auto 18px; border-radius: 50%; }
.resume.classic .headline h1 { font-family: 'Playfair Display', Georgia, serif; }
.resume.classic .contact-line { justify-content: center; }
.resume.classic .resume-body { grid-template-columns: 1fr; }
.resume.classic .resume-side { min-height: 0; display: grid; grid-template-columns: repeat(2,1fr); gap: 10px 30px; padding: 28px 48px 0; background: white; }
.resume.classic .resume-main { padding-top: 14px; }

/* Minimal */
.resume.minimal .resume-header { padding-left: 50px; border-top: 8px solid var(--resume-accent); }
.resume.minimal .resume-photo { border-radius: 50%; }
.resume.minimal .resume-body { grid-template-columns: 200px 1fr; }
.resume.minimal .resume-side { background: white; border-right: 1px solid #e8edf4; padding-left: 35px; }
.resume.minimal .tag { border-radius: 6px; }

.empty { color: #94a3b8 !important; font-style: italic; }
.hidden { display: none !important; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .builder-panel { border-right: 0; }
  .preview-panel { border-top: 1px solid var(--line); }
}
@media (max-width: 650px) {
  .topbar { padding: 0 14px; }
  .builder-panel, .preview-panel { padding: 15px; }
  .grid.two { grid-template-columns: 1fr; }
  .template-picker { grid-template-columns: 1fr; }
  .preview-panel { overflow: hidden; }
  .paper-wrap { transform-origin: top left; }
  .resume { transform: scale(.72); transform-origin: top left; margin-bottom: -300px; }
}

@page { size: A4; margin: 0; }
@media print {
  body { background: white; }
  .topbar, .builder-panel, .preview-toolbar { display: none !important; }
  .app-shell, .preview-panel, .paper-wrap { display: block; padding: 0; margin: 0; overflow: visible; }
  .resume { box-shadow: none; margin: 0; width: 210mm; min-height: 297mm; transform: none !important; }
}
