/* ============================================================
   StudyPortal — CSS
   Design: GitHub-dark inspired, Sovamoon product blue (#2F81F7)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg:          #0D1117;
  --bg-card:     #161B22;
  --bg-input:    #0D1117;
  --bg-hover:    #1C2128;
  --border:      rgba(255,255,255,0.08);
  --border-focus: #2F81F7;
  --accent:      #2F81F7;
  --accent-hover: #388bfd;
  --accent-dim:  rgba(47,129,247,0.15);
  --text:        #E6EDF3;
  --text-muted:  #7D8590;
  --text-subtle: #484f58;
  --success:     #3fb950;
  --success-dim: rgba(63,185,80,0.15);
  --warning:     #d29922;
  --warning-dim: rgba(210,153,34,0.15);
  --danger:      #f85149;
  --danger-dim:  rgba(248,81,73,0.15);
  --sidebar-w:   240px;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.2);
  --transition:  all 0.18s ease;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

h1, h2, h3, h4, h5 { line-height: 1.3; font-weight: 600; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }

p { color: var(--text-muted); }

ul, ol { padding-left: 1.25rem; }
li { margin-bottom: 0.25rem; }

hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ── Layout ────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo a {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
}

.sidebar-logo .logo-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
}

.nav-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  padding: 0.75rem 1.25rem 0.375rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5625rem 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0;
  transition: var(--transition);
  position: relative;
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-hover);
  text-decoration: none;
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.sidebar-user .user-avatar {
  width: 28px; height: 28px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.sidebar-user .user-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}

.page-header {
  padding: 1.5rem 2rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 1.375rem; }

.page-body {
  padding: 1.75rem 2rem;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
}

.card:hover {
  border-color: rgba(255,255,255,0.14);
  box-shadow: 0 0 0 1px rgba(47,129,247,0.1), var(--shadow);
}

.card-body { padding: 1.25rem; }
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.card-footer {
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* Study set grid */
.study-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.study-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  text-decoration: none;
  color: inherit;
}

.study-card:hover {
  border-color: rgba(47,129,247,0.4);
  box-shadow: 0 0 0 1px rgba(47,129,247,0.15), var(--shadow);
  text-decoration: none;
  transform: translateY(-1px);
}

.study-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.study-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.study-card-stats {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.study-card-date {
  font-size: 0.75rem;
  color: var(--text-subtle);
}

.study-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1.5;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}

.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
  text-decoration: none;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: rgba(255,255,255,0.15);
  color: var(--text);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-dim);
  color: var(--danger);
  text-decoration: none;
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.btn-success:hover {
  background: #2ea043;
  color: #fff;
  text-decoration: none;
}

.btn-sm {
  padding: 0.3125rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.6875rem 1.5rem;
  font-size: 1rem;
}

.btn-block { width: 100%; }

.btn svg { width: 15px; height: 15px; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1875rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 20px;
  line-height: 1.4;
}

.badge-pending {
  background: var(--warning-dim);
  color: var(--warning);
  border: 1px solid rgba(210,153,34,0.3);
}

.badge-processing {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(47,129,247,0.3);
}

.badge-done {
  background: var(--success-dim);
  color: var(--success);
  border: 1px solid rgba(63,185,80,0.3);
}

.badge-error {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(248,81,73,0.3);
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 10px; height: 10px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.125rem; }

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.375rem;
}

.form-label .required { color: var(--danger); margin-left: 2px; }

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9375rem;
  font-family: inherit;
  padding: 0.5625rem 0.875rem;
  transition: var(--transition);
  outline: none;
  -webkit-appearance: none;
}

.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-subtle); }

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(47,129,247,0.12);
}

.form-textarea {
  resize: vertical;
  min-height: 180px;
  line-height: 1.6;
}

.form-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.3125rem;
}

.char-counter {
  font-size: 0.75rem;
  color: var(--text-subtle);
  text-align: right;
  margin-top: 0.25rem;
}

.char-counter.near-limit { color: var(--warning); }
.char-counter.at-limit { color: var(--danger); }

/* ── Auth Page ──────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--bg);
}

.auth-logo {
  margin-bottom: 2rem;
  text-align: center;
}

.auth-logo .logo-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.5rem;
}

.auth-logo .logo-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
}

.auth-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-logo p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.auth-tab-btn {
  flex: 1;
  padding: 0.875rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  margin-bottom: -1px;
}

.auth-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.auth-tab-btn:hover:not(.active) {
  color: var(--text);
  background: var(--bg-hover);
}

.auth-form { padding: 1.5rem; }

.auth-form .form-group:last-of-type { margin-bottom: 1.25rem; }

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  border: 1px solid;
}

.alert-error {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: rgba(248,81,73,0.3);
}

.alert-success {
  background: var(--success-dim);
  color: var(--success);
  border-color: rgba(63,185,80,0.3);
}

.alert-info {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(47,129,247,0.3);
}

/* ── Tabs Component ─────────────────────────────────────────── */
.tabs-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 0.75rem 1.125rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  white-space: nowrap;
  margin-bottom: -1px;
}

.tab-btn:hover:not(.active) {
  color: var(--text);
  background: var(--bg-hover);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel { display: none; padding: 1.5rem; }
.tab-panel.active { display: block; }

/* ── Flashcard Flip ─────────────────────────────────────────── */
.flashcard-scene {
  perspective: 1000px;
  width: 100%;
  max-width: 560px;
  height: 280px;
  margin: 0 auto;
  cursor: pointer;
  user-select: none;
}

.flashcard-inner {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4,0,0.2,1);
}

.flashcard-inner.flipped { transform: rotateY(180deg); }

.flashcard-face {
  position: absolute;
  inset: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flashcard-face.back {
  transform: rotateY(180deg);
  background: var(--bg-hover);
  border-color: rgba(47,129,247,0.25);
}

.flashcard-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-subtle);
  margin-bottom: 1rem;
}

.flashcard-text {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.5;
}

.flashcard-hint {
  font-size: 0.75rem;
  color: var(--text-subtle);
  margin-top: 1rem;
}

/* ── Practice Mode ──────────────────────────────────────────── */
.practice-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 1.5rem 0;
}

.practice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.practice-mode-label {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 0.25rem 0.625rem;
  border-radius: 4px;
}

.practice-timer {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.progress-bar-container {
  margin-bottom: 1.5rem;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Question card */
.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 1.25rem;
}

.question-text {
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 1.5rem;
}

/* T/F buttons */
.tf-buttons {
  display: flex;
  gap: 0.75rem;
}

.tf-btn {
  flex: 1;
  padding: 0.875rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.tf-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.tf-btn.correct {
  border-color: var(--success);
  background: var(--success-dim);
  color: var(--success);
}

.tf-btn.wrong {
  border-color: var(--danger);
  background: var(--danger-dim);
  color: var(--danger);
}

/* MC options */
.mc-options {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.mc-option {
  padding: 0.875rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9375rem;
  font-family: inherit;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  line-height: 1.5;
}

.mc-option .option-letter {
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 1.25rem;
}

.mc-option:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.mc-option.correct {
  border-color: var(--success);
  background: var(--success-dim);
}

.mc-option.correct .option-letter { color: var(--success); }

.mc-option.wrong {
  border-color: var(--danger);
  background: var(--danger-dim);
}

.mc-option.wrong .option-letter { color: var(--danger); }

/* Explanation box */
.explanation-box {
  margin-top: 1rem;
  padding: 0.875rem 1rem;
  background: rgba(0,0,0,0.2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  display: none;
}

.explanation-box.visible { display: block; }
.explanation-box strong { color: var(--text); }

/* ── Practice Navigation ────────────────────────────────────── */
.practice-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}

.practice-score-inline {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Results Screen ─────────────────────────────────────────── */
.results-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
  max-width: 480px;
  margin: 0 auto;
}

.results-score-circle {
  width: 100px; height: 100px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 3px solid var(--accent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.results-score-pct {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.results-score-sub {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.results-stats {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.results-stat { text-align: center; }
.results-stat .val { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.results-stat .label { font-size: 0.75rem; color: var(--text-muted); }

/* ── Key Concepts ───────────────────────────────────────────── */
.concepts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.875rem;
}

.concept-card {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.concept-term {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.375rem;
}

.concept-def {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ── Flashcard List (study-set.php) ─────────────────────────── */
.flashcard-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.flashcard-list-item {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.flashcard-list-front {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.flashcard-list-back {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── Questions List ─────────────────────────────────────────── */
.question-list { display: flex; flex-direction: column; gap: 0.75rem; }

.question-list-item {
  background: rgba(0,0,0,0.15);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.question-list-q {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.question-list-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ── Upload Page ─────────────────────────────────────────────── */
.upload-container { max-width: 680px; }

.upload-tabs-inner {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.upload-tab-btn {
  padding: 0.4375rem 0.875rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.upload-tab-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
  background: rgba(0,0,0,0.1);
}

.dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.dropzone svg { color: var(--text-subtle); margin-bottom: 0.75rem; }
.dropzone p { font-size: 0.9375rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.dropzone small { font-size: 0.8125rem; color: var(--text-subtle); }

.dropzone-file-selected {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--success-dim);
  border: 1px solid rgba(63,185,80,0.3);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;
  margin-top: 0.75rem;
}

.dropzone-file-selected svg { color: var(--success); flex-shrink: 0; }
.dropzone-file-name { font-size: 0.875rem; color: var(--text); flex: 1; }
.dropzone-file-size { font-size: 0.75rem; color: var(--text-muted); }

/* ── Update Mode Options (Replace / Append) ────────────────── */
.update-mode-options {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-top: 0.5rem;
}

.update-mode-option {
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
  padding: 1rem 1.125rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.update-mode-option:hover {
  border-color: var(--border-hover);
  background: var(--surface-hover);
}
.update-mode-option input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--accent);
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  cursor: pointer;
}
.update-mode-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.update-mode-content { flex: 1; min-width: 0; }
.update-mode-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
  flex-wrap: wrap;
}
.update-mode-icon { font-size: 1rem; }
.update-mode-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.55;
}
.update-mode-desc em { font-style: normal; color: var(--accent); font-weight: 500; }

/* ── History Table ──────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.15);
}

.data-table td {
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,0.02); }

.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.score-high { color: var(--success); background: var(--success-dim); }
.score-mid  { color: var(--warning); background: var(--warning-dim); }
.score-low  { color: var(--danger);  background: var(--danger-dim);  }

/* ── Stats bar ──────────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.stat-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1.25rem;
  flex: 1;
  min-width: 120px;
}

.stat-chip .val {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 0.25rem;
}

.stat-chip .label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Summary bullets ────────────────────────────────────────── */
.summary-text {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 1.25rem;
}

.bullet-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bullet-list li {
  padding: 0.625rem 0.875rem;
  background: rgba(0,0,0,0.15);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.5;
}

/* ── ELI5 box ──────────────────────────────────────────────── */
.eli5-box {
  background: var(--warning-dim);
  border: 1px solid rgba(210,153,34,0.3);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-top: 1.25rem;
}

.eli5-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--warning);
  margin-bottom: 0.5rem;
}

.eli5-text {
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.65;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.empty-state svg {
  color: var(--text-subtle);
  margin-bottom: 1rem;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.empty-state h3 { color: var(--text); margin-bottom: 0.5rem; }
.empty-state p { margin-bottom: 1.5rem; }

/* ── Toast Notifications ────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1.125rem;
  font-size: 0.875rem;
  color: var(--text);
  box-shadow: var(--shadow);
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 280px;
  max-width: 380px;
  animation: slideInUp 0.25s ease;
}

.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error   { border-left: 3px solid var(--danger); }
.toast.toast-info    { border-left: 3px solid var(--accent); }
.toast.toast-warning { border-left: 3px solid var(--warning); }

.toast-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toast-success .toast-dot { background: var(--success); }
.toast-error   .toast-dot { background: var(--danger); }
.toast-info    .toast-dot { background: var(--accent); }
.toast-warning .toast-dot { background: var(--warning); }

.toast-msg { flex: 1; }

.toast.fade-out { animation: slideOutDown 0.2s ease forwards; }

@keyframes slideInUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

@keyframes slideOutDown {
  from { transform: translateY(0); opacity: 1; }
  to   { transform: translateY(16px); opacity: 0; }
}

/* ── Practice Mode Feedback Flash ───────────────────────────── */
@keyframes flashCorrect {
  0%   { box-shadow: 0 0 0 0 rgba(63,185,80,0.6); }
  50%  { box-shadow: 0 0 0 8px rgba(63,185,80,0.1); }
  100% { box-shadow: 0 0 0 0 rgba(63,185,80,0); }
}

@keyframes flashWrong {
  0%   { box-shadow: 0 0 0 0 rgba(248,81,73,0.6); }
  50%  { box-shadow: 0 0 0 8px rgba(248,81,73,0.1); }
  100% { box-shadow: 0 0 0 0 rgba(248,81,73,0); }
}

.flash-correct { animation: flashCorrect 0.5s ease; }
.flash-wrong   { animation: flashWrong 0.5s ease; }

/* ── Mobile Hamburger ───────────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  z-index: 200;
  padding: 0 1rem;
  align-items: center;
  justify-content: space-between;
}

.hamburger-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

/* ── Misc Utilities ─────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.p-0 { padding: 0; }
.w-full { width: 100%; }
.hidden { display: none; }

/* ── Loading skeleton ───────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .mobile-header { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay.visible { display: block; }

  .main-content {
    margin-left: 0;
    padding-top: 56px;
  }

  .page-header {
    padding: 1rem;
  }

  .page-body {
    padding: 1rem;
  }

  .study-grid {
    grid-template-columns: 1fr;
  }

  .flashcard-list {
    grid-template-columns: 1fr;
  }

  .flashcard-scene {
    height: 220px;
  }

  .concepts-grid {
    grid-template-columns: 1fr;
  }

  .stats-bar {
    gap: 0.75rem;
  }

  .stat-chip { min-width: 0; }

  .data-table th:nth-child(4),
  .data-table td:nth-child(4) { display: none; }

  .tf-buttons { flex-direction: column; }

  .results-stats { flex-direction: column; gap: 0.75rem; }

  .auth-card { max-width: 100%; }
}
