:root {
  --accent: #d43a25;
  --page-bg: #ffffff;
  --canvas-bg: #eef1f5;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #d8dee8;
  --border-strong: #c7cfda;
  --text: #26313d;
  --muted: #64748b;
  --shadow: 0 22px 50px rgba(15, 23, 42, 0.12);
  --radius: 18px;
  --page-width: 210mm;
  --page-height: 297mm;
  --page-padding-x: 14mm;
  --page-padding-top: 8mm;
  --page-padding-bottom: 14mm;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  background: var(--canvas-bg);
  color: var(--text);
  font-family: "Source Sans 3", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  max-width: 100%;
  display: block;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 430px) 1fr;
  gap: 24px;
  min-height: 100vh;
  padding: 24px;
  align-items: start;
}

.editor-column {
  min-width: 0;
}

.preview-column {
  min-width: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.07);
}

.sticky-panel {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.panel-header {
  padding: 24px 24px 0;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.84rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

.panel-header h1 {
  font-size: 1.85rem;
  line-height: 1.1;
  margin-bottom: 8px;
}

.muted {
  color: var(--muted);
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 18px 24px 0;
}

.btn {
  border: 1px solid var(--border-strong);
  background: white;
  color: var(--text);
  padding: 11px 14px;
  border-radius: 12px;
  font-weight: 600;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.btn-danger {
  color: #7f1d1d;
}

.btn-small {
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 0.92rem;
}

.btn-ghost {
  background: var(--surface-muted);
}

.info-box {
  margin: 18px 24px 0;
  padding: 14px 15px;
  border-radius: 14px;
  border: 1px solid rgba(212, 58, 37, 0.15);
  background: rgba(212, 58, 37, 0.05);
  display: grid;
  gap: 6px;
  font-size: 0.96rem;
  line-height: 1.45;
}

.editor-form {
  padding: 18px 24px 24px;
}

.form-section {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 20px;
}

.form-section:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.form-section__header {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
}

.form-section__header h2 {
  font-size: 1.15rem;
}

.field-grid {
  display: grid;
  gap: 12px;
}

.field-grid.two-cols {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field-grid.three-cols {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 6px;
}

.field > span,
.field legend {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px 12px;
  background: white;
  color: var(--text);
}

.field textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.45;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 25%, white);
  outline-offset: 0;
  border-color: var(--accent);
}

.note {
  font-size: 0.9rem;
  color: var(--muted);
}

.color-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.color-control input[type="color"] {
  width: 56px;
  min-width: 56px;
  height: 44px;
  padding: 4px;
}

.color-chip {
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92rem;
}

.repeater-stack {
  display: grid;
  gap: 14px;
}

.repeater-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-muted);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.repeater-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.repeater-card__title {
  font-weight: 700;
}

.repeater-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.add-row {
  margin-top: 12px;
}

.photo-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.preview-toolbar strong {
  display: block;
  font-size: 1.02rem;
  margin-bottom: 2px;
}

.preview-badge {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-weight: 700;
  font-size: 0.92rem;
}

.preview-stage {
  overflow: auto;
}

.cv-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding-bottom: 24px;
}

.cv-page {
  width: var(--page-width);
  min-height: var(--page-height);
  height: var(--page-height);
  background: var(--page-bg);
  box-shadow: var(--shadow);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  padding: var(--page-padding-top) var(--page-padding-x) var(--page-padding-bottom);
  position: relative;
  color: #4a4a4a;
}

.cv-page__main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.cv-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.cv-header {
  display: grid;
  grid-template-columns: 44mm 1fr;
  gap: 10mm;
  align-items: center;
  margin-bottom: 6mm;
}

.cv-header__photo {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.profile-photo {
  width: 38mm;
  height: 38mm;
  border-radius: 999px;
  object-fit: cover;
  background: #efefef;
  border: 0.5mm solid rgba(0, 0, 0, 0.08);
}

.profile-photo--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8b8b8b;
  font-family: "Roboto", sans-serif;
  font-weight: 300;
  font-size: 15pt;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.cv-header__info {
  display: grid;
  justify-items: end;
}

.name-line {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  column-gap: 2mm;
  line-height: 1;
}

.name-line .first-name {
  font-family: "Roboto", sans-serif;
  font-weight: 300;
  font-size: 32pt;
  color: #767676;
}

.name-line .last-name {
  font-family: "Roboto", sans-serif;
  font-weight: 700;
  font-size: 32pt;
  color: #2f2f2f;
}

.header-position {
  margin-top: 1.2mm;
  color: var(--accent);
  font-size: 7.6pt;
  line-height: 1.2;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
}

.header-address {
  margin-top: 1mm;
  color: #9a9a9a;
  font-family: "Roboto", sans-serif;
  font-style: italic;
  font-size: 8pt;
}

.header-social {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4mm;
  margin-top: 2.2mm;
  color: #424242;
  font-family: "Roboto", sans-serif;
  font-size: 6.9pt;
  line-height: 1.3;
}

.social-item {
  display: inline-flex;
  align-items: center;
  gap: 1.2mm;
  color: inherit;
  text-decoration: none;
}

.social-item svg {
  width: 3.2mm;
  height: 3.2mm;
  fill: currentColor;
}

.section-block {
  margin-top: 5mm;
}

.section-title {
  display: flex;
  align-items: flex-end;
  gap: 2mm;
  margin-bottom: 2.5mm;
}

.section-title h2 {
  margin: 0;
  font-size: 16pt;
  line-height: 1;
  font-weight: 700;
  color: #333333;
}

.section-title .accent {
  color: var(--accent);
}

.section-title .rule {
  flex: 1;
  border-top: 0.9pt solid #656565;
  transform: translateY(-1.2mm);
}

.cv-paragraph {
  font-size: 9pt;
  line-height: 1.38;
  color: #4a4a4a;
}

.skill-row {
  display: grid;
  grid-template-columns: 31mm 1fr;
  gap: 4mm;
  margin-top: 1.6mm;
}

.skill-type {
  font-size: 10pt;
  font-weight: 700;
  color: #2f2f2f;
}

.skill-value {
  font-size: 9pt;
  color: #4a4a4a;
}

.entry-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3mm 4mm;
  align-items: end;
  margin-top: 2.3mm;
}

.entry-header__title {
  font-size: 10pt;
  line-height: 1.2;
  font-weight: 700;
  color: #323232;
}

.entry-header__location {
  font-size: 9pt;
  line-height: 1.2;
  font-style: italic;
  color: var(--accent);
  text-align: right;
}

.entry-header__subtitle {
  font-size: 8pt;
  line-height: 1.2;
  color: #6d6d6d;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.entry-header__date {
  font-size: 8pt;
  line-height: 1.2;
  color: #7b7b7b;
  font-style: italic;
  text-align: right;
}

.entry-header.is-continuation {
  opacity: 0.86;
}

.entry-header.is-continuation .entry-header__title::after {
  content: " (continued)";
  font-weight: 400;
}

.entry-bullet,
.publication-description {
  margin-top: 1.3mm;
  padding-left: 4mm;
  position: relative;
  font-size: 9pt;
  line-height: 1.33;
  color: #4a4a4a;
}

.entry-bullet::before,
.publication-description::before {
  content: "•";
  position: absolute;
  left: 0;
  top: 0;
}

.entry-bullet strong,
.publication-description strong {
  font-weight: 700;
}

.subsection-label {
  margin-top: 2.8mm;
  font-size: 12pt;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #444444;
}

.honor-row {
  display: grid;
  grid-template-columns: 15mm 1fr auto;
  gap: 4mm;
  align-items: baseline;
  margin-top: 1.6mm;
}

.honor-year {
  font-size: 9pt;
  color: #6f6f6f;
}

.honor-main {
  font-size: 9pt;
  color: #4a4a4a;
}

.honor-main strong {
  color: #2f2f2f;
}

.honor-location {
  font-size: 9pt;
  color: var(--accent);
  font-style: italic;
  text-align: right;
}

.page-footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 4mm;
  align-items: center;
  font-size: 8pt;
  line-height: 1;
  color: #a0a0a0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-top: 3mm;
}

.page-footer__center {
  text-align: center;
}

.page-footer__right {
  text-align: right;
}

.is-compact {
  font-size: 8.2pt !important;
  line-height: 1.24 !important;
}

.cv-paragraph,
.entry-header__title,
.entry-bullet,
.publication-description,
.skill-value,
.honor-main {
  overflow-wrap: anywhere;
}

.hidden {
  display: none !important;
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sticky-panel {
    position: static;
    max-height: none;
  }

  .preview-column {
    order: -1;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px;
    gap: 16px;
  }

  .toolbar,
  .field-grid.two-cols,
  .field-grid.three-cols {
    grid-template-columns: 1fr;
  }

  .preview-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
}

@page {
  size: A4;
  margin: 0;
}

@media print {
  html,
  body {
    background: white !important;
  }

  body {
    margin: 0;
  }

  .screen-only {
    display: none !important;
  }

  .app-shell {
    display: block;
    padding: 0;
  }

  .preview-column,
  .preview-stage,
  .cv-preview {
    margin: 0;
    padding: 0;
    overflow: visible !important;
  }

  .cv-preview {
    gap: 0;
    align-items: stretch;
  }

  .cv-page {
    width: 210mm;
    min-height: 297mm;
    height: 297mm;
    margin: 0;
    box-shadow: none;
    break-after: page;
    page-break-after: always;
  }

  .cv-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }
}
