@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ═══════════════════════════════════════════
   CSS DESIGN SYSTEM — Dark Glassmorphism
   ═══════════════════════════════════════════ */

:root {
  /* Colors */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(30, 41, 59, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-glass-hover: rgba(255, 255, 255, 0.06);
  --bg-sidebar: rgba(15, 23, 42, 0.95);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #a78bfa;

  --accent-primary: #8b5cf6;
  --accent-secondary: #6366f1;
  --accent-gradient: linear-gradient(135deg, #8b5cf6, #6366f1, #3b82f6);
  --accent-gradient-soft: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(99, 102, 241, 0.15));
  --accent-glow: 0 0 20px rgba(139, 92, 246, 0.3);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.1);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.1);

  --border: rgba(148, 163, 184, 0.1);
  --border-hover: rgba(139, 92, 246, 0.3);

  /* Sizing */
  --sidebar-width: 340px;
  --header-height: 70px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(139, 92, 246, 0.15);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
}

/* ═══════════ Reset & Base ═══════════ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background effect */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(59, 130, 246, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(99, 102, 241, 0.03) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ═══════════ Scrollbar ═══════════ */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.3);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.5);
}

/* ═══════════ Layout ═══════════ */

.app-container {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ═══════════ Sidebar ═══════════ */

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  transition: transform var(--transition-base);
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.sidebar-logo .logo-icon {
  width: 42px;
  height: 42px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: var(--accent-glow);
}

.sidebar-logo .logo-text {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-logo .logo-text span {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Progress bar */
.progress-section {
  padding: 0 20px 16px;
  border-bottom: 1px solid var(--border);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.progress-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.progress-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-primary);
}

.progress-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 10px;
  transition: width var(--transition-slow);
  min-width: 0%;
}

/* Search */
.search-container {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}

.search-input-wrapper {
  position: relative;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: all var(--transition-fast);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  border-color: var(--accent-primary);
  background: rgba(139, 92, 246, 0.05);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* Section tabs */
.section-tabs {
  display: flex;
  padding: 12px 20px;
  gap: 6px;
  border-bottom: 1px solid var(--border);
}

.section-tab {
  flex: 1;
  padding: 8px 4px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  line-height: 1.3;
}

.section-tab:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.section-tab.active {
  background: var(--accent-gradient-soft);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.section-tab .tab-count {
  display: block;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 2px;
}

/* Question list */
.question-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
}

.question-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
  border: 1px solid transparent;
}

.question-item:hover {
  background: var(--bg-glass-hover);
}

.question-item.active {
  background: var(--accent-gradient-soft);
  border-color: rgba(139, 92, 246, 0.2);
}

.question-item .q-checkbox {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  transition: all var(--transition-fast);
  cursor: pointer;
  font-size: 11px;
  color: transparent;
}

.question-item .q-checkbox:hover {
  border-color: var(--accent-primary);
}

.question-item .q-checkbox.checked {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.question-item .q-number {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  background: var(--bg-glass);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.question-item .q-title {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  transition: color var(--transition-fast);
}

.question-item:hover .q-title,
.question-item.active .q-title {
  color: var(--text-primary);
}

.question-item .q-checkbox.checked+.q-number+.q-title {
  text-decoration: line-through;
  opacity: 0.5;
}

/* ═══ Section dividers in question list ═══ */
.q-section-divider {
  padding: 10px 12px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin: 8px 0 4px;
}

.q-section-divider:first-child {
  margin-top: 0;
}

.q-section-divider.sec-basic {
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.2);
}

.q-section-divider.sec-field {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.2);
}

.q-section-divider.sec-spec {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.2);
}

/* Color accent on left border per section */
.question-item.sec-basic {
  border-left: 2px solid rgba(96, 165, 250, 0.25);
}

.question-item.sec-field {
  border-left: 2px solid rgba(245, 158, 11, 0.25);
}

.question-item.sec-spec {
  border-left: 2px solid rgba(52, 211, 153, 0.25);
}

.question-item.sec-basic.active {
  border-left-color: #60a5fa;
}

.question-item.sec-field.active {
  border-left-color: #f59e0b;
}

.question-item.sec-spec.active {
  border-left-color: #34d399;
}

.question-item.sec-basic .q-number {
  color: #60a5fa;
}

.question-item.sec-field .q-number {
  color: #f59e0b;
}

.question-item.sec-spec .q-number {
  color: #34d399;
}

/* ═══ Answer footer (bottom of question) ═══ */
.answer-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.answer-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-arrow {
  flex: 1;
  min-width: 140px;
  padding: 10px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  line-height: 1.4;
}

.nav-arrow:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.nav-arrow:last-child {
  text-align: right;
}



/* Sidebar footer */
.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.quiz-btn {
  width: 100%;
  padding: 12px 16px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--accent-glow);
}

.quiz-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 40px rgba(139, 92, 246, 0.3);
}

.quiz-btn:active {
  transform: translateY(0);
}

/* Mobile toggle */
.mobile-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  width: 56px;
  height: 56px;
  background: var(--accent-gradient);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 24px;
  cursor: pointer;
  box-shadow: var(--shadow-lg), var(--accent-glow);
  transition: transform var(--transition-fast);
}

.mobile-toggle:active {
  transform: scale(0.95);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

/* ═══════════ Main Content ═══════════ */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  position: relative;
}

/* Main header */
.main-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.main-header h1 {
  font-size: 18px;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.header-btn {
  padding: 8px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-btn:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.header-btn.active {
  background: var(--accent-gradient-soft);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* Content area */
.content-area {
  padding: 24px 32px 60px;
  max-width: 900px;
}

/* Question card detail */
.question-detail {
  animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.question-detail-header {
  margin-bottom: 24px;
}

.question-detail-header .section-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--accent-gradient-soft);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent-primary);
  margin-bottom: 12px;
}

.question-detail-header h2 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 6px;
}

.question-detail-header .q-title-en {
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
}

.mastered-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-top: 16px;
}

.mastered-toggle:hover {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}

.mastered-toggle.active {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}

/* Answer content styling */
.answer-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  backdrop-filter: blur(10px);
}

.answer-content h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 28px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.answer-content h3:first-child {
  margin-top: 0;
}

.answer-content h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-primary);
  margin: 20px 0 8px;
}

.answer-content p {
  color: var(--text-secondary);
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.7;
}

.answer-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.answer-content em {
  color: var(--text-accent);
}

.answer-content ul,
.answer-content ol {
  margin: 8px 0 16px 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

.answer-content li {
  margin-bottom: 6px;
  line-height: 1.6;
}

.answer-content li::marker {
  color: var(--accent-primary);
}

/* Tables */
.answer-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
}

.answer-content thead th {
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent-primary);
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid rgba(139, 92, 246, 0.2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.answer-content tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}

.answer-content tbody tr:hover {
  background: var(--bg-glass-hover);
}

.answer-content tbody tr:last-child td {
  border-bottom: none;
}

/* Code blocks */
.answer-content code {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(139, 92, 246, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--accent-primary);
}

.answer-content pre {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  overflow-x: auto;
  margin: 16px 0;
}

.answer-content pre code {
  background: none;
  padding: 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

/* Blockquotes */
.answer-content blockquote {
  border-left: 3px solid var(--accent-primary);
  padding: 12px 16px;
  margin: 16px 0;
  background: var(--accent-gradient-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.answer-content blockquote strong {
  color: var(--accent-primary);
}

/* Horizontal rules */
.answer-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* ═══════════ Welcome Screen ═══════════ */

.welcome-screen {
  text-align: center;
  padding: 80px 32px;
  animation: fadeInUp 0.5s ease;
}

.welcome-icon {
  font-size: 64px;
  margin-bottom: 24px;
}

.welcome-screen h2 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 12px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-screen p {
  color: var(--text-secondary);
  font-size: 16px;
  max-width: 500px;
  margin: 0 auto 32px;
  line-height: 1.6;
}

.welcome-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: 600px;
  margin: 0 auto 40px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  text-align: center;
  transition: all var(--transition-fast);
}

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.stat-card .stat-number {
  font-size: 32px;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.welcome-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.welcome-actions button {
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent-gradient);
  border: none;
  color: white;
  box-shadow: var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 40px rgba(139, 92, 246, 0.3);
}

.btn-secondary {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* ═══════════ Quiz Mode ═══════════ */

.quiz-container {
  max-width: 700px;
  animation: fadeInUp 0.3s ease;
}

.quiz-header {
  margin-bottom: 24px;
}

.quiz-header h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.quiz-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.quiz-progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 10px;
  transition: width var(--transition-base);
}

.quiz-progress-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.quiz-question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  margin-bottom: 20px;
}

.quiz-question-card .quiz-q-text {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 20px;
}

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.quiz-option:hover:not(.disabled) {
  background: var(--bg-glass-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.quiz-option .option-letter {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.quiz-option.selected {
  border-color: var(--accent-primary);
  background: var(--accent-gradient-soft);
}

.quiz-option.selected .option-letter {
  background: var(--accent-primary);
  color: white;
}

.quiz-option.correct {
  border-color: var(--success);
  background: var(--success-bg);
}

.quiz-option.correct .option-letter {
  background: var(--success);
  color: white;
}

.quiz-option.wrong {
  border-color: var(--error);
  background: var(--error-bg);
}

.quiz-option.wrong .option-letter {
  background: var(--error);
  color: white;
}

.quiz-option.disabled {
  cursor: default;
  opacity: 0.7;
}

.quiz-option.disabled.correct {
  opacity: 1;
}

.quiz-explanation {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--info-bg);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  animation: fadeInUp 0.2s ease;
}

.quiz-explanation strong {
  color: var(--info);
}

.quiz-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}

.quiz-nav button {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

/* Quiz results */
.quiz-results {
  text-align: center;
  animation: fadeInUp 0.4s ease;
}

.quiz-results .result-icon {
  font-size: 72px;
  margin-bottom: 16px;
}

.quiz-results h2 {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
}

.quiz-results .score-text {
  font-size: 48px;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 16px 0;
}

.quiz-results .score-details {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 32px;
}

.quiz-results .result-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Quiz setup */
.quiz-setup {
  animation: fadeInUp 0.3s ease;
}

.quiz-setup h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 24px;
}

.quiz-config-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  margin-bottom: 16px;
}

.quiz-config-card label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.quiz-config-card .config-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.config-chip {
  padding: 8px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.config-chip:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.config-chip.active {
  background: var(--accent-gradient-soft);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.quiz-start-btn {
  margin-top: 24px;
}

/* ═══════════ Score bar ═══════════ */
.score-bar-wrap {
  margin: 20px auto;
  max-width: 400px;
}

.score-bar {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.8s ease;
}

/* ═══════════ Perfect badge ═══════════ */
.perfect-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid var(--success);
  border-radius: var(--radius-md);
  color: var(--success);
  font-size: 16px;
  font-weight: 600;
  margin: 24px auto;
}

/* ═══════════ Wrong answers review ═══════════ */
.wrong-section {
  margin-top: 32px;
  text-align: left;
}

.wrong-section h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--error);
}

.wrong-card {
  background: var(--bg-card);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
  animation: fadeInUp 0.3s ease;
}

.wrong-question {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 14px;
  line-height: 1.5;
}

.wrong-answers {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.wa-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
}

.wa-correct {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--success);
  color: var(--success);
}

.wa-wrong {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--error);
  color: var(--error);
  text-decoration: line-through;
  opacity: 0.8;
}

.wa-letter {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  background: var(--bg-glass);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

.wa-tag {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  white-space: nowrap;
}

.wa-tag.wa-tag-wrong {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
}

.wrong-explanation {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 10px 14px;
  background: rgba(59, 130, 246, 0.07);
  border-left: 3px solid var(--info);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  line-height: 1.6;
}

/* ═══════════ btn-warning ═══════════ */
.btn-warning {
  padding: 12px 24px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid var(--warning);
  border-radius: var(--radius-sm);
  color: var(--warning);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-warning:hover {
  background: rgba(245, 158, 11, 0.25);
  transform: translateY(-1px);
}



@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.visible {
    display: block;
  }

  .mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .main-content {
    margin-left: 0;
  }

  .content-area {
    padding: 20px 16px 80px;
  }

  .main-header {
    padding: 12px 16px;
  }

  .main-header h1 {
    font-size: 15px;
  }

  .welcome-stats {
    grid-template-columns: 1fr;
    max-width: 300px;
  }

  .question-detail-header h2 {
    font-size: 20px;
  }

  .answer-content {
    padding: 20px 16px;
  }

  .answer-content table {
    font-size: 12px;
  }

  .answer-content thead th,
  .answer-content tbody td {
    padding: 8px 10px;
  }
}

@media (max-width: 600px) {
  .section-tabs {
    flex-direction: column;
  }

  .welcome-actions {
    flex-direction: column;
    align-items: center;
  }

  .quiz-nav {
    flex-direction: column;
  }
}

/* ═══════════ Utility Animations ═══════════ */

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.6;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.animate-pulse {
  animation: pulse 2s infinite;
}

/* ═══════════ No-select for interactive elements ═══════════ */
.question-item,
.quiz-option,
.section-tab,
.config-chip,
.filter-chip,
.mastered-toggle,
.quiz-btn,
.header-btn,
button {
  user-select: none;
  -webkit-user-select: none;
}

/* ═══════════════════════════════════════════════
   SIDEBAR FILTERS
═══════════════════════════════════════════════ */
.sidebar-filters {
  padding: 8px 12px 4px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-chip:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}

.filter-chip.active {
  background: var(--accent-gradient-soft);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

.filter-chip.lang-toggle {
  width: 100%;
  text-align: center;
  border-radius: var(--radius-sm);
}

.filter-chip.lang-toggle.active {
  background: rgba(52, 211, 153, 0.12);
  border-color: #34d399;
  color: #34d399;
}

/* Sidebar footer 2 buttons */
.quiz-btn-flash {
  background: linear-gradient(135deg, #f59e0b, #d97706) !important;
  margin-bottom: 6px;
}

/* ═══════════════════════════════════════════════
   WELCOME — PROGRESS RINGS
═══════════════════════════════════════════════ */
.total-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 24px auto 8px;
  padding: 20px 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 340px;
}

.total-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.total-label strong {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-primary);
}

.total-label span {
  font-size: 13px;
  color: var(--text-secondary);
}

.ring-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card .ring-center {
  margin-bottom: 8px;
}

/* ═══════════════════════════════════════════════
   KEYBOARD LEGEND
═══════════════════════════════════════════════ */
.keyboard-legend {
  margin-top: 36px;
  padding: 20px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
}

.keyboard-legend h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kbd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}

.kbd-grid div {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 3px 7px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════
   QUESTION DETAIL — IMPROVED NAV & FOOTER
═══════════════════════════════════════════════ */
.header-actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.btn-print-sm {
  padding: 8px 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-print-sm:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.nav-arrow {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.nav-arrow.nav-next {
  text-align: right;
}

.nav-arrow:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.nav-dir {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-primary);
}

.nav-title {
  font-size: 12px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.mastered-toggle-bottom {
  align-self: flex-start;
}

/* btn-flashcard on welcome */
.btn-flashcard {
  padding: 12px 24px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.25);
}

.btn-flashcard:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 30px rgba(245, 158, 11, 0.4);
}

/* ═══════════════════════════════════════════════
   FLASHCARD MODE
═══════════════════════════════════════════════ */
.flashcard-wrap {
  animation: fadeInUp 0.3s ease;
  max-width: 860px;
}

.flashcard-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.flashcard-top h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.flashcard-progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.fc-counter {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.fc-exit {
  margin-left: auto;
}

.flashcard-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: all var(--transition-base);
  backdrop-filter: blur(10px);
}

.flashcard-card.revealed {
  border-color: rgba(16, 185, 129, 0.2);
}

.fc-front {
  padding: 36px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  min-height: 200px;
  justify-content: center;
  transition: opacity 0.2s;
}

.fc-faded {
  opacity: 0.5;
  padding: 20px 40px 12px;
  min-height: auto;
}

.fc-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  background: var(--accent-gradient-soft);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.fc-chip-ans {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.2);
  color: var(--success);
}

.fc-q {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
}

.fc-en {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

.btn-reveal {
  padding: 12px 28px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--accent-glow);
  margin-top: 8px;
}

.btn-reveal:hover {
  transform: translateY(-1px);
}

.btn-reveal kbd {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.2);
  color: white;
}

.fc-btn-small {
  padding: 6px 14px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--success);
  border-radius: var(--radius-sm);
  color: var(--success);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.fc-back {
  padding: 24px 40px 32px;
  border-top: 1px solid var(--border);
}

.fc-chip-ans {
  margin-bottom: 16px;
}

.fc-answer {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
  max-height: 60vh;
  overflow-y: auto;
}

/* Summary mode (used in flashcards) */
.fc-answer-summary {
  max-height: none;
  overflow: visible;
}

.fc-sum-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fc-sum-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
}

.fc-sum-list li::before {
  content: '✦';
  color: var(--accent-primary);
  font-size: 10px;
  flex-shrink: 0;
  margin-top: 3px;
}

.fc-sum-para {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-primary);
  margin: 0 0 12px;
}

.fc-sum-tip {
  padding: 12px 16px;
  background: rgba(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-left: 3px solid var(--accent-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 12px;
}

/* "Pełne opracowanie" link button */
.fc-full-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding: 7px 14px;
  background: transparent;
  border: 1px dashed var(--border-hover);
  border-radius: var(--radius-sm);
  color: var(--accent-primary);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
  opacity: 0.8;
}

.fc-full-link:hover {
  background: var(--accent-gradient-soft);
  opacity: 1;
}

/* Back to flashcards button */
.fc-back-to-flash {
  margin: 0 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}



.fc-answer h3 {
  font-size: 15px;
  color: var(--text-primary);
  margin: 16px 0 8px;
}

.fc-answer h3:first-child {
  margin-top: 0;
}

.fc-answer table {
  font-size: 12px;
}

.fc-answer blockquote {
  font-size: 12px;
}

.fc-verdict {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.fc-btn {
  flex: 1;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.fc-wrong {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--error);
  color: var(--error);
}

.fc-wrong:hover {
  background: rgba(239, 68, 68, 0.2);
}

.fc-correct {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid var(--success);
  color: var(--success);
}

.fc-correct:hover {
  background: rgba(16, 185, 129, 0.25);
}

.fc-btn kbd {
  font-size: 10px;
  opacity: 0.7;
}

.fc-done {
  text-align: center;
  padding: 60px 32px;
  animation: fadeInUp 0.4s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.fc-done h2 {
  font-size: 26px;
  font-weight: 800;
}

.fc-done p {
  color: var(--text-secondary);
  font-size: 16px;
}

.fc-done-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}

/* ═══════════════════════════════════════════════
   GLOSSARY — Abbreviation Tooltips
═══════════════════════════════════════════════ */
.glossary-tip {
  text-decoration: underline dotted rgba(139, 92, 246, 0.6);
  text-underline-offset: 3px;
  color: inherit;
  cursor: help;
  font-style: normal;
  border-bottom: none;
}

.glossary-tip:hover {
  color: var(--accent-primary);
  text-decoration-color: var(--accent-primary);
}

/* Floating popup */
.glossary-popup {
  position: absolute;
  z-index: 9999;
  max-width: 280px;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.97);
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(139, 92, 246, 0.1);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  backdrop-filter: blur(10px);
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.glossary-popup.visible {
  opacity: 1;
  transform: translateY(0);
}