/* ===== App shell ===== */
* { box-sizing: border-box; }
:root { --ink: #1d2433; --muted: #5b6475; --line: #d3d8e0; --bg: #eceff3; --accent: #1f5fbf; }
body { margin: 0; font: 16px/1.45 system-ui, "Segoe UI", Arial, sans-serif; color: var(--ink); background: var(--bg); }
button, select, input, textarea { font: inherit; }
h1, h2, h3, p { margin: 0; }

.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: center; justify-content: space-between; }
.topbar h1 { font-size: 1.3rem; }
.sub { color: var(--muted); font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.tpl { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); }
.status { flex-basis: 100%; min-height: 1.3em; font-size: .9rem; color: var(--accent); }
.status:empty { display: none; }

.btn { min-height: 40px; padding: 6px 14px; border: 1px solid #9aa3b2; border-radius: 6px; background: #fff; color: var(--ink); cursor: pointer; }
.btn:hover { background: #f1f4f8; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #184d9a; }
.btn.danger { color: #a3262a; border-color: #d8a3a5; }
.btn.small { min-height: 36px; padding: 4px 10px; font-size: .9rem; }
.btn:disabled { opacity: .4; cursor: default; }
:focus-visible { outline: 3px solid #7aa7ec; outline-offset: 1px; }
select { min-height: 40px; padding: 6px 8px; border: 1px solid #9aa3b2; border-radius: 6px; background: #fff; }

.editor, .preview { padding: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 14px; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.card-head[draggable] { cursor: grab; }
.card-head h2 { flex: 1; font-size: 1.05rem; }
.grip { width: 16px; height: 2px; background: #8a93a3; box-shadow: 0 -5px #8a93a3, 0 5px #8a93a3; margin: 0 4px; }
.card-body { padding: 12px; }
.card.dragging { opacity: .5; }
.card.drop-before { box-shadow: 0 -4px 0 var(--accent); }
.card.drop-after { box-shadow: 0 4px 0 var(--accent); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid .wide { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 3px; font-size: .85rem; color: var(--muted); }
input, textarea { width: 100%; padding: 8px 10px; border: 1px solid #b4bcc9; border-radius: 6px; background: #fff; color: var(--ink); }
textarea { resize: vertical; }
.item { border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin-bottom: 10px; background: #fafbfc; }
.item h3 { font-size: .9rem; margin-bottom: 8px; }
.item .btn { margin-top: 10px; }

.pages { font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.paper { width: 210mm; min-height: 297mm; margin: 0 auto; padding: 14mm; background: #fff; color: #111; box-shadow: 0 1px 8px rgba(0, 0, 0, .25);
  font-size: 10pt; line-height: 1.4; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.empty { color: #777; font-family: system-ui, sans-serif; }

/* Desktop: editor on the left, preview beside it, each scrolls on its own. */
@media screen and (min-width: 900px) {
  body { height: 100vh; display: flex; flex-direction: column; }
  .layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(340px, 480px) 1fr; }
  .editor, .preview { overflow: auto; }
}
@media (max-width: 520px) { .grid { grid-template-columns: 1fr; } .actions .btn { flex: 1 1 auto; } }

/* ===== Resume content (shared) ===== */
.paper ul { margin: 1mm 0 0; padding-left: 4.5mm; }
.paper li { break-inside: avoid; }
.paper h1, .paper h2 { margin: 0; }
.sec { margin-top: 5mm; }
.sec-title { break-after: avoid; }
.summary { white-space: pre-line; orphans: 3; widows: 3; margin-top: 2mm; }
.entry { display: grid; grid-template-columns: 1fr auto; margin-top: 3mm; break-inside: avoid; }
.e-main { min-width: 0; }
.e-title { font-weight: 700; }
.e-date { white-space: nowrap; padding-left: 4mm; font-size: 9pt; }
.skills { margin-top: 2mm; }

/* ===== Template 1: Classic (serif, centered, ruled headings) ===== */
.t-classic { font-family: Georgia, "Times New Roman", serif; }
.t-classic .r-head { text-align: center; }
.t-classic .r-name { font-size: 24pt; font-weight: 400; letter-spacing: .05em; line-height: 1.15; }
.t-classic .r-title { font-style: italic; font-size: 11.5pt; }
.t-classic .r-contact { margin-top: 1.5mm; font-size: 9.5pt; }
.t-classic .r-contact span:not(:last-child)::after { content: "|"; margin: 0 2.5mm; color: #888; }
.t-classic .sec-title { font-size: 10.5pt; text-transform: uppercase; letter-spacing: .12em; border-bottom: 1px solid #111; padding-bottom: .6mm; }
.t-classic .e-sub { font-style: italic; color: #333; }
.t-classic .chip:not(:last-child)::after { content: ", "; }

/* ===== Template 2: Modern (sans, dark header block, accent bars, chips) ===== */
.t-modern { font-family: "Segoe UI", Helvetica, Arial, sans-serif; }
.t-modern .r-head { background: #17324d; color: #fff; padding: 7mm 8mm; border-radius: 2mm; }
.t-modern .r-name { font-size: 25pt; font-weight: 700; line-height: 1.1; }
.t-modern .r-title { font-size: 12pt; color: #b5d0ee; margin-top: 1mm; }
.t-modern .r-contact { display: flex; flex-wrap: wrap; gap: 1mm 6mm; margin-top: 3mm; font-size: 9pt; }
.t-modern .sec-title { font-size: 11pt; text-transform: uppercase; letter-spacing: .06em; color: #1f5fbf; border-left: 1.4mm solid #1f5fbf; padding-left: 2.5mm; }
.t-modern .e-sub { color: #1f5fbf; font-weight: 600; }
.t-modern .e-date:not(:empty) { align-self: start; margin-left: 4mm; padding: .3mm 2.5mm; background: #e6eefa; color: #17324d; border-radius: 2mm; font-weight: 600; }
.t-modern .chip { display: inline-block; margin: 0 1.5mm 1.5mm 0; padding: .6mm 2.8mm; background: #e6eefa; color: #17324d; border-radius: 2mm; font-size: 9pt; }

/* ===== Template 3: Timeline (dates in a left column, shaded headings) ===== */
.t-timeline { font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif; font-size: 9.8pt; }
.t-timeline .r-head { display: grid; grid-template-columns: 1fr auto; gap: 6mm; align-items: end; border-bottom: 1mm solid #222; padding-bottom: 4mm; }
.t-timeline .r-name { font-size: 28pt; font-weight: 300; text-transform: uppercase; letter-spacing: .03em; line-height: 1; }
.t-timeline .r-title { font-size: 11pt; color: #555; margin-top: 2mm; }
.t-timeline .r-contact { text-align: right; font-size: 9pt; }
.t-timeline .r-contact span { display: block; }
.t-timeline .sec-title { font-size: 9.5pt; text-transform: uppercase; letter-spacing: .2em; background: #eee; padding: 1.2mm 3mm; }
.t-timeline .entry { grid-template-columns: 34mm 1fr; }
.t-timeline .e-date { order: -1; padding: 0; color: #666; white-space: normal; }
.t-timeline .e-main { border-left: .6mm solid #bbb; padding-left: 4mm; }
.t-timeline .chip:not(:last-child)::after { content: " /"; color: #999; margin-right: 1mm; }

/* ===== Print: only the resume, exact A4, margins from @page ===== */
@page { size: A4; margin: 14mm; }
@media print {
  html, body { height: auto; background: #fff; }
  .topbar, .editor, .pages { display: none !important; }
  .preview { padding: 0; overflow: visible; }
  .paper { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; zoom: 1 !important; }
}
