/* Minimal Premium Design Tokens */
:root {
  --red: #de3e48;
  --red-deep: #6e0f15;
  --red-light: #fff5f5;
  --black: #111111;
  --white: #ffffff;
  
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-muted: #f7f9fc;
  --text: #1a1a1a;
  --muted: #777777;
  --border: #eaeaea;
  --border-dark: #cccccc;
  --border-strong: #d5dbe4;
  
  --font-ui: 'Montserrat', system-ui, -apple-system, sans-serif;
  --font-ticker: 'DotGothic16', monospace;
}

/* Reset & Basics */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  background: var(--bg);
  font-family: var(--font-ui);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  height: 100%;
  overflow: hidden;
}

a {
  color: var(--red);
  text-decoration: none;
}

.wrap {
  width: 100%;
  max-width: 1520px;
  margin: 0 auto;
  padding: 0 28px;
}

/* Minimal Sticky Header */
header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 14px 0 12px;
}
.nav {
  display: flex;
  align-items: center;
  gap: 14px 20px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.brand-logo-img {
  height: 32px;
  width: auto;
  display: block;
}
.brand-logo {
  font-size: 22px;
  font-weight: 800;
  color: var(--black);
  letter-spacing: 0;
}
.brand-logo .red-dot {
  color: var(--red);
}
.brand-badge {
  font-size: 9px;
  font-weight: 700;
  background: var(--red-light);
  color: var(--red-deep);
  border: 1px solid #ffe1e4;
  padding: 2px 6px;
  border-radius: 99px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Settings Bar inside Header */
.cv-settings-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
  order: 3;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.settings-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-muted);
}
.group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
}

/* Dropdown styling */
.minimal-select {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  color: var(--black);
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  padding: 6px 28px 6px 12px;
  border-radius: 6px;
  height: 34px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px;
  transition: all 0.15s ease;
}
.minimal-select:hover {
  border-color: #cbd5e1;
  background-color: #f1f5f9;
}
.minimal-select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(222, 62, 72, 0.06);
}

/* Sizing controls */
.size-options {
  display: flex;
  background: #f5f5f5;
  padding: 2px;
  border-radius: 6px;
  gap: 2px;
}
.size-btn {
  background: transparent;
  border: none;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.size-btn:hover {
  color: var(--black);
}
.size-btn.active {
  background: var(--white);
  color: var(--red);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

/* Color palettes picker */
.color-options {
  display: flex;
  align-items: center;
  gap: 6px;
}
.color-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.1);
  cursor: pointer;
  position: relative;
  transition: transform 0.15s;
  padding: 0;
}
.color-swatch:hover {
  transform: scale(1.25);
}
.color-swatch.active::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Minimalist Button Styling */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 38px;
  justify-content: center;
}
.btn-primary {
  background: var(--black);
  color: var(--white);
}
.btn-primary:hover {
  background: var(--red);
}
.btn-outline {
  background: transparent;
  border-color: var(--border-dark);
  color: var(--muted);
}
.btn-outline:hover {
  border-color: var(--black);
  color: var(--black);
}
.btn-text {
  background: transparent;
  color: var(--muted);
}
.btn-text:hover {
  color: var(--black);
}
.btn-text-danger {
  background: transparent;
  color: var(--muted);
}
.btn-text-danger:hover {
  color: #c62828;
}
.btn-add {
  background: transparent;
  border: 1px dashed var(--border-dark);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-add:hover {
  border-color: var(--red);
  color: var(--red);
}

/* Mobile View Tabs */
.mobile-tabs {
  display: none;
  border-bottom: 1px solid var(--border);
  background: var(--white);
}
.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 14px 0;
  text-align: center;
  cursor: pointer;
}
.tab-btn.active {
  color: var(--red);
  border-bottom-color: var(--red);
}

/* Workspace Frame (Splits Screen, Non-scrollable Body) */
.main-workspace {
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(520px, 1.05fr);
  height: calc(100vh - 125px);
  overflow: hidden;
  max-width: 100%;
  padding: 0;
  background: var(--bg);
}

/* LEFT: EDITOR PANEL (Scrollable) */
.editor-panel {
  padding: 24px 32px 40px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 28px;
  background: var(--panel);
  min-height: 0;
}
.editor-panel::-webkit-scrollbar {
  width: 6px;
}
.editor-panel::-webkit-scrollbar-thumb {
  background: #e5e5e5;
  border-radius: 4px;
}

.editor-overview {
  position: sticky;
  top: 0;
  z-index: 8;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 0 0 18px;
  border-bottom: 1px solid var(--border);
}
.editor-overview-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  margin-bottom: 16px;
}
.overview-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}
.overview-value {
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
  color: var(--black);
}
.overview-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.overview-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-muted);
  font-size: 11px;
  font-weight: 600;
  color: #4a5568;
}
.editor-jump-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  scrollbar-width: none;
}
.editor-jump-nav::-webkit-scrollbar {
  display: none;
}
.jump-btn {
  border: 1px solid var(--border-strong);
  background: var(--white);
  color: #475467;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.jump-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

/* Minimal Form Block */
.editor-section-block {
  border-bottom: 1px solid var(--border);
  padding-bottom: 26px;
}
.editor-section-block:last-child {
  border-bottom: none;
}
.section-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 20px;
  color: var(--black);
}
.section-header-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.section-header-action .section-title {
  margin-bottom: 0;
}

/* Form Fields */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.col-span-2 {
  grid-column: span 2;
}
label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="date"],
textarea {
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--white);
  color: var(--black);
  outline: none;
  transition: all 0.15s ease;
  width: 100%;
}
input:focus,
textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(222, 62, 72, 0.06);
}
textarea {
  resize: vertical;
}

/* Photo upload layout controls */
.photo-upload-group {
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel-muted);
}
.photo-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.file-input-hidden {
  display: none !important;
}
.file-input-label {
  background: var(--white);
  border: 1px solid var(--border-dark);
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  display: inline-block;
  transition: all 0.15s;
}
.file-input-label:hover {
  background: #f2f2f2;
  border-color: #999999;
}
.btn-remove-file {
  background: transparent;
  border: 1px solid #ffd1d1;
  color: #c62828;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-remove-file:hover {
  background: #fff0f0;
}
.photo-thumbnail-container {
  display: flex;
  align-items: center;
}
.photo-thumbnail {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--border-dark);
  background-size: cover;
  background-position: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.checkbox-group input {
  accent-color: var(--red);
  cursor: pointer;
}
.checkbox-group label {
  text-transform: none;
  font-size: 11px;
  cursor: pointer;
  letter-spacing: 0;
}

/* Dynamic list card (Flat and Clean) */
.list-item-card {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: 8px;
  background: var(--panel-muted);
  padding: 16px 16px 12px;
  margin-bottom: 20px;
  position: relative;
}
.list-item-card:hover {
  border-left-color: var(--red);
}
.btn-delete-item {
  position: absolute;
  top: 0;
  right: 0;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  transition: color 0.15s;
}
.btn-delete-item:hover {
  color: #c62828;
}

/* RIGHT: PREVIEW PANEL */
.preview-panel {
  background: #e8edf4;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
}

/* Preview Toolbar (Minimal Zoom & ATS score badge) */
.preview-toolbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  z-index: 10;
  position: sticky;
  top: 0;
}

.ats-compact-score {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}
.ats-compact-score:hover {
  background: #f5f5f5;
}
.score-badge {
  background: var(--black);
  color: var(--white);
  font-family: var(--font-ticker);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}
.score-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fcfcfd;
}
.zoom-btn {
  background: var(--white);
  border: 1px solid #dcdcdc;
  font-family: var(--font-ui);
  font-size: 12px;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.zoom-btn:hover {
  background: #f5f5f5;
  border-color: #999;
}
.zoom-btn.btn-fit {
  width: auto;
  padding: 0 8px;
}
.zoom-val {
  font-size: 11px;
  font-weight: 600;
  width: 36px;
  text-align: center;
}

/* ATS Drawer Panel (Compact popup list) */
.ats-drawer {
  position: absolute;
  top: 60px;
  left: 20px;
  background: var(--white);
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  padding: 12px 16px;
  z-index: 20;
  display: none;
  width: 260px;
}
.ats-drawer.active {
  display: block;
}
.ats-checklist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ats-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}
.ats-check-item svg {
  flex-shrink: 0;
}
.ats-check-item.passed {
  color: #2e7d32;
}
.ats-check-item.failed {
  color: #c62828;
}

/* Scrollable Paper Area */
.cv-page-wrapper {
  flex: 1;
  overflow: auto;
  padding: 28px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* A4 CANVAS RENDERING */
.cv-page {
  --cv-base-size: 12px; /* fallback default size */
  --cv-primary-color: #222222; /* fallback default color */
  
  background: var(--white);
  width: 794px;
  min-height: 1123px;
  padding: 54px 64px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(15, 23, 42, 0.06);
  flex-shrink: 0;
  transition: transform 0.15s ease-out;
  transform-origin: top center;
  margin-bottom: calc(1123px * (var(--zoom-level, 1) - 1));
  transform: scale(var(--zoom-level, 1));
}

/* PDF Direct Export active override to remove box-shadow and lock page heights to 1120px */
.cv-page.pdf-export-active {
  box-shadow: none !important;
  border: none !important;
  margin: 0 !important;
  height: 1120px !important;
  min-height: 1120px !important;
  max-height: 1120px !important;
}

/* FONT PAIRINGS OVERRIDES */
.font-pair-modern {
  font-family: 'Lato', sans-serif;
}
.font-pair-modern .cv-name,
.font-pair-modern .cv-title,
.font-pair-modern .cv-section-title,
.font-pair-modern .cv-block-header {
  font-family: 'Inter', sans-serif;
}

.font-pair-editorial {
  font-family: 'Lora', serif;
}
.font-pair-editorial .cv-name,
.font-pair-editorial .cv-title,
.font-pair-editorial .cv-section-title,
.font-pair-editorial .cv-block-header {
  font-family: 'Lora', serif;
}

.font-pair-traditional-serif,
.font-pair-traditional {
  font-family: 'Arial', 'Helvetica', sans-serif;
}
.font-pair-traditional-serif .cv-name,
.font-pair-traditional-serif .cv-title,
.font-pair-traditional-serif .cv-section-title,
.font-pair-traditional-serif .cv-block-header {
  font-family: 'Georgia', serif;
}

.font-pair-elegant {
  font-family: 'Lato', sans-serif;
}
.font-pair-elegant .cv-name,
.font-pair-elegant .cv-title,
.font-pair-elegant .cv-section-title,
.font-pair-elegant .cv-block-header {
  font-family: 'Playfair Display', serif;
}

/* TEXT SIZES COMPOSITE CLASSES */
.cv-page.size-small {
  --cv-base-size: 10px !important;
}
.cv-page.size-medium {
  --cv-base-size: 12px !important;
}
.cv-page.size-large {
  --cv-base-size: 13.8px !important;
}

/* PROFILE PHOTO ELEMENT */
.cv-photo-container {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-dark);
  flex-shrink: 0;
  display: block;
}
.cv-photo-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* CV Inner Elements styling (linked to CSS variables for dynamic customizer sizing) */
.cv-header {
  display: flex;
  align-items: center;
  gap: 20px;
}
.cv-header-text {
  flex: 1;
}
.cv-name {
  font-size: calc(var(--cv-base-size) * 2);
  font-weight: 700;
  color: var(--cv-primary-color);
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}
.cv-title {
  font-size: calc(var(--cv-base-size) * 1.1);
  font-weight: 600;
  margin-bottom: 8px;
  color: #444;
}
.cv-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: calc(var(--cv-base-size) * 0.85);
  color: #666;
}
.cv-contact span {
  display: inline-flex;
  align-items: center;
}

.cv-section {
  margin-top: calc(var(--cv-base-size) * 1.5);
}
.cv-section-title {
  font-size: calc(var(--cv-base-size) * 0.95);
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cv-primary-color);
  padding-bottom: 3px;
  margin-bottom: calc(var(--cv-base-size) * 0.8);
}
.cv-section-content {
  font-size: calc(var(--cv-base-size) * 0.9);
  color: #2b2b2b;
}

.cv-block {
  margin-bottom: calc(var(--cv-base-size) * 0.9);
}
.cv-block-header {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  color: #111;
  margin-bottom: 1px;
}
.cv-block-subheader {
  display: flex;
  justify-content: space-between;
  font-style: italic;
  color: #555;
  margin-bottom: 3px;
}
.cv-block-desc {
  margin-left: 14px;
}
.cv-block-desc ul {
  list-style-type: disc;
  margin-top: 2px;
}
.cv-block-desc li {
  margin-bottom: 2px;
}

/* TEMPLATE 1: CLASSIC (Centered headers, clean borders) */
.template-classic .cv-header {
  flex-direction: column;
  text-align: center;
  gap: 12px;
}
.template-classic .cv-photo-container {
  border-radius: 50%;
}
.template-classic .cv-contact {
  justify-content: center;
}
.template-classic .cv-contact span:not(:last-child)::after {
  content: "|";
  margin-left: 10px;
  color: #aaa;
}
.template-classic .cv-section-title {
  border-bottom: 1.5px solid var(--cv-primary-color);
}

/* TEMPLATE 2: MODERN (Flat aligned list with section horizontal line decoration) */
.template-modern .cv-header {
  flex-direction: row;
  text-align: left;
  gap: 20px;
  padding-bottom: 14px;
}
.template-modern .cv-photo-container {
  border-radius: 8px;
}
.template-modern .cv-contact span:not(:last-child)::after {
  content: "|";
  margin-left: 10px;
  color: #ddd;
}
.template-modern .cv-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.template-modern .cv-section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-dark);
}

/* TEMPLATE 3: SERIF (Indented listings, double metadata gap) */
.template-serif .cv-header {
  flex-direction: column;
  text-align: center;
  gap: 12px;
}
.template-serif .cv-photo-container {
  border-radius: 0px;
  width: 78px;
  height: 78px;
}
.template-serif .cv-contact {
  justify-content: center;
  gap: 4px 14px;
}
.template-serif .cv-contact span:not(:last-child)::after {
  content: "  /  ";
  margin-left: 14px;
  color: #ccc;
}
.template-serif .cv-section-title {
  text-align: center;
  letter-spacing: 0.15em;
  margin-bottom: calc(var(--cv-base-size) * 1.0);
}
.template-serif .cv-block-subheader {
  font-size: calc(var(--cv-base-size) * 0.85);
}

/* Mobile Sticky FAB for print */
.mobile-print-fab-btn {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--red);
  color: var(--white);
  border: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  transition: transform 0.2s;
}
.mobile-print-fab-btn:active {
  transform: scale(0.9);
}

/* style panels & mobile previews default hidden on desktop */
.style-panel {
  display: none;
}
.mobile-preview-actions {
  display: none;
}

/* RESPONSIVE LAYOUT */
@media (max-width: 1200px) {
  .wrap {
    padding: 0 20px;
  }

  .settings-group {
    padding: 6px 9px;
  }

  .main-workspace {
    grid-template-columns: minmax(360px, 0.92fr) minmax(0, 1.08fr);
    height: calc(100vh - 132px);
  }

  .editor-panel {
    padding: 22px 22px 32px;
  }

  .editor-overview-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .overview-pills {
    justify-content: flex-start;
  }

  .preview-toolbar {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  .cv-page-wrapper {
    padding: 20px 16px 24px;
  }

  .cv-page {
    width: 760px;
    padding: 48px 54px;
  }
}

@media (max-width: 820px) {
  html,
  body {
    height: auto !important;
    min-height: 100dvh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  body {
    overscroll-behavior-y: auto;
    touch-action: pan-y;
  }

  header {
    padding: 12px 0;
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06) !important;
  }

  .wrap {
    padding: 0 16px;
  }

  .brand-badge,
  .cv-settings-bar,
  .header-actions {
    display: none !important;
  }

  .mobile-tabs {
    display: flex;
    position: sticky !important;
    top: 57px !important;
    z-index: 99 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04) !important;
    background: rgba(255, 255, 255, 0.88) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-bottom: 1px solid rgba(0,0,0,0.06) !important;
  }

  .main-workspace {
    display: flex;
    flex-direction: column;
    height: auto !important;
    min-height: calc(100dvh - 105px);
    overflow: visible !important;
  }

  .editor-panel {
    display: none;
    width: 100% !important;
    height: calc(100dvh - 105px) !important;
    min-height: calc(100dvh - 105px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 20px 16px 28px;
    border-right: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  .editor-overview {
    position: static;
    padding-bottom: 16px;
  }

  .editor-jump-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .style-panel {
    display: none;
    flex-direction: column;
    width: 100% !important;
    height: calc(100dvh - 105px) !important;
    min-height: calc(100dvh - 105px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 20px 16px 28px;
    gap: 24px;
    background: var(--white);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  .preview-panel {
    display: none;
    width: 100% !important;
    height: calc(100dvh - 105px) !important;
    min-height: calc(100dvh - 105px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    border-top: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  .preview-toolbar {
    padding: 12px 12px 8px;
  }

  .cv-page-wrapper {
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    padding: 12px 10px 94px !important;
    display: flex;
    justify-content: center;
    align-items: flex-start;
  }

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

  .col-span-2 {
    grid-column: span 1;
  }

  .editor-panel input[type="text"],
  .editor-panel input[type="email"],
  .editor-panel input[type="tel"],
  .editor-panel input[type="url"],
  .editor-panel input[type="date"],
  .editor-panel textarea,
  .style-panel select.minimal-select,
  .style-panel select.mobile-select-full {
    font-size: 14px !important;
    padding: 10px 14px !important;
    border-radius: 8px !important;
  }

  .editor-panel input[type="text"],
  .editor-panel input[type="email"],
  .editor-panel input[type="tel"],
  .editor-panel input[type="url"],
  .editor-panel input[type="date"],
  .style-panel select.minimal-select,
  .style-panel select.mobile-select-full {
    height: 44px !important;
  }

  .mobile-select-full {
    width: 100% !important;
    font-size: 13px !important;
    padding: 8px 12px !important;
    background-position: right 12px center !important;
    background-size: 12px !important;
  }

  .mobile-size-options {
    width: 100%;
  }

  .mobile-size-options .size-btn {
    flex: 1;
    height: 38px;
    font-size: 12px;
  }

  .mobile-color-options {
    gap: 12px;
  }

  .mobile-color-options .color-swatch {
    width: 32px;
    height: 32px;
  }

  .mobile-preview-actions {
    display: flex;
    gap: 10px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-top: 1px solid rgba(0,0,0,0.06) !important;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.06) !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    z-index: 101 !important;
    box-sizing: border-box;
  }

  .mobile-preview-actions .btn {
    height: 46px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    border-radius: 8px !important;
  }

  body.editor-active .editor-panel {
    display: flex;
  }

  body.style-active .style-panel {
    display: flex;
  }

  body.preview-active .preview-panel {
    display: flex;
    flex-direction: column;
  }

  body.preview-active .mobile-print-fab-btn {
    display: flex;
  }

  .cv-page {
    width: 100%;
    min-height: auto;
    padding: 28px 20px;
    max-width: 100%;
    margin-bottom: 0;
  }

  .template-modern .cv-header,
  .template-classic .cv-header,
  .template-serif .cv-header {
    gap: 14px;
  }

  .cv-block-header,
  .cv-block-subheader {
    flex-direction: column;
    gap: 2px;
  }
}


/* PRINT MEDIA STYLES - FIX BLANK PAGE BUG */
@media print {
  @page {
    size: A4 portrait;
    margin: 15mm 15mm 15mm 15mm;
  }
  
  body, html {
    background: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 210mm !important;
    height: 297mm !important;
    overflow: visible !important;
  }

  /* Hide everything except preview panel */
  header,
  .mobile-tabs,
  .editor-panel,
  .style-panel,
  .preview-toolbar,
  .ats-drawer,
  .mobile-print-fab-btn,
  .mobile-preview-actions {
    display: none !important;
  }

  .main-workspace {
    display: block !important;
    height: auto !important;
    width: 210mm !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }

  .preview-panel {
    background: transparent !important;
    display: block !important;
    height: auto !important;
    width: 210mm !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .cv-page-wrapper {
    display: block !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    width: 210mm !important;
    height: auto !important;
  }

  .cv-page {
    display: block !important;
    border: none !important;
    box-shadow: none !important;
    width: 210mm !important;
    height: 297mm !important;
    min-height: 297mm !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    background: transparent !important;
    transform: none !important; /* remove zoom scale during prints */
  }
}
