* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #e0e7ff;
  --success: #10b981;
  --danger: #f56565;
  --warning: #ed8936;
  --gray-100: #f7fafc;
  --gray-200: #edf2f7;
  --gray-300: #e2e8f0;
  --gray-600: #718096;
  --gray-800: #2d3748;
  --bg: var(--gray-100);
  --card-bg: white;
  --text: var(--gray-800);
  --text-secondary: var(--gray-600);
}

body.dark-mode {
  --bg: #1a202c;
  --card-bg: #2d3748;
  --text: #f7fafc;
  --text-secondary: #a0aec0;
  --gray-100: #2d3748;
  --gray-200: #4a5568;
  --gray-300: #4a5568;
  --primary-light: #312e81;
}

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

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 100px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  margin-bottom: 16px;
}

header h1 {
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--card-bg);
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  text-decoration: none;
  color: var(--text);
}

.icon-btn:hover { background: var(--gray-200); }

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 11px;
  padding: 4px 12px;
  transition: color 0.2s;
}

.nav-item.active { color: var(--primary); }

.nav-icon {
  font-size: 22px;
  margin-bottom: 2px;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Progress bar */
.progress-bar-container {
  background: var(--gray-200);
  border-radius: 8px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 4px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 8px;
  transition: width 0.4s ease;
}

.progress-text {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: right;
  margin-top: 2px;
}

/* Date header */
.date-header {
  text-align: center;
  margin-bottom: 16px;
}

.date-header-day {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.date-header-info {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Text input */
.text-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s;
}

.text-input:focus {
  outline: none;
  border-color: var(--primary);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--gray-300);
  border-radius: 28px;
  transition: background 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--gray-800);
  color: white;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 200;
  white-space: nowrap;
}

body.dark-mode .toast { background: #4a5568; color: #f7fafc; }

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 8px;
}

.empty-text {
  font-size: 15px;
  margin-bottom: 16px;
}

.empty-btn {
  display: inline-block;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

/* ============ FLASHCARD ============ */
.flashcard {
  margin: 20px 0;
  perspective: 1000px;
}

.flashcard-inner {
  position: relative;
  min-height: 220px;
  background: var(--card-bg);
  border-radius: 20px;
  padding: 32px 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.flashcard-inner:active { transform: scale(0.98); }

.flashcard-level {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  background: var(--primary-light);
  color: var(--primary);
  margin-bottom: 16px;
}

.flashcard-word {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.flashcard-divider {
  width: 40px;
  height: 2px;
  background: var(--gray-200);
  margin: 16px auto;
}

.flashcard-translation {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 8px;
}

.flashcard-example {
  font-size: 14px;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.4;
}

.flashcard-tap-hint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 16px;
}

.flashcard-category {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* Rating buttons */
.rating-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.rating-btn {
  padding: 12px 8px;
  border: none;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.rating-btn:active { transform: scale(0.95); }

.rating-again { background: #fef2f2; color: #dc2626; }
.rating-hard { background: #fff7ed; color: #ea580c; }
.rating-good { background: #f0fdf4; color: #16a34a; }
.rating-easy { background: #eff6ff; color: #2563eb; }

body.dark-mode .rating-again { background: rgba(220,38,38,0.15); }
body.dark-mode .rating-hard { background: rgba(234,88,12,0.15); }
body.dark-mode .rating-good { background: rgba(22,163,74,0.15); }
body.dark-mode .rating-easy { background: rgba(37,99,235,0.15); }

.rating-label {
  display: block;
  font-size: 11px;
  font-weight: 400;
  margin-top: 2px;
  opacity: 0.7;
}

/* ============ QUIZ ============ */
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.quiz-score {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
}

.quiz-question-num {
  font-size: 13px;
  color: var(--text-secondary);
}

.quiz-prompt {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  padding: 24px 16px;
  color: var(--primary);
}

.quiz-options {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.quiz-option {
  padding: 16px;
  background: var(--card-bg);
  border: 2px solid var(--gray-200);
  border-radius: 14px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  color: var(--text);
}

.quiz-option:active { transform: scale(0.98); }
.quiz-option.correct { border-color: var(--success); background: #ecfdf5; }
.quiz-option.wrong { border-color: var(--danger); background: #fef2f2; }

body.dark-mode .quiz-option.correct { background: rgba(16,185,129,0.15); }
body.dark-mode .quiz-option.wrong { background: rgba(245,101,101,0.15); }

.quiz-fill-input {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--gray-200);
  border-radius: 14px;
  font-size: 18px;
  text-align: center;
  background: var(--bg);
  color: var(--text);
  margin-top: 16px;
}

.quiz-fill-input:focus {
  outline: none;
  border-color: var(--primary);
}

.quiz-type-tabs {
  display: flex;
  gap: 0;
  background: var(--gray-200);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 16px;
}

.quiz-type-tab {
  flex: 1;
  padding: 8px 4px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  white-space: nowrap;
}

.quiz-type-tab.active {
  background: var(--card-bg);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.quiz-result {
  text-align: center;
  padding: 32px 16px;
}

.quiz-result-score {
  font-size: 48px;
  font-weight: 700;
  color: var(--primary);
}

.quiz-result-label {
  font-size: 16px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.quiz-result-pct {
  font-size: 20px;
  font-weight: 600;
  margin-top: 12px;
}

.quiz-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 12px;
}

.quiz-btn:hover { opacity: 0.9; }
.quiz-btn:active { transform: scale(0.98); }

/* ============ DICTIONARY ============ */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.search-input {
  flex: 1;
  padding: 10px 14px;
  border: none;
  background: transparent;
  font-size: 15px;
  color: var(--text);
  outline: none;
}

.search-input::placeholder { color: var(--text-secondary); }

.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}

.filter-pill {
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--gray-200);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-pill.active {
  background: var(--primary);
  color: white;
}

.word-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  background: var(--card-bg);
  border-radius: 14px;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  cursor: pointer;
  transition: transform 0.15s;
}

.word-item:active { transform: scale(0.98); }

.word-info { flex: 1; }

.word-english {
  font-size: 16px;
  font-weight: 600;
}

.word-russian {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.word-tags {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.word-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--gray-200);
  color: var(--text-secondary);
}

.word-tag.level {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.word-tag.learned { background: #ecfdf5; color: #10b981; }
.word-tag.learning { background: #fff7ed; color: #ea580c; }

body.dark-mode .word-tag.learned { background: rgba(16,185,129,0.15); }
body.dark-mode .word-tag.learning { background: rgba(234,88,12,0.15); }

.word-status {
  font-size: 20px;
  flex-shrink: 0;
  margin-left: 12px;
}

.word-count {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 12px;
}

/* FAB button */
.fab {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  font-size: 28px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
  cursor: pointer;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}

.fab:active { transform: scale(0.9); }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.show { opacity: 1; pointer-events: auto; }

.modal-content {
  background: var(--card-bg);
  border-radius: 20px 20px 0 0;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s;
}

.modal-overlay.show .modal-content { transform: translateY(0); }

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

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
}

.form-group {
  margin-bottom: 12px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
}

.form-select {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  appearance: none;
  cursor: pointer;
}

.form-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

.form-btn:hover { opacity: 0.9; }

.form-btn-danger {
  background: var(--danger);
  margin-top: 8px;
}

/* ============ STATS ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-200);
}

.progress-row:last-child { border-bottom: none; }

.progress-row-label {
  font-size: 14px;
  width: 80px;
  flex-shrink: 0;
}

.progress-row-bar {
  flex: 1;
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
}

.progress-row-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.4s;
}

.progress-row-pct {
  font-size: 13px;
  font-weight: 600;
  width: 40px;
  text-align: right;
  color: var(--primary);
}

/* ============ CARD CONTENT (Claude-generated) ============ */
.card-content {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  text-align: left;
  max-height: 60vh;
  overflow-y: auto;
  padding: 4px 0;
}

/* ============ GROUP TABS ============ */
.group-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}

.group-tab {
  padding: 8px 16px;
  border-radius: 20px;
  background: var(--gray-200);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.group-tab.active {
  background: var(--primary);
  color: white;
}

.group-tab.new-group {
  background: var(--primary-light);
  color: var(--primary);
}

.group-tab.new-group.active {
  background: var(--primary);
  color: white;
}

/* ============ NAV BUTTONS ============ */
.nav-buttons {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.nav-btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-btn:active { transform: scale(0.95); }
.nav-btn:disabled { opacity: 0.4; cursor: default; }
.nav-btn:disabled:active { transform: none; }

.nav-btn-prev {
  background: var(--gray-200);
  color: var(--text);
}

.nav-btn-next {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
}

/* ============ FLASHCARD PROGRESS ============ */
.flashcard-progress {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 8px;
}

/* ============ GENERATE BUTTON ============ */
.generate-btn {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.generate-btn:hover { opacity: 0.9; }
.generate-btn:disabled { opacity: 0.6; cursor: default; }

/* ============ LOADING & SPINNER ============ */
.loading-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-small {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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

/* ============ WORD META ============ */
.word-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
  margin-left: 12px;
}
