/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f7f8fc;
  color: #1a1a2e;
  line-height: 1.65;
}
a { color: #4f46e5; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ───────────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* ── Header ───────────────────────────────────────────────── */
header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #e2e8f0;
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
.logo { font-size: 1.25rem; font-weight: 700; color: #4f46e5; }
nav a { margin-left: 24px; color: #475569; font-weight: 500; font-size: 0.95rem; }
nav a:hover { color: #4f46e5; text-decoration: none; }

/* ── Hero ─────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #2563eb 100%);
  color: white; padding: 80px 0 70px;
  text-align: center;
}
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 800; margin-bottom: 16px; }
.hero p { font-size: 1.15rem; opacity: 0.9; margin-bottom: 36px; max-width: 600px; margin-left: auto; margin-right: auto; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
  display: inline-block;
  background: white; color: #4f46e5;
  font-weight: 700; padding: 12px 28px; border-radius: 8px;
  border: none; cursor: pointer; font-size: 1rem;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.2); text-decoration: none; color: #4f46e5; }
.btn-primary.btn-large { padding: 14px 36px; font-size: 1.1rem; background: #4f46e5; color: white; }
.btn-primary.btn-large:hover { background: #4338ca; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-secondary {
  display: inline-block;
  background: #f1f5f9; color: #475569;
  font-weight: 600; padding: 8px 16px; border-radius: 6px;
  border: 1px solid #e2e8f0; cursor: pointer; font-size: 0.875rem;
  transition: background 0.15s;
}
.btn-secondary:hover { background: #e2e8f0; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* ── Features ─────────────────────────────────────────────── */
.features { padding: 64px 0; background: white; }
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 28px;
}
.feature-card {
  background: #f8faff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 28px 24px;
  transition: box-shadow 0.2s;
}
.feature-card:hover { box-shadow: 0 4px 20px rgba(79,70,229,0.12); }
.feature-icon { font-size: 2rem; margin-bottom: 12px; }
.feature-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.feature-card p { font-size: 0.9rem; color: #64748b; }

/* ── Generator ────────────────────────────────────────────── */
.section-white { background: #f7f8fc; padding: 64px 0; }
.section-title { font-size: 1.75rem; font-weight: 700; text-align: center; margin-bottom: 36px; }
.form-card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 20px rgba(0,0,0,0.06);
  padding: 36px;
}
fieldset {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 20px 24px;
  margin-bottom: 24px;
}
legend {
  font-weight: 700; font-size: 0.875rem;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: #4f46e5; padding: 0 8px;
}
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-group { flex: 1; min-width: 160px; margin-bottom: 0; }
.form-group.full { flex: 100%; }
label { display: block; font-weight: 600; font-size: 0.875rem; margin-bottom: 6px; color: #374151; }
input, select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid #d1d5db; border-radius: 7px;
  font-size: 0.95rem; background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79,70,229,0.12);
}
.required { color: #ef4444; }

/* ── Output ───────────────────────────────────────────────── */
.output-area {
  margin-top: 32px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 20px rgba(0,0,0,0.06);
  overflow: hidden;
}
.output-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid #e2e8f0;
  background: #fafbff;
}
.output-header h3 { font-size: 1.1rem; font-weight: 700; }
.output-actions { display: flex; align-items: center; gap: 10px; }
.badge {
  background: #e0e7ff; color: #4f46e5;
  font-size: 0.8rem; font-weight: 600;
  padding: 3px 10px; border-radius: 20px;
}
.essay-pre {
  padding: 28px;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 0.975rem;
  line-height: 1.85;
  white-space: pre-wrap;
  color: #1a1a2e;
}

/* ── Loader ───────────────────────────────────────────────── */
.loader-bar { background: #e0e7ff; height: 4px; }
.loader-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #4f46e5, #7c3aed);
  animation: loading 2.5s ease-in-out infinite;
  border-radius: 2px;
}
@keyframes loading {
  0%   { width: 0%;   margin-left: 0%; }
  50%  { width: 60%;  margin-left: 20%; }
  100% { width: 0%;   margin-left: 100%; }
}

/* ── Footer ───────────────────────────────────────────────── */
footer {
  background: #1e1b4b; color: #a5b4fc;
  text-align: center; padding: 28px 0;
  font-size: 0.875rem;
}
footer a { color: #818cf8; }
footer a:hover { color: white; }

/* ── Writing Studio page ──────────────────────────────────── */
.studio-layout {
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  gap: 20px;
  align-items: start;
}
.sidebar {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
  position: sticky;
  top: 80px;
}
.sidebar h4 {
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: #94a3b8; margin-bottom: 10px; margin-top: 20px;
}
.sidebar h4:first-child { margin-top: 0; }
.tool-btn {
  display: block; width: 100%; text-align: left;
  padding: 9px 12px; margin-bottom: 6px;
  background: #f8faff; border: 1px solid #e2e8f0;
  border-radius: 7px; cursor: pointer; font-size: 0.875rem;
  transition: all 0.15s;
}
.tool-btn:hover { background: #e0e7ff; border-color: #4f46e5; }
.editor-card {
  background: white; border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
  overflow: hidden;
}
.editor-toolbar {
  display: flex; gap: 10px; padding: 14px 20px;
  border-bottom: 1px solid #e2e8f0; flex-wrap: wrap; align-items: center;
}
.editor-toolbar select { width: auto; padding: 6px 10px; font-size: 0.875rem; }
.editor-toolbar button { padding: 6px 14px; font-size: 0.875rem; }
#studio-editor {
  width: 100%; min-height: 520px;
  padding: 24px; border: none; outline: none; resize: vertical;
  font-family: 'Georgia', serif; font-size: 16px; line-height: 1.9;
  color: #1a1a2e;
}
.stats-card {
  background: white; border-radius: 12px;
  padding: 20px; box-shadow: 0 2px 12px rgba(0,0,0,0.05);
  position: sticky; top: 80px;
}
.stat-item {
  background: #f8faff; border-radius: 8px;
  padding: 12px 16px; margin-bottom: 10px;
  border-left: 3px solid #4f46e5;
}
.stat-label { font-size: 0.8rem; color: #64748b; margin-bottom: 2px; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: #1e1b4b; }
.tone-tag {
  display: inline-block; background: #e0e7ff; color: #4f46e5;
  border-radius: 20px; padding: 3px 10px; font-size: 0.8rem;
  margin: 3px;
}
.issue-item {
  background: #fffbeb; border-left: 3px solid #f59e0b;
  border-radius: 4px; padding: 8px 12px; margin-bottom: 8px; font-size: 0.85rem;
}
.issue-fix { color: #059669; cursor: pointer; text-decoration: underline; margin-left: 6px; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 500;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white; border-radius: 16px;
  padding: 32px; max-width: 560px; width: 90%; max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.modal-close {
  background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #64748b;
}
.tone-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px;
}
.tone-card {
  border: 2px solid #e2e8f0; border-radius: 10px; padding: 14px 10px;
  text-align: center; cursor: pointer; transition: all 0.15s;
}
.tone-card:hover { border-color: #4f46e5; background: #f8faff; }
.tone-card.selected { border-color: #4f46e5; background: #4f46e5; color: white; }
.tone-card .emoji { font-size: 1.6rem; margin-bottom: 6px; }
.tone-card .name { font-size: 0.85rem; font-weight: 600; }
.tone-card .desc { font-size: 0.75rem; opacity: 0.7; margin-top: 4px; }

/* ── Processing ───────────────────────────────────────────── */
.processing-bar {
  display: none; padding: 14px 20px;
  background: #e0e7ff; color: #4f46e5; font-weight: 600;
  border-top: 1px solid #c7d2fe; font-size: 0.9rem;
  align-items: center; gap: 10px;
}
.spinner {
  width: 18px; height: 18px; border: 3px solid #c7d2fe;
  border-top-color: #4f46e5; border-radius: 50%;
  animation: spin 0.8s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .studio-layout { grid-template-columns: 1fr; }
  .sidebar, .stats-card { position: static; }
  .form-card { padding: 20px; }
}
