/* Fusion: Fraunces display (a4) + Inter body + dusty rose palette (a2) + warm cream (a) */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,500;0,9..144,700;1,9..144,400&family=Inter:wght@400;500&display=swap');

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

:root {
  --bg: #FDFCFA;
  --surface: #F5F1EC;
  --text: #2D2A26;
  --text-secondary: #9A8F82;
  --border: #E6E0D8;
  --accent: #B5706A;
  --accent-hover: #9A5B55;
  --error: #B54234;
  --error-bg: #FDF0EE;
  --radius: 8px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body { font-family: var(--font-body); background: var(--bg); color: var(--text); line-height: 1.6; font-size: 15px; overflow: hidden; height: 100vh; }
.container { max-width: 600px; margin: 0 auto; padding: 0 24px; height: 100vh; display: flex; flex-direction: column; }
.progress { font-size: 0.7rem; color: var(--text-secondary); padding: 20px 0 0; letter-spacing: 0.15em; text-transform: uppercase; flex-shrink: 0; }
.wizard-viewport { flex: 1; overflow: hidden; position: relative; }
.wizard-track { transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1); will-change: transform; }
.step { height: calc(100vh - 80px); display: flex; flex-direction: column; justify-content: center; padding: 20px 0; }
.step-options { justify-content: flex-start; padding-top: 48px; overflow-y: auto; }
.step-output { justify-content: flex-start; padding-top: 24px; overflow-y: auto; }
.step-top { margin-bottom: 12px; flex-shrink: 0; }

.step-label { font-family: var(--font-display); font-size: 1.85rem; font-weight: 700; margin-bottom: 24px; line-height: 1.2; flex-shrink: 0; letter-spacing: -0.01em; }

textarea, input[type="text"] { width: 100%; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.95rem; font-family: var(--font-body); background: #fff; color: var(--text); transition: border-color 0.2s, box-shadow 0.2s; }
textarea:focus, input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(181, 112, 106, 0.08); }
textarea { resize: vertical; flex-shrink: 0; }
textarea::placeholder, input::placeholder { color: var(--text-secondary); opacity: 0.6; }

/* Voice input */
.textarea-wrap { position: relative; }
.textarea-wrap textarea { padding-right: 44px; }
.btn-mic { position: absolute; right: 8px; bottom: 8px; width: 32px; height: 32px; border: none; border-radius: 50%; background: var(--surface); color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; }
.btn-mic:hover { background: var(--border); color: var(--text); }
.btn-mic.listening { background: var(--accent); color: #fff; animation: micPulse 1.5s ease infinite; }
@keyframes micPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(181, 112, 106, 0.4); } 50% { box-shadow: 0 0 0 8px rgba(181, 112, 106, 0); } }

.step-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; flex-shrink: 0; }
.step-nav-right { display: flex; align-items: center; gap: 12px; }
.step-hint { font-size: 0.7rem; color: var(--text-secondary); }

.btn-next { padding: 10px 26px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); font-size: 0.9rem; font-family: var(--font-body); font-weight: 500; cursor: pointer; transition: background 0.2s; }
.btn-next:hover { background: var(--accent-hover); }
.btn-back { background: none; border: none; color: var(--text-secondary); font-family: var(--font-body); font-size: 0.85rem; cursor: pointer; padding: 4px 0; transition: color 0.2s; }
.btn-back:hover { color: var(--text); }

.options-grid { display: flex; gap: 24px; margin-bottom: 20px; flex-wrap: wrap; }
.option-group { margin-bottom: 12px; }
.option-label { display: block; font-size: 0.65rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-secondary); margin-bottom: 8px; }

.pills { display: flex; gap: 6px; }
.pill { padding: 7px 16px; border: 1px solid var(--border); border-radius: 24px; background: #fff; font-family: var(--font-body); font-size: 0.8rem; cursor: pointer; transition: all 0.2s; color: var(--text); }
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.email-fields { margin-bottom: 16px; }
.email-row { display: flex; gap: 10px; }
.email-input { flex: 1; padding: 10px 14px; font-size: 0.85rem; }
.optional-tag { font-weight: 400; color: var(--text-secondary); opacity: 0.6; text-transform: none; letter-spacing: 0; }

/* Research phase */
.research-phase { padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.research-phase.fade-out { opacity: 0; transition: opacity 0.6s ease; }
.research-steps { display: flex; flex-direction: column; gap: 16px; }
.research-step { display: flex; align-items: flex-start; gap: 12px; opacity: 0; animation: fadeSlideIn 0.4s ease forwards; }
.research-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: var(--border); }
.research-step.searching .research-dot { background: var(--accent); animation: pulse 1.2s ease infinite; }
.research-step.found .research-dot { background: var(--accent); }
.research-step.writing .research-dot { background: var(--accent); animation: pulse 1.2s ease infinite; }
.research-label { font-size: 0.85rem; font-weight: 500; color: var(--text); }
.research-detail { font-size: 0.75rem; color: var(--text-secondary); margin-top: 4px; line-height: 1.4; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.4; transform: scale(0.7); } }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.expandable { margin-bottom: 20px; }
.expand-toggle { background: none; border: none; color: var(--accent); font-family: var(--font-body); font-size: 0.85rem; cursor: pointer; padding: 4px 0; transition: opacity 0.2s; }
.expand-toggle:hover { opacity: 0.7; }

.btn-generate { width: 100%; padding: 14px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); font-size: 0.95rem; font-weight: 500; font-family: var(--font-body); cursor: pointer; transition: background 0.2s; }
.btn-generate:hover { background: var(--accent-hover); }
.btn-generate:disabled { opacity: 0.4; cursor: not-allowed; }

.subject-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; flex-shrink: 0; }
.subject-prefix { font-size: 0.7rem; color: var(--text-secondary); flex-shrink: 0; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; }
.subject-text { font-family: var(--font-display); font-size: 0.95rem; font-weight: 500; flex: 1; min-width: 0; word-break: break-word; }
.btn-copy-small { padding: 3px 10px; background: #fff; border: 1px solid var(--border); border-radius: 6px; font-family: var(--font-body); font-size: 0.6rem; cursor: pointer; flex-shrink: 0; transition: all 0.2s; text-transform: uppercase; letter-spacing: 0.05em; }
.btn-copy-small:hover { border-color: var(--accent); color: var(--accent); }

.intro-body { white-space: pre-wrap; line-height: 1.8; font-size: 0.95rem; font-family: var(--font-body); padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; min-height: 120px; flex: 1; overflow-y: auto; outline: none; margin-bottom: 16px; }
.intro-body:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(181, 112, 106, 0.08); }
.intro-body.streaming::after { content: '\2588'; animation: blink 0.7s step-end infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

.output-actions { display: flex; gap: 8px; flex-wrap: wrap; flex-shrink: 0; padding-bottom: 8px; }
.btn-action { padding: 8px 16px; background: #fff; color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.8rem; font-family: var(--font-body); cursor: pointer; transition: all 0.2s; }
.btn-action:hover { border-color: var(--accent); color: var(--accent); }

.skill-promo { font-size: 0.75rem; color: var(--text-secondary); text-align: center; padding: 10px 0 4px; flex-shrink: 0; opacity: 0; animation: fadeSlideIn 0.5s ease 0.3s forwards; }
.skill-promo a { color: var(--accent); text-decoration: none; font-weight: 500; }
.skill-promo a:hover { text-decoration: underline; }

.error { background: var(--error-bg); border: 1px solid #F5C6C0; color: var(--error); padding: 12px 16px; border-radius: var(--radius); margin-top: 16px; font-size: 0.85rem; }

.step-hero { justify-content: center; align-items: center; text-align: center; }
.hero-content { max-width: 440px; }
.hero-title { font-family: var(--font-display); font-size: 3rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 16px; line-height: 1.1; }
.hero-subtitle { font-size: 1.1rem; color: var(--text); margin-bottom: 12px; line-height: 1.5; }
.hero-description { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 32px; line-height: 1.6; }
.hero-content .btn-generate { max-width: 280px; margin: 0 auto; }
.btn-example { display: block; margin: 10px auto 0; background: none; border: none; color: var(--accent); font-family: var(--font-body); font-size: 0.85rem; cursor: pointer; padding: 6px 12px; transition: opacity 0.2s; }
.btn-example:hover { opacity: 0.7; }
.nav-hint { display: block; margin-top: 12px; font-size: 0.7rem; color: var(--text-secondary); }

footer { text-align: center; padding: 16px 0; color: var(--text-secondary); font-size: 0.7rem; flex-shrink: 0; }

@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.shake { animation: shake 0.4s ease; }
.hidden { display: none !important; }

@media (max-width: 600px) {
  .container { padding: 0 20px; }
  .step-label { font-size: 1.45rem; }
  .hero-title { font-size: 2.2rem; }
  .hero-subtitle { font-size: 1rem; }
  .options-grid { flex-direction: column; gap: 12px; }
  .email-row { flex-direction: column; }
  .output-actions { flex-direction: column; }
  .output-actions .btn-action { width: 100%; text-align: center; }
}
