/* ==========================================================
   STUDY HELPER - CORE DESIGN SYSTEM & STYLESHEET
   ========================================================== */

/* ----------------------------------------------------------
   1. CSS Custom Properties / Color Palette & Tokens
   ---------------------------------------------------------- */
:root {
  /* Fonts */
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Dark Theme Tokens (Default) */
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-tertiary: #1f293d;
  --bg-card: rgba(22, 30, 49, 0.72);
  --bg-card-hover: rgba(30, 41, 67, 0.85);
  --bg-glass: rgba(18, 26, 44, 0.65);
  --bg-input: rgba(15, 23, 42, 0.8);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.6);
  --border-card: rgba(255, 255, 255, 0.12);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  /* Accent Colors */
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-glow: rgba(99, 102, 241, 0.35);
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  /* Shadow & Blur */
  --glass-blur: blur(16px);
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 20px 35px -10px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.35);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Light Theme Variables */
body.light-theme {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-tertiary: #e2e8f0;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-glass: rgba(255, 255, 255, 0.75);
  --bg-input: #ffffff;

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(99, 102, 241, 0.6);
  --border-card: rgba(0, 0, 0, 0.08);

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-faint: #94a3b8;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 30px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.2);
}

/* ----------------------------------------------------------
   2. Reset & Baseline
   ---------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  position: relative;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(168, 85, 247, 0.12) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(6, 182, 212, 0.08) 0px, transparent 60%);
  background-attachment: fixed;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  border: none;
  background: none;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}

/* ----------------------------------------------------------
   3. App Layout & Header
   ---------------------------------------------------------- */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 3rem;
  position: relative;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  background: var(--bg-glass);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
  position: sticky;
  top: 1rem;
  z-index: 50;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  box-shadow: var(--shadow-glow);
  flex-shrink: 0;
}

.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.1;
  background: linear-gradient(to right, var(--text-main), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  padding: 0.3rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  gap: 0.25rem;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.15rem;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.nav-tab .tab-icon {
  width: 17px;
  height: 17px;
}

.nav-tab:hover {
  color: var(--text-main);
}

.nav-tab.active {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

/* Header Action Controls */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

/* Ambient Sound Widget */
.ambient-widget {
  position: relative;
}

.ambient-widget .icon-btn {
  width: auto;
  padding: 0 0.85rem;
  gap: 0.45rem;
  border-radius: var(--radius-full);
}

.ambient-label {
  font-size: 0.78rem;
  font-weight: 600;
}

.ambient-widget.playing .icon-btn {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
}

.ambient-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: 210px;
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  z-index: 100;
  animation: slideDownFade 0.2s ease-out;
}

.ambient-menu-header {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.5rem;
}

.ambient-option {
  text-align: left;
  padding: 0.45rem 0.65rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.ambient-option:hover {
  background: var(--bg-tertiary);
  color: var(--text-main);
}

.ambient-option.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-light);
  font-weight: 600;
}

.ambient-volume-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.5rem 0.2rem;
  border-top: 1px solid var(--border-subtle);
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-faint);
}

.ambient-volume-row input[type="range"] {
  width: 95px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ----------------------------------------------------------
   4. Common Cards, Buttons, and Utilities
   ---------------------------------------------------------- */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  transition: border-color var(--transition-normal);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.3rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

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

.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-danger:hover {
  background: var(--accent-rose);
  color: #ffffff;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.text-btn {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-light);
  transition: color var(--transition-fast);
}

.text-btn:hover {
  color: var(--text-main);
  text-decoration: underline;
}

.hidden {
  display: none !important;
}

/* Tab Panels */
.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.tab-pane.active {
  display: block;
}

/* ----------------------------------------------------------
   5. TAB 1: POMODORO CLOCK
   ---------------------------------------------------------- */
.pomodoro-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 680px;
  margin: 0 auto;
  gap: 1.5rem;
}

/* Mode Switcher */
.pomo-mode-selector {
  display: flex;
  background: var(--bg-glass);
  padding: 0.35rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-card);
  gap: 0.4rem;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.25rem;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.mode-btn:hover {
  color: var(--text-main);
}

.mode-btn.active {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: var(--shadow-glow);
}

.mode-dur-badge {
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
}

/* Timer Display Card */
.timer-display-card {
  width: 100%;
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.8rem;
  position: relative;
  overflow: hidden;
}

.timer-circle-wrap {
  position: relative;
  width: 290px;
  height: 290px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.timer-track {
  fill: none;
  stroke: var(--bg-tertiary);
  stroke-width: 12;
}

.timer-progress {
  fill: none;
  stroke: url(#timerGradient);
  stroke: var(--primary-light);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 880; /* 2 * PI * 140 = ~879.6 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.5s ease, stroke 0.3s ease;
  filter: drop-shadow(0 0 10px var(--primary-glow));
}

.timer-center-content {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.timer-mode-tag {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin-bottom: 0.25rem;
}

.timer-digits {
  font-family: var(--font-mono);
  font-size: 4.2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-main);
  letter-spacing: -0.04em;
  text-shadow: 0 0 25px rgba(99, 102, 241, 0.2);
}

.timer-status-pulse {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-weight: 500;
}

/* Task Input for Current Session */
.focus-task-container {
  width: 100%;
  max-width: 440px;
}

.task-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.55rem 1rem;
  transition: all var(--transition-fast);
}

.task-input-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.task-input-wrapper input {
  width: 100%;
  font-size: 0.88rem;
  color: var(--text-main);
  outline: none;
}

.task-input-wrapper input::placeholder {
  color: var(--text-faint);
}

/* Timer Controls */
.timer-controls {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.pomo-ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.pomo-ctrl-btn.secondary {
  padding: 0.65rem 1.25rem;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  font-size: 0.85rem;
}

.pomo-ctrl-btn.secondary svg {
  width: 16px;
  height: 16px;
}

.pomo-ctrl-btn.secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.pomo-ctrl-btn.primary.large {
  padding: 0.85rem 2.2rem;
  background: var(--primary-gradient);
  color: #ffffff;
  font-size: 1.1rem;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.pomo-ctrl-btn.primary.large svg {
  width: 20px;
  height: 20px;
}

.pomo-ctrl-btn.primary.large:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.55);
}

/* Bottom Stats and Presets Grid */
.pomodoro-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  gap: 1.25rem;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-title-row h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  flex: 1;
  margin-left: 0.5rem;
}

.stats-row {
  display: flex;
  justify-content: space-around;
  text-align: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-number {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary-light);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.preset-pills {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.preset-btn {
  text-align: left;
  padding: 0.55rem 0.85rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.preset-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-focus);
}

.preset-btn.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--primary);
  color: var(--primary-light);
  font-weight: 600;
}

/* ----------------------------------------------------------
   6. TAB 2: FLASHCARDS
   ---------------------------------------------------------- */
.flashcards-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 720px;
  margin: 0 auto;
  gap: 1.5rem;
  width: 100%;
}

.deck-top-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.4rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.deck-selector-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 220px;
}

.field-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.custom-select-wrap {
  flex: 1;
  position: relative;
}

.custom-select-wrap select, .quiz-select, .modal-form select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.85rem;
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.custom-select-wrap select:focus, .quiz-select:focus, .modal-form select:focus {
  border-color: var(--border-focus);
}

.deck-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Deck Progress */
.deck-progress-bar-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.progress-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.mastery-badge {
  color: var(--accent-emerald);
}

.dual-progress-bar {
  height: 8px;
  width: 100%;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
  display: flex;
}

.progress-mastered {
  background: var(--accent-emerald);
  transition: width 0.3s ease;
}

.progress-learning {
  background: var(--accent-amber);
  transition: width 0.3s ease;
}

/* 3D Flip Card Scene */
.flashcard-scene {
  width: 100%;
  height: 380px;
  perspective: 1200px;
  cursor: pointer;
  user-select: none;
}

.flashcard-3d {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: var(--radius-lg);
}

.flashcard-3d.is-flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  padding: 2rem 2.2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-lg);
  box-sizing: border-box;
}

/* Card Front */
.card-front {
  background: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.12) 0%, var(--bg-card) 90%);
}

/* Card Back */
.card-back {
  transform: rotateY(180deg);
  background: radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.12) 0%, var(--bg-card) 90%);
}

.card-face-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-type-tag {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.18);
  color: var(--primary-light);
}

.card-type-tag.tag-answer {
  background: rgba(16, 185, 129, 0.18);
  color: var(--accent-emerald);
}

.card-status-pill {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.card-status-pill.status-mastered {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
}

.card-hint-trigger {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-amber);
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.card-hint-trigger:hover {
  background: rgba(245, 158, 11, 0.15);
}

.card-face-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.card-prompt-text, .card-answer-text {
  font-family: var(--font-heading);
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-main);
  max-width: 90%;
  word-break: break-word;
}

.card-hint-text, .card-notes-text {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
  max-width: 85%;
  background: var(--bg-tertiary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
}

.card-face-footer {
  text-align: center;
}

.flip-instruction {
  font-size: 0.78rem;
  color: var(--text-faint);
}

/* Flashcard Navigation and Controls */
.flashcard-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  width: 100%;
}

.fcard-nav-btn {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.fcard-nav-btn svg {
  width: 22px;
  height: 22px;
}

.fcard-nav-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.assessment-buttons {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.assess-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.assess-repeat {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.assess-repeat:hover {
  background: var(--accent-amber);
  color: #000000;
  transform: translateY(-2px);
}

.assess-flip {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}

.assess-flip:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.assess-mastered {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.assess-mastered:hover {
  background: var(--accent-emerald);
  color: #ffffff;
  transform: translateY(-2px);
}

/* Bottom Card Tools */
.flashcard-sub-tools {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.tool-chip {
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.tool-chip:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-card);
}

.tool-chip.delete-chip:hover {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border-color: var(--accent-rose);
}

.tool-chip.quiz-shortcut-chip {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-light);
  border-color: rgba(99, 102, 241, 0.3);
}

.tool-chip.quiz-shortcut-chip:hover {
  background: var(--primary-gradient);
  color: #ffffff;
}

/* ----------------------------------------------------------
   7. TAB 3: QUIZ ARENA
   ---------------------------------------------------------- */
.quiz-container {
  max-width: 780px;
  margin: 0 auto;
  width: 100%;
}

.quiz-hero-card {
  text-align: center;
  padding: 2.2rem 1.8rem;
  margin-bottom: 1.5rem;
}

.hero-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.25rem 0.85rem;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.18);
  color: var(--primary-light);
  margin-bottom: 0.6rem;
}

.quiz-hero-card h2 {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.quiz-hero-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 580px;
  margin: 0 auto;
}

.quiz-modes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.quiz-option-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.8rem;
}

.quiz-option-icon {
  font-size: 2.2rem;
}

.quiz-option-card h3 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
}

.quiz-option-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.quiz-btn-row {
  display: flex;
  gap: 0.6rem;
  margin-top: auto;
}

.quiz-btn-row .btn {
  flex: 1;
}

/* Active Quiz Runner Card */
.quiz-runner-card {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.quiz-runner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quiz-title-info h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
}

.quiz-counter-tag {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.quiz-score-live {
  font-family: var(--font-mono);
  font-weight: 700;
  background: var(--bg-tertiary);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  font-size: 0.88rem;
}

.live-score-val {
  color: var(--accent-emerald);
  margin-left: 0.25rem;
}

.exit-quiz-btn {
  color: var(--text-faint);
}

.quiz-progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--primary-gradient);
  transition: width 0.35s ease;
}

.quiz-question-box {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quiz-question-box h2 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.4;
}

/* Multiple choice options grid */
.quiz-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.quiz-option-btn {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.1rem 1.3rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-align: left;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  transition: all var(--transition-fast);
  cursor: pointer;
  word-break: break-word;
}

.quiz-option-btn:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.quiz-option-btn:disabled {
  cursor: default;
}

.opt-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--primary-light);
  flex-shrink: 0;
}

/* Option states */
.quiz-option-btn.selected-correct {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.quiz-option-btn.selected-correct .opt-letter {
  background: var(--accent-emerald);
  color: #ffffff;
}

.quiz-option-btn.selected-wrong {
  background: rgba(244, 63, 94, 0.2);
  border-color: var(--accent-rose);
  color: var(--accent-rose);
}

.quiz-option-btn.selected-wrong .opt-letter {
  background: var(--accent-rose);
  color: #ffffff;
}

.quiz-option-btn.reveal-correct {
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
}

/* Feedback Banner */
.quiz-feedback-banner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.2rem 1.5rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  animation: slideUpFade 0.3s ease-out;
}

.quiz-feedback-banner.correct {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
}

.quiz-feedback-banner.incorrect {
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.3);
}

.feedback-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.feedback-content {
  flex: 1;
}

.feedback-content h4 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.feedback-content p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Quiz Results Screen */
.quiz-results-card {
  padding: 2.5rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2rem;
}

.results-trophy {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  animation: bounce 1s infinite alternate;
}

.results-header h2 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
}

.score-showcase {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.score-circle {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 4px solid var(--primary-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px var(--primary-glow);
}

.score-pct {
  font-family: var(--font-mono);
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-main);
}

.score-fraction {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 0.35rem;
}

.results-badge {
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.35rem 1rem;
  border-radius: var(--radius-full);
  background: rgba(99, 102, 241, 0.18);
  color: var(--primary-light);
}

.results-breakdown-wrapper {
  width: 100%;
  text-align: left;
}

.results-breakdown-wrapper h4 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.results-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.breakdown-item {
  background: var(--bg-tertiary);
  border-left: 4px solid var(--accent-rose);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
}

.breakdown-item.correct {
  border-left-color: var(--accent-emerald);
}

.breakdown-item-q {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.breakdown-item-ans {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.results-action-row {
  display: flex;
  gap: 1rem;
}

/* ----------------------------------------------------------
   8. Study Buddy Widget
   ---------------------------------------------------------- */
.study-buddy-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: flex-end;
  gap: 0.85rem;
  z-index: 90;
}

.buddy-bubble {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1.1rem;
  max-width: 250px;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: slideUpFade 0.3s ease-out;
}

.buddy-bubble p {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.35;
}

.bubble-close-btn {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 1rem;
  color: var(--text-faint);
  line-height: 1;
}

.buddy-avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.45);
  cursor: pointer;
  position: relative;
  transition: transform var(--transition-bounce);
  flex-shrink: 0;
}

.buddy-avatar:hover {
  transform: scale(1.1) rotate(5deg);
}

.buddy-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.buddy-eyes {
  display: flex;
  gap: 10px;
}

.buddy-eyes .eye {
  width: 6px;
  height: 6px;
  background: #ffffff;
  border-radius: 50%;
  animation: blink 4s infinite;
}

.buddy-mouth {
  width: 10px;
  height: 5px;
  border-bottom: 2px solid #ffffff;
  border-radius: 0 0 10px 10px;
}

/* ----------------------------------------------------------
   9. Modals & Forms
   ---------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 200;
  animation: fadeIn 0.2s ease-out;
}

.modal-dialog {
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.8rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: relative;
  animation: scaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-dialog.modal-large {
  max-width: 720px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
}

.modal-close-btn {
  font-size: 1.6rem;
  color: var(--text-muted);
  line-height: 1;
  padding: 0.2rem;
  transition: color var(--transition-fast);
}

.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.9rem;
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-fast);
}

.form-group input:focus, .form-group textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
}

.checkbox-group .checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-main);
}

.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* Deck Manager Card List */
.manager-search-bar {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.manager-search-bar input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.85rem;
}

.manager-card-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 0.3rem;
}

.manager-card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  gap: 0.75rem;
}

.manager-card-text {
  flex: 1;
}

.manager-card-q {
  font-weight: 600;
  font-size: 0.9rem;
}

.manager-card-a {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.manager-item-actions {
  display: flex;
  gap: 0.4rem;
}

/* Custom Quiz Builder Rows */
.quiz-questions-builder {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 0.5rem;
  margin-bottom: 0.75rem;
}

.builder-question-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.builder-q-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary-light);
}

.builder-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.builder-opt-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.builder-opt-row input[type="radio"] {
  accent-color: var(--accent-emerald);
  cursor: pointer;
}

.builder-opt-row input[type="text"] {
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
}

/* Settings block */
.settings-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.settings-action-block {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.settings-action-block h4 {
  font-size: 0.95rem;
  font-weight: 600;
}

.settings-action-block p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.settings-action-block.danger-zone {
  border-color: rgba(244, 63, 94, 0.3);
}

/* ----------------------------------------------------------
   10. Toast Notifications
   ---------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 300;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-card);
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slideUpFade 0.25s ease-out;
}

.toast.toast-success {
  border-color: var(--accent-emerald);
  color: var(--accent-emerald);
}

.toast.toast-info {
  border-color: var(--primary);
  color: var(--primary-light);
}

.toast.toast-warning {
  border-color: var(--accent-amber);
  color: var(--accent-amber);
}

/* ----------------------------------------------------------
   11. Keyframe Animations
   ---------------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes slideDownFade {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes blink {
  0%, 94%, 98%, 100% { transform: scaleY(1); }
  96% { transform: scaleY(0.1); }
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

/* ----------------------------------------------------------
   12. Responsive Media Queries
   ---------------------------------------------------------- */
@media (max-width: 768px) {
  .app-header {
    flex-wrap: wrap;
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }

  .nav-tabs {
    order: 3;
    width: 100%;
    justify-content: space-around;
  }

  .nav-tab {
    padding: 0.45rem 0.85rem;
    font-size: 0.82rem;
  }

  .header-actions {
    margin-left: auto;
  }

  .ambient-label {
    display: none;
  }

  .pomodoro-bottom-grid {
    grid-template-columns: 1fr;
  }

  .quiz-modes-grid {
    grid-template-columns: 1fr;
  }

  .quiz-options-grid {
    grid-template-columns: 1fr;
  }

  .flashcard-scene {
    height: 330px;
  }

  .card-prompt-text, .card-answer-text {
    font-size: 1.25rem;
  }

  .builder-options-grid {
    grid-template-columns: 1fr;
  }

  .form-row-3 {
    grid-template-columns: 1fr;
  }

  .study-buddy-widget {
    bottom: 1rem;
    right: 1rem;
  }

  .buddy-bubble {
    max-width: 190px;
    font-size: 0.75rem;
  }
}
