:root {
  --ink: #1e252d;
  --muted: #67717f;
  --line: #d8dee6;
  --soft: #f4f6f8;
  --panel: #ffffff;
  --accent: #12616b;
  --accent-dark: #0a4249;
  --warn: #9f3c3c;
  --paper: #ffffff;
  --shadow: 0 18px 48px rgba(24, 39, 54, 0.16);
  color: var(--ink);
  font-family: 'Aptos', 'Segoe UI', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

* {
  box-sizing: border-box;
}

html {
  background: #e2e7ec;
}

body {
  margin: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.brand-block {
  min-width: 220px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

.app-header h1,
.panel-head h2,
.preview-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  letter-spacing: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.tool-button,
.small-button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
}

.tool-button {
  min-height: 38px;
  padding: 8px 12px;
}

.tool-button.primary {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
  color: #ffffff;
}

.tool-button.danger {
  color: var(--warn);
}

.tool-button:hover,
.small-button:hover,
.icon-button:hover {
  border-color: var(--accent);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 450px) minmax(620px, 1fr);
  gap: 18px;
  max-width: 1520px;
  margin: 0 auto;
  padding: 18px;
}

.editor-panel,
.preview-panel {
  min-width: 0;
}

.editor-panel {
  height: calc(100vh - 108px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel-head,
.preview-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head p,
.preview-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.editor-root {
  padding: 14px;
}

.editor-group {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.editor-group > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  list-style: none;
  cursor: pointer;
}

.editor-group > summary::-webkit-details-marker {
  display: none;
}

.summary-title {
  flex: 1;
  min-width: 0;
  font-weight: 800;
  color: var(--ink);
}

.summary-meta {
  color: var(--muted);
  font-size: 12px;
}

.group-body {
  display: grid;
  gap: 12px;
  padding: 0 12px 14px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.field.full {
  grid-column: 1 / -1;
}

.field label,
.toggle-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 8px 9px;
}

.field textarea {
  min-height: 86px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid rgba(18, 97, 107, 0.2);
  border-color: var(--accent);
}

.toggle-row,
.section-actions,
.item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-row {
  justify-content: space-between;
  padding: 8px 0 2px;
}

.toggle-row label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 800;
}

.section-actions {
  flex-wrap: wrap;
}

.small-button {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 12px;
}

.icon-button {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 13px;
}

.icon-button.danger,
.small-button.danger {
  color: var(--warn);
}

.item-card {
  display: grid;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.item-top strong {
  color: var(--ink);
  font-size: 12px;
}

.empty-state {
  margin: 0;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #ffffff;
}

.preview-panel {
  overflow: auto;
}

.preview-root {
  display: flex;
  justify-content: center;
  padding-bottom: 32px;
}

.cv-sheet {
  width: 210mm;
  min-height: 297mm;
  display: grid;
  grid-template-columns: 64mm 1fr;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.cv-sidebar {
  background: var(--accent);
  color: #ffffff;
  padding: 17mm 8mm 13mm;
}

.cv-main {
  padding: 17mm 13mm 13mm;
}

.cv-name {
  margin: 0 0 7px;
  color: #ffffff;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 31px;
  line-height: 1.04;
  letter-spacing: 0;
}

.cv-headline {
  margin: 0 0 18px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  line-height: 1.45;
  text-transform: uppercase;
}

.cv-side-section {
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.28);
}

.cv-side-title {
  margin: 0 0 8px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.cv-contact,
.cv-tags {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cv-contact li,
.cv-tags li {
  overflow-wrap: anywhere;
}

.cv-contact-label {
  display: block;
  color: rgba(255, 255, 255, 0.7);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.cv-section {
  margin-bottom: 17px;
  break-inside: avoid;
}

.cv-section-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 9px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.cv-section-title::after {
  content: '';
  height: 1px;
  flex: 1;
  background: var(--line);
}

.cv-summary {
  margin: 0;
  color: #303741;
  font-size: 13.5px;
}

.cv-entry {
  margin-bottom: 10px;
  break-inside: avoid;
}

.cv-entry-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: baseline;
}

.cv-entry-title {
  font-weight: 800;
  color: var(--ink);
}

.cv-entry-date {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.cv-entry-sub {
  margin: 2px 0 4px;
  color: var(--muted);
  font-style: italic;
}

.cv-lines,
.cv-publications,
.cv-list {
  margin: 4px 0 0 17px;
  padding: 0;
}

.cv-lines li,
.cv-publications li,
.cv-list li {
  margin: 2px 0;
}

.cv-publication-status {
  color: var(--muted);
  font-size: 12px;
}

.cv-reference-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.cv-reference {
  min-height: 84px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
}

.cv-reference strong {
  display: block;
  margin-bottom: 2px;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    height: auto;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .app-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .workspace {
    padding: 10px;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .preview-root {
    justify-content: flex-start;
    overflow-x: auto;
  }
}

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

@media print {
  html,
  body {
    width: 210mm;
    min-height: 297mm;
    background: #ffffff;
  }

  [data-print-hidden] {
    display: none !important;
  }

  .workspace,
  .preview-panel,
  .preview-root {
    display: block;
    width: 210mm;
    margin: 0;
    padding: 0;
    overflow: visible;
  }

  .cv-sheet {
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    box-shadow: none;
  }
}
