/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --surface-alt: #f5f2ee;
  --border: #e2ddd6;
  --text: #2d2a26;
  --text-secondary: #6b6560;
  --text-muted: #9e9890;
  --accent: #ff6b35;
  --accent-hover: #e55a28;
  --accent-light: #fff0eb;
  --accent-glow: rgba(255,107,53,0.15);
  --success: #2d9d5b;
  --success-light: #edf7f1;
  --warning: #d4a017;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.10);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --max-width: 1200px;
}
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.6; -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
.container { width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }
.skip-link { position: absolute; top: -100%; left: 16px; background: var(--accent); color: white; padding: 8px 16px; border-radius: var(--radius-sm); z-index: 9999; font-weight: 600; }
.skip-link:focus { top: 16px; }

/* === Header === */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: var(--text); }
.logo:hover { text-decoration: none; color: var(--text); }
.logo-accent { color: var(--accent); }
.logo-icon { color: var(--text); }
.nav { display: flex; gap: 24px; align-items: center; }
.nav a { font-size: 0.9rem; color: var(--text-secondary); font-weight: 500; }
.nav a:hover { color: var(--text); text-decoration: none; }

/* === Hero === */
.hero { padding: 64px 0 48px; text-align: center; background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%); }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; line-height: 1.2; max-width: 640px; margin: 0 auto 16px; letter-spacing: -0.02em; }
.hero-sub { font-size: 1.1rem; color: var(--text-secondary); max-width: 520px; margin: 0 auto; }

/* === Generator === */
.generator { padding: 48px 0 64px; }
.generator-grid { display: grid; grid-template-columns: 380px 1fr; gap: 40px; align-items: start; }
.controls-panel { position: sticky; top: 80px; }
.controls-panel h2,
.results-panel h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 20px; }

/* === Form === */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.field input,
.field select { width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: 0.95rem; color: var(--text); font-family: var(--font); transition: border-color 0.15s; }
.field input:focus,
.field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.field input::placeholder { color: var(--text-muted); }

/* === Buttons === */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 24px; border: none; border-radius: var(--radius-sm); font-size: 0.95rem; font-weight: 600; font-family: var(--font); cursor: pointer; transition: all 0.15s; }
.btn-generate { width: 100%; background: var(--accent); color: white; margin-top: 8px; }
.btn-generate:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-text { background: none; color: var(--text-muted); padding: 8px 0; font-size: 0.85rem; }
.btn-text:hover { color: var(--text-secondary); }
.btn-copy { background: var(--accent-light); color: var(--accent); padding: 8px 16px; font-size: 0.85rem; }
.btn-copy:hover { background: var(--accent); color: white; text-decoration: none; }
.btn-save { background: var(--surface-alt); color: var(--text-secondary); padding: 8px 16px; font-size: 0.85rem; border: 1px solid var(--border); }
.btn-save:hover { background: var(--border); text-decoration: none; }
.btn-export { background: var(--success-light); color: var(--success); padding: 8px 16px; font-size: 0.85rem; }
.btn-export:hover { background: var(--success); color: white; text-decoration: none; }

/* === Saved Section === */
.saved-section { margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
.saved-section h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 12px; }
.saved-list { display: flex; flex-direction: column; gap: 8px; }
.saved-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--surface-alt); border-radius: var(--radius-sm); font-size: 0.85rem; }
.saved-item-name { font-weight: 600; color: var(--text); }
.saved-item-meta { color: var(--text-muted); font-size: 0.8rem; }
.saved-item button { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.8rem; padding: 4px 8px; }
.saved-item button:hover { color: var(--accent); }

/* === Results === */
.empty-state { text-align: center; padding: 64px 24px; color: var(--text-muted); }
.empty-state svg { margin: 0 auto 16px; }
.empty-state p { max-width: 320px; margin: 0 auto; font-size: 0.95rem; }
.email-cards { display: flex; flex-direction: column; gap: 24px; }
.email-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: box-shadow 0.15s; }
.email-card:hover { box-shadow: var(--shadow-md); }
.email-card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; background: var(--surface-alt); border-bottom: 1px solid var(--border); cursor: pointer; }
.email-card-header h3 { font-size: 0.95rem; font-weight: 700; }
.email-card-header .badge { font-size: 0.75rem; padding: 3px 10px; border-radius: 20px; font-weight: 600; }
.badge-1 { background: #e8f4fd; color: #2563eb; }
.badge-2 { background: #fef3c7; color: #b45309; }
.badge-3 { background: var(--accent-light); color: var(--accent); }
.email-card-body { padding: 20px; }
.email-field { margin-bottom: 12px; }
.email-field label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); display: block; margin-bottom: 4px; }
.email-field .value { font-size: 0.95rem; color: var(--text); line-height: 1.5; }
.email-body-text { background: var(--surface-alt); padding: 16px; border-radius: var(--radius-sm); font-size: 0.9rem; line-height: 1.7; white-space: pre-wrap; border: 1px solid var(--border); }
.email-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.email-timing { margin-top: 16px; padding: 12px 16px; background: var(--success-light); border-radius: var(--radius-sm); font-size: 0.85rem; color: var(--success); }
.email-timing strong { display: block; margin-bottom: 2px; }

/* === Timing Guide === */
.timing-guide { padding: 64px 0; background: var(--surface); border-top: 1px solid var(--border); }
.timing-guide h2 { font-size: 1.4rem; font-weight: 800; text-align: center; margin-bottom: 40px; }
.timing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.timing-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; position: relative; }
.timing-num { position: absolute; top: -16px; left: 24px; background: var(--accent); color: white; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.9rem; }
.timing-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; padding-top: 8px; }
.timing-when { font-size: 0.9rem; color: var(--accent); font-weight: 600; margin-bottom: 8px; }
.timing-card p { font-size: 0.9rem; color: var(--text-secondary); }

/* === Mistakes === */
.mistakes { padding: 64px 0; }
.mistakes h2 { font-size: 1.4rem; font-weight: 800; text-align: center; margin-bottom: 40px; }
.mistakes-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.mistake-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; border-left: 4px solid var(--warning); }
.mistake-card h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 8px; }
.mistake-card p { font-size: 0.9rem; color: var(--text-secondary); }

/* === Tone Guide === */
.tone-guide { padding: 64px 0; background: var(--surface); border-top: 1px solid var(--border); }
.tone-guide h2 { font-size: 1.4rem; font-weight: 800; text-align: center; margin-bottom: 40px; }
.tone-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.tone-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.tone-card h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 8px; color: var(--accent); }
.tone-card p { font-size: 0.9rem; color: var(--text-secondary); }

/* === Assumptions === */
.assumptions { padding: 64px 0; }
.assumptions h2 { font-size: 1.4rem; font-weight: 800; text-align: center; margin-bottom: 40px; }
.assumptions-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-bottom: 40px; }
.assumption-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; }
.assumption-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.assumption-card p { font-size: 0.9rem; color: var(--text-secondary); }
.last-updated { text-align: center; font-size: 0.85rem; color: var(--text-muted); }

/* === Footer === */
.site-footer { background: var(--text); color: rgba(255,255,255,0.7); padding: 48px 0 24px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 40px; margin-bottom: 32px; }
.footer-grid h4 { color: white; font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }
.footer-grid a { display: block; color: rgba(255,255,255,0.6); font-size: 0.9rem; padding: 4px 0; }
.footer-grid a:hover { color: white; }
.footer-copy { text-align: center; font-size: 0.8rem; color: rgba(255,255,255,0.4); padding-top: 24px; border-top: 1px solid rgba(255,255,255,0.1); }

/* === Toast === */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--text); color: white; padding: 12px 20px; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 500; box-shadow: var(--shadow-lg); z-index: 9999; transform: translateY(100px); opacity: 0; transition: all 0.3s; }
.toast.show { transform: translateY(0); opacity: 1; }

/* === Responsive === */
@media (max-width: 1024px) {
  .generator-grid { grid-template-columns: 1fr; }
  .controls-panel { position: static; }
  .timing-grid { grid-template-columns: 1fr; }
  .mistakes-grid { grid-template-columns: repeat(2, 1fr); }
  .tone-grid { grid-template-columns: repeat(2, 1fr); }
  .assumptions-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .site-header .container { padding: 0 16px; }
  .container { padding: 0 16px; }
  .hero { padding: 40px 0 32px; }
  .hero h1 { font-size: 1.5rem; }
  .hero-sub { font-size: 1rem; }
  .generator { padding: 32px 0 48px; }
  .timing-guide, .mistakes, .tone-guide, .assumptions { padding: 48px 0; }
  .mistakes-grid, .tone-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .nav { gap: 16px; }
  .nav a { font-size: 0.85rem; }
}

/* === Print === */
@media print {
  .site-header, .site-footer, .controls-panel, .hero, .timing-guide, .mistakes, .tone-guide, .assumptions { display: none; }
  .results-panel { display: block; }
  .email-card { break-inside: avoid; }
}



/* Factory-injected deployment helpers. The AI owns the site design above this block. */
.ad-unit {
  width: min(100%, 720px);
  min-height: 120px;
  margin: 24px auto;
  display: block;
}

.legal-page {
  width: min(900px, calc(100% - 32px));
  margin: 40px auto;
}

.factory-fallback-nav {
  width: min(900px, calc(100% - 32px));
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 0.95rem;
}

.factory-fallback-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
