/* ===== CSS Variables ===== */
:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --accent: #7c3aed;
  --accent-dark: #6d28d9;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --success: #10b981;
  --error: #ef4444;
  --radius: 10px;
  --shadow: 0 2px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(79,70,229,0.12);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }
img { max-width: 100%; }

/* ===== Navbar ===== */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}
.logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.5px;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.nav-links a {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--primary); }
.btn-nav {
  background: var(--primary) !important;
  color: #fff !important;
  padding: 0.45rem 1.1rem;
  border-radius: 6px;
  font-weight: 600 !important;
  transition: background 0.2s !important;
}
.btn-nav:hover { background: var(--primary-dark) !important; text-decoration: none !important; }

/* ===== Buttons ===== */
.btn-primary {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  text-decoration: none;
}
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  display: inline-block;
  background: var(--surface);
  color: var(--primary);
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1rem;
  border: 2px solid var(--primary);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-secondary:hover { background: var(--primary); color: #fff; text-decoration: none; }

.btn-full { width: 100%; text-align: center; display: block; }

.btn-sm {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
}
.btn-sm:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }

.btn-upgrade {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  padding: 0.5rem 1.2rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: opacity 0.2s;
}
.btn-upgrade:hover { opacity: 0.9; text-decoration: none; color: #fff; }
.btn-upgrade-plus {
  background: linear-gradient(135deg, var(--accent), #db2777);
}

/* ===== Hero Section ===== */
.hero {
  text-align: center;
  padding: 6rem 2rem 4rem;
  background: linear-gradient(135deg, #ede9fe 0%, #e0e7ff 100%);
}
.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  color: var(--primary-dark);
  line-height: 1.2;
  margin-bottom: 1.2rem;
}
.hero-sub {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 2rem;
}

/* ===== How It Works ===== */
.how {
  padding: 4rem 2rem;
  text-align: center;
  background: var(--surface);
}
.how h2 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2.5rem;
}
.steps {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
  max-width: 860px;
  margin: 0 auto;
}
.step {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  width: 240px;
  text-align: center;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 1rem;
}
.step p { color: var(--text-muted); font-size: 0.95rem; }

/* ===== Pricing ===== */
.pricing {
  padding: 5rem 2rem;
  text-align: center;
  background: var(--bg);
}
.pricing h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 2.5rem;
}
.plans {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  max-width: 900px;
  margin: 0 auto;
}
.plan {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.5rem;
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: box-shadow 0.2s;
}
.plan:hover { box-shadow: var(--shadow-lg); }
.plan-featured {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-6px);
}
.plan h3 { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.plan-price {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}
.plan-price span { font-size: 1rem; font-weight: 400; color: var(--text-muted); }
.plan ul { text-align: left; }
.plan ul li {
  padding: 0.4rem 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.plan ul li:last-child { border: none; }
.btn-plan {
  display: block;
  background: var(--primary);
  color: #fff;
  padding: 0.7rem;
  border-radius: 8px;
  font-weight: 600;
  text-align: center;
  transition: background 0.2s;
  text-decoration: none;
  margin-top: auto;
}
.btn-plan:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }

/* ===== Auth Card ===== */
.auth-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 130px);
  padding: 2rem;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-card h1 {
  font-size: 1.7rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text);
}
.auth-link {
  text-align: center;
  margin-top: 1.2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ===== Forms ===== */
form label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
  margin-top: 1rem;
}
form input[type="text"],
form input[type="email"],
form input[type="password"],
form select,
form textarea {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s;
  outline: none;
}
form input:focus,
form select:focus {
  border-color: var(--primary);
  background: #fff;
}
form button[type="submit"] { margin-top: 1.5rem; }
.form-group { margin-bottom: 0.2rem; }
.form-check label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 400;
}
.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}
.hint-center {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}
.locked-feature {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: #92400e;
  margin: 1rem 0;
}
.alert-error {
  background: #fee2e2;
  border: 1px solid var(--error);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: #991b1b;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* ===== Dashboard ===== */
.dashboard {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.dashboard-header h1 {
  font-size: 1.7rem;
  font-weight: 700;
}
.sub-card {
  background: linear-gradient(135deg, #ede9fe, #e0e7ff);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.upgrade-row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.dashboard h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
}
.muted { color: var(--text-muted); }

/* ===== Table ===== */
.gen-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 0.9rem;
}
.gen-table thead {
  background: var(--primary);
  color: #fff;
}
.gen-table th {
  padding: 0.8rem 1rem;
  text-align: left;
  font-weight: 600;
}
.gen-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.gen-table tbody tr:last-child td { border: none; }
.gen-table tbody tr:hover { background: #f8fafc; }

/* ===== Generate Page ===== */
.gen-wrap {
  max-width: 620px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}
.gen-wrap h1 {
  font-size: 1.7rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}
.diff-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.diff-row span:first-child { min-width: 80px; }
.diff-range { flex: 1; accent-color: var(--primary); }
.diff-label {
  min-width: 36px;
  font-weight: 600;
  color: var(--primary);
  font-size: 0.9rem;
}
.btn-generate { margin-top: 1.5rem; font-size: 1.05rem; padding: 0.8rem; }
.btn-generate:disabled { background: var(--text-muted); cursor: not-allowed; }

/* ===== Result Page ===== */
.result-wrap {
  max-width: 860px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}
.result-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.result-header h1 {
  font-size: 1.7rem;
  font-weight: 700;
  flex: 1;
}
.result-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}
.result-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  overflow-x: auto;
  box-shadow: var(--shadow);
}
.result-preview pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'Segoe UI', sans-serif;
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text);
}

/* ===== Footer ===== */
footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: auto;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .navbar { padding: 0 1rem; }
  .nav-links { gap: 1rem; }
  .hero { padding: 4rem 1rem 3rem; }
  .hero h1 { font-size: 2rem; }
  .plans { flex-direction: column; align-items: center; }
  .plan-featured { transform: none; }
  .steps { flex-direction: column; align-items: center; }
  .dashboard-header { flex-direction: column; align-items: flex-start; }
  .sub-card { flex-direction: column; align-items: flex-start; }
  .result-header { flex-direction: column; align-items: flex-start; }
  .gen-table { font-size: 0.8rem; }
  .gen-table th, .gen-table td { padding: 0.5rem 0.6rem; }
}

@media (max-width: 480px) {
  .auth-card { padding: 1.5rem 1rem; }
  .nav-links .btn-nav { display: none; }
}

/* === Grade & Topics UI additions === */
.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.form-row .form-group {
  flex: 1;
  min-width: 180px;
}
.topic-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.chip {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
}
.chip:hover {
  background: #e0e7ff;
  border-color: #6366f1;
}
.chip-active {
  background: #4f46e5;
  color: #fff;
  border-color: #4f46e5;
}
.diff-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.diff-num {
  min-width: 90px;
  display: inline-block;
  font-size: 14px;
  color: #374151;
}
.diff-range {
  flex: 1;
  accent-color: #4f46e5;
}
.diff-label {
  min-width: 140px;
  font-size: 13px;
  color: #6b7280;
}
.topics-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
