/* ---- CSS VARIABLES (Light Theme) ---- */
:root {
  --brand-navy: #1a1472;
  --brand-purple: #6b5ce7;
  --brand-gold: #d4a843;
  --brand-gold-light: #f0c96e;

  --bg-base: #f4f5f9;
  --bg-surface: #ffffff;
  --bg-surface2: #f9fafc;
  --sidebar-bg: #1a1472;
  --sidebar-text: rgba(255,255,255,0.75);
  --sidebar-active: rgba(255,255,255,0.12);
  --sidebar-active-text: #ffffff;

  --text-primary: #0f1123;
  --text-secondary: #5a6070;
  --text-muted: #9aa0b0;

  --border: #e5e8f0;
  --border-focus: #6b5ce7;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --sidebar-width: 220px;
  --topbar-height: 56px;

  --transition: 0.2s ease;
}

/* ---- Dark Theme ---- */
[data-theme="dark"] {
  --bg-base: #0d0e1a;
  --bg-surface: #151728;
  --bg-surface2: #1c1e32;
  --sidebar-bg: #0a0b14;

  --text-primary: #eceef8;
  --text-secondary: #8b8fa8;
  --text-muted: #50536b;

  --border: #252840;
  --border-focus: #6b5ce7;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
}

/* ---- RESET & BASE ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }
svg { display: block; }

.hidden { display: none !important; }

/* =====================================================
   AUTH PAGES
   ===================================================== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0d0e20 0%, #1a1472 40%, #2d1f7a 70%, #1a1472 100%);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

/* Subtle background star pattern */
.auth-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(212,168,67,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 60%, rgba(255,255,255,0.2) 0%, transparent 100%),
    radial-gradient(1px 1px at 50% 80%, rgba(107,92,231,0.4) 0%, transparent 100%),
    radial-gradient(80px 80px at 15% 70%, rgba(212,168,67,0.06) 0%, transparent 100%),
    radial-gradient(120px 120px at 85% 20%, rgba(107,92,231,0.08) 0%, transparent 100%);
  pointer-events: none;
}

.auth-page {
  width: 100%;
  max-width: 420px;
  animation: fadeUp 0.4s ease both;
}

.auth-card {
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  justify-content: center;
}

.logo-mark {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.logo-mark.small { width: 32px; height: 32px; }
.logo-mark.xsmall { width: 26px; height: 26px; }

.logo-text {
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: 0.12em;
  color: #ffffff;
}
.logo-text.dark { color: var(--brand-navy); }
[data-theme="dark"] .logo-text.dark { color: var(--text-primary); }

.auth-title {
  font-family: 'Sora', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: #ffffff;
  text-align: center;
  margin-bottom: 6px;
}

.auth-sub {
  color: rgba(255,255,255,0.5);
  text-align: center;
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.auth-error {
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 16px;
}

/* ---- Field Group ---- */
.field-group {
  margin-bottom: 16px;
}
.field-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.03em;
}
/* For non-auth pages */
.main-content .field-group label,
.card .field-group label {
  color: var(--text-secondary);
}

.field-group input,
.field-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06);
  color: #fff;
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field-group input:focus,
.field-group select:focus {
  border-color: var(--brand-gold);
  box-shadow: 0 0 0 3px rgba(212,168,67,0.15);
}

.field-group input::placeholder { color: rgba(255,255,255,0.25); }

/* Main content overrides for field groups */
.main-content .field-group input,
.main-content .field-group select {
  background: var(--bg-base);
  border-color: var(--border);
  color: var(--text-primary);
}
.main-content .field-group input::placeholder { color: var(--text-muted); }
.main-content .field-group input:focus,
.main-content .field-group select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(107,92,231,0.12);
}
[data-theme="dark"] .main-content .field-group input,
[data-theme="dark"] .main-content .field-group select {
  background: var(--bg-surface2);
  border-color: var(--border);
  color: var(--text-primary);
}

/* ---- Buttons ---- */
.btn-primary {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--brand-purple) 0%, var(--brand-navy) 100%);
  color: #fff;
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
  transition: opacity var(--transition), transform var(--transition);
  margin-top: 4px;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.auth-switch {
  text-align: center;
  color: rgba(255,255,255,0.45);
  font-size: 0.85rem;
  margin-top: 20px;
}
.auth-switch a {
  color: var(--brand-gold);
  font-weight: 500;
}
.auth-switch a:hover { opacity: 0.8; }

/* =====================================================
   APP LAYOUT
   ===================================================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 8px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover {
  background: var(--sidebar-active);
  color: var(--sidebar-active-text);
}
.nav-item.active {
  background: linear-gradient(135deg, rgba(107,92,231,0.35) 0%, rgba(212,168,67,0.15) 100%);
  color: var(--sidebar-active-text);
  border-left: 2px solid var(--brand-gold);
}

/* ---- Sidebar Footer ---- */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-util-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.85rem;
  width: 100%;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}
.sidebar-util-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-util-btn:hover { background: var(--sidebar-active); color: #fff; }
.sidebar-util-btn.danger:hover { background: rgba(239,68,68,0.15); color: #fca5a5; }

/* ---- MOBILE TOPBAR ---- */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 99;
  box-shadow: var(--shadow-sm);
}

.mobile-menu-btn, .icon-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  transition: background var(--transition);
}
.mobile-menu-btn:hover, .icon-btn:hover { background: var(--bg-base); }
.mobile-menu-btn svg, .icon-btn svg { width: 20px; height: 20px; }

.mobile-logo { display: flex; align-items: center; gap: 8px; }

.mobile-actions { display: flex; gap: 4px; }

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px;
  max-width: 960px;
}

/* ---- PAGE ---- */
.page { display: none; animation: fadeUp 0.3s ease both; }
.page.active { display: block; }

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

.greeting {
  font-family: 'Sora', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.greeting-sub {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.date-badge {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

/* ---- STAT CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.total { background: rgba(26,20,114,0.1); color: var(--brand-navy); }
.stat-icon.done { background: rgba(107,92,231,0.12); color: var(--brand-purple); }
.stat-icon.pending { background: rgba(212,168,67,0.15); color: #b8891e; }
[data-theme="dark"] .stat-icon.total { background: rgba(107,92,231,0.2); color: #a89bf5; }
[data-theme="dark"] .stat-icon.done { background: rgba(107,92,231,0.2); color: #a89bf5; }
[data-theme="dark"] .stat-icon.pending { background: rgba(212,168,67,0.15); color: var(--brand-gold); }

.stat-value {
  font-family: 'Sora', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-primary);
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ---- PROGRESS ---- */
.progress-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.progress-pct {
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  color: var(--brand-purple);
}

.progress-track {
  height: 8px;
  background: var(--bg-base);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-navy) 0%, var(--brand-purple) 50%, var(--brand-gold) 100%);
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- SECTION HEADER ---- */
.section-header {
  margin-bottom: 14px;
}
.section-header h3 {
  font-family: 'Sora', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ---- COUNTDOWN LIST ---- */
.countdown-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 32px;
}

.countdown-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  transition: border-color var(--transition);
}
.countdown-item.warn-yellow { border-left: 3px solid #eab308; }
.countdown-item.warn-red { border-left: 3px solid #ef4444; }

.countdown-task-info { flex: 1; min-width: 0; }
.countdown-task-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.countdown-task-subject {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.countdown-time {
  font-family: 'Sora', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brand-purple);
  white-space: nowrap;
  text-align: right;
}
.countdown-item.warn-yellow .countdown-time { color: #ca8a04; }
.countdown-item.warn-red .countdown-time { color: #ef4444; }

/* ---- CARDS ---- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.form-card {
  margin-bottom: 24px;
}
.form-card h3 {
  font-family: 'Sora', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.form-grid.four-col {
  grid-template-columns: 1fr 2fr 1fr 1fr;
}

.form-card .btn-primary { width: auto; padding: 10px 24px; }

/* ---- TASK LIST ---- */
.task-list { display: flex; flex-direction: column; gap: 10px; }

.task-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), opacity var(--transition);
}
.task-item:hover { box-shadow: var(--shadow-md); }
.task-item.done { opacity: 0.6; }
.task-item.done .task-title { text-decoration: line-through; }

.task-check {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}
.task-check.checked {
  background: var(--brand-purple);
  border-color: var(--brand-purple);
}
.task-check svg { width: 12px; height: 12px; color: #fff; }

.task-info { flex: 1; min-width: 0; }
.task-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.task-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.task-subject-badge {
  background: rgba(107,92,231,0.1);
  color: var(--brand-purple);
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 500;
}
[data-theme="dark"] .task-subject-badge {
  background: rgba(107,92,231,0.2);
  color: #a89bf5;
}

.task-deadline { color: var(--text-muted); }
.task-deadline.warn-yellow { color: #ca8a04; font-weight: 500; }
.task-deadline.warn-red { color: #ef4444; font-weight: 500; }

.task-actions { display: flex; gap: 6px; }
.task-del-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.task-del-btn:hover { background: rgba(239,68,68,0.1); color: #ef4444; }
.task-del-btn svg { width: 16px; height: 16px; }

.empty-state {
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
  padding: 32px;
}

/* ---- SCHEDULE ---- */
.schedule-mode-toggle {
  display: flex;
  gap: 6px;
}

.pill-btn {
  padding: 6px 16px;
  border-radius: 99px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  transition: all var(--transition);
}
.pill-btn:hover { border-color: var(--brand-purple); color: var(--brand-purple); }
.pill-btn.active {
  background: var(--brand-purple);
  border-color: var(--brand-purple);
  color: #fff;
}

.schedule-grid {
  display: grid;
  gap: 14px;
}

.day-column {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.day-column.today .day-header {
  background: linear-gradient(135deg, var(--brand-navy) 0%, var(--brand-purple) 100%);
  color: #fff;
}
.day-column.today { border-color: var(--brand-purple); }

.day-header {
  padding: 12px 16px;
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--bg-surface2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.day-today-badge {
  font-size: 0.7rem;
  background: rgba(212,168,67,0.2);
  color: var(--brand-gold);
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.day-column.today .day-today-badge {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.day-activities {
  padding: 8px 0;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  transition: background var(--transition);
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--bg-base); }

.activity-time {
  font-family: 'Sora', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand-purple);
  white-space: nowrap;
  min-width: 100px;
}
[data-theme="dark"] .activity-time { color: #a89bf5; }

.activity-name { flex: 1; font-weight: 500; color: var(--text-primary); }

.activity-del {
  width: 26px; height: 26px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.activity-del:hover { background: rgba(239,68,68,0.1); color: #ef4444; }
.activity-del svg { width: 13px; height: 13px; }

.day-empty {
  padding: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* ---- SIDEBAR OVERLAY (mobile) ---- */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* =====================================================
   ANIMATIONS
   ===================================================== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
  .mobile-topbar { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }

  .main-content {
    margin-left: 0;
    padding: 80px 16px 24px;
  }

  .stats-grid { grid-template-columns: 1fr; gap: 10px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.four-col { grid-template-columns: 1fr 1fr; }

  .page-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 600px) {
  .auth-card { padding: 28px 22px; }
  .form-grid.four-col { grid-template-columns: 1fr; }
}

@media (min-width: 769px) and (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .main-content { padding: 28px 24px; }
}

/* =====================================================
   SUMMARIZE PAGE
   ===================================================== */
.summary-textarea {
  width: 100%;
  min-height: 200px;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.5;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}

[data-theme="dark"] .summary-textarea {
  background: var(--bg-surface2);
}

.summary-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(107,92,231,0.12);
}

.summary-result-content {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-base);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.summary-result-content p {
  margin-bottom: 12px;
}
.summary-result-content p:last-child {
  margin-bottom: 0;
}
.summary-result-content ul, .summary-result-content ol {
  margin-left: 20px;
  margin-bottom: 12px;
}
.summary-result-content h1, .summary-result-content h2, .summary-result-content h3 {
  margin-top: 16px;
  margin-bottom: 8px;
  font-family: 'Sora', sans-serif;
}

/* =====================================================
   AI FEATURES — SHARED
   ===================================================== */

/* AI Banner */
.ai-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: linear-gradient(135deg, rgba(107,92,231,0.08), rgba(26,20,114,0.06));
  border: 1px solid rgba(107,92,231,0.2);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.82rem;
  color: var(--brand-purple);
  font-weight: 500;
}
[data-theme="dark"] .ai-banner {
  background: rgba(107,92,231,0.12);
  border-color: rgba(107,92,231,0.25);
  color: #a89bf5;
}
.ai-banner svg { width: 16px; height: 16px; flex-shrink: 0; }

/* form-card header row */
.form-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.form-card-header h3 { margin-bottom: 0; }

/* Language / count selectors */
.ai-controls-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.ai-lang-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-lang-select-wrap label {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.ai-lang-select {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}
.ai-lang-select:focus { border-color: var(--border-focus); }
[data-theme="dark"] .ai-lang-select { background: var(--bg-surface2); }

/* AI button variant */
.btn-ai {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--brand-purple) 0%, var(--brand-navy) 100%);
}
.btn-ai svg { width: 16px; height: 16px; }
.btn-ai:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

/* Secondary button */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: 'Sora', sans-serif;
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.03em;
  transition: all var(--transition);
  cursor: pointer;
  margin-top: 12px;
  margin-right: 8px;
}
.btn-secondary:hover {
  border-color: var(--brand-purple);
  color: var(--brand-purple);
  background: rgba(107,92,231,0.05);
}

/* Loading state */
.ai-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.ai-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--brand-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Result header with copy button */
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.result-header h3 { margin-bottom: 0; }
.copy-btn {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface2);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.copy-btn:hover { border-color: var(--brand-purple); color: var(--brand-purple); }

/* =====================================================
   QUIZ PAGE
   ===================================================== */
.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.quiz-header h3 {
  font-family: 'Sora', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}
.quiz-meta { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }

.quiz-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  animation: fadeUp 0.3s ease both;
}
.quiz-qnum {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand-purple);
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
[data-theme="dark"] .quiz-qnum { color: #a89bf5; }

.quiz-question {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 18px;
}
.quiz-options { display: flex; flex-direction: column; gap: 8px; }

.quiz-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.quiz-option input[type="radio"] { display: none; }
.quiz-option:hover {
  border-color: var(--brand-purple);
  background: rgba(107,92,231,0.04);
}
.quiz-option.selected {
  border-color: var(--brand-purple);
  background: rgba(107,92,231,0.08);
}
[data-theme="dark"] .quiz-option.selected { background: rgba(107,92,231,0.15); }

.option-letter {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-base);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: all var(--transition);
}
.quiz-option.selected .option-letter {
  background: var(--brand-purple);
  border-color: var(--brand-purple);
  color: #fff;
}
.option-text { font-size: 0.875rem; color: var(--text-primary); line-height: 1.4; }

.quiz-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
  margin-bottom: 24px;
}
.btn-quiz-submit { width: auto; padding: 12px 32px; font-family: 'Sora', sans-serif; font-weight: 600; }

/* Score display */
.score-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  display: flex;
  align-items: center;
  gap: 32px;
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.score-circle { position: relative; width: 120px; height: 120px; flex-shrink: 0; }
.score-circle svg { width: 120px; height: 120px; }
.score-ring-bg { stroke: var(--border); }
.score-ring-fill { stroke: var(--brand-purple); }
.score-number {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Sora', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}
.score-info { flex: 1; }
.score-title {
  font-family: 'Sora', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.score-detail { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 6px; }
.score-emoji { font-size: 1rem; color: var(--text-primary); font-weight: 500; }

/* Review cards */
#quiz-review-container { margin-top: 20px; }
.review-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 10px;
}
.review-card.correct { border-left-color: #22c55e; }
.review-card.wrong   { border-left-color: #ef4444; }
.review-qnum { font-weight: 600; font-size: 0.875rem; color: var(--text-primary); margin-bottom: 10px; line-height: 1.4; }
.review-answers { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.review-yours { font-size: 0.82rem; color: var(--text-secondary); }
.review-correct { font-size: 0.82rem; color: #16a34a; }
[data-theme="dark"] .review-correct { color: #4ade80; }
.review-explanation { font-size: 0.82rem; color: var(--text-muted); font-style: italic; margin-top: 4px; }

@media (max-width: 600px) {
  .score-card { flex-direction: column; text-align: center; gap: 20px; }
  .form-card-header { flex-direction: column; align-items: flex-start; }
}
