/* ============================================
   RESET & BASE
============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid #005fcc;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10000;
  padding: 8px 16px;
  background: #005fcc;
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 6px 0;
}
.skip-link:focus {
  left: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #eceae5;
  color: #1a1a1a;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ============================================
   SPINNER
============================================ */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}
.spinner-lg {
  width: 28px;
  height: 28px;
  border: 3px solid #e0ddd8;
  border-top-color: #1a1a1a;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

/* ============================================
   APP HEADER
============================================ */
.app-header {
  background: #1a1a1a;
  color: #fff;
  padding: 9px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-brand > div { display: flex; flex-direction: column; gap: 1px; }
.header-brand h1 { font-size: 14px; font-weight: 700; letter-spacing: -0.3px; }
.header-brand span { font-size: 11px; opacity: 0.7; }
.header-brand svg { flex-shrink: 0; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* ============================================
   BUTTON SYSTEM
============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  -webkit-appearance: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.btn:active:not(:disabled) { opacity: 0.8; }

.btn-sm   { padding: 4px 9px; font-size: 12px; border-radius: 5px; }
.btn-lg   { padding: 9px 14px; font-size: 14px; font-weight: 600; }
.btn-block { width: 100%; }
.btn-icon {
  padding: 0;
  width: 26px;
  height: 26px;
  font-size: 16px;
  border-radius: 5px;
  flex-shrink: 0;
}

.btn-primary {
  background: #1a1a1a;
  color: #fff;
  border-color: #1a1a1a;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: #2d2d2d; border-color: #2d2d2d; }

.btn-secondary {
  background: transparent;
  color: #333;
  border-color: #c5c2bc;
}
.btn-secondary:hover:not(:disabled) { background: #f5f3ef; border-color: #bbb; color: #1a1a1a; }

.btn-ghost {
  background: transparent;
  color: #555;
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: #f0ede8; color: #1a1a1a; }

.btn-danger {
  background: transparent;
  color: #555;
  border-color: transparent;
}
.btn-danger:hover:not(:disabled) { background: #fff1f2; color: #be123c; }

.btn-on-dark {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-color: rgba(255,255,255,0.2);
}
.btn-on-dark:hover:not(:disabled) { background: rgba(255,255,255,0.2); }
.btn-on-dark.active { background: rgba(255,255,255,0.25); outline: 1.5px solid rgba(255,255,255,0.5); }
.btn-on-dark:focus-visible { outline-color: rgba(255,255,255,0.8); }

/* ============================================
   LAYOUT — 3-column
============================================ */
.app-body { display: flex; flex: 1; overflow: hidden; }

/* ============================================
   SIDEBARS
============================================ */
.sidebar {
  flex-shrink: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.25s ease, min-width 0.25s ease;
}
.sidebar-left {
  width: 268px;
  min-width: 268px;
  border-right: 1px solid #e0ddd8;
}
.sidebar-right {
  width: 300px;
  min-width: 300px;
  border-left: 1px solid #e0ddd8;
}
.sidebar-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 8px;
}
.sidebar-footer {
  padding: 11px 16px 14px;
  border-top: 1px solid #f0ede8;
  background: #fafaf8;
}

/* Collapse bar */
.sidebar-collapse-bar {
  display: flex;
  align-items: center;
  padding: 5px 7px;
  flex-shrink: 0;
  border-bottom: 1px solid #f0ede8;
}
.sidebar-left .sidebar-collapse-bar { justify-content: flex-end; }
.sidebar-right .sidebar-collapse-bar { justify-content: flex-start; }

.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: #767676;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sidebar-collapse-btn:hover { background: #f0ede8; color: #444; }
.sidebar-shortcut-hint {
  font-size: 10px;
  color: #bbb;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: -0.3px;
  user-select: none;
}
.sidebar.collapsed .sidebar-shortcut-hint { display: none; }
.sidebar-collapse-btn svg { transition: transform 0.25s ease; }

/* Collapsed state */
.sidebar.collapsed { width: 40px !important; min-width: 40px !important; }
.sidebar.collapsed .sidebar-content { display: none; }
.sidebar.collapsed .sidebar-collapse-bar {
  justify-content: center;
  border-bottom: none;
}
.sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
.sidebar.collapsed .sidebar-collapse-btn {
  background: #f0ede8;
  color: #777;
}
.sidebar.collapsed .sidebar-collapse-btn:hover {
  background: #e5e2dc;
  color: #444;
}

.form-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #767676;
  margin-bottom: 8px;
  margin-top: 16px;
}
.form-section-label:first-child { margin-top: 0; }
.form-section-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  margin-bottom: 8px;
}
.form-section-label-row .form-section-label {
  margin: 0;
}
.btn-history {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  color: #767676;
  cursor: pointer;
  border: none;
  background: none;
  transition: color 0.15s, background 0.15s;
}
.btn-history:hover { color: #1a1a1a; background: rgba(0,0,0,0.06); }
.btn-history.has-history { color: #1a1a1a; }

/* History panel */
.history-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.history-panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e2dd;
  margin-bottom: 8px;
}
.history-panel-title {
  font-size: 11px;
  font-weight: 600;
  color: #555;
}
.history-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.history-item {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  font-size: 11px;
  line-height: 1.4;
  color: #1a1a1a;
  transition: background 0.12s;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.history-item:hover { background: rgba(0,0,0,0.05); }
.history-item-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.history-item-meta {
  font-size: 10px;
  color: #999;
}
.history-empty {
  font-size: 11px;
  color: #999;
  padding: 16px 0;
  text-align: center;
}
.form-group { margin-bottom: 8px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #444;
  margin-bottom: 4px;
}

.form-input, .form-textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #d5d2cc;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fafaf8;
  color: #1a1a1a;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.form-input:focus, .form-textarea:focus {
  border-color: #1a1a1a;
  box-shadow: 0 0 0 3px rgba(26,26,26,0.1);
}
.form-input:focus-visible, .form-textarea:focus-visible {
  outline: 2px solid #005fcc;
  outline-offset: 0;
}
.form-input:disabled, .form-textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.form-textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.form-hint { font-size: 10.5px; color: #767676; margin-top: 4px; line-height: 1.45; }

.model-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23767676' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}
.model-select:focus-visible {
  outline: 2px solid #005fcc;
  outline-offset: 0;
}
.prompt-textarea {
  min-height: 180px;
}
.prompt-group-wrap {
  position: relative;
}
.prompt-clear-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: rgba(0,0,0,0.06);
  color: #999;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.prompt-clear-btn:hover {
  background: rgba(0,0,0,0.12);
  color: #555;
}

details.accordion {
  border-top: 1px solid #f0ede8;
  margin-top: 2px;
}
details.accordion > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 9px 0;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #767676;
  user-select: none;
  transition: color 0.12s;
}
details.accordion > summary::-webkit-details-marker { display: none; }
details.accordion > summary::marker { display: none; content: ''; }
details.accordion > summary:hover,
details.accordion[open] > summary { color: #1a1a1a; }
details.accordion > summary:focus-visible {
  outline: 2px solid #005fcc;
  outline-offset: 2px;
  border-radius: 4px;
}
.accordion-chevron {
  margin-left: auto;
  flex-shrink: 0;
  color: #aaa;
  transition: transform 0.2s, color 0.12s;
}
details.accordion > summary:hover .accordion-chevron,
details.accordion[open] > summary .accordion-chevron { color: #555; }
details.accordion[open] > summary .accordion-chevron { transform: rotate(180deg); }
.accordion-content { padding-bottom: 6px; }

.apikey-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.apikey-input-row .form-input { flex: 1; min-width: 0; }
.apikey-input-row .btn { flex-shrink: 0; }

.apikey-saved {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
}
.apikey-saved-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.apikey-saved-dot {
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  flex-shrink: 0;
}
.apikey-saved-mask {
  font-size: 12px;
  font-weight: 600;
  color: #15803d;
  font-family: 'SF Mono', 'Fira Code', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.apikey-saved-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

#reset-btn { margin-top: 6px; }

#status-inline {
  font-size: 12px;
  line-height: 1.5;
  border-radius: 6px;
  padding: 8px 10px;
  margin-top: 10px;
  display: none;
}
#status-inline.show { display: flex; align-items: flex-start; gap: 7px; }
#status-inline.loading { background: #eef2ff; color: #3b5bdb; }
#status-inline.success { background: #ebfbee; color: #2f9e44; }
#status-inline.error   { background: #fff5f5; color: #a12020; }

.status-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(59,91,219,0.25);
  border-top-color: #3b5bdb;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ============================================
   VIEW TOGGLE & EDIT BAR
============================================ */
#view-toggle {
  position: sticky;
  top: 0;
  z-index: 10;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 14px 0 12px;
  background: linear-gradient(to bottom, #eceae5 82%, transparent);
  pointer-events: none;
}
#view-toggle.hidden { display: none; }
.vt-group.hidden { display: none; }

.vt-group {
  display: flex;
  background: rgba(26,26,26,0.1);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
  pointer-events: auto;
}
.vt-btn {
  padding: 6px 20px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.2;
  color: rgba(26,26,26,0.65);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.vt-btn.vt-active {
  background: #fff;
  color: #1a1a1a;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.vt-btn:hover:not(.vt-active) { color: #1a1a1a; }
.vt-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.cv-zoom-controls {
  position: fixed;
  bottom: 16px;
  right: calc(300px + 16px);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 8px;
  padding: 4px 6px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
  transition: right 0.25s ease;
}
.cv-zoom-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: rgba(26,26,26,0.7);
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.cv-zoom-btn:hover {
  background: rgba(255,255,255,0.8);
  color: #1a1a1a;
}
.cv-zoom-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(26,26,26,0.8);
  min-width: 40px;
  text-align: center;
}

/* Layout controls (font & gap) */
.cv-layout-controls {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 8px;
  padding: 4px 6px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
  pointer-events: auto;
}
.cv-layout-control {
  display: flex;
  align-items: center;
  gap: 2px;
}
.cv-layout-control + .cv-layout-control {
  margin-left: 2px;
  padding-left: 6px;
  border-left: 1px solid rgba(0,0,0,0.08);
}
.cv-layout-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(26,26,26,0.55);
  margin-right: 2px;
  user-select: none;
}
.cv-layout-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: rgba(26,26,26,0.6);
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.cv-layout-btn:hover {
  background: rgba(0,0,0,0.06);
  color: #1a1a1a;
}
.cv-layout-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.cv-layout-value {
  font-size: 11px;
  font-weight: 600;
  color: rgba(26,26,26,0.7);
  min-width: 32px;
  text-align: center;
  user-select: none;
}
.cv-layout-reset {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: rgba(26,26,26,0.35);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  margin-left: 2px;
}
.cv-layout-reset:hover {
  background: rgba(0,0,0,0.06);
  color: #1a1a1a;
}
.cv-layout-reset:disabled {
  opacity: 0;
  pointer-events: none;
}

#cv-pages-wrap {
  transform-origin: top center;
  transition: transform 0.2s ease;
}

/* Inline editing — click to edit, check to save, close to reset */
.cv-section-with-ai {
  position: relative;
  width: 100%;
  min-width: 0;
}
.cv-section-with-ai .cv-inline-editable { width: 100%; min-width: 0; }
.cv-ai-btn {
  position: absolute;
  right: -30px;
  top: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.12);
  color: #4f46e5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  opacity: 0.7;
}
.cv-ai-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  color: #4338ca;
  opacity: 1;
}
.cv-ai-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.cv-ai-btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(79, 70, 229, 0.3);
  border-top-color: #4f46e5;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}
.cv-ai-popover {
  position: fixed;
  z-index: 100;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  padding: 14px;
  min-width: 280px;
  max-width: 360px;
}
.cv-ai-popover-title {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 10px;
}
.cv-ai-popover textarea {
  width: 100%;
  min-height: 60px;
  padding: 8px 10px;
  border: 1px solid #d5d2cc;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 10px;
  box-sizing: border-box;
}
.cv-ai-popover textarea:focus {
  outline: 2px solid #005fcc;
  outline-offset: 0;
  border-color: #005fcc;
}
.cv-ai-popover-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.cv-ai-popover .btn { font-size: 12px; padding: 6px 12px; }

.cv-inline-editable {
  position: relative;
  cursor: pointer;
  border-radius: 4px;
  display: block;
  width: 100%;
  min-width: 0;
  transition: background 0.15s;
  overflow-wrap: break-word;
  word-break: break-word;
}
.cv-inline-editable:hover,
.cv-inline-editable:focus-visible {
  background: rgba(67, 56, 202, 0.06);
}
.cv-inline-editable:focus-visible {
  outline: 2px solid #005fcc;
  outline-offset: 1px;
}
.cv-inline-editable:hover .cv-edit-hint,
.cv-inline-editable:focus-visible .cv-edit-hint {
  opacity: 1;
}
.cv-edit-hint {
  opacity: 0;
  margin-left: 6px;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.cv-inline-editable .cv-edit-hint {
  display: inline;
  vertical-align: baseline;
}
.cv-inline-edit-active {
  cursor: default;
  background: transparent !important;
}
.cv-inline-edit-active:hover {
  background: transparent !important;
}
.cv-inline-edit-wrap {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.cv-inline-edit-wrap .cv-inline-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: normal;
  line-height: 1.4;
  background: #fafbff;
  color: #000;
  resize: vertical;
  min-height: 1.5em;
  box-sizing: border-box;
}
.cv-inline-edit-wrap .cv-inline-input:focus {
  outline: 2px solid #005fcc;
  outline-offset: 0;
  border-color: #005fcc;
}
.cv-inline-edit-wrap .cv-inline-input.cv-inline-textarea {
  min-height: 56px;
}
/* Match CV font sizes per context */
.cv-name-group .cv-inline-edit-wrap .cv-inline-input {
  font-size: 12px;
  font-weight: bold;
  letter-spacing: -0.36px;
  line-height: 1.25;
}
.cv-item .cv-inline-edit-wrap .cv-inline-input.cv-inline-textarea {
  font-size: 11px;
  line-height: 1.4;
}
.cv-skill-item .cv-inline-editable:first-child .cv-inline-input {
  font-size: 12px;
  font-weight: bold;
}
.cv-inline-edit-actions {
  display: flex;
  flex-direction: row;
  gap: 4px;
  flex-shrink: 0;
  align-items: center;
  padding-top: 2px;
}
.cv-inline-edit-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.cv-inline-edit-btn-ok {
  background: #15803d;
  color: #fff;
}
.cv-inline-edit-btn-ok:hover {
  background: #166534;
}
.cv-inline-edit-btn-cancel {
  background: #e5e7eb;
  color: #555;
}
.cv-inline-edit-btn-cancel:hover {
  background: #d1d5db;
  color: #1a1a1a;
}

/* ============================================
   PREVIEW AREA
============================================ */
.preview-area {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 0 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

#loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(236,234,229,0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  opacity: 1;
  transition: opacity 0.2s;
}
#loading-overlay.hidden { display: none; }
.loading-card {
  background: #fff;
  border-radius: 12px;
  padding: 28px 36px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.loading-card p {
  font-size: 14px;
  font-weight: 500;
  color: #444;
}
.loading-card span {
  font-size: 12px;
  color: #aaa;
}

@keyframes blink { 0%,80%,100%{opacity:0} 40%{opacity:1} }
.dot { display: inline-block; animation: blink 1.4s infinite both; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

#cv-pages {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: flex-start;
}

/* ============================================
   CV PAGE STYLES
============================================ */
#cv-pages {
  --cv-font-scale: 1;
  --cv-gap-scale: 1;
}
.cv-page {
  width: 595px;
  min-height: 842px;
  height: 842px;
  background: #fff;
  padding: 24px;
  box-shadow: 0 2px 20px rgba(0,0,0,0.13);
  font-family: Arial, Helvetica, sans-serif;
  color: #000;
  position: relative;
  overflow: hidden;
}
.cv-page.cv-page-last {
  height: auto;
  min-height: 0;
}
.cv-page-inner { display: flex; flex-direction: column; gap: calc(6px * var(--cv-gap-scale)); }
.cv-section-header-block { display: flex; flex-direction: column; gap: 0; }

.cv-contact-section { display: flex; flex-direction: column; gap: calc(4px * var(--cv-gap-scale)); }
.cv-name-group { display: flex; flex-direction: column; gap: calc(2px * var(--cv-gap-scale)); }
.cv-name { font-size: calc(18px * var(--cv-font-scale)); font-weight: bold; letter-spacing: -0.9px; line-height: 1.1; margin: 0; }
.cv-subtitle { font-size: calc(12px * var(--cv-font-scale)); font-weight: bold; letter-spacing: -0.36px; line-height: 1.25; }
.cv-section-title { font-size: calc(15px * var(--cv-font-scale)); font-weight: bold; letter-spacing: -0.45px; line-height: normal; margin: 0; }
.cv-contacts { font-size: calc(11px * var(--cv-font-scale)); font-weight: bold; line-height: 1.3; letter-spacing: -0.33px; font-style: normal; }
.cv-contacts a { color: #000; text-decoration: underline; text-underline-offset: 1.5px; }

.cv-section { display: flex; flex-direction: column; gap: calc(6px * var(--cv-gap-scale)); }
.cv-divider { width: 100%; height: 0; border-top: 1px solid #000; }

/* Screen-reader only — for accessibility & ATS, hidden visually */
.cv-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.cv-item-list { display: flex; flex-direction: column; gap: calc(4px * var(--cv-gap-scale)); }

.cv-item { display: flex; flex-direction: column; gap: calc(3px * var(--cv-gap-scale)); }
.cv-item-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; line-height: normal; }
.cv-item-left { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: calc(2px * var(--cv-gap-scale)); }
.cv-item-title-block { display: flex; flex-direction: column; gap: 1px; }
.cv-item-title { font-size: calc(12px * var(--cv-font-scale)); font-weight: bold; line-height: 1.2; }
.cv-item-caption { font-size: calc(10px * var(--cv-font-scale)); font-weight: normal; opacity: 0.8; line-height: 1.2; }
.cv-item-subtitle { font-size: calc(11px * var(--cv-font-scale)); font-weight: normal; line-height: 1.2; }
.cv-item-date { font-size: calc(11px * var(--cv-font-scale)); font-weight: normal; white-space: nowrap; flex-shrink: 0; line-height: 1.2; }
.cv-item-body { font-size: calc(11px * var(--cv-font-scale)); font-weight: normal; line-height: 1.35; }
.cv-item-bullets { margin: 0; padding-left: 16.5px; list-style: disc; }
.cv-item-bullets li { font-size: calc(11px * var(--cv-font-scale)); font-weight: normal; line-height: 1.35; }

.cv-skill-item { display: flex; flex-direction: column; gap: calc(2px * var(--cv-gap-scale)); }

.cv-no-bullets-hint {
  font-size: calc(11px * var(--cv-font-scale));
  opacity: 0.6;
  line-height: 1.2;
}

.cv-changed {
  outline: 1.5px solid rgba(34,197,94,0.45);
  border-radius: 3px;
  background: rgba(34,197,94,0.03);
}
.cv-req-highlight {
  background: #fef08a;
  color: #000;
  border-radius: 2px;
  padding: 0 1px;
  transition: background 0.15s;
}

/* ============================================
   ANALYSIS PANEL (Right Sidebar)
============================================ */
.analysis-accordion { border-top: none; margin-top: 0; }
.analysis-accordion + .analysis-accordion { border-top: 1px solid #f0ede8; }
.analysis-accordion > summary { padding: 8px 0; }
.analysis-accordion > .accordion-content { padding-bottom: 4px; }
.analysis-empty {
  font-size: 11.5px;
  color: #999;
  line-height: 1.5;
  padding: 4px 0;
}
#analysis-footer { padding: 6px 16px 10px; }
#analysis-status {
  font-size: 11px;
  line-height: 1.4;
}

.match-comparison {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.match-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.match-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.match-label {
  font-size: 11px;
  font-weight: 600;
  color: #555;
}
.match-pct-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.match-bar-wrap {
  width: 100%;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
}
.match-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease, background 0.2s;
}
.match-pct {
  font-size: 12px;
  font-weight: 700;
}
.match-delta {
  font-size: 11px;
  font-weight: 700;
}
.match-delta.positive { color: #16a34a; }
.match-delta.negative { color: #dc2626; }
.match-state-label {
  font-size: 11px;
  font-weight: 600;
  margin-top: 2px;
}
.changes-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.change-row {
  font-size: 11.5px;
  display: flex;
  align-items: center;
  gap: 7px;
  line-height: 1.3;
}
.change-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.change-row.is-changed { color: #15803d; }
.change-row.is-changed .change-dot { background: #22c55e; }
.change-row.is-same { color: #767676; }
.change-row.is-same .change-dot { background: #ddd; }
.changes-note {
  padding: 5px 0 2px;
  font-size: 10.5px;
  color: #999;
  border-top: 1px solid #f0ede8;
  margin-top: 4px;
}

/* --- Requirement items --- */
.req-stats {
  font-size: 12px;
  font-weight: 600;
  color: #444;
  padding: 2px 0 8px;
}
.req-stats-matched { color: #15803d; }

.req-category { margin-bottom: 10px; }
.req-category:last-child { margin-bottom: 0; }
.req-category-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
  margin-bottom: 4px;
  padding-bottom: 3px;
  border-bottom: 1px solid #f0ede8;
}

.req-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 4px;
  margin: 0 -4px;
  font-size: 12px;
  line-height: 1.3;
  border-radius: 4px;
  cursor: default;
  transition: background 0.12s;
}
.req-item:hover {
  background: rgba(254, 240, 138, 0.35);
}
.req-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.req-status-dot.present { background: #22c55e; }
.req-status-dot.missing { background: #f59e0b; }

.req-label {
  flex: 1;
  min-width: 0;
  color: #1a1a1a;
}
.req-item.is-present .req-label { color: #15803d; }
.req-item.is-missing .req-label { color: #92400e; }

.req-action-btn {
  flex-shrink: 0;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.req-action-add {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}
.req-action-add:hover { background: #dcfce7; }

.req-action-remove {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fed7aa;
}
.req-action-remove:hover { background: #ffedd5; }

.req-action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.cv-section-loading { opacity: 0.5; pointer-events: none; transition: opacity 0.2s; }

.req-action-spinner {
  width: 10px;
  height: 10px;
  border: 1.5px solid rgba(0,0,0,0.15);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

/* ============================================
   PUBLISH MODAL
============================================ */
.publish-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.publish-modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.18);
  padding: 24px;
  width: 440px;
  max-width: 90vw;
}
.publish-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.publish-modal-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: #1a1a1a;
}
.publish-modal-header .btn-icon {
  font-size: 20px;
  line-height: 1;
  color: #999;
}
.publish-modal-desc {
  font-size: 13px;
  color: #666;
  line-height: 1.5;
  margin-bottom: 16px;
}
.publish-link-section {
  margin-bottom: 16px;
}
.publish-label {
  font-size: 11px;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  display: block;
}
.publish-url-row {
  display: flex;
  gap: 8px;
}
.publish-url-input {
  flex: 1;
  padding: 8px 10px;
  font-size: 13px;
  font-family: monospace;
  border: 1px solid #d5d2cc;
  border-radius: 6px;
  background: #f8f7f5;
  color: #1a1a1a;
  min-width: 0;
}
.publish-url-input:focus {
  outline: 2px solid #005fcc;
  outline-offset: 0;
  border-color: #005fcc;
}
.publish-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.publish-unpublish-btn {
  margin-right: auto;
  color: #c92a2a !important;
}
.publish-modal-wide { width: 520px; }

/* Tabs */
.pub-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 16px;
}
.pub-tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: #888;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.pub-tab:hover { color: #333; }
.pub-tab.active { color: #1a1a1a; border-bottom-color: #1a1a1a; }
.pub-count-badge {
  background: #e5e7eb;
  color: #555;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  line-height: 1.4;
}
.pub-tab-content { display: none; }
.pub-tab-content.active { display: block; }

/* Published CVs list */
.pub-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
}
.pub-list-empty {
  font-size: 13px;
  color: #999;
  text-align: center;
  padding: 24px 0;
}
.pub-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  background: #fafafa;
}
.pub-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.pub-card-title {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pub-card-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.pub-card-badge.public { background: #dcfce7; color: #15803d; }
.pub-card-badge.restricted { background: #fef3c7; color: #92400e; }

.pub-card-url {
  font-size: 11px;
  color: #666;
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 8px;
}
.pub-card-meta {
  font-size: 11px;
  color: #999;
  margin-bottom: 8px;
}
.pub-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.pub-card-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 4px;
  border: 1px solid #d5d2cc;
  background: #fff;
  color: #333;
  cursor: pointer;
  transition: background 0.12s;
}
.pub-card-btn:hover { background: #f0f0f0; }
.pub-card-btn.danger { color: #c92a2a; border-color: #fca5a5; }
.pub-card-btn.danger:hover { background: #fef2f2; }

/* Inline edit form inside card */
.pub-card-edit {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pub-card-edit label {
  font-size: 11px;
  font-weight: 600;
  color: #555;
}
.pub-card-edit input[type="text"],
.pub-card-edit textarea {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
  border: 1px solid #d5d2cc;
  border-radius: 4px;
  box-sizing: border-box;
}
.pub-card-edit textarea { resize: vertical; }
.pub-card-edit-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.publish-visibility-section {
  margin-bottom: 16px;
}
.publish-visibility-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
.publish-radio {
  font-size: 13px;
  color: #333;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.publish-radio input { margin: 0; }
.publish-emails-section {
  margin-top: 8px;
}
.publish-emails-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid #d5d2cc;
  border-radius: 6px;
  resize: vertical;
  box-sizing: border-box;
}
.publish-emails-input:focus {
  outline: 2px solid #005fcc;
  border-color: #005fcc;
}

/* ============================================
   PASSWORD GATE
============================================ */
.password-gate {
  position: fixed;
  inset: 0;
  background: #eceae5;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.password-gate-box {
  background: #fff;
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  width: 320px;
  text-align: center;
}
.password-gate-box h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}
.password-gate-box p {
  font-size: 13px;
  color: #666;
  margin-bottom: 16px;
}
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: #333;
  background: #fff;
  border: 1px solid #dadce0;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.btn-google:hover {
  background: #f7f8f8;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.btn-signout {
  opacity: 0.7;
  font-size: 12px !important;
  padding: 6px 10px !important;
}
.btn-signout:hover { opacity: 1; }

/* ============================================
   VERSION PREVIEW BANNER
============================================ */
/* ============================================
   EDIT DEFAULT BAR
============================================ */
.edit-default-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: rgba(26,26,26,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
}
.edit-default-bar-actions {
  display: flex;
  gap: 6px;
}
.edit-default-bar .btn-ghost { color: #ccc; }
.edit-default-bar .btn-ghost:hover { color: #fff; background: rgba(255,255,255,0.1); }
.edit-default-bar .btn-primary { background: #22c55e; }
.edit-default-bar .btn-primary:hover { background: #16a34a; }

.version-preview-banner {
  position: fixed;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  font-size: 13px;
  font-weight: 500;
  color: #92400e;
}
.version-preview-actions {
  display: flex;
  gap: 6px;
}

.password-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid #d5d2cc;
  border-radius: 6px;
  margin-bottom: 12px;
  font-family: inherit;
}
.password-input:focus {
  outline: 2px solid #005fcc;
  border-color: #005fcc;
}


/* ============================================
   PRINT STYLES — ATS-optimized, accessible, no hidden layers
============================================ */
@media print {
  @page { size: A4 portrait; margin: 0; }

  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
    color: black !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  body {
    overflow: visible !important;
    height: auto !important;
    display: block !important;
  }

  /* Remove all non-CV content — no hidden layers in PDF */
  .app-header,
  .sidebar,
  .sidebar-collapse-bar,
  #loading-overlay,
  #view-toggle,
  .cv-zoom-controls,
  .cv-layout-controls,
  .cv-edit-hint,
  .cv-ai-btn,
  .cv-ai-popover,
  .cv-inline-edit-wrap,
  .cv-inline-edit-actions,
  .cv-no-bullets-hint,
  .publish-modal-overlay {
    display: none !important;
  }

  .app-body { display: block !important; overflow: visible !important; }
  .preview-area { overflow: visible !important; padding: 0 !important; display: block !important; }
  #cv-pages-wrap { transform: none !important; }
  #cv-pages { display: block !important; gap: 0 !important; }

  .cv-page {
    width: 595px !important;
    height: 842px !important;
    padding: 24px !important;
    margin: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    page-break-after: always !important;
    break-after: always !important;
    position: relative !important;
    /* Scale 595×842 preview to fill 210mm×297mm A4 page (ratio ≈ 4/3) */
    transform: scale(1.334) !important;
    transform-origin: top left !important;
  }
  .cv-page:last-child,
  .cv-page.cv-page-last {
    page-break-after: avoid !important;
    break-after: avoid !important;
    height: auto !important;
  }

  .cv-changed { outline: none !important; background: transparent !important; }
  .cv-section-with-ai { display: block !important; gap: 0 !important; padding: 0 !important; margin: 0 !important; }
  .cv-inline-editable { cursor: default !important; background: transparent !important; outline: none !important; padding: 0 !important; margin: 0 !important; border-radius: 0 !important; }
  .cv-sr-only { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; }
  .cv-divider { border-top: 1px solid #000 !important; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  /* Full opacity on all text for ATS readability */
  .cv-item-caption { opacity: 1 !important; }

  /* Ensure links are preserved and recognizable in PDF/ATS */
  .cv-contacts a { color: #000 !important; text-decoration: underline !important; }
}
