* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-hover: #f2efeb;
  --text: #1c1917;
  --text-secondary: #78716c;
  --accent: #7c2d3e;
  --accent-hover: #9b3a50;
  --accent-light: rgba(124, 45, 62, 0.08);
  --border: #e7e1db;
  --radius: 10px;
}

body {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ─── Logo ─── */
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.logo-text {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.logo-sm .logo-text {
  font-size: 1rem;
}

/* ─── Topbar ─── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
}

/* ─── Screens ─── */
.screen { display: none; }
.screen.active { display: flex; }

/* ─── UPLOAD SCREEN ─── */
#uploadScreen {
  flex-direction: column;
  min-height: 100vh;
}

.upload-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

.upload-container h1 {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

/* Examples */
.examples {
  margin-top: 48px;
  width: 100%;
  max-width: 700px;
}

.examples h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  text-align: center;
}

.examples-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.example-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.example-label {
  display: block;
  padding: 8px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
}

.example-canvas {
  width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 500px) {
  .examples-grid {
    grid-template-columns: 1fr;
  }
}

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 36px;
  font-size: 0.95rem;
}

.drop-zone {
  width: 100%;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

.drop-zone .link {
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ─── EDITOR SCREEN ─── */
#editorScreen {
  flex-direction: column;
  min-height: 100vh;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.photo-counter {
  color: var(--text-secondary);
  font-size: 0.85rem;
  flex: 1;
}

.header-right {
  display: flex;
  gap: 8px;
}

/* ─── Buttons ─── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-icon {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
}

.btn-icon:hover { background: var(--surface-hover); }

.btn-small {
  background: var(--surface-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-small:hover {
  background: var(--border);
  color: var(--text);
}

/* ─── Editor layout ─── */
.editor-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Preview */
.preview-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #eae6e1;
  overflow: auto;
  position: relative;
}

.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.35);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, opacity 0.2s;
  z-index: 5;
  opacity: 0.6;
}

.nav-btn:hover { background: rgba(0,0,0,0.6); opacity: 1; }
.nav-btn.hidden { display: none; }
.nav-prev { left: 12px; }
.nav-next { right: 12px; }

#previewCanvas {
  max-width: calc(100% - 80px);
  max-height: calc(100vh - 100px);
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  transition: transform 0.15s ease;
}

/* Preview controls (zoom + title) */
.preview-controls {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  z-index: 6;
}

.ctrl-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 5px 7px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  font-size: 0.78rem;
  transition: background 0.15s;
}

.ctrl-btn:hover { background: var(--surface-hover); }

.ctrl-label { font-weight: 500; }

.zoom-level {
  font-size: 0.75rem;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: center;
  font-weight: 600;
}

.ctrl-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

/* ─── Title Popup ─── */
.popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}

.popup-overlay.hidden { display: none !important; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.popup-card {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  width: 420px;
  max-width: 92%;
  max-height: 85vh;
  overflow-y: auto;
}

.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.popup-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.popup-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

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

.popup-body {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.popup-body > label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.popup-body input[type="text"] {
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}

.popup-body input[type="text"]:focus {
  border-color: var(--accent);
}

.font-grid-sm {
  grid-template-columns: repeat(4, 1fr);
}

/* Config panel */
.config-panel {
  width: 340px;
  min-width: 340px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  max-height: calc(100vh - 57px);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.config-section h3 {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}

/* Hidden */
.hidden { display: none !important; }

/* Mode toggle */
.mode-toggle {
  display: flex;
  gap: 6px;
}

.mode-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s, border-color 0.15s;
}

.mode-option:hover { background: var(--surface-hover); }

.mode-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-light);
}

.mode-option input[type="radio"] {
  accent-color: var(--accent);
}

/* Align toggle */
.align-toggle {
  display: flex;
  gap: 6px;
}

.pos-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  transition: background 0.15s, border-color 0.15s;
}

.pos-option:hover { background: var(--surface-hover); }

.pos-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-light);
}

.pos-option input[type="radio"] {
  accent-color: var(--accent);
}

/* Style row */
.style-row {
  display: flex;
  gap: 8px;
}

.style-row label {
  flex: 1;
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Range slider */
.range-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.range-label span {
  display: flex;
  justify-content: space-between;
}

.range-label input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Font grid */
.font-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.font-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px 6px;
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.font-option:hover { background: var(--surface-hover); }

.font-option.selected {
  border-color: var(--accent);
  background: var(--accent-light);
}

.font-preview {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.font-name {
  font-size: 0.58rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1;
}

/* Inputs */
.config-panel input[type="text"],
.config-panel select {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.config-panel input[type="text"]:focus,
.config-panel select:focus {
  border-color: var(--accent);
}

#lensCustom { margin-top: 6px; }

/* Select actions */
.select-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

/* EXIF groups */
.exif-groups {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.exif-group {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 12px;
}

.exif-group-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.exif-fields {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.exif-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  padding: 2px 0;
}

.exif-field input[type="checkbox"] {
  accent-color: var(--accent);
  flex-shrink: 0;
}

.exif-field .field-name {
  color: var(--text-secondary);
  min-width: 100px;
}

.exif-field .field-value {
  color: var(--text);
  font-weight: 500;
  word-break: break-word;
}

/* ─── Ad slots ─── */
.ad-slot {
  margin: 24px auto;
  text-align: center;
  min-height: 50px;
  background: var(--surface-hover);
  border: 1px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.75rem;
  overflow: hidden;
}

.ad-leaderboard {
  max-width: 728px;
  min-height: 90px;
}

.ad-rectangle {
  max-width: 336px;
  min-height: 280px;
}

.ad-slot.ad-hidden {
  display: none;
}

/* Placeholder text when no ad loaded */
.ad-slot::after {
  content: 'Espace publicitaire';
  opacity: 0.5;
}

.ad-slot .adsbygoogle[data-ad-status="filled"] + .ad-slot::after {
  display: none;
}

/* ─── Footer ─── */
.site-footer {
  margin-top: 32px;
  padding: 16px 0;
  text-align: center;
}

.cookie-link {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}

.cookie-link:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.footer-sep {
  color: var(--border);
  font-size: 0.8rem;
  margin: 0 2px;
}

/* ─── Cookie Banner ─── */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.1);
  padding: 20px 24px;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.cookie-banner.hidden {
  display: none !important;
}

.cookie-content {
  max-width: 800px;
  margin: 0 auto;
}

.cookie-header h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}

.cookie-header p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  line-height: 1.4;
}

.cookie-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
}

.cookie-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.cookie-toggle-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.cookie-toggle-info strong {
  font-size: 0.85rem;
  color: var(--text);
}

.cookie-toggle-info small {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* Toggle switch */
.cookie-toggle input[type="checkbox"] {
  display: none;
}

.toggle-slider {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--border);
  border-radius: 11px;
  flex-shrink: 0;
  transition: background 0.2s;
  cursor: pointer;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.cookie-toggle input:checked + .toggle-slider {
  background: var(--accent);
}

.cookie-toggle input:checked + .toggle-slider::after {
  transform: translateX(18px);
}

.toggle-slider.locked {
  background: var(--accent);
  opacity: 0.6;
  cursor: not-allowed;
}

.toggle-slider.locked::after {
  transform: translateX(18px);
}

.cookie-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-cookie-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-cookie-secondary:hover {
  background: var(--surface-hover);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .editor-layout { flex-direction: column; }

  .config-panel {
    width: 100%;
    min-width: 100%;
    max-height: none;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .preview-panel { min-height: 300px; }
  .style-row { flex-direction: column; }
  .nav-btn { width: 32px; height: 32px; }
  .nav-prev { left: 6px; }
  .nav-next { right: 6px; }

  .cookie-actions { flex-direction: column; }
  .cookie-actions button { width: 100%; }
}
