/* ===== Custom Properties ===== */
:root {
  --color-bg: #F5F0EB;
  --color-bg-gradient: linear-gradient(145deg, #F5F0EB 0%, #E8E0D8 100%);
  --color-surface: #FAFAF9;
  --color-surface-hover: #FFFFFF;
  --color-border: #D6D3CD;
  --color-border-focus: #3D405B;
  --color-text: #2C2C2C;
  --color-text-secondary: #6B6B6B;
  --color-text-muted: #9A9A9A;
  --color-accent: #3D405B;
  --color-accent-hover: #2E3047;
  --color-accent-light: rgba(61, 64, 91, 0.08);
  --color-link: #3D405B;
  --color-link-hover: #2E3047;
  --color-shadow: rgba(61, 64, 91, 0.06);
  --color-shadow-hover: rgba(61, 64, 91, 0.12);
  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-card: 0 1px 3px var(--color-shadow), 0 4px 14px var(--color-shadow);
  --shadow-card-hover: 0 2px 8px var(--color-shadow-hover), 0 8px 24px var(--color-shadow);
  --transition-base: 0.2s ease;
  --transition-slow: 0.35s ease;
}

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

body {
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg-gradient);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Layout ===== */
.container {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 48px 20px 64px;
}

/* ===== Header ===== */
.header {
  text-align: center;
  margin-bottom: 32px;
}

.header h1 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.85rem;
  color: var(--color-accent);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  margin-top: 6px;
  font-weight: 400;
}

/* ===== Cards ===== */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition-slow);
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
}

.card h2 {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.15rem;
  color: var(--color-accent);
  margin-bottom: 16px;
}

.card-section {
  margin-bottom: 22px;
}

.card-section:last-of-type {
  margin-bottom: 24px;
}

/* ===== Field Labels ===== */
.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

/* ===== Custom Select ===== */
.select-wrapper {
  position: relative;
}

.select-wrapper select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 12px 40px 12px 16px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
  outline: none;
}

.select-wrapper select:hover {
  border-color: var(--color-text-muted);
}

.select-wrapper select:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px var(--color-accent-light);
}

.select-arrow {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--color-text-muted);
  pointer-events: none;
}

/* ===== Custom File Input ===== */
.file-input-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 20px;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color var(--transition-base), background var(--transition-base);
  text-align: center;
}

.file-input-label:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}

.file-input-label:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.upload-icon {
  width: 32px;
  height: 32px;
  color: var(--color-text-muted);
  transition: color var(--transition-base);
}

.file-input-label:hover .upload-icon {
  color: var(--color-accent);
}

.file-input-text {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: color var(--transition-base);
}

.file-input-label:hover .file-input-text {
  color: var(--color-accent);
}

#imageInput {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== Download Button ===== */
#downloadButton {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: #FFFFFF;
  background: var(--color-accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-base), transform var(--transition-base), box-shadow var(--transition-base);
}

#downloadButton:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(61, 64, 91, 0.25);
}

#downloadButton:active {
  transform: translateY(0);
  box-shadow: none;
}

.btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ===== Instructions ===== */
#instructions ol {
  list-style: none;
  counter-reset: steps;
  padding: 0;
}

#instructions li {
  counter-increment: steps;
  position: relative;
  padding-left: 36px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  line-height: 1.55;
}

#instructions li:last-child {
  margin-bottom: 0;
}

#instructions li::before {
  content: counter(steps);
  position: absolute;
  left: 0;
  top: 1px;
  width: 24px;
  height: 24px;
  background: var(--color-accent-light);
  color: var(--color-accent);
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#instructions a {
  color: var(--color-link);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition-base);
}

#instructions a:hover {
  border-bottom-color: var(--color-link-hover);
}

/* ===== Preview ===== */
.preview-card {
  text-align: center;
}

.canvas-wrapper {
  display: flex;
  justify-content: center;
  padding: 8px 0;
}

#previewCanvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
}

/* ===== Responsive ===== */
@media (max-width: 560px) {
  .container {
    padding: 32px 16px 48px;
  }

  .header h1 {
    font-size: 1.55rem;
  }

  .card {
    padding: 22px;
    border-radius: var(--radius-md);
  }
}
