/*
 * style.css — SendLetters design system
 *
 * Sections:
 *   Base         — reset, CSS variables, typography
 *   Layout       — page container, nav, hero, footer
 *   Utilities    — spacing, flex, text, background helpers
 *   Forms        — inputs, selects, textareas, validation states
 *   Tier Selector — printed vs handwritten format picker
 *   Components   — cards, badges, buttons, pricing, FAQ, steps
 *   Page-specific — compose, confirmation, admin, dashboard
 *   Accessibility — focus rings, skip link, reduced motion
 *   Print        — print-friendly overrides
 */

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

:root {
  --ink: #171717;
  --paper: #faf8f5;
  --cream: #f5f0e8;
  --warm: #8b7355;
  --accent: #2c2c2c;
  --success: #2d6a4f;
  --warning: #92702a;
  --danger: #7c4d4f;
  --text-secondary: #555;
  --muted: #666;
  --muted-light: #999;
  --border: #e0dcd4;
  --radius: 14px;

  /* Typography scale */
  --text-xs:   clamp(11px, 2.5vw, 13px);
  --text-sm:   clamp(13px, 3vw,   15px);
  --text-base: clamp(15px, 3.5vw, 17px);
  --text-lg:   clamp(17px, 4vw,   20px);
  --text-xl:   clamp(20px, 4.5vw, 24px);
  --text-2xl:  clamp(22px, 5vw,   28px);
  --text-3xl:  clamp(26px, 6vw,   36px);
  --text-4xl:  clamp(30px, 7vw,   48px);

  /* Spacing */
  --space-page-x: clamp(16px, 4vw, 24px);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--text-base);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'DM Serif Display', Georgia, 'Times New Roman', serif;
}

a { color: var(--ink); }

/* === Layout === */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 var(--space-page-x);
}

.container-wide {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--space-page-x);
}

/* === Nav === */
nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px var(--space-page-x);
  max-width: 960px;
  margin: 0 auto;
  gap: 12px;
  flex-wrap: nowrap;
}

nav .logo {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(17px, 4vw, 20px);
  font-weight: normal;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: 0.3px;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

/* Shared nav link group used on all pages */
nav .nav-links {
  display: flex;
  gap: clamp(10px, 2.5vw, 20px);
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

nav .nav-links a {
  text-decoration: none;
  color: var(--warm);
  font-size: clamp(12px, 3vw, 14px);
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 2px;
}

nav .nav-links a:hover { color: var(--ink); }

#nav-auth {
  display: flex;
  gap: clamp(8px, 2vw, 16px);
  align-items: center;
  flex-wrap: wrap;
}

#nav-auth a {
  text-decoration: none;
  color: var(--warm);
  font-size: clamp(12px, 3vw, 14px);
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

#nav-auth a:hover { color: var(--ink); }

/* === Hero === */
.hero {
  text-align: center;
  padding: clamp(48px, 10vw, 80px) var(--space-page-x) clamp(36px, 8vw, 60px);
}

.hero h1 {
  font-size: clamp(28px, 6vw, 52px);
  font-weight: normal;
  font-style: italic;
  margin-bottom: 20px;
  line-height: 1.2;
  word-break: break-word;
  overflow-wrap: break-word;
}

.hero p {
  font-size: clamp(15px, 3.5vw, 18px);
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto 32px;
  line-height: 1.7;
  text-align: center;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 16px clamp(24px, 5vw, 40px);
  background: linear-gradient(135deg, #1a1a1a 0%, #333 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(15px, 3.5vw, 17px);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  min-height: 48px;
  text-align: center;
  white-space: normal;
  word-break: break-word;
  line-height: 1.3;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  letter-spacing: 0.2px;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,0,0,0.18); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-outline {
  background: transparent;
  color: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: none;
}

.btn-outline:hover { background: var(--ink); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,0,0,0.12); }

.btn-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  font-size: clamp(13px, 3vw, 14px);
  min-height: 44px;
  white-space: nowrap;
}

/* === Sections === */
section {
  padding: clamp(40px, 8vw, 60px) var(--space-page-x);
}

section h2 {
  font-size: clamp(20px, 5vw, 28px);
  font-weight: normal;
  text-align: center;
  margin-bottom: 16px;
  word-break: break-word;
  overflow-wrap: break-word;
}

section .subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: clamp(14px, 3vw, 16px);
  max-width: 500px;
  margin: 0 auto 40px;
  /* Only center for short subtitles — they're all short here so centering is fine */
}

/* === How It Works === */
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 32px;
  max-width: 720px;
  margin: 0 auto;
}

.step {
  text-align: center;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--warm) 0%, #6b4226 100%);
  color: #fff;
  border-radius: 50%;
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 17px;
  margin-bottom: 16px;
}

.step h3 {
  font-size: clamp(15px, 3.5vw, 18px);
  margin-bottom: 8px;
  font-weight: normal;
}

.step p {
  color: var(--text-secondary);
  font-size: clamp(13px, 3vw, 15px);
}

/* === Product Gallery === */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  max-width: 720px;
  margin: 0 auto;
}

.gallery-item {
  aspect-ratio: 4/5;
  background: var(--cream);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
  border: 1px solid var(--border);
}

/* === Pricing === */
.pricing-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 24px;
  max-width: 640px;
  margin: 0 auto;
}

.pricing-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(24px, 5vw, 32px);
  text-align: center;
  background: #fff;
  transition: border-color 0.2s, transform 0.2s ease, box-shadow 0.2s ease;
}

.pricing-card:hover { border-color: var(--ink); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.06); }

.pricing-card.featured {
  border-color: var(--ink);
  position: relative;
}

.pricing-card.featured::before {
  content: 'Most Popular';
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 12px;
  letter-spacing: 0.5px;
}

.pricing-card h3 {
  font-size: clamp(16px, 4vw, 20px);
  margin-bottom: 8px;
  font-weight: normal;
}

.pricing-card .price {
  font-size: clamp(28px, 6vw, 36px);
  margin-bottom: 16px;
}

.pricing-card ul {
  list-style: none;
  margin-bottom: 24px;
}

.pricing-card ul li {
  padding: 6px 0;
  font-size: clamp(13px, 3vw, 15px);
  color: var(--text-secondary);
  text-align: left;
}

.pricing-card ul li::before {
  content: '✓ ';
  color: var(--success);
}

.pricing-note {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: 16px;
}

.pricing-note a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
}

/* === FAQ === */
.faq {
  max-width: 600px;
  margin: 0 auto;
}

.faq-item {
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}

.faq-item h3 {
  font-size: clamp(14px, 3.5vw, 16px);
  font-weight: bold;
  margin-bottom: 8px;
  cursor: pointer;
}

.faq-item p {
  color: var(--text-secondary);
  font-size: clamp(13px, 3vw, 15px);
  line-height: 1.6;
  text-align: left;
}

/* === Meet Writer === */
.writer-section {
  text-align: center;
  background: var(--cream);
  border-radius: var(--radius);
  padding: clamp(24px, 5vw, 40px);
  max-width: 500px;
  margin: 0 auto;
}

.writer-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--border);
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

/* === Final CTA === */
.final-cta {
  text-align: center;
  padding: clamp(56px, 12vw, 96px) var(--space-page-x);
  background: var(--cream);
}

.final-cta h2 {
  font-style: italic;
  font-size: clamp(20px, 4.5vw, 28px);
  margin-bottom: 16px;
}

.final-cta p {
  color: var(--text-secondary);
  font-size: clamp(14px, 3vw, 16px);
  max-width: 480px;
  margin: 0 auto 36px;
  text-align: center;
}

/* === Footer === */
footer {
  text-align: center;
  padding: 32px 20px;
  color: var(--muted);
  font-size: 13px;
}

footer a {
  color: var(--warm);
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
}

.footer-promo {
  max-width: 600px; margin: 0 auto 24px;
  text-align: center; font-size: 15px; line-height: 1.8;
}
.footer-promo-heading { font-weight: 600; margin-bottom: 8px; }
.footer-promo a { color: var(--warm); }

/* === Shared utility classes (extracted from inline styles) === */

/* Background accent sections */
.bg-cream { background: var(--cream); }

/* Disabled/coming-soon state */
.state-disabled { opacity: 0.6; pointer-events: none; }
.btn-disabled-inline { opacity: 0.5; cursor: not-allowed; }

/* Badge for "Coming Soon" labels */
.badge-coming { font-size: 11px; background: #f0f0f0; padding: 2px 8px; border-radius: 4px; }

/* Muted helper text */
.text-muted { color: var(--muted); }
.text-muted-sm { color: var(--muted); font-size: 14px; }
.text-muted-xs { color: var(--muted); font-size: 13px; }

/* Content separators */
.divider { border: none; border-top: 1px solid var(--border); margin: 32px 0; }
.divider-sm { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* Flex row utilities */
.flex-row { display: flex; gap: 8px; flex-wrap: wrap; }
.flex-row-center { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.flex-row-end { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }

/* Spacing helpers */
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.ml-8 { margin-left: 8px; }
.text-center { text-align: center; }

/* Compose page: AI draft/polish area */
.compose-ai-box {
  margin-bottom: 24px; padding: clamp(16px, 3vw, 20px);
  background: transparent; border-radius: 0;
  border: none; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.compose-ai-label { font-weight: 600; margin-bottom: 8px; display: block; }
.compose-ai-input { flex: 1; min-width: min(200px, 100%); }
.compose-ai-btn { flex-shrink: 0; }
.compose-ai-status { font-size: 13px; color: var(--muted); margin-top: 4px; display: block; }
.compose-polish-status { font-size: 13px; color: var(--muted); margin-left: 4px; }
.compose-ai-remaining { font-size: 13px; color: var(--muted); display: block; margin-bottom: 16px; }
.compose-polish-result { margin-bottom: 24px; }
.compose-polished-text { margin-top: 8px; white-space: pre-wrap; }
.compose-submit-btn { width: 100%; font-size: 18px; }
.compose-legal { text-align: center; color: var(--muted-light, #999); font-size: 13px; margin-top: 12px; }
.compose-template-list {
  display: grid !important; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px;
}
.template-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 8px; background: #fff; border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer; transition: all 0.2s ease;
  font-family: 'Inter', sans-serif; font-size: 13px; color: var(--ink);
  text-align: center; min-height: 72px;
}
.template-card:hover {
  border-color: var(--warm); background: var(--cream);
  transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.template-card.selected { border-color: var(--warm); background: var(--cream); }
.template-card-icon { font-size: 22px; line-height: 1; }
.template-card-label { font-size: clamp(12px, 2.5vw, 13px); font-weight: 500; line-height: 1.2; }
.compose-format-note { color: var(--muted); font-size: 14px; margin-bottom: 16px; }

/* Wizard progress bar */
.wizard-progress {
  display: flex; flex-direction: row; gap: 0; margin-bottom: 32px;
  border-bottom: 1px solid rgba(139,115,85,0.2); padding-bottom: 0;
}
.wizard-step {
  flex: 1; text-align: center; padding: 14px 8px 12px; font-size: clamp(13px, 3vw, 14px);
  color: var(--muted); border-bottom: 3px solid transparent; transition: all 0.2s ease;
  display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap;
}
.wizard-step.active { color: var(--ink); border-bottom-color: var(--warm); font-weight: 600; }
.wizard-step.completed { color: var(--success); border-bottom-color: var(--success); }
.wizard-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; font-size: 12px; font-weight: 700;
  background: rgba(139,115,85,0.1); color: var(--warm); border: 1px solid rgba(139,115,85,0.3);
  flex-shrink: 0;
}
.wizard-step.active .wizard-num { background: var(--warm); color: #fff; border-color: var(--warm); }
.wizard-step.completed .wizard-num { background: var(--success); color: #fff; border-color: var(--success); }

/* Step containers */
.step-container { display: none; }
.step-container.active { display: block; }

/* Step navigation */
.step-nav { display: flex; justify-content: space-between; margin-top: 32px; gap: 16px; }

/* Letter preview on step 3 */
.letter-preview {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: clamp(24px, 5vw, 32px); font-family: Georgia, 'Times New Roman', serif;
  font-size: clamp(15px, 3.5vw, 17px); line-height: 1.8; white-space: pre-wrap;
  margin-bottom: 24px; min-height: 120px;
}

/* Address summary on step 3 */
.address-summary {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px;
  font-size: clamp(13px, 3vw, 15px); line-height: 1.6;
}
.address-summary h4 {
  font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-bottom: 8px;
}

/* Review price line */
.review-price {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; background: var(--cream); border-radius: var(--radius);
  margin-bottom: 24px; font-size: clamp(15px, 3.5vw, 17px);
}
.review-price strong { font-family: 'DM Serif Display', Georgia, serif; font-size: clamp(20px, 5vw, 24px); }

/* Confirmation page */
.confirm-page { text-align: center; }
.confirm-loading { color: var(--muted); font-size: 16px; margin-top: 60px; }
.confirm-icon { font-size: clamp(36px, 10vw, 48px); margin-bottom: 16px; }
.confirm-title { font-size: clamp(20px, 5vw, 28px); word-break: break-word; }
.confirm-subtitle { text-align: center; }
.confirm-details {
  background: var(--cream); border-radius: var(--radius); padding: clamp(16px, 4vw, 24px);
  text-align: left; max-width: 400px; margin: 32px auto; line-height: 1.8;
  font-size: clamp(14px, 3vw, 15px);
}
.confirm-recipient { word-break: break-word; }
.confirm-preview { font-style: italic; color: var(--text-secondary); margin-top: 4px; word-break: break-word; }
.confirm-timeline { color: var(--muted); font-size: clamp(13px, 3vw, 14px); margin-bottom: 24px; }
.confirm-another { color: var(--warm); font-size: clamp(13px, 3vw, 14px); }

/* Admin page */
.admin-page { max-width: 960px; }
.admin-loading { text-align: center; color: var(--muted); padding: 40px; }
.admin-letter-preview {
  background: var(--cream); padding: 16px; border-radius: var(--radius);
  margin: 8px 0 20px; white-space: pre-wrap; font-size: 15px; line-height: 1.7;
}
.admin-letter-text { white-space: pre-wrap; font-family: Georgia, serif; font-size: 14px; color: var(--text-secondary); margin: 4px 0 0; }
.admin-btn-danger { margin-left: 8px; color: var(--danger); border-color: var(--danger); }

/* Dashboard page */
.dashboard-loading { text-align: center; color: var(--muted); padding: 40px; }

/* === Forms === */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: clamp(15px, 3.5vw, 16px); /* 16px prevents iOS zoom on focus */
  background: #fff;
  color: var(--ink);
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group textarea {
  resize: vertical;
  min-height: 200px;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: #aaa;
  opacity: 1;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(23,23,23,0.08);
}

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

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 100px 120px;
  gap: 16px;
}

.word-count {
  text-align: right;
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.word-count.over { color: var(--danger); font-weight: bold; }

/* === Tier Selector === */
.tier-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.tier-option {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(14px, 3vw, 20px);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s;
  background: #fff;
}

.tier-option.selected { border-color: var(--ink); background: var(--cream); }
.tier-option:hover { border-color: var(--ink); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.tier-option h3 { font-size: clamp(14px, 3.5vw, 16px); margin-bottom: 4px; font-weight: 600; font-family: 'Inter', sans-serif; }
.tier-option .price { font-size: clamp(18px, 4vw, 22px); font-weight: bold; font-family: 'DM Serif Display', Georgia, serif; }
.tier-option p { font-size: clamp(11px, 2.5vw, 12px); color: var(--text-secondary); margin-top: 6px; }

/* === Cards (dashboard/admin) === */
.order-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(16px, 4vw, 20px);
  margin-bottom: 16px;
  background: #fff;
}

.order-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  gap: 8px;
  flex-wrap: wrap;
}

.order-num { font-weight: bold; flex-shrink: 0; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: clamp(11px, 2.5vw, 12px);
  font-weight: bold;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-pending { background: #f5f0e0; color: #7c6a3d; }
.badge-paid { background: #e0f2fe; color: #075985; }
.badge-writing { background: #dbeafe; color: #1e40af; }
.badge-mailed { background: #d1fae5; color: #065f46; }
.badge-sent { background: #d1fae5; color: #065f46; }
.badge-failed { background: #f0e4e5; color: #7c4d4f; }
.badge-refunded { background: #ede8e0; color: #7c6a55; }

.order-meta {
  font-size: clamp(12px, 3vw, 14px);
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  text-align: left;
}

.order-meta span {
  /* gap handles spacing now */
}

.order-preview {
  margin-top: 12px;
  padding: 12px;
  background: var(--cream);
  border-radius: 4px;
  font-size: clamp(13px, 3vw, 14px);
  color: var(--text-secondary);
  font-style: italic;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* === Alerts === */
.alert {
  padding: clamp(12px,3vw,14px) clamp(14px,4vw,20px);
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: clamp(14px,3vw,15px);
  word-break: break-word;
  overflow-wrap: break-word;
}

.alert-success { background: #d1fae5; color: #065f46; }
.alert-error { background: #f0e4e5; color: var(--danger); }
.alert-info { background: #dbeafe; color: #1e40af; }

/* === Page wrapper === */
.page {
  padding: clamp(24px, 5vw, 40px) var(--space-page-x);
  max-width: 720px;
  margin: 0 auto;
}

.page h1 {
  font-size: clamp(22px, 5vw, 28px);
  font-weight: normal;
  margin-bottom: 8px;
  word-break: break-word;
  overflow-wrap: break-word;
}

.page .subtitle {
  color: var(--text-secondary);
  font-size: clamp(14px, 3vw, 16px);
  margin-bottom: 32px;
  text-align: left;
}

/* === Loading === */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* === Admin table === */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th, .admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  font-weight: bold;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.admin-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.admin-filters button {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: #fff;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  cursor: pointer;
  min-height: 44px;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.admin-filters button.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

/* === Print === */
@media print {
  nav, footer, .no-print, .admin-filters, .btn { display: none !important; }

  .print-letter {
    font-family: 'DM Serif Display', Georgia, serif;
    font-size: 18px;
    line-height: 1.8;
    max-width: 600px;
    margin: 0 auto;
    padding: 40px;
  }

  .print-address {
    margin-top: 60px;
    font-size: 16px;
    line-height: 1.6;
  }
}

/* === Responsive === */
@media (max-width: 600px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 8px; }
  .form-group { margin-bottom: 12px; }
  .tier-selector { grid-template-columns: 1fr; }
  .pricing-cards { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
  .address-summary { grid-template-columns: 1fr; gap: 16px; }
  .compose-template-list { grid-template-columns: repeat(2, 1fr); }

  /* Admin table — make horizontally scrollable on mobile */
  .admin-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Modal edge-to-edge on mobile */
  #order-modal > div {
    margin: 16px;
    padding: 20px 16px;
  }
}

@media (max-width: 420px) {
  /* Very narrow: stack tier selector */
  .tier-selector { grid-template-columns: 1fr; }
}

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

/* === Focus visible for accessibility === */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--warm);
  outline-offset: 2px;
}

/* Interactive cards need focus rings for keyboard navigation */
.tier-option:focus-visible,
.use-card:focus-visible,
.occasion-card:focus-visible,
.rep-card:focus-visible {
  outline: 2px solid var(--warm);
  outline-offset: 2px;
}

/* Skip to main content — screen reader / keyboard nav */
.skip-link {
  position: absolute; top: -40px; left: 16px; z-index: 1000;
  background: var(--ink); color: #fff; padding: 8px 16px;
  border-radius: 0 0 8px 8px; font-size: 14px; text-decoration: none;
}
.skip-link:focus { top: 0; }

/* === Subtle link transitions === */
a {
  transition: color 0.2s ease;
}
