/* Builder Workspace Styles for 简力 (Jianli) */

body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-light);
}

/* Header Toolbar */
.builder-header {
  height: 80px;
  background-color: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: 1.5rem;
  z-index: 100;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.workspace-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-title);
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background-color: var(--border-color);
}

/* Logo Styling */
.logo-area {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
}

.logo-icon {
  flex-shrink: 0;
  filter: drop-shadow(0 2px 8px rgba(0, 118, 254, 0.15));
}

.logo-img {
  height: 68px;
  width: auto;
  object-fit: contain;
}

.logo-text {
  font-family: var(--font-title);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-mi {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-weight: 900;
  font-style: italic;
  text-transform: lowercase;
  margin-right: 1px;
  font-size: 1.1em;
  letter-spacing: -1.5px;
  display: inline-block;
}

.logo-dot {
  color: var(--accent-color);
}

.builder-style-bar {
  height: 66px;
  background-color: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px) saturate(120%);
  -webkit-backdrop-filter: blur(16px) saturate(120%);
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-inline: 1.5rem;
  z-index: 95; /* Floats above the workspace pane (which has z-index < 95) */
  flex-shrink: 0;
  overflow-x: auto; /* Allow horizontal scrolling when layout overflows */
  overflow-y: visible; /* Prevent vertical clipping where possible */
  scrollbar-width: none; /* Hide scrollbar Firefox */
  -ms-overflow-style: none; /* Hide scrollbar IE/Edge */
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch; /* Momentum scrolling iOS */
}

.builder-style-bar::-webkit-scrollbar {
  display: none; /* Hide scrollbar Chrome/Safari/Webkit */
}

.style-card {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.375rem 0.75rem;
  background: rgba(248, 250, 252, 0.65);
  border: 1px solid rgba(226, 232, 240, 0.65);
  border-radius: var(--radius-md);
  transition: all var(--transition-normal);
  flex-shrink: 0;
  height: 48px;
}

.style-card:hover {
  background: var(--bg-white);
  border-color: rgba(0, 118, 254, 0.25);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.style-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(0, 118, 254, 0.08) 0%, rgba(13, 148, 136, 0.08) 100%);
  color: var(--primary-color);
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.style-card:hover .style-icon-wrapper {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
  color: var(--text-white);
}

.style-icon {
  width: 16px;
  height: 16px;
}

.style-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.style-label {
  font-size: 0.725rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1;
}

.builder-style-bar .select-control {
  padding: 0.125rem 1.25rem 0.125rem 0;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--text-main);
  background-color: transparent;
  border: none;
  cursor: pointer;
  outline: none;
  transition: all var(--transition-fast);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.5' 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 0 center;
  background-size: 10px;
  min-width: 80px;
  height: 20px;
}

.builder-style-bar .select-control:hover,
.builder-style-bar .select-control:focus {
  color: var(--primary-color);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234f46e5' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* Specific select dropdown widths */
#template-select {
  min-width: 140px;
}

#font-size-select {
  min-width: 80px;
}

#margin-select {
  min-width: 75px;
}

#line-height-select {
  min-width: 75px;
}

/* Color Picker */
.color-picker-group {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.125rem;
  height: 20px;
}

.color-dot {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
}

.color-dot:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.color-dot.active {
  box-shadow: 0 0 0 2px var(--bg-white), 0 0 0 4px var(--primary-color);
  transform: scale(1.15);
}

.color-indigo { background-color: var(--theme-indigo); }
.color-black { background-color: var(--theme-black); }
.color-blue { background-color: var(--theme-blue); }
.color-teal { background-color: var(--theme-teal); }
.color-red { background-color: var(--theme-red); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Dropdown */
.dropdown-wrapper {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  display: none;
  flex-direction: column;
  padding: 0.5rem;
  min-width: 180px;
  z-index: 100;
  transform-origin: top right;
  animation: dropdownFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.dropdown-menu.show {
  display: flex;
}

.dropdown-item {
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: left;
  border: none;
  background-color: transparent;
  color: var(--text-main);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dropdown-item:hover {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

/* Workspace Layout */
.builder-workspace {
  flex-grow: 1;
  display: flex;
  overflow: hidden;
  height: calc(100vh - 146px); /* 80px header + 66px style bar */
}

/* Premium Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-normal);
  font-family: var(--font-body);
  white-space: nowrap;
}

.btn-pill {
  border-radius: var(--radius-full);
}

.btn-primary {
  color: var(--text-white);
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
  box-shadow: 0 4px 12px rgba(0, 118, 254, 0.25);
  border: none;
  padding: calc(0.5rem + 2px) calc(1.25rem + 2px);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover) 0%, var(--accent-hover) 100%);
  box-shadow: 0 6px 18px rgba(0, 118, 254, 0.4);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-outline {
  color: var(--text-muted);
  background-color: var(--bg-white);
  border-color: var(--border-color);
}

.btn-outline:hover {
  color: var(--primary-color);
  border-color: rgba(0, 118, 254, 0.35);
  background-color: var(--primary-light);
  box-shadow: 0 2px 8px rgba(0, 118, 254, 0.04);
}

.btn-ghost {
  color: var(--text-muted);
  background-color: transparent;
}

.btn-ghost:hover {
  color: var(--text-main);
  background-color: var(--bg-light);
}

/* Add Item Button (Bento dash-bordered style) */
.add-item-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.875rem;
  margin-block-start: 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-color);
  background-color: rgba(0, 118, 254, 0.02);
  border: 2px dashed rgba(0, 118, 254, 0.25);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-normal);
}

.add-item-btn:hover {
  color: var(--primary-hover);
  background-color: var(--primary-light);
  border: 2px solid var(--primary-color);
  box-shadow: 0 4px 12px rgba(0, 118, 254, 0.08);
  transform: translateY(-2px);
}

.add-item-btn:active {
  transform: translateY(0);
}

/* Editor Pane (Left) */
.editor-pane {
  width: 45%;
  min-width: 480px;
  max-width: 600px;
  border-right: 1px solid var(--border-color);
  background-color: var(--bg-white);
  padding: 1.5rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

/* Drag Resize Divider */
.resize-divider {
  width: 10px;
  cursor: col-resize;
  background-color: var(--border-color);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-normal);
  z-index: 10;
  user-select: none;
  flex-shrink: 0;
  touch-action: none; /* Prevents scroll gestures on touch screens while dragging the divider */
}

.resize-divider:hover,
.resize-divider.dragging {
  background-color: var(--primary-color);
}

.resize-handle {
  width: 4px;
  height: 40px;
  border-radius: var(--radius-full);
  background-color: var(--text-muted);
  opacity: 0.6;
  transition: background-color var(--transition-normal), opacity var(--transition-normal);
}

.resize-divider:hover .resize-handle,
.resize-divider.dragging .resize-handle {
  background-color: var(--text-white);
  opacity: 1;
}

.editor-pane::-webkit-scrollbar {
  width: 6px;
}

.editor-pane::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: var(--radius-full);
}

/* Details Accordion Sections */
.editor-section {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-block-end: 1rem;
  overflow: hidden;
  transition: border-color var(--transition-normal);
}

.editor-section[open] {
  border-color: var(--border-focus);
}

.editor-section summary {
  list-style: none;
  padding: 1rem 1.25rem;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  background-color: var(--bg-light);
  display: flex;
  align-items: center;
  user-select: none;
  outline: none;
  transition: background-color var(--transition-fast);
}

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

.editor-section summary:hover {
  background-color: var(--border-color);
}

.editor-section[draggable="true"] summary {
  cursor: grab;
}

.editor-section[draggable="true"] summary:active {
  cursor: grabbing;
}

.editor-section.dragging {
  opacity: 0.5;
  border: 2px dashed var(--primary-color) !important;
}

.editor-section.drag-over {
  border: 2px solid var(--primary-color) !important;
}

.drag-handle:hover {
  color: var(--primary-color) !important;
}


.section-icon {
  margin-right: 0.625rem;
  font-size: 1.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--primary-color);
  flex-shrink: 0;
}

.section-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.section-content {
  padding: 1.25rem;
  background-color: var(--bg-white);
  border-top: 1px solid var(--border-color);
}

/* Grid helper */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

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

/* Form Styles */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-block-end: 1rem;
}

.form-group label {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input, .form-group textarea {
  font-family: inherit;
  font-size: 0.925rem;
  padding: 0.625rem 0.875rem;
  color: var(--text-main);
  background-color: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: all var(--transition-fast);
  min-height: 40px;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.form-group input:focus, .form-group textarea:focus {
  border-color: var(--primary-color);
  background-color: var(--bg-white);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
/* Avatar Upload Group */
.avatar-upload-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.avatar-upload-group input {
  flex-grow: 1;
}

.upload-or {
  font-size: 0.825rem;
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}

.btn-file-upload {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  padding: 0.625rem 1.25rem;
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  min-height: 40px;
  box-sizing: border-box;
}

.btn-file-upload:hover {
  background-color: var(--bg-light);
  border-color: var(--text-muted);
}

/* List Item Card (inside Education, Experience, etc.) */
.list-item-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-block-end: 1.25rem;
  background-color: var(--bg-light);
  position: relative;
  transition: border-color var(--transition-fast);
}

.list-item-card:hover {
  border-color: var(--text-muted);
}

.list-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-block-end: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border-color);
}

.list-item-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-remove {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 0.825rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast);
}

.btn-remove:hover {
  background-color: #fee2e2;
}

.btn-block {
  width: 100%;
  margin-block-start: 0.5rem;
}

/* AI Polish Button layout inside textareas */
.textarea-wrapper {
  display: flex;
  flex-direction: column;
}

.btn-ai-polish {
  align-self: flex-end;
  background-color: var(--primary-light);
  color: var(--primary-color);
  border: 1px solid rgba(255, 111, 32, 0.2);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: all var(--transition-fast);
  margin-top: 0.35rem;
}

.btn-ai-polish:hover {
  background-color: var(--primary-color);
  color: var(--text-white);
  border-color: var(--primary-color);
}

.btn-ai-polish:disabled,
.btn-ai-polish.disabled {
  background-color: var(--bg-light) !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border-color) !important;
  cursor: not-allowed !important;
  opacity: 0.65 !important;
  pointer-events: none;
}

.ai-polish-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  box-sizing: border-box;
}

.ai-polish-group .btn-ai-polish {
  align-self: stretch;
  justify-content: center;
  margin-top: 0;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
}

/* Preview Pane (Right) */
.preview-pane {
  flex-grow: 1;
  background-color: #475569;
  display: flex;
  justify-content: center;
  overflow-y: auto;
  padding: 2.5rem 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.preview-pane::-webkit-scrollbar {
  width: 6px;
}

.preview-pane::-webkit-scrollbar-thumb {
  background-color: rgba(255,255,255,0.2);
  border-radius: var(--radius-full);
}

.preview-viewport {
  position: relative;
  width: 100%;
  max-width: 820px;
  display: flex;
  justify-content: center;
  align-items: start;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-overlay.show {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 680px;
  background-color: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  animation: modalScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes modalScaleUp {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.ai-tip {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.original-box {
  background-color: var(--bg-light);
  border-left: 3px solid var(--text-muted);
  padding: 1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-top: 0.75rem;
}

.original-box h4 {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

#ai-original-text {
  font-size: 0.875rem;
  color: var(--text-main);
  white-space: pre-wrap;
  line-height: 1.5;
}

.ai-suggestions-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.suggestion-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  cursor: pointer;
  transition: all var(--transition-normal);
  background-color: var(--bg-white);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: left;
}

.suggestion-card:hover {
  border-color: var(--primary-color);
  background-color: var(--primary-light);
  transform: translateY(-2px);
}

.suggestion-content {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-main);
  white-space: pre-wrap;
}

.btn-apply-suggestion {
  align-self: flex-end;
  background-color: var(--primary-color);
  color: var(--text-white);
  border: none;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.375rem 0.875rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.btn-apply-suggestion:hover {
  background-color: var(--primary-hover);
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  background-color: var(--bg-light);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Responsive Builder Layout */
@media (max-width: 1024px) {
  .builder-workspace {
    height: calc(100vh - 136px);
  }
  
  .hide-tablet {
    display: none !important;
  }
  
  .editor-pane {
    min-width: 360px !important;
  }
  
  .preview-pane {
    padding: 1.5rem 1rem !important;
  }
}

@media (max-width: 767px) {
  .hide-mobile {
    display: none !important;
  }

  .builder-header {
    flex-direction: column;
    height: auto;
    align-items: stretch;
    padding-block: 0.75rem;
    padding-inline: 1rem;
    gap: 0.5rem;
  }
  
  .header-left {
    justify-content: space-between;
    width: 100%;
  }

  .header-actions {
    justify-content: flex-start;
    width: 100%;
    gap: 0.375rem;
    flex-wrap: wrap;
  }
  
  .header-actions .dropdown-wrapper {
    flex-grow: 1;
  }
  
  .header-actions .btn {
    flex-grow: 1;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }

  .builder-workspace {
    flex-direction: row;
    overflow: hidden;
    height: calc(100vh - 80px - 66px - 54px) !important;
    height: calc(100dvh - 80px - 66px - 54px - env(safe-area-inset-bottom)) !important;
  }
  
  /* Hide resize divider */
  .resize-divider {
    display: none !important;
  }

  /* Control active pane displays */
  body[data-active-tab="preview"] .editor-pane {
    display: none !important;
  }
  body[data-active-tab="preview"] .preview-pane {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 100% !important;
    padding: 1rem 0.5rem !important;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  
  body[data-active-tab="preview"] .preview-viewport {
    margin-inline: auto !important;
  }
  
  body[data-active-tab="editor"] .preview-pane {
    display: none !important;
  }
  body[data-active-tab="editor"] .editor-pane {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 100% !important;
    border-right: none !important;
    padding: 1rem !important;
  }

  /* Mobile bottom tab switcher style */
  .mobile-tab-bar {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding-top: 6px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px) saturate(120%);
    -webkit-backdrop-filter: blur(20px) saturate(120%);
    border-top: 1px solid rgba(226, 232, 240, 0.8);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    box-sizing: border-box;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.03);
  }
  
  body.dark-theme .mobile-tab-bar {
    background: rgba(28, 25, 23, 0.85); /* Stone-900 Warm Charcoal */
    border-top: 1px solid rgba(63, 63, 70, 0.5);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  }
  
  .mobile-tab-bar .tab-btn {
    flex: 1;
    height: 100%;
    background: transparent;
    border: none;
    font-size: 0.825rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: all var(--transition-fast);
    font-family: var(--font-body);
  }

  .mobile-tab-bar .tab-btn .tab-icon {
    color: var(--text-muted);
    transition: color var(--transition-fast), transform var(--transition-fast);
  }
  
  .mobile-tab-bar .tab-btn.active {
    color: var(--primary-color);
  }

  .mobile-tab-bar .tab-btn.active .tab-icon {
    color: var(--primary-color);
  }

  /* Mobile preview floating zoom controls widget */
  .zoom-controls {
    display: none;
    position: fixed;
    right: 16px;
    bottom: calc(76px + env(safe-area-inset-bottom)); /* sits right above the bottom tab bar */
    background: rgba(15, 23, 42, 0.82); /* Dark warm slate */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 9999px;
    padding: 6px 12px;
    align-items: center;
    gap: 8px;
    z-index: 999;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    box-sizing: border-box;
    height: 40px;
  }
  
  body.dark-theme .zoom-controls {
    background: rgba(28, 25, 23, 0.85); /* Stone-900 Warm Charcoal */
    border: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  body[data-active-tab="preview"] .zoom-controls {
    display: flex;
  }
  
  .zoom-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    padding: 0;
    line-height: 1;
    font-family: inherit;
  }
  
  .zoom-btn:active {
    transform: scale(0.9);
    background: var(--primary-color);
  }
  
  .zoom-percent {
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 38px;
    text-align: center;
    font-family: monospace;
    user-select: none;
  }

  /* Adjust style bar on mobile for smooth horizontal scrolling */
  .builder-style-bar {
    padding-inline: 1rem;
    gap: 0.75rem;
    height: 60px;
  }
  
  .style-card {
    padding-inline: 0.5rem;
    flex-shrink: 0;
  }

  /* Increase padding for touch areas on forms */
  .editor-section {
    padding: 1rem !important;
    margin-bottom: 0.75rem !important;
    border-radius: var(--radius-md) !important;
  }

  .grid-2 {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  .form-group.span-2 {
    grid-column: span 1 !important;
  }

  .form-group label {
    margin-bottom: 0.35rem !important;
    font-size: 0.8rem !important;
  }

  .form-group input, 
  .form-group textarea, 
  .form-group select {
    padding: 0.65rem 0.75rem !important;
    font-size: 0.85rem !important;
  }
  
  /* Scale adjustments for canvas wrapper container */
  .preview-viewport {
    padding: 0 !important;
    display: flex;
    justify-content: flex-start !important; /* Align layout box to top-left to sync with top-left scaling */
    align-items: flex-start;
    width: 100%;
  }

  /* AI import banner spacing */
  .ai-import-banner {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 1rem !important;
  }

  .ai-import-banner button {
    width: 100%;
    justify-content: center;
  }
}

/* ==========================================================================
   Custom Template Selector Dropdown Grid & Mockups
   ========================================================================== */
.select-trigger-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  background-color: transparent;
  cursor: pointer;
  min-width: 140px;
  height: 20px;
  user-select: none;
}

.select-trigger-btn:hover {
  color: var(--primary-color);
}

.trigger-arrow {
  transition: transform var(--transition-fast);
}

.dropdown-wrapper.show .trigger-arrow {
  transform: rotate(180deg);
}

.template-select-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 480px;
  background-color: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: none;
  flex-direction: column;
  padding: 1rem;
  z-index: 110;
  transform-origin: top left;
  animation: dropdownFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.template-select-dropdown.show {
  display: flex;
}

.template-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.75rem;
}

.template-dropdown-header span:first-child {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-main);
}

.template-dropdown-header .template-count {
  font-size: 0.75rem;
  color: var(--text-light);
  font-weight: 600;
}

/* Category Tabs inside Template Dropdown */
.template-categories-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.75rem;
}

.category-tab {
  background-color: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.725rem;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.category-tab:hover {
  border-color: var(--text-muted);
  color: var(--text-main);
  background-color: var(--bg-white);
}

.category-tab.active {
  background-color: var(--primary-light);
  border-color: var(--primary-color);
  color: var(--primary-color);
  box-shadow: 0 1px 3px rgba(99, 102, 241, 0.1);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 0.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.template-grid::-webkit-scrollbar {
  width: 4px;
}

.template-grid::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: var(--radius-full);
}

.template-item-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  background-color: var(--bg-light);
  transition: all var(--transition-normal);
  user-select: none;
}

.template-item-card:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.template-item-card.active {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px var(--primary-glow);
  background-color: var(--primary-light);
}

.template-item-preview {
  height: 95px;
  background-color: var(--bg-white);
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.template-img-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  transition: transform var(--transition-normal);
}

.template-item-card:hover .template-img-thumb {
  transform: scale(1.04);
}

.template-item-info {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  background: var(--bg-white);
}

.template-item-card.active .template-item-info {
  background: var(--primary-light);
}

.template-item-name {
  font-size: 0.775rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-item-card.active .template-item-name {
  color: var(--primary-color);
}

.template-item-tag {
  font-size: 0.65rem;
  color: var(--text-light);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Live miniature resume layout previews */
.mini-resume-scale-wrapper {
  width: 100%;
  height: 95px;
  overflow: hidden;
  position: relative;
  background-color: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
}

.mini-resume-scale-wrapper .resume-canvas {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 794px !important; /* A4 width */
  height: 1123px !important; /* A4 height */
  transform: scale(0.18) !important; /* Scale to fit A4 layout inside preview cards */
  transform-origin: top left !important;
  pointer-events: none !important;
  box-shadow: none !important;
  margin: 0 !important;
  overflow: hidden !important;
  border: none !important;
  border-radius: 0 !important;
}

/* Responsive adjustment for custom template selector */
@media (max-width: 767px) {
  .template-select-dropdown {
    width: calc(100vw - 2rem);
    left: 1rem;
    position: fixed;
    top: 140px;
    box-sizing: border-box;
    transform-origin: top center;
  }
}

@media (max-width: 500px) {
  .template-select-dropdown {
    width: calc(100vw - 2rem);
    left: 1rem;
    position: fixed;
    top: 190px;
  }
  .template-grid {
    grid-template-columns: repeat(2, 1fr);
    max-height: 280px;
  }
}

/* ==========================================================================
   AI Template Scanner Modal Styles
   ========================================================================== */

/* 1. Radar Laser Scanner Beam */
.laser-scanner-beam {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--primary-color), #a855f7, var(--primary-color), transparent);
  box-shadow: 0 0 12px 3px rgba(99, 102, 241, 0.8), 0 0 20px 6px rgba(168, 85, 247, 0.4);
  animation: laserScan 2.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  z-index: 10;
}

@keyframes laserScan {
  0% {
    top: 0%;
  }
  50% {
    top: 100%;
  }
  100% {
    top: 0%;
  }
}

/* 2. Glowing Colorful Spinner */
.spinner-colorful {
  width: 36px;
  height: 36px;
  border: 4px solid rgba(0, 0, 0, 0.05);
  border-top-color: var(--primary-color);
  border-right-color: #a855f7;
  border-bottom-color: #ec4899;
  border-radius: 50%;
  animation: spinColorful 0.8s linear infinite;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.15);
}

@keyframes spinColorful {
  to {
    transform: rotate(360deg);
  }
}

/* 3. Drag and Drop Highlighting State */
#ai-scan-dropzone.drag-over {
  border-color: #a855f7 !important;
  background: rgba(168, 85, 247, 0.06) !important;
  box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.15);
}

/* 4. Alternative Template Option Buttons */
.alt-template-btn {
  flex: 1;
  padding: 0.6rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  background: var(--bg-white);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alt-template-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: rgba(99, 102, 241, 0.02);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* 5. Breathing Glow Effect for Color Indicator */
@keyframes pulseColorGlow {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0px rgba(99, 102, 241, 0.4);
  }
  50% {
    transform: scale(1.15);
    box-shadow: 0 0 8px 2px rgba(99, 102, 241, 0.6);
  }
}

.result-color-indicator {
  animation: pulseColorGlow 2s infinite ease-in-out;
}

/* ==========================================================================
   VIP & Locked Template Card Styles
   ========================================================================== */

/* 1. VIP badge on locked cards */
.vip-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  color: #1e1b4b;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.4);
  z-index: 5;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* 2. Locked template card style */
.template-item-card.locked {
  opacity: 0.68;
  filter: grayscale(40%);
  cursor: pointer;
}

.template-item-card.locked:hover {
  opacity: 0.85;
  filter: grayscale(10%);
  border-color: #fbbf24;
}

/* 3. Golden upgrade button breath animation */
.btn-gold-pulse {
  animation: goldGlow 2.5s infinite ease-in-out;
}

@keyframes goldGlow {
  0%, 100% {
    box-shadow: 0 0 4px rgba(245, 158, 11, 0.3), 0 2px 4px rgba(0,0,0,0.1);
  }
  50% {
    box-shadow: 0 0 14px 4px rgba(245, 158, 11, 0.75), 0 2px 8px rgba(245, 158, 11, 0.2);
  }
}

/* Floating selection color bubble */
#selection-color-bubble {
  position: absolute;
  z-index: 10000;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  border-radius: 9999px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  transform: scale(0.9) translateY(10px);
  opacity: 0;
  pointer-events: none;
}
#selection-color-bubble.show {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}
.bubble-color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.bubble-color-dot:hover {
  transform: scale(1.2);
  border-color: #ffffff;
}
.bubble-color-picker-wrapper {
  position: relative;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: conic-gradient(red, yellow, green, cyan, blue, magenta, red);
  transition: transform 0.15s ease;
}
.bubble-color-picker-wrapper:hover {
  transform: scale(1.2);
}
.bubble-color-picker-wrapper input[type="color"] {
  position: absolute;
  top: -5px;
  left: -5px;
  width: 30px;
  height: 30px;
  opacity: 0;
  cursor: pointer;
}
.bubble-color-picker-wrapper .picker-icon {
  font-size: 0.75rem;
  color: white;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.bubble-reset-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #e2e8f0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.bubble-reset-btn:hover {
  background: #ef4444;
  color: white;
}
