:root {
  --bg-page: #eef1ed;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-head: linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(230, 242, 236, 0.88));
  --bg-toolbar: #16302c;
  --text-main: #183131;
  --text-muted: #607473;
  --line: rgba(25, 72, 67, 0.14);
  --accent: #0f7d67;
  --accent-dark: #0b5e4e;
  --accent-soft: rgba(15, 125, 103, 0.12);
  --input-bg: rgba(255, 255, 255, 0.86);
  --shadow: 0 22px 60px rgba(24, 49, 49, 0.12);
  --shadow-soft: 0 8px 24px rgba(20, 35, 35, 0.08);
  --radius: 22px;
  --radius-sm: 14px;
  --bg-secondary: rgba(246, 248, 245, 0.92);
  --bg-hover-light: #eef6f3;
  --bg-drag-over: #e4f4ef;
  --canvas-bg: #ffffff;
  --canvas-border: rgba(16, 45, 43, 0.18);
  --preview-bg: linear-gradient(180deg, #dbe6e1 0%, #cbd8d2 100%);
  --focus-border: #4d9f90;
  --focus-shadow: rgba(77, 159, 144, 0.2);
  --error-color: #d14343;
  --disabled-bg: #9cb8b0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #111917;
    --bg-card: rgba(18, 31, 29, 0.9);
    --bg-head: linear-gradient(145deg, rgba(22, 41, 38, 0.98), rgba(15, 59, 51, 0.92));
    --bg-toolbar: #091310;
    --text-main: #e6f2ef;
    --text-muted: #93aaa4;
    --line: rgba(170, 213, 200, 0.12);
    --accent: #20c1a0;
    --accent-dark: #15957b;
    --accent-soft: rgba(32, 193, 160, 0.14);
    --input-bg: rgba(22, 39, 36, 0.88);
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
    --shadow-soft: 0 10px 26px rgba(0, 0, 0, 0.24);
    --bg-secondary: rgba(15, 24, 22, 0.9);
    --bg-hover-light: #1f322e;
    --bg-drag-over: #17362f;
    --canvas-bg: #13201d;
    --canvas-border: rgba(187, 228, 216, 0.12);
    --preview-bg: linear-gradient(180deg, #15211e 0%, #101917 100%);
    --focus-border: #53cfb2;
    --focus-shadow: rgba(83, 207, 178, 0.18);
    --error-color: #ff6b6b;
    --disabled-bg: #48675f;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Manrope', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--text-main);
  background: var(--bg-page);
  background-image:
    radial-gradient(circle at top left, rgba(15, 125, 103, 0.14), transparent 28%),
    radial-gradient(circle at bottom right, rgba(25, 91, 151, 0.12), transparent 24%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.45), transparent 45%);
  min-height: 100vh;
}

.page {
  width: min(1240px, calc(100% - 32px));
  margin: 28px auto 36px;
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(460px, 1.15fr);
  gap: 26px;
  align-items: start;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(14px);
}

.card-header {
  background: var(--bg-head);
  border-bottom: 1px solid var(--line);
  padding: 26px 28px;
}

.card-footer {
  border-top: 1px solid var(--line);
  padding: 20px 28px;
  background: var(--bg-secondary);
}

.controls-card {
  min-height: 780px;
  display: flex;
  flex-direction: column;
}

.controls-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.title-wrap h1 {
  margin: 6px 0 0;
  font-size: clamp(24px, 3vw, 32px);
  letter-spacing: 0.02em;
  line-height: 1.05;
}

.title-wrap p {
  margin: 12px 0 0;
  color: var(--text-muted);
  font-size: 15px;
  max-width: 34ch;
}

.mode-switch {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 176px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.mode-btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-main);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.mode-btn.active {
  background: linear-gradient(135deg, var(--accent) 0%, #1b9f89 100%);
  color: #ffffff;
  box-shadow: 0 10px 18px rgba(15, 125, 103, 0.22);
}

.mode-btn:disabled {
  opacity: 0.9;
  cursor: not-allowed;
}

.controls-body {
  padding: 22px 28px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field[hidden] {
  display: none;
}

.field label {
  font-size: 16px;
  font-weight: 600;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.control-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.12));
  box-shadow: var(--shadow-soft);
}

.section-heading {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.section-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

.section-copy {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.45;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.required {
  color: var(--error-color);
}

.field-inline {
  align-items: flex-start;
}

input,
select {
  height: 52px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 16px;
  color: var(--text-main);
  background: var(--input-bg);
  padding: 8px 14px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

input:focus,
select:focus {
  border-color: var(--focus-border);
  box-shadow: 0 0 0 3px var(--focus-shadow);
}

.file-picker {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 18px;
  display: grid;
  grid-template-columns: 120px 108px 1fr;
  overflow: hidden;
  background: var(--input-bg);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  box-shadow: var(--shadow-soft);
}

.file-picker.drag-over {
  border-color: var(--accent);
  background: var(--bg-drag-over);
  box-shadow: 0 0 0 4px rgba(15, 125, 103, 0.12);
}

.file-label,
.file-btn,
.file-name {
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 15px;
}

.file-label,
.file-btn {
  border-right: 1px solid var(--line);
}

.file-btn {
  cursor: pointer;
  user-select: none;
  justify-content: center;
  background: rgba(15, 125, 103, 0.08);
  color: var(--accent);
  font-weight: 700;
}

.file-btn:hover {
  background: var(--bg-hover-light);
}

.file-name {
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.multiple-photo-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.multiple-photo-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-secondary);
  box-shadow: var(--shadow-soft);
}

.multiple-photo-name {
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
}

.multiple-photo-index {
  display: block;
  margin-bottom: 2px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.multiple-photo-filename {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multiple-photo-input {
  width: 100%;
  min-width: 0;
  text-align: center;
}

.field-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.45;
}

.controls-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
    var(--bg-secondary);
}

.submit-btn,
.download-btn {
  border: 0;
  background: linear-gradient(135deg, var(--accent) 0%, #1aa088 100%);
  color: #ffffff;
  border-radius: 16px;
  padding: 13px 30px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 16px 28px rgba(15, 125, 103, 0.24);
}

.secondary-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-main);
  border-radius: 14px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
  box-shadow: var(--shadow-soft);
}

.secondary-btn:hover {
  background: var(--bg-hover-light);
  transform: translateY(-2px);
}

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

.submit-btn:hover,
.download-btn:hover {
  background: var(--accent-dark);
  transform: translateY(-2px);
  box-shadow: 0 20px 32px rgba(15, 125, 103, 0.28);
}

.submit-btn:active,
.download-btn:active {
  transform: translateY(0);
}

.download-btn:disabled {
  background: var(--disabled-bg);
  cursor: not-allowed;
}

.print-btn:disabled {
  color: var(--text-muted);
  background: var(--bg-hover-light);
  cursor: not-allowed;
}

.branding-copy {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.branding-label {
  color: var(--accent);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.branding-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(37, 211, 102, 0.22);
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.16), rgba(15, 125, 103, 0.08));
  color: #128c4a;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: var(--shadow-soft);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.branding-link:hover,
.branding-link:focus-visible {
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.24), rgba(15, 125, 103, 0.14));
  box-shadow: 0 16px 28px rgba(18, 140, 74, 0.18);
  transform: translateY(-2px);
  outline: none;
}

.branding-link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: #25d366;
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.branding-link-number {
  color: inherit;
}

.preview-card {
  display: flex;
  flex-direction: column;
  min-height: 780px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}

.preview-header h2 {
  margin: 8px 0 0;
  font-size: clamp(24px, 3vw, 30px);
}

.preview-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  max-width: 26ch;
  text-align: right;
}

.preview-toolbar {
  height: 64px;
  background: var(--bg-toolbar);
  color: #f5f5f5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
}

.toolbar-page {
  font-weight: 700;
  min-width: 64px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.06);
}

.toolbar-btn {
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  color: #f5f5f5;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 19px;
  font-weight: 700;
  cursor: pointer;
}

.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.zoom-label {
  margin-left: auto;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.preview-shell {
  position: relative;
  height: 580px;
  overflow: auto;
  background: var(--preview-bg);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.empty-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 16px;
  padding: 20px;
}

#previewCanvas {
  display: none;
  background: var(--canvas-bg);
  border: 1px solid var(--canvas-border);
  transform-origin: top left;
  border-radius: 12px;
  box-shadow: 0 24px 36px rgba(10, 18, 18, 0.15);
}

.preview-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  background: var(--bg-secondary);
}

.crop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 22, 34, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  z-index: 50;
  overflow: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.crop-overlay.active {
  opacity: 1;
  visibility: visible;
}

.crop-card {
  width: min(520px, 100%);
  max-height: calc(100dvh - 32px);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.crop-overlay.active .crop-card {
  transform: scale(1);
}

.crop-header {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 14px 18px;
  background: var(--bg-head);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 600;
}

.crop-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.crop-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.crop-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  overflow: auto;
}

#cropCanvas {
  width: 100%;
  max-height: calc(100dvh - 170px);
  height: auto;
  background: var(--preview-bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: grab;
  touch-action: none;
}

#cropCanvas.dragging {
  cursor: grabbing;
}

.crop-controls {
  width: 100%;
  display: grid;
  grid-template-columns: 60px 1fr;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.crop-controls input[type="range"] {
  height: 28px;
}

.crop-help {
  grid-column: 1 / -1;
  font-size: 13px;
  color: var(--text-muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  border: 0;
  padding: 0;
  clip: rect(0 0 0 0);
  overflow: hidden;
}

@media (max-width: 960px) {
  .page {
    grid-template-columns: 1fr;
  }
  .controls-card,
  .preview-card {
    min-height: auto;
  }
  .preview-shell {
    height: 440px;
  }
  .preview-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .preview-header p {
    text-align: left;
  }
}

@media (max-width: 560px) {
  .page {
    width: min(100%, calc(100% - 18px));
    margin-top: 18px;
  }
  .card-header,
  .card-footer,
  .controls-body {
    padding-left: 18px;
    padding-right: 18px;
  }
  .controls-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .mode-switch {
    width: 100%;
  }
  .field-grid {
    grid-template-columns: 1fr;
  }
  .file-picker {
    grid-template-columns: 1fr;
  }
  .file-label,
  .file-btn {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    min-height: 48px;
  }
  .multiple-photo-row {
    grid-template-columns: 1fr;
  }
  .branding-copy {
    flex-direction: column;
  }
  .branding-link {
    width: 100%;
    justify-content: center;
  }
}

/* ── Love Banner Popup Styles ── */
@keyframes slideInDown {
  from { opacity: 0; transform: translate(-50%, -50%) translateY(-60px) scale(0.9); }
  to   { opacity: 1; transform: translate(-50%, -50%) translateY(0) scale(1); }
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  25%       { transform: scale(1.1); }
  50%       { transform: scale(1); }
}

@keyframes shimmer {
  0%, 100% { background-position: -1000px 0; }
  50%       { background-position: 1000px 0; }
}

.love-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  animation: slideInDown 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.love-banner-content {
  position: relative;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 25%, #f093fb 50%, #4facfe 75%, #00f2fe 100%);
  background-size: 400% 400%;
  animation: shimmer 8s ease infinite;
  border-radius: 20px;
  padding: 40px 50px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 40px rgba(102, 126, 234, 0.4);
  text-align: center;
  min-width: 320px;
  max-width: 500px;
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

/* ── FIXED: banner close button – works on both mobile and desktop ── */
.love-banner-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: rgba(255, 255, 255, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.6);
  color: white;
  font-size: 22px;
  line-height: 1;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
  font-weight: 700;
  /* Prevent 300ms tap delay on mobile */
  touch-action: manipulation;
  /* Ensure the button is always on top and tappable */
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.love-banner-close:hover,
.love-banner-close:focus-visible {
  background: rgba(255, 255, 255, 0.55);
  transform: rotate(90deg) scale(1.1);
  border-color: rgba(255, 255, 255, 0.9);
  outline: none;
}

.love-banner-close:active {
  transform: rotate(90deg) scale(0.95);
}

.love-banner-heart {
  font-size: 60px;
  animation: heartbeat 1.5s ease infinite;
  margin-bottom: 15px;
  display: block;
}

.love-banner-title {
  margin: 0 0 10px 0;
  font-size: 32px;
  font-weight: 700;
  color: white;
  text-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.love-banner-text {
  margin: 0 0 20px 0;
  font-size: 24px;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-weight: 600;
}

.love-banner-whatsapp {
  display: inline-block;
  background: rgba(255, 255, 255, 0.95);
  color: #667eea;
  padding: 12px 28px;
  border-radius: 50px;
  text-decoration: none;
  font-weight: 700;
  font-size: 16px;
  transition: all 0.3s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  border: 2px solid white;
  cursor: pointer;
  touch-action: manipulation;
}

.love-banner-whatsapp:hover {
  background: white;
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  color: #764ba2;
}

.love-banner-whatsapp span {
  margin-right: 8px;
  font-size: 18px;
}

@media (max-width: 600px) {
  .love-banner-content {
    padding: 30px 25px;
    min-width: 280px;
    max-width: calc(100vw - 30px);
  }
  .love-banner-title { font-size: 26px; }
  .love-banner-text  { font-size: 20px; }
  .love-banner-heart { font-size: 50px; }
  .love-banner-whatsapp { font-size: 14px; padding: 10px 22px; }
  .love-banner-close {
    width: 44px;
    height: 44px;
    font-size: 20px;
    top: 10px;
    right: 10px;
  }
}
