:root {
  --accent: #6a1b9a;
  --accent-dark: #4b008f;
  --accent-mid: #9b6bd3;
  --accent-soft: #c7b8e3;
  --accent-light: #d8c3f0;
  --text: #111;
  --muted: #555;
  --line: #6a1b9a;
  --soft-line: #dedede;
  --page-w: 794px;
  --page-h: 1123px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #eef0f4;
  font-family: "Open Sans", Arial, sans-serif;
  color: var(--text);
}

.cv-page {
  width: min(var(--page-w), calc(100vw - 24px));
  min-height: var(--page-h);
  margin: 24px auto;
  position: relative;
  overflow: hidden;
  padding: 72px 63px 42px 55px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px #d0d0d0;
  background:
    radial-gradient(rgba(0, 0, 0, 0.03) 0.65px, transparent 0.75px),
    radial-gradient(rgba(106, 27, 154, 0.025) 0.65px, transparent 0.85px),
    linear-gradient(#fff, #fff);
  background-size: 6px 6px, 10px 10px, auto;
  background-position: 0 0, 3px 4px, 0 0;
}

.cv-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.cv-decor svg {
  width: 100%;
  height: 100%;
  display: block;
}

.cv-content {
  position: relative;
  z-index: 2;
}

.cv-header {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 34px;
  align-items: start;
  margin-bottom: 30px;
}

h1,
h2 {
  font-family: "Montserrat", sans-serif;
  text-transform: uppercase;
}

h1 {
  font-size: 39px;
  line-height: 1;
  margin: 0 0 8px;
  font-weight: 800;
  letter-spacing: -1.3px;
}

.cv-subtitle {
  font-family: "Montserrat", sans-serif;
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 20px;
}

.cv-contact {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 10px;
  font-weight: 700;
  color: #333;
}

.cv-contact div {
  display: flex;
  align-items: center;
}

.cv-contact div:first-child {
  flex-direction: row;
  gap: 18px;
}

.cv-contact div:last-child {
  margin-top: 2px;
}

.cv-contact span {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 0;
  white-space: nowrap;
}

.cv-contact i {
  color: var(--accent);
  font-size: 11px;
}

.cv-photo {
  width: 150px;
  height: 150px;
  object-fit: cover;
  object-position: center;
  margin-top: -25px;
  border-radius: 50%;
}

.cv-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 38px;
}

.cv-section {
  margin-bottom: 33px;
}

.cv-section > h2 {
  font-size: 25px;
  line-height: 1.1;
  font-weight: 800;
  margin: 0 0 16px;
  padding-bottom: 6px;
  border-bottom: 3px solid var(--line);
  color: var(--accent);
  letter-spacing: -0.8px;
}

.cv-item {
  border-bottom: 1px dashed var(--soft-line);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.cv-item h3 {
  font-size: 20px;
  line-height: 1.15;
  margin: 0 0 3px;
  font-weight: 400;
  letter-spacing: -0.4px;
}

.cv-item strong {
  display: block;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 5px;
}

.cv-meta {
  display: flex;
  gap: 17px;
  font-size: 8.5px;
  color: #444;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.cv-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cv-meta i {
  font-size: 9px;
  color: #555;
}

.cv-role-quote {
  margin: 3px 0 10px;
  padding: 0;
  font-family: "Montserrat", sans-serif;
  font-size: 12px;
  font-weight: 600;
  font-style: italic;
  line-height: 1.45;
  color: var(--accent-dark);
  letter-spacing: -0.02em;
}

ul {
  margin: 4px 0 0 13px;
  padding: 0;
  color: var(--muted);
  font-size: 10.2px;
  line-height: 1.45;
}

ul i {
  color: var(--accent);
}

.cv-tech {
  list-style: none;
  margin-left: -13px;
  color: var(--accent);
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  margin-top: 1px;
}

.cv-tech::marker {
  content: "";
}

.cv-tech i {
  color: var(--accent);
  margin-right: 5px;
}

.cv-proud-item {
  display: grid;
  grid-template-columns: 23px 1fr;
  gap: 9px;
  border-bottom: 1px dashed var(--soft-line);
  padding: 4px 0 16px;
  margin-bottom: 18px;
}

.cv-proud-item > i {
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
  margin-top: 2px;
}

.cv-proud-item h3 {
  font-size: 13px;
  font-weight: 800;
  margin: 0 0 3px;
}

.cv-proud-item p,
.cv-right p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  margin: 0;
}

.cv-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.cv-tags span {
  border: 1px solid #cfcfcf;
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.78);
}

.cv-skills-wrap {
  width: 100%;
  margin-top: 10px;
}

.cv-skills-wrap .cv-skill-item {
  padding: 3px 0 10px;
  margin-bottom: 10px;
}

.cv-skills-wrap .cv-skill-item:last-child {
  margin-bottom: 0;
  padding-bottom: 2px;
}

.stack-title,
.stack-group-title {
  font-family: "Montserrat", sans-serif;
  font-size: 15px;
  font-weight: 800;
  fill: var(--accent);
  letter-spacing: 0.5px;
}

.stack-text {
  font-family: "Open Sans", Arial, sans-serif;
  font-size: 10px;
  fill: #333;
}

.stack-center {
  font-family: "Montserrat", sans-serif;
  font-size: 11px;
  font-weight: 800;
  fill: #fff;
}

.skill-node text {
  font-family: "Montserrat", sans-serif;
  font-size: 11px;
  font-weight: 700;
}

.cv-footer {
  position: absolute;
  left: 55px;
  right: 55px;
  bottom: 27px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  font-size: 8.5px;
  color: #555;
  z-index: 3;
}

@media (max-width: 820px) {
  body {
    background: #fff;
  }

  .cv-page {
    width: 100%;
    min-height: auto;
    margin: 0;
    padding: 34px 20px 36px;
    box-shadow: none;
  }

  .cv-decor {
    opacity: 0.16;
  }

  .cv-header {
    grid-template-columns: 1fr;
    gap: 18px;
    text-align: center;
    margin-bottom: 30px;
  }

  h1 {
    font-size: clamp(30px, 9vw, 42px);
  }

  .cv-subtitle {
    font-size: 16px;
  }

  .cv-contact {
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 8px;
  }

  .cv-contact div,
  .cv-contact div:first-child {
    flex-direction: column;
    align-items: center;
    gap: 8px;
  }

  .cv-contact div:last-child {
    margin-top: 0;
  }

  .cv-contact span {
    justify-content: center;
    white-space: normal;
    align-items: flex-start;
  }

  .cv-photo {
    order: -1;
    width: 132px;
    height: 132px;
    margin: 0 auto;
  }

  .cv-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .cv-section {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 18px;
    padding: 18px 16px;
    margin-bottom: 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  }

  .cv-section > h2 {
    font-size: 22px;
  }

  .cv-item h3 {
    font-size: 18px;
  }

  .cv-meta,
  ul,
  .cv-proud-item p {
    font-size: 13px;
  }

  .cv-footer {
    position: static;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    font-size: 10px;
  }
  .cv-grid {
  display: flex;
  flex-direction: column;
}

.cv-right {
  display: contents;
}

.cv-left {
  display: contents;
}

.cv-right .cv-section:nth-of-type(1) {
  order: 1;
}

.cv-right .cv-section:nth-of-type(2) {
  order: 2;
}

.cv-left .cv-section {
  order: 3;
}

.cv-right .cv-section:nth-of-type(3) {
  order: 4;
}

.cv-right .cv-section:nth-of-type(4) {
  order: 5;
}
}

@media print {
  /*
   * Vertical space from @page only (same every sheet). Do NOT use
   * box-decoration-break: clone with large padding — it stacks with @page and
   * creates a huge empty band at the top of page 2+.
   * Padding-top/bottom apply to first/last fragments only (slice); left/right
   * apply throughout — @page handles top/bottom safe area on all pages.
   */
  @page {
    size: A4 portrait;
    margin: 11mm 12mm 13mm 12mm;
  }

  html,
  body {
    margin: 0;
    padding: 0;
    background: #fff;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    color-adjust: exact;
  }

  .cv-page {
    width: 100%;
    max-width: 100%;
    min-height: 0;
    margin: 0;
    padding: 20px 50px 16px 44px;
    box-shadow: none;
    overflow: visible;
    break-after: auto;
    page-break-after: auto;
  }

  .cv-header {
    display: grid;
    grid-template-columns: 1fr 150px;
    gap: 34px;
    align-items: start;
    text-align: left;
    margin-bottom: 14px;
  }

  .cv-header h1 {
    font-size: 32px;
    letter-spacing: -1px;
  }

  .cv-subtitle {
    font-size: 15px;
    margin-bottom: 10px;
  }

  .cv-contact {
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 6px;
    text-align: left;
    font-size: 8.5px;
  }

  .cv-contact div {
    align-items: flex-start;
  }

  .cv-contact div:first-child {
    flex-direction: row;
    gap: 18px;
  }

  .cv-contact div:last-child {
    margin-top: 0;
    font-size: 7.5px;
    line-height: 1.35;
  }

  .cv-contact span {
    justify-content: flex-start;
    text-align: left;
    margin-bottom: 0;
  }

  .cv-photo {
    order: initial;
    width: 150px;
    height: 150px;
    margin-top: -25px;
  }

  /*
   * Print: single-column flow. Grid + pagination cannot fill a “dead” second
   * column on later pages — only a linear stack is predictable in browsers.
   * Order: summary → experience → skills → achievements → education.
   */
  .cv-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: stretch;
    min-height: 0;
  }

  .cv-right {
    display: contents;
  }

  /*
   * With display:contents on aside, sections are flex items of .cv-grid but
   * still DOM children of .cv-right — use .cv-right > … (not .cv-grid > … nth-child).
   */
  .cv-grid > .cv-left {
    order: 2;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    break-inside: auto;
    page-break-inside: auto;
  }

  .cv-right > .cv-section:nth-child(1) {
    order: 1;
  }

  .cv-right > .cv-section.cv-stack-section {
    order: 3;
  }

  .cv-right > .cv-section:nth-child(3) {
    order: 4;
  }

  .cv-right > .cv-section:nth-child(4) {
    order: 5;
  }

  .cv-section {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    margin-bottom: 18px;
    break-inside: auto;
    page-break-inside: auto;
    min-height: 0;
  }

  .cv-section:first-child {
    margin-top: 0;
  }

  /* Only rhythm here — font sizes follow screen rules (Experience h2 = 25px, sidebar = .cv-right .cv-section h2) */
  .cv-section > h2 {
    break-after: avoid;
    page-break-after: avoid;
    margin: 0 0 10px;
    padding-bottom: 6px;
  }

  .cv-stack-section {
    margin-top: 0;
    margin-bottom: 12px;
    padding-top: 8px;
  }

  .cv-stack-section > h2 {
    margin-bottom: 10px;
    padding-bottom: 5px;
  }

  .cv-skills-wrap {
    margin-top: 4px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .cv-skills-wrap .cv-skill-item {
    padding: 2px 0 6px;
    margin-bottom: 6px;
  }

  .cv-skills-wrap .cv-skill-item > i {
    font-size: 17px;
  }

  .cv-skills-wrap .cv-skill-item h3 {
    font-size: 12px;
    margin: 0 0 2px;
  }

  .cv-skills-wrap .cv-skill-item p {
    font-size: 10.5px;
    line-height: 1.32;
  }

  .cv-proud-item {
    padding: 6px 0 12px;
    margin-bottom: 14px;
    gap: 9px;
  }

  .cv-proud-item > i {
    font-size: 20px;
    margin-top: 2px;
  }

  .cv-proud-item h3 {
    margin: 0 0 4px;
    font-size: 13px;
  }

  .cv-proud-item p,
  .cv-right p {
    font-size: 13px;
    line-height: 1.4;
  }

  /* Short sidebar block: keep “Education” + degree together */
  .cv-right > .cv-section:last-of-type {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Avoid tiny orphans only — letting jobs split fills pages (less huge bottom gap). */
  .cv-tags,
  .cv-proud-item {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .cv-item,
  .cv-right .cv-section {
    break-inside: auto;
    page-break-inside: auto;
  }

  .cv-item {
    padding-bottom: 10px;
    margin-bottom: 12px;
  }

  .cv-item ul {
    orphans: 2;
    widows: 2;
  }

  .cv-role-quote {
    margin: 2px 0 8px;
    padding: 0;
    font-size: 11.5px;
  }

  .cv-footer {
    position: fixed;
    left: 55px;
    right: 55px;
    bottom: 27px;
    flex-direction: row;
    justify-content: space-between;
  }
}

.cv-right .cv-section h2 {
  font-size: 17px; /* statt 25px */
  line-height: 27px;
}