:root {
  --parchment: #F5F0E8;
  --parchment-dark: #E8E0D0;
  --ink: #1a1a1a;
  --navy: #1a1a2e;
  --gold: #C5A55A;
  --gold-light: #D4B96A;
  --maroon: #6B1D1D;
  --cream: #FAF7F0;
  --section-bg: #FDFCF9;
}

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

body {
  font-family: 'Crimson Pro', Georgia, serif;
  background-color: var(--parchment);
  color: var(--ink);
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(197, 165, 90, 0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(107, 29, 29, 0.04) 0%, transparent 50%),
    linear-gradient(180deg, #F5F0E8 0%, #EDE6D6 100%);
}

.font-display {
  font-family: 'Playfair Display', Georgia, serif;
}

.font-body {
  font-family: 'Crimson Pro', Georgia, serif;
}

/* Watermark overlay */
.watermark-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.watermark-text {
  position: absolute;
  font-family: 'Playfair Display', serif;
  font-size: 80px;
  font-weight: 900;
  color: rgba(197, 165, 90, 0.03);
  transform: rotate(-35deg);
  white-space: nowrap;
  letter-spacing: 20px;
  user-select: none;
}

/* Seal watermark */
.seal-watermark {
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  border: 4px double rgba(197, 165, 90, 0.08);
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 0;
}

.seal-watermark::before {
  content: '';
  position: absolute;
  top: 15px;
  left: 15px;
  right: 15px;
  bottom: 15px;
  border-radius: 50%;
  border: 2px solid rgba(197, 165, 90, 0.06);
}

.seal-watermark::after {
  content: '★';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 60px;
  color: rgba(197, 165, 90, 0.06);
}

/* Ornamental divider */
.ornament {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
}

.ornament::before,
.ornament::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
}

.ornament-diamond {
  width: 8px;
  height: 8px;
  background: var(--gold);
  transform: rotate(45deg);
  flex-shrink: 0;
}

/* Double border sections */
.dossier-section {
  border: 2px solid var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: 3px;
  background: var(--section-bg);
  position: relative;
}

.dossier-section::before {
  content: '';
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  border: 1px solid rgba(26, 26, 26, 0.15);
  pointer-events: none;
}

/* Section header rule */
.section-header {
  position: relative;
  padding-bottom: 8px;
  margin-bottom: 16px;
}

.section-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(to right, var(--navy), var(--gold), var(--navy));
}

/* Form field styling */
.form-field textarea {
  font-family: 'Crimson Pro', Georgia, serif;
  font-size: 16px;
  background: var(--cream);
  border: 1px solid #8B8578;
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: vertical;
}

.form-field textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(197, 165, 90, 0.2);
}

.form-field textarea::placeholder {
  font-style: italic;
  color: #9B9488;
}

/* Stamp effect */
.classified-stamp {
  position: relative;
  display: inline-block;
  padding: 4px 16px;
  border: 3px solid var(--maroon);
  color: var(--maroon);
  font-family: 'Playfair Display', serif;
  font-weight: 900;
  letter-spacing: 4px;
  transform: rotate(-3deg);
  opacity: 0.7;
}

.eyes-only-stamp {
  position: fixed;
  bottom: 80px;
  right: 20px;
  padding: 6px 18px;
  border: 2px solid rgba(107, 29, 29, 0.15);
  color: rgba(107, 29, 29, 0.12);
  font-family: 'Playfair Display', serif;
  font-weight: 900;
  font-size: 14px;
  letter-spacing: 6px;
  transform: rotate(-12deg);
  pointer-events: none;
  z-index: 1000;
  user-select: none;
}

/* Generate button */
.generate-btn {
  background: var(--navy);
  color: var(--gold-light);
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  letter-spacing: 3px;
  border: 2px solid var(--gold);
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.generate-btn:hover:not(:disabled) {
  background: #252547;
  box-shadow: 0 0 20px rgba(197, 165, 90, 0.3), inset 0 0 20px rgba(197, 165, 90, 0.1);
  transform: translateY(-1px);
}

.generate-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.regenerate-btn {
  background: var(--maroon);
  color: var(--cream);
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  letter-spacing: 2px;
  border: 2px solid #8B3030;
  transition: all 0.3s;
}

.regenerate-btn:hover {
  background: #7B2525;
  box-shadow: 0 0 15px rgba(107, 29, 29, 0.3);
}

/* Flag frame */
.flag-frame {
  border: 3px solid var(--ink);
  box-shadow:
    inset 0 0 0 1px rgba(197, 165, 90, 0.3),
    4px 4px 12px rgba(0, 0, 0, 0.15),
    0 0 0 6px var(--parchment-dark),
    0 0 0 8px rgba(26, 26, 26, 0.2);
}

/* Loading animation */
@keyframes pulse-gold {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.loading-dots span {
  animation: pulse-gold 1.4s infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Fade in animation for sections */
@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-animate {
  animation: fadeSlideIn 0.6s ease-out forwards;
}

.section-animate:nth-child(1) { animation-delay: 0s; }
.section-animate:nth-child(2) { animation-delay: 0.15s; }
.section-animate:nth-child(3) { animation-delay: 0.3s; }
.section-animate:nth-child(4) { animation-delay: 0.45s; }
.section-animate:nth-child(5) { animation-delay: 0.6s; }
.section-animate:nth-child(6) { animation-delay: 0.75s; }
.section-animate:nth-child(7) { animation-delay: 0.9s; }

/* Portrait frame */
.portrait-frame {
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
}

/* Label styling */
.field-label {
  font-variant: small-caps;
  letter-spacing: 1.5px;
  font-weight: 600;
  color: #4A463E;
  border-bottom: 1px solid rgba(139, 133, 120, 0.3);
  padding-bottom: 2px;
  display: inline-block;
  margin-bottom: 6px;
}

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

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(197, 165, 90, 0.3);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

/* Timeline */
.timeline-item {
  position: relative;
  padding-left: 24px;
  border-left: 2px solid var(--gold);
  margin-left: 8px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 6px;
  width: 10px;
  height: 10px;
  background: var(--gold);
  border-radius: 50%;
  border: 2px solid var(--navy);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--parchment);
}

::-webkit-scrollbar-thumb {
  background: rgba(197, 165, 90, 0.4);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(197, 165, 90, 0.6);
}

/* Retry button */
.retry-btn {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-family: 'Crimson Pro', serif;
  cursor: pointer;
  padding: 4px 12px;
  transition: all 0.2s;
}

.retry-btn:hover {
  background: rgba(197, 165, 90, 0.1);
}

/* Image loading */
.img-loading {
  background: repeating-linear-gradient(
    45deg,
    rgba(197, 165, 90, 0.05),
    rgba(197, 165, 90, 0.05) 10px,
    transparent 10px,
    transparent 20px
  );
}