:root {
  --primary: #0f172a;
  --accent: #0ea5a4;
  --background: #f4f7fb;
  --page: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --chip: #eef2ff;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, "Segoe UI", sans-serif;
  background: var(--background);
  color: var(--text);
}

body {
  padding: 24px;
}

button, input, textarea {
  font: inherit;
}

.app-shell {
  max-width: 1500px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(700px, 1fr);
  gap: 24px;
  align-items: start;
}

.editor-panel,
.cv-paper {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(8px);
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.editor-panel {
  border-radius: 22px;
  padding: 22px;
  position: sticky;
  top: 20px;
}

.panel-header {
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
}

.panel-header h1 {
  margin: 0;
  font-size: 2rem;
}

.group {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.65);
}

.group h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 12px;
}

input, textarea {
  width: 100%;
  margin-top: 6px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

input[type="color"] {
  min-height: 42px;
  padding: 6px;
}

textarea {
  resize: vertical;
}

.experience-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  margin-bottom: 12px;
  width: 100%;
  min-width: 0;
}

.experience-card label,
.experience-card .experience-grid {
  width: 100%;
}

.experience-card .experience-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 600px) {
  .experience-card .experience-grid {
    grid-template-columns: 1fr;
  }
}

.experience-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.experience-card h3 {
  margin: 0;
  font-size: 0.95rem;
}

.delete-exp {
  border: none;
  background: transparent;
  color: #dc2626;
  cursor: pointer;
  font-weight: 700;
}

.experience-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.secondary-btn,
.primary-btn,
.ghost-btn {
  border: none;
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
  transition: transform 0.15s ease;
  font-weight: 700;
}

.secondary-btn:hover,
.primary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.secondary-btn {
  width: 100%;
  background: var(--chip);
  color: var(--primary);
}

.primary-btn {
  background: var(--primary);
  color: #fff;
}

.ghost-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

.action-row {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.action-row > * {
  flex: 1;
}

.theme-group .color-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.cv-paper {
  border-radius: 28px;
  padding: 32px 36px 24px;
  min-height: 980px;
  color: var(--text);
}

.cv-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  padding-bottom: 18px;
  border-bottom: 3px solid var(--primary);
}

.meta-label {
  color: var(--accent);
  margin: 0 0 12px;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
}

.cv-header h1 {
  margin: 0;
  font-size: clamp(2rem, 1.7rem + 1vw, 3rem);
  color: var(--primary);
}

.cv-header h2 {
  margin: 8px 0 0;
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--muted);
}

.contact-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: right;
  color: var(--muted);
  font-size: 0.9rem;
}

.summary-box {
  padding: 20px 0 12px;
}

.summary-box h3,
.cv-content h3,
.side-block h3 {
  margin: 0 0 10px;
  color: var(--primary);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
}

.summary-box p {
  margin: 0;
  line-height: 1.6;
  color: var(--text);
}

.cv-body {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 26px;
  margin-top: 12px;
}

.cv-side {
  border-right: 1px solid var(--line);
  padding-right: 18px;
}

.side-block {
  margin-bottom: 18px;
}

.side-block ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text);
}

.side-block li {
  background: var(--chip);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.84rem;
  width: fit-content;
}

.side-block p {
  margin: 6px 0;
  color: var(--muted);
}

.cv-content {
  min-width: 0;
}

.job {
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  margin-bottom: 18px;
}

.job:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.job-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.job-role {
  margin: 0;
  font-size: 1.08rem;
  color: var(--primary);
}

.job-company {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 600;
}

.job-period {
  font-size: 0.8rem;
  color: var(--accent);
  white-space: nowrap;
  font-weight: 700;
}

.job-list {
  margin: 12px 0 0 18px;
  padding: 0;
  color: var(--text);
  line-height: 1.6;
}

#cvSkills,
#cvLanguages,
#cvCertifications {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#cvSkills li,
#cvLanguages li,
#cvCertifications li {
  background: var(--chip);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.84rem;
  line-height: 1.4;
  color: var(--text);
}

#cvTitle {
  white-space: normal;
}

textarea#title {
  min-height: 72px;
}

.editable-list,
.sortable-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.draggable-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: grab;
}

.experience-card.draggable-item {
  display: block;
  padding: 12px;
}

.experience-card.draggable-item .experience-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.experience-card.draggable-item .drag-handle {
  margin-right: 6px;
}

.experience-card.draggable-item input,
.experience-card.draggable-item textarea {
  width: 100%;
  flex: none;
}

.draggable-item input,
.draggable-item textarea {
  flex: 1;
}

.mini-delete {
  border: none;
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-weight: 700;
}

.list-add-btn {
  margin-top: 4px;
}

@media (max-width: 980px) {
  body {
    padding: 16px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    position: static;
  }

  .cv-paper {
    min-height: auto;
  }
}

@media print {
  @page {
    margin: 0.4in;
    size: A4;
  }

  body {
    background: #fff;
    padding: 0;
  }

  .editor-panel {
    display: none !important;
  }

  .app-shell {
    display: block;
    max-width: 100%;
    width: 100%;
  }

  .cv-paper {
    width: 100%;
    max-width: 100%;
    min-height: auto;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0;
    display: block;
  }

  .cv-header {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 18px;
    align-items: end;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 14px;
    margin-bottom: 18px;
  }

  .contact-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
    margin-top: 0;
  }

  .summary-box {
    padding-top: 0;
    margin-bottom: 12px;
  }

  .cv-body {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 16px;
  }

  .cv-content {
    order: 1;
    width: 100%;
    margin-bottom: 4px;
  }

  .cv-side {
    order: 2;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    width: 100%;
    border-right: none;
    padding-right: 0;
  }

  .side-block {
    margin: 0;
    break-inside: avoid;
  }

  .side-block:nth-child(1) {
    order: 2;
  }

  .side-block:nth-child(2) {
    order: 3;
  }

  .side-block:nth-child(3) {
    order: 4;
  }

  #cvSkills,
  #cvLanguages,
  #cvCertifications {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
  }

  #cvSkills {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #cvLanguages,
  #cvCertifications {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #cvSkills li,
  #cvLanguages li,
  #cvCertifications li {
    width: 100%;
    display: flex;
    align-items: center;
    min-height: 32px;
  }

  .job {
    page-break-inside: avoid;
  }
}
