/* ==========================================================================
   ITPE Technical Specialist Flashcards - Stylesheet
   Design Aesthetic: Premium Dark Glassmorphism with Vibrant Accents
   ========================================================================== */

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-glass: rgba(30, 41, 59, 0.75);
  --bg-glass-hover: rgba(51, 65, 85, 0.85);
  --card-bg-front: #1e293b;
  --card-bg-back: #0f172a;
  --border-color: rgba(255, 255, 255, 0.1);
  --border-highlight: rgba(99, 102, 241, 0.4);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-indigo: #6366f1;
  --accent-indigo-hover: #4f46e5;
  --accent-purple: #a855f7;

  --color-easy: #10b981;
  --color-easy-bg: rgba(16, 185, 129, 0.15);
  --color-medium: #f59e0b;
  --color-medium-bg: rgba(245, 158, 11, 0.15);
  --color-hard: #ef4444;
  --color-hard-bg: rgba(239, 68, 68, 0.15);
  --color-due: #38bdf8;

  --font-main: 'Inter', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 0 15px rgba(99, 102, 241, 0.2);
}

/* Light Theme Variables */
body.light-theme {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.85);
  --bg-glass-hover: #e2e8f0;
  --card-bg-front: #ffffff;
  --card-bg-back: #f8fafc;
  --border-color: #cbd5e1;
  --border-highlight: #6366f1;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 24px rgba(99, 102, 241, 0.15);
}

/* Global Reset & Basic Formatting */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  line-height: 1.5;
}

/* App Header */
.app-header {
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1.5rem;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

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

.logo-icon {
  font-size: 1.8rem;
  color: var(--accent-indigo);
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.logo-text .subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Header Stats Bar */
.header-stats {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

.stat-pill.easy { color: var(--color-easy); border-color: rgba(16, 185, 129, 0.3); }
.stat-pill.medium { color: var(--color-medium); border-color: rgba(245, 158, 11, 0.3); }
.stat-pill.hard { color: var(--color-hard); border-color: rgba(239, 68, 68, 0.3); }
.stat-pill.due { color: var(--color-due); border-color: rgba(56, 189, 248, 0.35); }

/* The dashboard keeps only the two decisions that matter before study. */
.header-stats .stat-pill:not(.due) { display: none; }

.progress-bar-container {
  width: 160px;
  height: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-indigo), var(--color-easy));
  transition: width 0.4s ease;
}

.progress-text {
  position: absolute;
  width: 100%;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.mobile-filter-btn,
.mobile-sidebar-title {
  display: none;
}

.icon-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--accent-indigo);
  color: #fff;
  border-color: var(--accent-indigo);
}

.icon-btn.danger:hover {
  background: var(--color-hard);
  border-color: var(--color-hard);
}

/* App Layout Grid */
.app-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  min-height: calc(100vh - 65px);
}

/* Sidebar Filter Panel */
.sidebar {
  background: var(--bg-glass);
  border-right: 1px solid var(--border-color);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
  max-height: calc(100vh - 65px);
}

.sidebar-section h3 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.badge {
  background: var(--accent-indigo);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

/* Mode Buttons */
.mode-menu {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.mode-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.mode-btn.active {
  background: var(--accent-indigo);
  color: #ffffff;
  border-color: var(--border-highlight);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Card Type Selector */
.type-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 0.3rem;
  background: var(--bg-secondary);
  padding: 0.25rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.type-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.type-btn.active {
  background: var(--accent-indigo);
  color: #fff;
}

/* Category List */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.cat-item-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s ease;
}

.cat-item-btn:hover {
  border-color: var(--accent-indigo);
  color: var(--text-primary);
}

.cat-item-btn.active {
  border-color: var(--accent-indigo);
  background: rgba(99, 102, 241, 0.15);
  color: var(--text-primary);
  font-weight: 700;
}

.cat-item-btn .cat-count {
  font-size: 0.72rem;
  background: rgba(255,255,255,0.1);
  padding: 1px 6px;
  border-radius: 6px;
}

/* Shortcut Guide */
.shortcut-guide {
  margin-top: auto;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.shortcut-guide ul {
  list-style: none;
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

kbd {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-primary);
}

/* Main Content Area */
.main-content {
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
}

.main-content > .toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--bg-glass);
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  flex: 1;
  max-width: 500px;
}

.search-box i {
  color: var(--text-muted);
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.9rem;
  width: 100%;
}

.clear-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

/* Toggle Switch */
.toggle-switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.slider {
  width: 36px;
  height: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  position: relative;
  transition: all 0.3s ease;
}

.slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  top: 2px;
  left: 2px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: all 0.3s ease;
}

.toggle-switch input:checked + .slider {
  background: var(--accent-indigo);
  border-color: var(--accent-indigo);
}

.toggle-switch input:checked + .slider::before {
  transform: translateX(16px);
  background: #fff;
}

.toggle-switch input:focus-visible + .slider {
  outline: 3px solid rgba(56, 189, 248, 0.75);
  outline-offset: 3px;
}

/* Buttons */
.btn {
  padding: 0.55rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.btn.primary {
  background: var(--accent-indigo);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-indigo-hover); }

.btn.secondary {
  background: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-primary);
}
.btn.secondary:hover { background: var(--bg-glass-hover); }

.btn.danger-outline {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--color-hard);
}
.btn.danger-outline:hover { background: var(--color-hard); color: #fff; }

/* Desktop keeps the reset action in the header only; the drawer copy is
   for mobile, where the header hides it to declutter (see max-width: 992px). */
.mobile-only-danger { display: none; }

/* View Panels */
.view-panel {
  display: none;
  flex-direction: column;
  gap: 1.25rem;
  animation: fadeIn 0.3s ease;
}

.view-panel.active {
  display: flex;
}

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

/* FLASHCARD DECK SCENE */
.flashcard-deck-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-counter {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-indigo);
}

.deck-category-tag {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
}

/* 3D Card Flip Scene */
.card-scene {
  width: 100%;
  max-width: 820px;
  height: min(520px, 62vh);
  min-height: 420px;
  margin: 0 auto;
  perspective: 1400px;
}

.card-3d {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}

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

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

/* Front Face */
.card-front {
  background: linear-gradient(135deg, var(--card-bg-front), #111827);
}

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

.card-badge-type {
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-indigo);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.mnemonic-badge {
  background: rgba(245, 158, 11, 0.2);
  color: var(--color-medium);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.card-front-body {
  margin: auto 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card-title {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text-primary);
  text-align: center;
}

.mnemonic-container {
  background: rgba(245, 158, 11, 0.08);
  border: 1px dashed rgba(245, 158, 11, 0.4);
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
}

.mnemonic-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-medium);
  margin-bottom: 0.4rem;
}

.mnemonic-list {
  list-style: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fef08a;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.keyword-hint-box {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.hint-label {
  font-weight: 700;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.2rem;
}

.card-flip-prompt {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Back Face */
.card-back {
  background: var(--card-bg-back);
  transform: rotateY(180deg);
  border-color: var(--border-highlight);
}

.card-back-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
}

.card-back-title {
  min-width: 0;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent-indigo);
}

.card-back-rating {
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-secondary);
}

.card-back-scrollable {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
  margin: 0.85rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Detail Content Blocks */
.detail-block h4 {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.detail-block p, .detail-block .detail-content {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-line;
}

.tags-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag-item {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
}

.card-back-footer {
  border-top: 1px solid var(--border-color);
  padding-top: 0.5rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Controls Bar */
.deck-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
  gap: 1rem;
}

.nav-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.65rem 1.25rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  background: var(--bg-glass-hover);
  border-color: var(--accent-indigo);
}

.rating-buttons {
  display: flex;
  gap: 0.75rem;
}

.rate-btn {
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.rate-hard {
  background: var(--color-hard-bg);
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--color-hard);
}
.rate-hard:hover { background: var(--color-hard); color: #fff; }

.rate-medium {
  background: var(--color-medium-bg);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--color-medium);
}
.rate-medium:hover { background: var(--color-medium); color: #fff; }

.rate-easy {
  background: var(--color-easy-bg);
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--color-easy);
}
.rate-easy:hover { background: var(--color-easy); color: #fff; }

/* QUIZ MODE STYLES */
.quiz-container {
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

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

.quiz-score-badge {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-indigo);
}

.quiz-box {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.quiz-question h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 0.5rem;
}

.quiz-cat-tag {
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-indigo);
  padding: 2px 8px;
  border-radius: 6px;
}

.quiz-prompt-quote {
  background: var(--bg-secondary);
  border-left: 4px solid var(--accent-indigo);
  padding: 1rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.95rem;
  line-height: 1.6;
  margin-top: 0.85rem;
  white-space: pre-line;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.quiz-opt-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.quiz-opt-btn:hover {
  border-color: var(--accent-indigo);
  background: var(--bg-glass-hover);
}

.quiz-opt-btn.correct {
  background: var(--color-easy-bg);
  border-color: var(--color-easy);
  color: var(--color-easy);
}

.quiz-opt-btn.incorrect {
  background: var(--color-hard-bg);
  border-color: var(--color-hard);
  color: var(--color-hard);
}

/* LIST / GRID MODE */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.grid-card-item {
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.85rem;
  transition: all 0.2s ease;
}

.grid-card-item:hover {
  border-color: var(--accent-indigo);
  transform: translateY(-2px);
}

.grid-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.grid-card-defn {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   VIEW 0: STUDY MODE (학습용 플래시 카드 스타일)
   ========================================================================== */

/* Header Stat Pill: Bookmark */
.stat-pill.bookmark {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.stat-pill.bookmark i {
  color: #f59e0b;
}

/* Study Deck Header */
.study-deck-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.study-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.study-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.study-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-glass);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.study-action-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--accent-indigo);
  transform: translateY(-1px);
}

.study-action-btn.bookmark-btn.active {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  border-color: #f59e0b;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}
.study-action-btn.bookmark-btn.active i {
  font-weight: 900;
}

.study-action-btn.read-btn.active {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  border-color: #10b981;
}
.study-action-btn.read-btn.active i {
  font-weight: 900;
}

.study-action-btn.doc-link-btn {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border-color: rgba(99, 102, 241, 0.3);
}

.study-action-btn.doc-link-btn:hover {
  background: rgba(99, 102, 241, 0.3);
  color: #fff;
  border-color: var(--accent-indigo);
}

/* Study Sub-Toolbar */
.study-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.6rem 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.study-view-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

body.light-theme .study-view-tabs {
  background: rgba(0, 0, 0, 0.06);
}

.study-tab-btn {
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.study-tab-btn:hover {
  color: var(--text-primary);
}

.study-tab-btn.active {
  background: var(--accent-indigo);
  color: #fff;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
}

.study-toolbar-options {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Autoplay Controls */
.autoplay-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  position: relative;
}

.btn-autoplay {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-glass);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-autoplay:hover {
  border-color: var(--accent-indigo);
}

.btn-autoplay.playing {
  background: #ef4444;
  border-color: #ef4444;
  color: #fff;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.autoplay-interval-select {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  outline: none;
  cursor: pointer;
}

.autoplay-progress {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  position: absolute;
  bottom: -6px;
  left: 0;
  overflow: hidden;
}

.autoplay-progress-bar {
  height: 100%;
  background: var(--accent-indigo);
  width: 0%;
}

/* Stepper Navigation */
.study-stepper-wrap {
  margin-bottom: 1.25rem;
}

.study-stepper {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 4px;
}

.step-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.95rem;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-glass);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.step-pill-btn span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
}

.step-pill-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent-indigo);
}

.step-pill-btn.active {
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.step-pill-btn.active span {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* Master Study Card */
.study-card-wrapper {
  margin-bottom: 1.5rem;
  max-width: 980px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.study-card {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 2rem;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.study-card:hover {
  border-color: var(--border-highlight);
  box-shadow: 0 20px 30px -5px rgba(0, 0, 0, 0.6), 0 0 20px rgba(99, 102, 241, 0.25);
}

.study-card-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.25rem;
  margin-bottom: 1.5rem;
}

.study-card-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.study-read-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-easy);
  background: var(--color-easy-bg);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.study-card-title {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.35;
  letter-spacing: -0.02em;
}

/* Study Blocks */
.study-block {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  transition: all 0.2s ease;
}

body.light-theme .study-block {
  background: rgba(241, 245, 249, 0.65);
}

.study-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.study-block-header h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.study-block-header h4 i {
  color: var(--accent-indigo);
}

.defn-content {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text-primary);
}

.mnemonic-content {
  background: rgba(245, 158, 11, 0.08);
  border-left: 4px solid var(--color-medium);
  padding: 0.85rem 1.1rem;
  border-radius: 0 8px 8px 0;
}

.mnemonic-content ul {
  list-style: none;
  padding-left: 0;
}

.mnemonic-content li {
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-primary);
}
.mnemonic-content li:last-child {
  margin-bottom: 0;
}

/* Concept Diagram Block */
.concept-diagram-code {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.55;
  color: #38bdf8;
  background: #070b14;
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 8px;
  padding: 1.1rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

body.light-theme .concept-diagram-code {
  background: #0f172a;
  color: #38bdf8;
}

.copy-diagram-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.copy-diagram-btn:hover {
  background: var(--accent-indigo);
  color: #fff;
  border-color: var(--accent-indigo);
}

.diff-content {
  background: rgba(168, 85, 247, 0.08);
  border-left: 4px solid var(--accent-purple);
  padding: 0.85rem 1.1rem;
  border-radius: 0 8px 8px 0;
}

.study-card-footer {
  padding-top: 1rem;
  margin-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Study Deck Navigation Controls */
.study-deck-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(56, 189, 248, 0.8);
  outline-offset: 3px;
}

/* Keyword Blur Masking (Active Recall Mode) */
.mask-keywords-active strong,
.mask-keywords-active code,
.mask-keywords-active .tag-item {
  filter: blur(5px);
  background: rgba(99, 102, 241, 0.22);
  border-radius: 4px;
  padding: 1px 6px;
  user-select: none;
  transition: filter 0.2s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease;
  cursor: pointer;
  display: inline-block;
}

.mask-keywords-active strong:hover,
.mask-keywords-active code:hover,
.mask-keywords-active .tag-item:hover,
.mask-keywords-active strong.revealed,
.mask-keywords-active code.revealed,
.mask-keywords-active .tag-item.revealed {
  filter: none;
  background: rgba(99, 102, 241, 0.12);
  user-select: auto;
}

/* Step Reveal Mode
   Actual show/hide is driven entirely by inline `display` set in
   updateStudyStepView() (app.js) — it's the single source of truth so an
   inline style can never be left fighting a class-based rule here. This
   class only triggers the reveal animation. */
.step-mode-active .step-block.step-visible {
  animation: fadeInStep 0.3s ease-in-out;
}

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

/* Responsive Rules */
@media (max-width: 992px) {
  .app-header { padding: 0.65rem 1rem; }
  .logo-text .subtitle,
  .header-stats .progress-bar-container { display: none; }
  .header-container { gap: 0.5rem; }
  .logo-text h1 { font-size: 1rem; }
  .logo-icon { font-size: 1.35rem; }
  .mobile-filter-btn { display: inline-flex; }

  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
    position: fixed;
    z-index: 200;
    top: 0;
    right: 0;
    width: min(360px, 92vw);
    height: 100dvh;
    max-height: none;
    border: 1px solid var(--border-color);
    box-shadow: -16px 0 40px rgba(0, 0, 0, 0.45);
  }

  .sidebar.mobile-open { display: flex; }
  .mobile-only-danger { display: block; }
  .mobile-sidebar-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
  }

  .main-content { padding: 1rem; gap: 1rem; }
  .toolbar { padding: 0.65rem; flex-wrap: wrap; }
  .toolbar-controls { width: 100%; justify-content: space-between; gap: 0.5rem; }
  .search-box { max-width: none; }
  .study-card { padding: 1.2rem; border-radius: 14px; }
  .study-card-title { font-size: clamp(1.35rem, 6vw, 1.7rem); }
  .study-block { padding: 1rem; margin-bottom: 0.85rem; }
  .study-deck-header, .study-toolbar, .study-deck-controls { align-items: stretch; }
  .study-header-actions, .study-toolbar-options, .study-deck-controls { flex-wrap: wrap; }
  .study-action-btn { flex: 1 1 auto; justify-content: center; }
  .study-deck-controls .nav-btn, .study-deck-controls .btn { flex: 1; justify-content: center; }

  .card-scene {
    min-height: 0;
    height: auto;
  }

  .card-3d { min-height: 440px; }
  .card-face { padding: 1.25rem; }
  .deck-controls { align-items: stretch; flex-wrap: wrap; }
  .rating-buttons { order: 2; width: 100%; justify-content: stretch; gap: 0.4rem; }
  .rate-btn { flex: 1; min-height: 48px; justify-content: center; padding: 0.5rem; }
  .nav-btn { min-height: 44px; }
}

/* Phone-first recall view: keep the question, answer and rating choices in
   the viewport. Search and filters remain available from the sliders button. */
@media (max-width: 640px) {
  .app-header { padding: 0.5rem 0.75rem; }
  .header-stats,
  .header-actions .danger { display: none; }
  .logo { gap: 0.45rem; }
  .logo-text h1 { font-size: 0.9rem; }

  body.flashcard-focus {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  body.flashcard-focus .app-layout {
    height: calc(100dvh - 53px);
    min-height: 0;
  }

  body.flashcard-focus .main-content {
    min-height: 0;
    padding: 0.55rem 0.75rem;
    gap: 0.55rem;
    overflow: hidden;
  }

  body.flashcard-focus .main-content > .toolbar { display: none; }

  body.flashcard-focus #view-flashcard.active {
    flex: 1;
    min-height: 0;
    gap: 0.55rem;
  }

  body.flashcard-focus .flashcard-deck-header {
    min-height: 26px;
  }

  body.flashcard-focus .deck-category-tag {
    max-width: 64vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0.25rem 0.6rem;
  }

  body.flashcard-focus .card-scene {
    flex: 1;
    min-height: 260px;
    height: min(440px, calc(100dvh - 225px));
  }

  body.flashcard-focus .card-3d { min-height: 0; }
  body.flashcard-focus .card-face { padding: 1rem; }
  body.flashcard-focus .card-front-body { gap: 0.75rem; }
  body.flashcard-focus .card-title { font-size: clamp(1.25rem, 6vw, 1.55rem); }
  body.flashcard-focus .mnemonic-container { padding: 0.65rem 0.8rem; }
  body.flashcard-focus .mnemonic-list { font-size: 0.8rem; }
  body.flashcard-focus .keyword-hint-box { padding: 0.55rem 0.75rem; }
  body.flashcard-focus .card-flip-prompt { font-size: 0.72rem; }

  body.flashcard-focus .deck-controls { gap: 0.4rem; }
  body.flashcard-focus .rating-buttons { gap: 0.35rem; }
  body.flashcard-focus .rate-btn { min-height: 44px; font-size: 0.72rem; }
  body.flashcard-focus .rate-btn kbd { display: none; }
  body.flashcard-focus .nav-btn { min-height: 40px; padding: 0.45rem 0.75rem; font-size: 0.76rem; }
}

@media (max-width: 640px) and (max-height: 620px) {
  body.flashcard-focus .mnemonic-container,
  body.flashcard-focus .keyword-hint-box { display: none; }
  body.flashcard-focus .card-title { font-size: clamp(1.15rem, 5.5vw, 1.4rem); }
}

/* Very narrow phones: keep all three rating labels on one line instead of
   letting only the longer two wrap unevenly. */
@media (max-width: 360px) {
  body.flashcard-focus .rating-buttons { gap: 0.25rem; }
  body.flashcard-focus .rate-btn {
    padding: 0.5rem 0.3rem;
    gap: 0.25rem;
    font-size: 0.62rem;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
