@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #1d2935;
  --muted: #647181;
  --gold: #a77b2d;
  --gold-light: #e9dfcb;
  --line: #e5e9ee;
  --paper: #fff;
  --bg: #f2f4f7;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Cairo", Tahoma, Arial, sans-serif;
  line-height: 1.65;
}
.topbar {
  background: #172534;
  color: white;
  padding: 18px clamp(16px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.topbar h1 { margin: 0; font-size: 22px; }
.topbar p { margin: 3px 0 0; color: #d5dde5; font-size: 13px; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; }
.btn {
  border: 0;
  border-radius: 7px;
  padding: 10px 17px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.btn-primary { background: #c49a50; color: #172534; }
.btn-light { background: #fff; color: #172534; }
.workspace {
  width: min(1500px, 100%);
  margin: 24px auto;
  padding: 0 18px;
  display: grid;
  grid-template-columns: minmax(290px, 390px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.editor {
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 5px 20px #1725340a;
}
.editor h2 { margin: 0; font-size: 19px; }
.hint { color: var(--muted); font-size: 12px; margin: 5px 0 15px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 700; }
.wide { grid-column: 1 / -1; }
input, textarea {
  width: 100%;
  border: 1px solid #d8dee6;
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  font: 400 13px/1.6 "Cairo", Tahoma, Arial, sans-serif;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 2px #a77b2d18; }
textarea { resize: vertical; min-height: 60px; }
.photo-field { border: 1px dashed #cbd3dc; padding: 12px; border-radius: 7px; }
.field-title { font-weight: 700; }
.text-btn { border: 0; background: transparent; color: #9a5c35; text-align: right; padding: 0; cursor: pointer; font: inherit; font-size: 12px; }
.preview-wrap { min-width: 0; }
.preview-label { color: var(--muted); font-size: 12px; margin: 0 0 8px; text-align: center; }
.cv-page {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 15mm 16mm 12mm;
  background: var(--paper);
  box-shadow: 0 8px 28px #17253418;
  display: flex;
  flex-direction: column;
  color: #202a34;
  overflow-wrap: anywhere;
}
.cv-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12mm;
  padding-bottom: 8mm;
  border-bottom: 2px solid var(--gold);
}
.identity { flex: 1; min-width: 0; }
.identity h1 { margin: 0 0 2px; color: #172534; font-size: 25pt; font-weight: 800; line-height: 1.35; }
.profession { color: var(--gold); font-size: 12pt; font-weight: 700; margin: 0 0 9px; }
.contact-line { display: flex; flex-wrap: wrap; gap: 3px 14px; color: #4f5b67; font-size: 9pt; }
.birth-line { margin: 4px 0 0; color: #4f5b67; font-size: 9pt; }
.photo-frame {
  width: 35mm;
  height: 45mm;
  flex: 0 0 35mm;
  border: 1px solid #d8d0c0;
  background: #f7f5f0;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  color: #9a8c73;
  text-align: center;
  font-size: 9pt;
}
.photo-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cv-body { flex: 1; }
.cv-section { margin-top: 6mm; break-inside: avoid; }
.cv-section h2 {
  font-size: 12pt;
  color: #172534;
  margin: 0 0 2.5mm;
  padding: 0 3mm 1.2mm 0;
  border-right: 3px solid var(--gold);
  border-bottom: 1px solid var(--gold-light);
  font-weight: 800;
}
.cv-content {
  white-space: pre-line;
  margin: 0;
  color: #394653;
  font-size: 10pt;
  line-height: 1.85;
}
.cv-footer {
  border-top: 1px solid var(--line);
  margin-top: 8mm;
  padding-top: 3mm;
  color: #8a929b;
  text-align: center;
  font-size: 8pt;
}
@media (max-width: 1050px) {
  .workspace { grid-template-columns: 1fr; }
  .editor { order: 1; }
  .preview-wrap { order: 2; overflow-x: auto; padding-bottom: 10px; }
}
@media (max-width: 650px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .field { grid-column: 1 / -1; }
  .cv-page { margin-right: 0; margin-left: 0; }
}
@page { size: A4; margin: 0; }
@media print {
  html, body { width: 210mm; min-height: 297mm; background: white !important; margin: 0 !important; }
  .no-print, .editor, .preview-label { display: none !important; }
  .workspace, .preview-wrap { display: block !important; width: 210mm !important; margin: 0 !important; padding: 0 !important; }
  .cv-page {
    width: 210mm !important;
    min-height: 297mm !important;
    height: auto;
    margin: 0 !important;
    padding: 15mm 16mm 12mm !important;
    box-shadow: none !important;
    border: 0 !important;
  }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}
