:root {
  --ink: #1c2526;
  --muted: #607071;
  --line: #d8dedb;
  --soft-line: #e8ece9;
  --paper: #ffffff;
  --canvas: #eef1ec;
  --panel: #f8f8f5;
  --panel-strong: #f0eee7;
  --teal: #007d73;
  --teal-dark: #005f57;
  --rust: #b4542e;
  --olive: #667a34;
  --gold: #c69b32;
  --plum: #6a4770;
  --shadow: 0 18px 48px rgba(28, 37, 38, 0.13);
  --radius: 8px;
  --focus: 0 0 0 3px rgba(0, 125, 115, 0.2);
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(90deg, rgba(28, 37, 38, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(28, 37, 38, 0.04) 1px, transparent 1px),
    var(--canvas);
  background-size: 28px 28px;
  font-size: 15px;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-color: var(--teal);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 248, 245, 0.96);
  backdrop-filter: blur(10px);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 190px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: #fff7df;
  color: var(--ink);
  font-weight: 800;
}

.brand-block h1,
.panel-heading h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.15;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.select-field {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  font-weight: 500;
}

select {
  min-height: 38px;
  padding: 0 34px 0 11px;
}

input {
  min-height: 39px;
  padding: 8px 10px;
}

textarea {
  resize: vertical;
  min-height: 86px;
  padding: 9px 10px;
}

.icon-button,
.secondary-button,
.add-button,
.segmented,
.small-icon-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
}

.icon-button,
.secondary-button,
.add-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 39px;
  padding: 0 13px;
  font-weight: 800;
}

.icon-button {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.secondary-button:hover,
.add-button:hover,
.segmented:hover,
.small-icon-button:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.button-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  font-weight: 900;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(360px, 520px) minmax(420px, 1fr);
  gap: 18px;
  align-items: start;
  padding: 18px;
}

.template-panel,
.editor-panel,
.preview-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 7px 24px rgba(28, 37, 38, 0.08);
}

.template-panel,
.editor-panel {
  padding: 16px;
}

.preview-panel {
  position: sticky;
  top: 82px;
  overflow: hidden;
  min-height: calc(100vh - 104px);
}

.panel-heading {
  margin-bottom: 14px;
}

.row-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.template-card {
  display: grid;
  gap: 8px;
  min-height: 148px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  text-align: start;
}

.template-card.is-active {
  border-color: var(--teal);
  box-shadow: var(--focus);
}

.template-thumb {
  display: grid;
  gap: 5px;
  height: 88px;
  padding: 8px;
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  background: #fbfbf8;
  overflow: hidden;
}

.template-thumb .thumb-head {
  height: 16px;
  border-radius: 4px;
  background: var(--thumb-accent, var(--teal));
}

.template-thumb .thumb-body {
  display: grid;
  grid-template-columns: var(--thumb-columns, 1fr 1.45fr);
  gap: 6px;
  min-height: 0;
}

.template-thumb .thumb-line {
  height: 6px;
  border-radius: 3px;
  background: #d5ddd8;
}

.template-thumb .thumb-line.short {
  width: 62%;
}

.template-thumb .thumb-panel {
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 5px;
  border-radius: 4px;
  background: var(--thumb-panel, #eef3ef);
}

.template-name {
  font-size: 13px;
  font-weight: 900;
}

.cv-form {
  display: grid;
  gap: 14px;
}

.form-section {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.form-section legend {
  padding: 0 7px;
  color: var(--teal-dark);
  font-weight: 900;
}

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

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

label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

label span,
.item-header strong {
  overflow-wrap: anywhere;
}

.wide-field {
  margin-top: 11px;
}

.item-list {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.editable-item {
  padding: 12px;
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  background: #fbfbf8;
}

.item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}

.small-icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  font-weight: 900;
}

.preview-heading {
  padding: 16px 16px 0;
}

.page-controls {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.segmented {
  min-width: 56px;
  min-height: 32px;
  border: 0;
  background: transparent;
  font-weight: 800;
}

.segmented.is-active {
  background: var(--ink);
  color: #ffffff;
}

.preview-stage {
  display: grid;
  place-items: start center;
  height: calc(100vh - 170px);
  min-height: 760px;
  overflow: auto;
  padding: 18px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.55) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.55) 1px, transparent 1px),
    #dfe5df;
  background-size: 24px 24px;
}

.cv-page {
  --accent: var(--teal);
  --accent-2: var(--rust);
  --cv-ink: #1c2526;
  --cv-muted: #687071;
  --cv-line: #d9dedb;
  --cv-soft: #f3f5f1;
  width: min(100%, 794px);
  min-height: 1123px;
  padding: 48px;
  background: var(--paper);
  color: var(--cv-ink);
  box-shadow: var(--shadow);
  font-family: Georgia, "Times New Roman", serif;
  transform-origin: top center;
}

.cv-page.page-letter {
  width: min(100%, 816px);
  min-height: 1056px;
}

.cv-page h1,
.cv-page h2,
.cv-page h3,
.cv-page p,
.cv-page ul {
  margin-top: 0;
}

.cv-page h1 {
  margin-bottom: 7px;
  font-size: 42px;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.cv-page h2 {
  margin-bottom: 12px;
  border-bottom: 1px solid var(--cv-line);
  color: var(--accent);
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 14px;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0;
}

.cv-page h3 {
  margin-bottom: 3px;
  font-size: 17px;
  line-height: 1.25;
}

.cv-page p,
.cv-page li {
  color: var(--cv-muted);
  font-size: 13px;
}

.cv-page ul {
  display: grid;
  gap: 5px;
  margin-bottom: 0;
  padding-inline-start: 20px;
}

.cv-header {
  display: grid;
  gap: 14px;
  margin-bottom: 30px;
}

.cv-title-row {
  display: grid;
  gap: 10px;
}

.cv-role {
  margin: 0;
  color: var(--accent);
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 17px;
  font-weight: 800;
}

.cv-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.cv-contact li {
  color: var(--cv-ink);
}

.cv-main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 22px;
}

.cv-section {
  break-inside: avoid;
}

.cv-item {
  display: grid;
  gap: 5px;
  break-inside: avoid;
  margin-bottom: 16px;
}

.cv-item:last-child {
  margin-bottom: 0;
}

.cv-meta {
  color: var(--cv-muted);
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: 700;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.pill-list li {
  padding: 5px 8px;
  border: 1px solid var(--cv-line);
  border-radius: 6px;
  background: var(--cv-soft);
  color: var(--cv-ink);
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
  font-size: 12px;
  font-weight: 800;
}

.cv-sidebar-layout {
  display: grid;
  grid-template-columns: 0.72fr 1.28fr;
  gap: 30px;
}

.cv-sidebar {
  display: grid;
  align-content: start;
  gap: 22px;
}

.cv-content {
  display: grid;
  align-content: start;
  gap: 22px;
}

.template-executive {
  --accent: #007d73;
  --accent-2: #b4542e;
  border-top: 12px solid var(--accent);
}

.template-executive .cv-header {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.template-executive .cv-contact {
  max-width: 280px;
  justify-content: flex-end;
  text-align: end;
}

.template-modern {
  --accent: #b4542e;
  --accent-2: #007d73;
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
}

.template-modern .cv-header {
  padding: 26px;
  margin: -12px -12px 30px;
  background: #1c2526;
  color: #ffffff;
}

.template-modern .cv-role,
.template-modern .cv-contact li {
  color: #f0c66a;
}

.template-modern .cv-main {
  grid-template-columns: 0.78fr 1.22fr;
  gap: 30px;
}

.template-classic {
  --accent: #6a4770;
  --accent-2: #667a34;
  font-family: Georgia, "Times New Roman", serif;
}

.template-classic .cv-header {
  text-align: center;
}

.template-classic .cv-contact {
  justify-content: center;
}

.template-classic h2 {
  color: var(--cv-ink);
}

.template-creative {
  --accent: #c69b32;
  --accent-2: #007d73;
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
}

.template-creative {
  border-inline-start: 24px solid var(--accent);
}

.template-creative .cv-header {
  padding-bottom: 20px;
  border-bottom: 4px solid var(--accent);
}

.template-academic {
  --accent: #667a34;
  --accent-2: #6a4770;
}

.template-academic h1 {
  font-size: 36px;
}

.template-academic .cv-header {
  border-bottom: 2px solid var(--accent);
  padding-bottom: 18px;
}

.template-minimal {
  --accent: #1c2526;
  --accent-2: #007d73;
  padding: 58px;
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
}

.template-minimal h2 {
  border-bottom: 0;
  color: var(--cv-muted);
}

.template-sidebar {
  --accent: #007d73;
  --accent-2: #c69b32;
  padding: 0;
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
}

.template-sidebar .cv-sidebar-layout {
  min-height: 1123px;
  gap: 0;
}

.template-sidebar.page-letter .cv-sidebar-layout {
  min-height: 1056px;
}

.template-sidebar .cv-sidebar {
  padding: 42px 28px;
  background: #1c2526;
  color: #ffffff;
}

.template-sidebar .cv-sidebar h2,
.template-sidebar .cv-sidebar p,
.template-sidebar .cv-sidebar li,
.template-sidebar .cv-sidebar .cv-meta {
  color: #ffffff;
}

.template-sidebar .cv-content {
  padding: 42px 38px;
}

.template-timeline {
  --accent: #b4542e;
  --accent-2: #667a34;
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
}

.template-timeline .cv-item {
  position: relative;
  padding-inline-start: 20px;
  border-inline-start: 2px solid var(--accent);
}

.template-timeline .cv-item::before {
  content: "";
  position: absolute;
  inset-inline-start: -6px;
  top: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
}

.template-compact {
  --accent: #6a4770;
  --accent-2: #b4542e;
  padding: 36px;
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
}

.template-compact .cv-main {
  gap: 15px;
}

.template-compact .cv-item {
  margin-bottom: 10px;
}

.template-editorial {
  --accent: #007d73;
  --accent-2: #c69b32;
}

.template-editorial .cv-header {
  grid-template-columns: 1fr;
  padding: 24px 0;
  border-top: 5px solid var(--accent-2);
  border-bottom: 1px solid var(--cv-line);
}

.template-editorial h1 {
  font-size: 48px;
}

.template-technical {
  --accent: #667a34;
  --accent-2: #b4542e;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

.template-technical .cv-header {
  padding: 20px;
  background: #f2f4ee;
  border: 1px solid var(--cv-line);
}

.template-technical .pill-list li {
  border-color: rgba(102, 122, 52, 0.35);
}

.template-portfolio {
  --accent: #c69b32;
  --accent-2: #6a4770;
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
}

.template-portfolio h1 {
  max-width: 520px;
}

.template-portfolio .cv-header {
  position: relative;
  padding-top: 30px;
}

.template-portfolio .cv-header::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  width: 82px;
  height: 8px;
  background: var(--accent);
}

[dir="rtl"] .topbar,
[dir="rtl"] .row-heading,
[dir="rtl"] .item-header,
[dir="rtl"] .brand-block {
  direction: rtl;
}

[dir="rtl"] select {
  padding: 0 11px 0 34px;
}

[dir="rtl"] .template-card,
[dir="rtl"] .cv-form,
[dir="rtl"] .preview-panel {
  direction: rtl;
}

[dir="rtl"] .template-executive .cv-contact {
  justify-content: flex-start;
  text-align: start;
}

.cv-page[dir="rtl"] {
  font-family: "Segoe UI", Tahoma, Arial, Helvetica, sans-serif;
}

.cv-page[dir="rtl"] .cv-contact,
.cv-page[dir="rtl"] .pill-list {
  direction: rtl;
}

@media (max-width: 1260px) {
  .workspace {
    grid-template-columns: minmax(220px, 280px) minmax(360px, 1fr);
  }

  .preview-panel {
    grid-column: 1 / -1;
    position: static;
    min-height: 0;
  }

  .preview-stage {
    height: auto;
    max-height: 940px;
  }
}

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

  .topbar-actions {
    justify-content: stretch;
    width: 100%;
  }

  .topbar-actions > * {
    flex: 1 1 150px;
  }

  .workspace {
    grid-template-columns: 1fr;
    padding: 12px;
  }

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

  .preview-stage {
    padding: 10px;
  }
}

@media (max-width: 640px) {
  .template-panel,
  .editor-panel {
    padding: 12px;
  }

  .template-grid,
  .field-grid.two,
  .template-modern .cv-main,
  .cv-sidebar-layout {
    grid-template-columns: 1fr;
  }

  .template-card {
    min-height: 120px;
  }

  .cv-page {
    min-height: auto;
    padding: 28px;
  }

  .template-sidebar {
    padding: 0;
  }

  .template-sidebar .cv-sidebar-layout,
  .template-sidebar.page-letter .cv-sidebar-layout {
    min-height: auto;
  }

  .template-sidebar .cv-sidebar,
  .template-sidebar .cv-content {
    padding: 28px;
  }

  .template-executive .cv-header {
    grid-template-columns: 1fr;
  }

  .template-executive .cv-contact {
    justify-content: flex-start;
    text-align: start;
  }

  .cv-page h1,
  .template-editorial h1 {
    font-size: 34px;
  }
}

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

@media print {
  body {
    background: #ffffff;
  }

  .topbar,
  .template-panel,
  .editor-panel,
  .preview-heading {
    display: none !important;
  }

  .app-shell,
  .workspace,
  .preview-panel,
  .preview-stage {
    display: block;
    padding: 0;
    margin: 0;
    border: 0;
    box-shadow: none;
    background: #ffffff;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

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

  .cv-page.page-letter {
    width: 8.5in;
    min-height: 11in;
  }
}
