/* ============================================================
   StudyAI - Complete Dark Mode Stylesheet
   ============================================================ */

/* CSS Variables */
:root {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-card: #1e2130;
  --bg-card-hover: #252840;
  --accent-purple: #6c63ff;
  --accent-cyan: #00d2ff;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-yellow: #f59e0b;
  --accent-gradient: linear-gradient(135deg, #6c63ff 0%, #00d2ff 100%);
  --text-primary: #e0e0e0;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --border-color: rgba(255, 255, 255, 0.08);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239ca3af' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  --border-accent: rgba(108, 99, 255, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --shadow-accent: 0 4px 24px rgba(108, 99, 255, 0.2);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition: 0.2s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  font-family: var(--font);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
  background: rgba(108, 99, 255, 0.4);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(108, 99, 255, 0.7);
}

a {
  color: var(--accent-purple);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover {
  color: var(--accent-cyan);
}

img { max-width: 100%; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.main-content {
  min-height: calc(100vh - 72px);
}

/* ============================================================
   Navbar
   ============================================================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 17, 23, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  height: 72px;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-icon {
  font-size: 28px;
  line-height: 1;
}

.logo-text {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.logo-text .accent {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
}

.nav-link:hover,
.nav-link.active {
  color: var(--text-primary);
  background: rgba(108, 99, 255, 0.1);
}

.nav-link.active {
  color: var(--accent-purple);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin-left: 8px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.btn-logout {
  color: var(--text-muted);
  font-size: 15px;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  text-decoration: none;
}

.btn-logout:hover {
  color: var(--accent-red);
  background: rgba(239, 68, 68, 0.1);
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--transition);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

/* ============================================================
   Settings
   ============================================================ */
.settings-page {
  max-width: 980px;
}

.settings-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.settings-tab {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
}

.settings-tab.is-active,
.settings-tab:hover {
  color: var(--text-primary);
  border-color: var(--border-accent);
  background: rgba(108, 99, 255, 0.12);
}

.settings-panel {
  display: none;
}

.settings-panel.is-active {
  display: block;
}

.settings-card {
  margin-bottom: 16px;
}

.settings-form {
  margin-top: 14px;
}

.settings-help {
  color: var(--text-secondary);
  margin-top: 6px;
}

.profile-row {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.profile-avatar-wrap {
  flex: 0 0 auto;
}

.profile-avatar-preview {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  background: var(--bg-card-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
}

.profile-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-fields {
  flex: 1;
}

.form-check-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-check-inline input[type='checkbox'] {
  width: 16px;
  height: 16px;
}

.summary-info-tooltip {
  position: relative;
  display: inline-flex;
  align-items: flex-start;
  justify-content: center;
  outline: none;
}

.summary-info-tooltip-content {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 240px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity var(--transition), transform var(--transition);
  z-index: 20;
  font-size: 13px;
  line-height: 1.45;
}

.summary-info-tooltip:hover .summary-info-tooltip-content,
.summary-info-tooltip:focus .summary-info-tooltip-content,
.summary-info-tooltip:focus-within .summary-info-tooltip-content {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 720px) {
  .profile-row {
    flex-direction: column;
  }

  .summary-info-tooltip-content {
    right: auto;
    left: 50%;
    transform: translate(-50%, -4px);
  }

  .summary-info-tooltip:hover .summary-info-tooltip-content,
  .summary-info-tooltip:focus .summary-info-tooltip-content,
  .summary-info-tooltip:focus-within .summary-info-tooltip-content {
    transform: translate(-50%, 0);
  }
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.05);
  opacity: 0;
  transition: opacity var(--transition);
}

.btn:hover::before { opacity: 1; }

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: var(--shadow-accent);
}

.btn-primary:hover {
  box-shadow: 0 6px 32px rgba(108, 99, 255, 0.4);
  color: #fff;
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-outline:hover {
  border-color: var(--accent-purple);
  color: var(--accent-purple);
  background: rgba(108, 99, 255, 0.05);
}

.btn-ghost {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.08);
}

.btn-ghost:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
  border-radius: var(--radius-lg);
}

.btn-full {
  width: 100%;
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius);
  flex-shrink: 0;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-hint {
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-yellow);
  border: 1px solid rgba(245, 158, 11, 0.2);
  padding: 7px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-hint:hover {
  background: rgba(245, 158, 11, 0.2);
  color: var(--accent-yellow);
}

.btn-ask-ai {
  background: rgba(108, 99, 255, 0.1);
  color: var(--accent-purple);
  border: 1px solid rgba(108, 99, 255, 0.2);
  padding: 7px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-ask-ai:hover {
  background: rgba(108, 99, 255, 0.2);
  color: var(--accent-purple);
}

.btn-show-answer {
  background: rgba(0, 210, 255, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 210, 255, 0.2);
  padding: 7px 14px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-show-answer:hover {
  background: rgba(0, 210, 255, 0.2);
  color: var(--accent-cyan);
}

/* ============================================================
   Flash Messages
   ============================================================ */
.flash-container {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 480px;
  padding: 0 16px;
  transition: opacity 0.3s ease;
}

.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  backdrop-filter: blur(10px);
  animation: slideDown 0.3s ease;
  box-shadow: var(--shadow);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.flash-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}
.flash-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}
.flash-info {
  background: rgba(108, 99, 255, 0.15);
  border: 1px solid rgba(108, 99, 255, 0.3);
  color: #a78bfa;
}
.flash-warning {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.flash-close {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity var(--transition);
  flex-shrink: 0;
}
.flash-close:hover { opacity: 1; }

/* ============================================================
   Forms
   ============================================================ */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group label i {
  margin-right: 6px;
  color: var(--accent-purple);
  font-size: 12px;
}

.form-input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  padding: 12px 16px;
  transition: all var(--transition);
  resize: vertical;
  outline: none;
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
  background: rgba(108, 99, 255, 0.03);
}

.form-select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

select.form-input,
select.form-select {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

select.form-input option,
select.form-input optgroup,
select.form-select option,
select.form-select optgroup,
select option,
select optgroup {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group .form-input {
  padding-right: 48px;
}

.input-toggle {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
  transition: color var(--transition);
}

.input-toggle:hover {
  color: var(--text-primary);
}

.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-purple);
  cursor: pointer;
}

.form-check label {
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

.form-row {
  display: flex;
  gap: 16px;
}

.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

/* Slider */
.slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-min, .slider-max {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 20px;
  text-align: center;
}

.form-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-secondary);
  outline: none;
  cursor: pointer;
  border: 1px solid var(--border-color);
}

.form-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-gradient);
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.2);
  transition: all var(--transition);
}

.form-slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 5px rgba(108, 99, 255, 0.3);
  transform: scale(1.1);
}

.form-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-gradient);
  cursor: pointer;
  border: none;
}

.accent-text {
  color: var(--accent-purple);
  font-weight: 700;
}

/* ============================================================
   Page Header
   ============================================================ */
.page-header {
  background: linear-gradient(180deg, rgba(108,99,255,0.05) 0%, transparent 100%);
  border-bottom: 1px solid var(--border-color);
  padding: 40px 0 32px;
  margin-bottom: 32px;
}

.page-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 6px;
}

.page-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

/* ============================================================
   Glass Card
   ============================================================ */
.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title i {
  color: var(--accent-purple);
}

/* ============================================================
   Hero Section
   ============================================================ */
.hero-section {
  position: relative;
  min-height: calc(100vh - 72px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 80px 24px;
}

.hero-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  animation: orbFloat 8s ease-in-out infinite;
}

.orb-1 {
  width: 600px;
  height: 600px;
  background: var(--accent-purple);
  top: -200px;
  left: -200px;
  animation-delay: 0s;
}

.orb-2 {
  width: 400px;
  height: 400px;
  background: var(--accent-cyan);
  bottom: -100px;
  right: -100px;
  animation-delay: -3s;
}

.orb-3 {
  width: 300px;
  height: 300px;
  background: #ff63b3;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -6s;
}

@keyframes orbFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-30px) scale(1.05); }
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 780px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(108, 99, 255, 0.1);
  border: 1px solid rgba(108, 99, 255, 0.25);
  color: #a78bfa;
  padding: 8px 18px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 28px;
  letter-spacing: 0.02em;
}

.hero-title {
  font-size: clamp(42px, 7vw, 72px);
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
  margin-bottom: 20px;
  letter-spacing: -2px;
}

.gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 19px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 40px;
  max-width: 580px;
  margin-left: auto;
  margin-right: auto;
}

.hero-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 56px;
}

.hero-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

.stat-divider {
  width: 1px;
  height: 40px;
  background: var(--border-color);
}

/* ============================================================
   Features Section
   ============================================================ */
.features-section {
  padding: 100px 0;
  background: var(--bg-secondary);
}

.section-title {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 56px;
  letter-spacing: -1px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-gradient);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.feature-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-accent);
  box-shadow: var(--shadow-accent);
}

.feature-card:hover::before {
  transform: scaleX(1);
}

.feature-icon {
  font-size: 40px;
  margin-bottom: 16px;
  line-height: 1;
}

.feature-card h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.feature-card p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ============================================================
   CTA Section
   ============================================================ */
.cta-section {
  padding: 100px 0;
}

.cta-card {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-xl);
  padding: 72px 48px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-accent);
}

.orb-cta {
  position: absolute;
  width: 400px;
  height: 400px;
  background: var(--accent-purple);
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.08;
  pointer-events: none;
}

.cta-card h2 {
  font-size: 36px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 12px;
  position: relative;
}

.cta-card p {
  font-size: 17px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  position: relative;
}

/* ============================================================
   Auth
   ============================================================ */
.auth-container {
  min-height: calc(100vh - 72px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: radial-gradient(ellipse at top, rgba(108,99,255,0.08) 0%, transparent 60%);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}

.auth-header {
  text-align: center;
  margin-bottom: 36px;
}

.auth-logo {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 16px;
}

.auth-header h1 {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.auth-header p {
  font-size: 15px;
  color: var(--text-secondary);
}

.auth-form {
  display: flex;
  flex-direction: column;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--accent-purple);
  font-weight: 600;
}

/* ============================================================
   Stats Bar
   ============================================================ */
.stats-bar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.stat-item i {
  color: var(--accent-purple);
  font-size: 16px;
}

/* ============================================================
   Sessions Grid
   ============================================================ */
.sessions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  padding-bottom: 48px;
}

.session-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.session-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.session-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-accent);
  box-shadow: var(--shadow-accent);
}

.session-card:hover::after {
  opacity: 0.03;
}

.session-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  width: fit-content;
}

.session-type-badge.summary {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.session-type-badge.questions {
  background: rgba(108, 99, 255, 0.1);
  color: #a78bfa;
  border: 1px solid rgba(108, 99, 255, 0.2);
}

.session-type-badge.essay {
  background: rgba(245, 158, 11, 0.1);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.session-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  flex: 1;
}

.session-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-line;
  line-height: 1.55;
  margin-top: 4px;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.session-date {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.session-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}

.session-view-btn {
  pointer-events: none;
}

.session-delete-btn {
  pointer-events: auto;
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--accent-red);
}

.session-delete-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.6);
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.empty-icon {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 8px;
}

.empty-state h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.empty-state p {
  font-size: 16px;
  color: var(--text-secondary);
}

.empty-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}

/* ============================================================
   Tool Layout (Two-panel)
   ============================================================ */
.tool-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 28px;
  align-items: start;
  padding-bottom: 48px;
}

.tool-form-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 90px;
}

.tool-result-panel {
  min-height: 400px;
}

.tips-card {
  padding: 20px 24px;
}

.tips-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tips-card h3 i {
  color: var(--accent-yellow);
}

.tips-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tips-card ul li {
  font-size: 13px;
  color: var(--text-secondary);
  padding-left: 16px;
  position: relative;
}

.tips-card ul li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--accent-purple);
}

.form-card-wide {
  max-width: 800px;
  margin: 0 auto;
  margin-bottom: 28px;
}

/* ============================================================
   Loading / Thinking Animations
   ============================================================ */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}

.ai-thinking {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.ai-thinking p {
  color: var(--text-secondary);
  font-size: 15px;
}

.thinking-dots {
  display: flex;
  gap: 8px;
}

.thinking-dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-gradient);
  animation: thinkBounce 1.2s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinkBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.7; }
  30% { transform: translateY(-14px); opacity: 1; }
}

.spinner-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(108, 99, 255, 0.1);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   Result / Summary Content
   ============================================================ */
.result-card {
  padding: 32px;
}

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.result-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.result-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.result-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.saved-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--accent-green);
}

.saved-badge i {
  font-size: 14px;
}

/* Markdown content styling */
.summary-content {
  color: var(--text-secondary);
  line-height: 1.8;
  font-size: 15px;
}

.summary-content h1,
.summary-content h2,
.summary-content h3 {
  color: var(--text-primary);
  font-weight: 700;
  margin: 24px 0 12px;
}

.summary-content h1 { font-size: 24px; }
.summary-content h2 { font-size: 20px; color: var(--accent-purple); }
.summary-content h3 { font-size: 17px; }

.summary-content p {
  margin-bottom: 14px;
  color: var(--text-secondary);
}

.summary-content ul {
  list-style: none;
  margin-bottom: 16px;
  padding: 0;
}

.summary-content ul li {
  padding: 6px 0 6px 20px;
  position: relative;
  color: var(--text-secondary);
}

.summary-content ul li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent-purple);
}

.summary-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.summary-content em {
  color: var(--accent-cyan);
  font-style: italic;
}

.summary-content code {
  background: rgba(108,99,255,0.1);
  border: 1px solid rgba(108,99,255,0.2);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: #c4b5fd;
}

.summary-content pre {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.summary-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.summary-content th,
.summary-content td {
  border: 1px solid var(--border-color);
  padding: 10px 12px;
  text-align: left;
}

.summary-content th {
  background: rgba(108, 99, 255, 0.15);
  color: var(--text-primary);
}

.summary-content .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 0;
}

.summary-content .katex {
  color: #dbeafe;
}

.chat-message .katex-display {
  margin: 10px 0;
}

.essay-content {
  font-size: 16px;
  line-height: 1.9;
}

.essay-content p {
  margin-bottom: 16px;
}

/* Empty result state */
.empty-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  text-align: center;
  gap: 12px;
  color: var(--text-muted);
}

.empty-icon-large {
  font-size: 64px;
  opacity: 0.2;
  margin-bottom: 8px;
}

.empty-result h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-result p {
  font-size: 14px;
  color: var(--text-muted);
}

/* ============================================================
   Question Cards
   ============================================================ */
.questions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.questions-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.questions-count {
  display: inline-block;
  margin-top: 4px;
  font-size: 14px;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 3px 10px;
  border-radius: 100px;
}

.questions-actions {
  display: flex;
  gap: 10px;
}

.questions-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 48px;
}

.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.4s ease, border-color 0.2s ease;
}

.question-card.card-visible {
  opacity: 1;
  transform: translateY(0);
}

.question-card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow);
}

.question-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.question-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.question-type-tag {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
}

.question-type-tag.multiple_choice {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.question-type-tag.essay {
  background: rgba(108, 99, 255, 0.1);
  color: #a78bfa;
  border: 1px solid rgba(108, 99, 255, 0.2);
}

.question-body {
  margin-bottom: 20px;
}

.question-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 20px;
}

/* Multiple choice */
.choices-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.choice-label {
  cursor: pointer;
  display: block;
}

.choice-label input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.choice-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  transition: all var(--transition);
}

.choice-label:hover .choice-box {
  border-color: var(--accent-purple);
  background: rgba(108, 99, 255, 0.05);
}

.choice-label.selected .choice-box {
  border-color: var(--accent-purple);
  background: rgba(108, 99, 255, 0.08);
}

.choice-label.correct .choice-box {
  border-color: var(--accent-green);
  background: rgba(16, 185, 129, 0.08);
}

.choice-label.incorrect .choice-box {
  border-color: var(--accent-red);
  background: rgba(239, 68, 68, 0.08);
}

.choice-letter {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(108, 99, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-purple);
  flex-shrink: 0;
}

.choice-label.correct .choice-letter {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-green);
}

.choice-label.incorrect .choice-letter {
  background: rgba(239, 68, 68, 0.2);
  color: var(--accent-red);
}

.choice-text {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.4;
}

/* Essay area */
.essay-area {
  margin-top: 8px;
}

.essay-input {
  resize: vertical;
  min-height: 100px;
}

/* Question footer */
.question-footer {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Hint & Answer sections */
.hint-section,
.answer-section {
  margin-top: 16px;
  border-radius: var(--radius);
  overflow: hidden;
}

.hint-section.slide-in,
.answer-section.slide-in {
  animation: slideIn 0.25s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hint-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: rgba(245, 158, 11, 0.05);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius);
}

.hint-icon {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
}

.hint-content p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.answer-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius);
}

.answer-icon {
  font-size: 20px;
  flex-shrink: 0;
  line-height: 1;
}

.answer-content strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-green);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 4px;
}

.answer-content p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ============================================================
   Chat Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalSlide 0.3s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.ai-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--transition);
}

.modal-close:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-red);
  border-color: rgba(239, 68, 68, 0.2);
}

/* Chat-specific */
.chat-modal {
  max-width: 580px;
  max-height: 80vh;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 420px;
}

.chat-message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.chat-message.user {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  line-height: 1;
}

.message-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.6;
}

.chat-message.assistant .message-bubble {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.chat-message.user .message-bubble {
  background: var(--accent-gradient);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.chat-input-area {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.chat-input-area textarea {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 14px;
  resize: none;
  outline: none;
  transition: border-color var(--transition);
  max-height: 100px;
  overflow-y: auto;
}

.chat-input-area textarea:focus {
  border-color: var(--accent-purple);
}

/* Session modal */
.session-modal {
  max-width: 700px;
  max-height: 80vh;
}

.modal-body {
  overflow-y: auto;
  padding: 24px;
  flex: 1;
}

.questions-preview {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.preview-question {
  display: flex;
  gap: 14px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.preview-question:last-child {
  border-bottom: none;
}

.q-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.q-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 10px;
  line-height: 1.5;
}

.q-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.choice-chip {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.q-answer {
  font-size: 13px;
  color: var(--accent-green);
}

.q-answer strong {
  color: var(--text-secondary);
}

.error-text {
  color: var(--accent-red);
  font-size: 14px;
}

/* ============================================================
   Toast Notifications
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.3s ease;
  pointer-events: auto;
  backdrop-filter: blur(10px);
}

.toast.toast-show {
  opacity: 1;
  transform: translateX(0);
}

.toast-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.toast-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.toast-info {
  background: rgba(108, 99, 255, 0.15);
  border: 1px solid rgba(108, 99, 255, 0.3);
  color: #a78bfa;
}

.toast-warning {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.toast-icon {
  font-size: 16px;
  flex-shrink: 0;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .tool-layout {
    grid-template-columns: 1fr;
  }

  .tool-form-panel {
    position: static;
  }
}

@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 72px;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 16px;
    flex-direction: column;
    gap: 4px;
    z-index: 99;
  }

  .nav-links.nav-open {
    display: flex;
  }

  .nav-toggle {
    display: flex;
  }

  .navbar { position: relative; }

  .nav-user {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }

  .hero-title { font-size: 36px; letter-spacing: -1px; }
  .hero-subtitle { font-size: 16px; }

  .hero-stats {
    gap: 16px;
  }

  .stat-divider { height: 30px; }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .page-header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .page-title { font-size: 24px; }

  .sessions-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-direction: column;
  }

  .auth-card {
    padding: 32px 24px;
  }

  .cta-card {
    padding: 48px 24px;
  }

  .chat-modal {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius-lg);
  }

  .session-modal {
    max-width: 100%;
    max-height: 90vh;
  }

  .question-footer {
    gap: 8px;
  }

  #toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .toast {
    max-width: 100%;
  }

  .questions-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .hero-section { padding: 60px 16px; }
  .hero-actions { flex-direction: column; align-items: center; }
  .hero-stats { flex-direction: column; gap: 16px; }
  .stat-divider { display: none; }
  .glass-card { padding: 20px; }
  .auth-card { padding: 28px 20px; }
}

/* ============================================================
   Progress Dashboard
   ============================================================ */
.progress-hero {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 28px;
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}
.progress-hero-main {
  flex: 1 1 320px;
  min-width: 0;
}
.progress-level-badge {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--shadow-accent);
}
.progress-level-label {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.progress-xp-bar {
  width: 100%;
  height: 14px;
  background: rgba(255,255,255,0.06);
  border-radius: 7px;
  margin: 12px 0 6px;
  overflow: hidden;
}
.progress-xp-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 7px;
  transition: width 0.6s ease;
}
.progress-xp-text {
  font-size: 13px;
  color: var(--text-secondary);
}
.progress-xp-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.progress-xp-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.progress-hero-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.stat-card {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 16px 20px;
  text-align: center;
  min-width: 110px;
  border: 1px solid var(--border-color);
}
.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
  line-height: 1.2;
}
.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Dashboard Tabs ── */
.dashboard-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 24px;
  overflow-x: auto;
}
.dash-tab {
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
  font-family: var(--font);
}
.dash-tab:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
}
.dash-tab.active {
  background: var(--accent-purple);
  color: #fff;
}
.dash-tab-content {
  display: none;
}
.dash-tab-content.active {
  display: block;
}

/* ── Dashboard Grid ── */
.dashboard-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
@media (max-width: 768px) {
  .dashboard-grid-2col { grid-template-columns: 1fr; }
}
.chart-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}
.chart-card h3 {
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--text-primary);
}

/* ── Activity Feed ── */
.activity-feed {
  max-height: 300px;
  overflow-y: auto;
  list-style: none;
  padding: 0;
  margin: 0;
}
.activity-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}
.activity-item:last-child { border-bottom: none; }
.activity-item .activity-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(108,99,255,0.15);
  color: var(--accent-purple);
  flex-shrink: 0;
  font-size: 14px;
}
.activity-item .activity-body {
  flex: 1;
  min-width: 0;
}
.activity-item .activity-body p {
  font-size: 14px;
  color: var(--text-primary);
  margin: 0;
}
.activity-item .activity-body small {
  font-size: 12px;
  color: var(--text-muted);
}
.activity-xp {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-green);
  white-space: nowrap;
}
.stats-bar {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.stats-bar .stat-mini {
  background: var(--bg-secondary);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  text-align: center;
  flex: 1;
  min-width: 80px;
}
.stats-bar .stat-mini span {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}
.stats-bar .stat-mini small {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ── Achievements ── */
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.achievement-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  border: 1px solid var(--border-color);
  transition: var(--transition);
  opacity: 0.45;
  filter: grayscale(0.8);
}
.achievement-card.earned {
  opacity: 1;
  filter: none;
  border-color: var(--accent-purple);
  box-shadow: 0 0 12px rgba(108,99,255,0.15);
}
.achievement-card .achievement-icon {
  font-size: 32px;
  margin-bottom: 8px;
}
.achievement-card .achievement-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.achievement-card .achievement-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ── Leaderboard ── */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}
.leaderboard-table th,
.leaderboard-table td {
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
}
.leaderboard-table th {
  color: var(--text-secondary);
  font-weight: 500;
  border-bottom: 1px solid var(--border-color);
}
.leaderboard-table td {
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}
.leaderboard-table tr:last-child td { border-bottom: none; }
.leaderboard-table .rank-1 td { color: #ffd700; }
.leaderboard-table .rank-2 td { color: #c0c0c0; }
.leaderboard-table .rank-3 td { color: #cd7f32; }
.leaderboard-myrank {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 16px;
  border: 1px solid var(--border-accent);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: var(--text-primary);
}

/* ============================================================
   Essay Evaluation
   ============================================================ */
.eval-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 28px;
  margin-top: 24px;
  border: 1px solid var(--border-color);
}
.eval-card h3 {
  font-size: 18px;
  margin-bottom: 20px;
  color: var(--text-primary);
}
.eval-scores {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.eval-score-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.eval-score-item label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}
.eval-score-bar {
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  overflow: hidden;
}
.eval-score-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}
.score-green { background: var(--accent-green); }
.score-yellow { background: var(--accent-yellow); }
.score-red { background: var(--accent-red); }
.eval-score-value {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}
.eval-feedback {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
}
.eval-suggestions {
  list-style: none;
  padding: 0;
}
.eval-suggestions li {
  padding: 8px 0 8px 20px;
  position: relative;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
}
.eval-suggestions li:last-child { border-bottom: none; }
.eval-suggestions li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--accent-purple);
  font-weight: 700;
}
.eval-xp-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16,185,129,0.15);
  color: var(--accent-green);
  font-size: 14px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  margin-top: 12px;
}
.eval-loading {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}
.eval-loading .spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.eval-history-list {
  margin-top: 16px;
}
.eval-history-item {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
}
.eval-history-item:hover {
  border-color: var(--border-accent);
}
.eval-history-item .eval-hist-score {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}
.eval-history-item .eval-hist-date {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================================
   Flashcards
   ============================================================ */
.deck-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border-color);
  transition: var(--transition);
}
.deck-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.deck-card h3 {
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.deck-card p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.deck-card .deck-actions {
  display: flex;
  gap: 8px;
}
.flashcard-flip-container {
  perspective: 1000px;
  width: 100%;
  max-width: 520px;
  height: 320px;
  margin: 32px auto;
  cursor: pointer;
}
.flashcard-flip-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}
.flashcard-flip-container.flipped .flashcard-flip-inner {
  transform: rotateY(180deg);
}
.flashcard-front,
.flashcard-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  border-radius: var(--radius-lg);
  font-size: 18px;
  line-height: 1.6;
  text-align: center;
  border: 1px solid var(--border-color);
}
.flashcard-front {
  background: var(--bg-card);
  color: var(--text-primary);
}
.flashcard-back {
  background: linear-gradient(135deg, #1e2130 0%, #252840 100%);
  color: var(--text-primary);
  transform: rotateY(180deg);
}
.rating-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 20px 0;
}
.btn-rating {
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  font-family: var(--font);
}
.btn-rating:hover {
  border-color: var(--accent-purple);
  background: rgba(108,99,255,0.1);
}
.btn-rating[data-quality="1"] { border-color: var(--accent-red); }
.btn-rating[data-quality="2"] { border-color: #f97316; }
.btn-rating[data-quality="3"] { border-color: var(--accent-yellow); }
.btn-rating[data-quality="4"] { border-color: #84cc16; }
.btn-rating[data-quality="5"] { border-color: var(--accent-green); }
.review-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  margin-bottom: 20px;
  overflow: hidden;
}
.review-progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 3px;
  transition: width 0.4s ease;
}
.review-counter {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* ============================================================
   Quiz Results
   ============================================================ */
.quiz-results-banner {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 24px;
  border: 1px solid var(--accent-green);
  margin-bottom: 20px;
  display: none;
}
.quiz-results-banner h3 {
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 12px;
}
.quiz-results-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.quiz-results-stats span {
  font-size: 14px;
  color: var(--text-secondary);
}
.quiz-results-stats strong {
  color: var(--text-primary);
}

/* ── Misc utility classes for new features ── */
.empty-state-sm {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.empty-state-sm i {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
  opacity: 0.5;
}
.form-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.form-row > * {
  flex: 1;
  min-width: 150px;
}

/* ── Responsive adjustments for new features ── */
@media (max-width: 768px) {
  .progress-hero {
    flex-direction: column;
    text-align: center;
    gap: 20px;
  }
  .progress-hero-stats {
    justify-content: center;
  }
  .eval-scores {
    grid-template-columns: 1fr;
  }
  .flashcard-flip-container {
    height: 260px;
  }
  .achievements-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}
@media (max-width: 480px) {
  .rating-buttons {
    flex-direction: column;
    align-items: stretch;
  }
  .quiz-results-stats {
    flex-direction: column;
    gap: 8px;
  }
}

/* ============================================================
   Deck Cards View
   ============================================================ */
.deck-cards-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.deck-card-item {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}
.deck-card-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.deck-card-content {
  flex: 1;
  min-width: 0;
}
.deck-card-front,
.deck-card-back {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}
.deck-card-front {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}
.deck-card-back {
  color: var(--text-secondary);
}

/* ============================================================
   Standalone Chat Page
   ============================================================ */
.chat-page-layout {
  display: flex;
  height: calc(100vh - 72px);
  overflow: hidden;
}
.chat-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}
.chat-sidebar-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.chat-sidebar-search {
  padding: 8px 12px;
}
.chat-sidebar-search .form-input {
  min-height: 36px;
  font-size: 13px;
}
.chat-session-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 4px 8px;
  margin: 0;
}
.chat-session-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  position: relative;
}
.chat-session-item:hover {
  background: rgba(255,255,255,0.04);
}
.chat-session-item.active {
  background: rgba(108,99,255,0.12);
  border-left: 3px solid var(--accent-purple);
}
.chat-session-title {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-session-date {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.chat-session-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 12px;
  opacity: 0;
  transition: var(--transition);
}
.chat-session-item:hover .chat-session-delete {
  opacity: 1;
}
.chat-session-delete:hover {
  color: var(--accent-red);
}

/* Chat main area */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-primary);
}
.chat-main-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}
.chat-main-header h2 {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
}
.chat-sidebar-toggle {
  display: none;
}
.chat-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.chat-welcome {
  margin: auto;
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 20px;
}
.chat-welcome-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.chat-welcome h2 {
  font-size: 22px;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.chat-welcome p {
  font-size: 15px;
  color: var(--text-muted);
}

/* Chat messages */
.sc-msg {
  display: flex;
  gap: 12px;
  max-width: 780px;
  width: 100%;
  align-self: flex-start;
}
.sc-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.sc-msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  background: var(--bg-card);
}
.sc-msg-bubble {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}
.sc-msg.user .sc-msg-bubble {
  background: rgba(108,99,255,0.15);
  border: 1px solid rgba(108,99,255,0.25);
}
.sc-msg-bubble p { margin: 0 0 8px; }
.sc-msg-bubble p:last-child { margin-bottom: 0; }
.sc-msg-bubble pre {
  background: rgba(0,0,0,0.3);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
}
.sc-msg-bubble code {
  font-size: 13px;
}

/* Chat input bar */
.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  align-items: flex-end;
}
.chat-input-bar .form-input {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 160px;
  font-size: 14px;
}
.chat-input-bar .btn-icon {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

/* Chat responsive */
@media (max-width: 768px) {
  .chat-sidebar {
    position: fixed;
    left: -280px;
    top: 72px;
    bottom: 0;
    z-index: 100;
    transition: left 0.3s ease;
  }
  .chat-sidebar.open {
    left: 0;
    box-shadow: var(--shadow-lg);
  }
  .chat-sidebar-toggle {
    display: inline-flex;
  }
}
