:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent-ui: #2563eb;
  --danger: #b91c1c;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 6px 18px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.5px;
}

.brand h1 { margin: 0; font-size: 18px; font-weight: 800; }
.brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border: none;
  border-radius: 10px;
  background: var(--accent-ui);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.6; cursor: wait; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 440px minmax(0, 1fr);
  gap: 20px;
  padding: 20px 24px 40px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.form-panel { padding: 8px 24px 24px; max-height: calc(100vh - 110px); overflow-y: auto; }

.preview-panel {
  position: sticky;
  top: 92px;
  background: #dfe6ee;
  padding: 28px;
  overflow: auto;
  max-height: calc(100vh - 110px);
}

/* ---------- Form ---------- */
.form-section { padding: 18px 0 6px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: none; }

.form-section h2 {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
}

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-head h2 { margin: 0; }

.btn-add {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--accent-ui);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-add:hover { background: #eff6ff; border-color: #bfdbfe; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field { margin-bottom: 14px; }

.field label {
  display: block;
  margin-bottom: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
}

.optional { font-weight: 400; color: var(--muted); }

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.45;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field select { min-height: 38px; cursor: pointer; }

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent-ui);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.field input::placeholder,
.field textarea::placeholder { color: #94a3b8; }

.field input[type="file"] { padding: 7px 10px; font-size: 12.5px; }
.field input[type="date"] { min-height: 38px; }
.field input:disabled { background: #f1f5f9; color: #94a3b8; cursor: not-allowed; }

.file-row { display: flex; gap: 8px; align-items: center; }
.file-row input[type="file"] { flex: 1; min-width: 0; }

.btn-remove-file {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: none;
  border-radius: 8px;
  background: #fee2e2;
  color: var(--danger);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-remove-file:hover { background: #fecaca; }

.field-check {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
  font-size: 13.5px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}
.field-check input { width: auto; min-height: 0; accent-color: var(--accent-ui); cursor: pointer; }

/* ---------- Dynamic entries ---------- */
.entries { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.entries:empty { display: none; }

.entry {
  position: relative;
  padding: 14px 14px 2px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

.entry-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: #fee2e2;
  color: var(--danger);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}
.entry-remove:hover { background: #fecaca; }

.entries-compact .entry { padding-top: 10px; }

/* ---------- Swatches ---------- */
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }

.swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.swatch:hover { transform: scale(1.1); }
.swatch.is-active { border-color: #0f172a; box-shadow: 0 0 0 2px #fff inset; }

/* ---------- CV Vorschau (A4) ---------- */
.cv {
  display: flex;
  width: 794px;
  min-height: 1123px;
  margin: 0 auto;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
  font-family: "Inter", system-ui, sans-serif;
}

.cv[data-accent="blau"]     { --accent: #2563eb; --accent-dark: #1e3a8a; --accent-darker: #172b63; --accent-light: #93c5fd; --accent-soft: #dbeafe; }
.cv[data-accent="teal"]     { --accent: #0d9488; --accent-dark: #134e4a; --accent-darker: #0d3b38; --accent-light: #5eead4; --accent-soft: #ccfbf1; }
.cv[data-accent="weinrot"]  { --accent: #be123c; --accent-dark: #881337; --accent-darker: #640e29; --accent-light: #fda4af; --accent-soft: #ffe4e6; }
.cv[data-accent="violett"]  { --accent: #7c3aed; --accent-dark: #4c1d95; --accent-darker: #3a146f; --accent-light: #c4b5fd; --accent-soft: #ede9fe; }
.cv[data-accent="anthrazit"]{ --accent: #475569; --accent-dark: #1f2937; --accent-darker: #111827; --accent-light: #cbd5e1; --accent-soft: #e2e8f0; }

.cv-side {
  width: 292px;
  flex-shrink: 0;
  padding: 44px 28px 36px;
  color: #ffffff;
  background: linear-gradient(170deg, var(--accent-dark) 0%, var(--accent-darker) 100%);
}

.cv-photo-wrap { margin-bottom: 22px; }

#cvPhoto,
.cv-initials {
  width: 138px;
  height: 138px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.28);
}

#cvPhoto { object-fit: cover; display: block; }

.cv-initials {
  display: grid;
  place-items: center;
  background: var(--accent);
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 1px;
}

.cv-side h2 {
  margin: 0 0 4px;
  font-size: 25px;
  font-weight: 800;
  line-height: 1.2;
  word-break: break-word;
}

.cv-jobtitle {
  margin: 0 0 26px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent-light);
  line-height: 1.4;
}

.cv-block { margin-bottom: 26px; }
.cv-block:last-child { margin-bottom: 0; }

.cv-block h3 {
  margin: 0 0 12px;
  padding-bottom: 7px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.28);
}

.cv-contact { list-style: none; margin: 0; padding: 0; }

.cv-contact li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.92);
  word-break: break-word;
}

.cv-contact li:last-child { margin-bottom: 0; }

.cv-contact svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; color: var(--accent-light); }

.skill { margin-bottom: 11px; }
.skill:last-child { margin-bottom: 0; }

.skill-name { font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }

.skill-bar { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.18); overflow: hidden; }
.skill-bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent-light); }

.lang { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: 12.5px; }
.lang:last-child { margin-bottom: 0; }
.lang-name { font-weight: 600; }
.lang-level { color: rgba(255, 255, 255, 0.75); text-align: right; }

.cv-main { flex: 1; padding: 46px 40px 40px; min-width: 0; }

.cv-main section { margin-bottom: 30px; page-break-inside: auto; }
.cv-main section:last-child { margin-bottom: 0; }

.cv-main h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
}

.cv-main h2::before {
  content: "";
  width: 24px;
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
  flex-shrink: 0;
}

.cv-about { margin: 0; font-size: 13.5px; line-height: 1.65; color: #334155; white-space: pre-line; }

.xp {
  position: relative;
  margin-left: 6px;
  padding: 2px 0 16px 18px;
  border-left: 2px solid var(--accent-soft);
  page-break-inside: avoid;
}
.xp:last-child { padding-bottom: 2px; }

.xp::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 7px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.xp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

.xp-role { margin: 0; font-size: 14.5px; font-weight: 700; color: #0f172a; }

.xp-period {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.xp-sub { margin: 3px 0 0; font-size: 13px; font-weight: 600; color: #475569; }

.xp-place { font-weight: 400; color: #94a3b8; }

.xp-desc { margin: 6px 0 0; font-size: 12.5px; line-height: 1.6; color: #475569; white-space: pre-line; }

.cv-hobbies { display: flex; flex-wrap: wrap; gap: 6px; }

.cv-hobby {
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 12px;
  font-weight: 500;
}

.cv-signature { margin-top: 48px; text-align: right; page-break-inside: avoid; }

#cvSig { display: block; max-height: 52px; max-width: 220px; margin: 0 0 4px auto; }

.cv-sig-line { font-size: 13px; color: #334155; }

/* ---------- Druck-Fallback (Strg+P -> Als PDF speichern) ---------- */
@media print {
  body { background: #ffffff; }
  .app-header, .form-panel { display: none !important; }
  .layout { display: block; padding: 0; margin: 0; }
  .preview-panel {
    position: static;
    top: auto;
    max-height: none;
    overflow: visible;
    padding: 0;
    background: #ffffff;
    border: none;
    box-shadow: none;
  }
  .cv { box-shadow: none; margin: 0; width: 210mm; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .form-panel { max-height: none; }
  .preview-panel { position: static; max-height: none; }
}

@media (max-width: 640px) {
  .app-header { flex-direction: column; align-items: stretch; text-align: center; }
  .brand { justify-content: center; }
  .grid-2 { grid-template-columns: 1fr; }
  .layout { padding: 14px; }
}
