/* === RESET & BASE === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-card-hover: #222636;
  --bg-input: #252836;
  --border: #2e3247;
  --text: #e8e9ed;
  --text-dim: #8b8fa3;
  --text-muted: #5c6078;
  --accent: #6c63ff;
  --accent-hover: #7b73ff;
  --accent-dim: rgba(108, 99, 255, 0.15);
  --green: #4caf7d;
  --green-dim: rgba(76, 175, 125, 0.15);
  --red: #ef5350;
  --red-dim: rgba(239, 83, 80, 0.15);
  --orange: #ffa726;
  --orange-dim: rgba(255, 167, 38, 0.15);
  --blue: #42a5f5;
  --blue-dim: rgba(66, 165, 245, 0.15);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

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

/* === NAVIGATION === */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.nav-btn:hover {
  background: var(--bg-input);
  color: var(--text);
}

.nav-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

/* === VIEWS === */
.view {
  display: none;
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 24px;
}

.view.active {
  display: block;
}

/* === DASHBOARD === */
.dashboard-header h1 {
  font-size: 1.8rem;
  margin-bottom: 4px;
}

.subtitle {
  color: var(--text-dim);
  font-size: 1rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 28px 0;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.stat-card.accent {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
}

.stat-card.accent .stat-number {
  color: var(--accent);
}

.stat-label {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 4px;
}

.progress-section {
  margin-top: 36px;
}

.progress-section h3 {
  margin-bottom: 16px;
  font-size: 1.1rem;
}

.category-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.category-name {
  width: 160px;
  font-size: 0.9rem;
  color: var(--text-dim);
  text-align: right;
}

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

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.category-count {
  width: 50px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.method-badges {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.method-badges h3 {
  margin-bottom: 12px;
  font-size: 1rem;
  color: var(--text-dim);
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-dim);
  cursor: help;
}

/* === BUTTONS === */
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 28px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-large {
  padding: 16px 40px;
  font-size: 1.1rem;
  display: block;
  width: 100%;
  margin-top: 8px;
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 4px 0;
}

.btn-text:hover {
  text-decoration: underline;
}

.btn-small {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-audio {
  background: var(--bg-input);
  border: 1px solid var(--border);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* === STUDY VIEW === */
.study-empty {
  text-align: center;
  padding: 80px 20px;
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
}

.study-empty h2 {
  margin-bottom: 8px;
}

.study-empty p {
  color: var(--text-dim);
  margin-bottom: 24px;
}

.study-progress-bar {
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  margin-bottom: 8px;
}

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

.study-counter {
  text-align: right;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.mode-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 24px;
}

.mode-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.mode-btn.active {
  background: var(--accent);
  color: white;
}

/* === FLASHCARD === */
.flashcard {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  text-align: center;
  min-height: 280px;
  margin-bottom: 24px;
  position: relative;
}

.flashcard-front,
.flashcard-back {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.card-emoji {
  font-size: 3rem;
  margin-bottom: 16px;
}

.card-word {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.card-answer {
  color: var(--accent);
}

.card-answer-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.card-category {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.card-pronunciation {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--blue-dim);
  border: 1px solid rgba(66, 165, 245, 0.3);
  border-radius: var(--radius-sm);
  width: 100%;
  text-align: left;
}

.pronunciation-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--blue);
  margin-bottom: 4px;
  font-weight: 600;
}

.pronunciation-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}

.card-tips {
  margin-top: 8px;
  padding: 12px 16px;
  background: var(--orange-dim);
  border: 1px solid rgba(255, 167, 38, 0.3);
  border-radius: var(--radius-sm);
  width: 100%;
  text-align: left;
}

.tips-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--orange);
  margin-bottom: 4px;
  font-weight: 600;
}

.tips-text {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}

.card-phrases {
  margin-top: 16px;
  text-align: left;
  width: 100%;
}

.phrase-item {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 8px;
}

.phrase-es {
  font-weight: 600;
  margin-bottom: 2px;
}

.phrase-en {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.card-personal-note {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--green-dim);
  border: 1px solid var(--green);
  border-radius: var(--radius-sm);
  width: 100%;
  text-align: left;
}

.note-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--green);
  margin-bottom: 4px;
}

.note-text {
  font-size: 0.95rem;
}

.quick-note {
  margin-top: 12px;
  width: 100%;
}

.quick-note-form {
  margin-top: 12px;
  text-align: left;
}

.guide-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--green);
  margin-bottom: 10px;
}

.guide-prompts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.guide-prompt {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.4;
}

.guide-prompt:hover {
  border-color: var(--green);
  background: var(--green-dim);
}

.guide-prompt .prompt-icon {
  margin-right: 6px;
}

.quick-note-form textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
}

.quick-note-form textarea:focus {
  outline: none;
  border-color: var(--green);
}

.quick-note-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

/* Typing input */
.typing-input {
  width: 100%;
  background: var(--bg-input);
  border: 2px solid var(--border);
  color: var(--text);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  text-align: center;
  margin-bottom: 12px;
}

.typing-input:focus {
  outline: none;
  border-color: var(--accent);
}

.typing-feedback {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-weight: 600;
  text-align: center;
}

.typing-feedback.correct {
  background: var(--green-dim);
  color: var(--green);
}

.typing-feedback.incorrect {
  background: var(--red-dim);
  color: var(--red);
}

/* Rating buttons */
.card-controls {
  text-align: center;
}

.hint-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 8px;
}

.rate-prompt {
  color: var(--text-dim);
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.rating-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.rate-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.rate-btn:hover {
  transform: translateY(-2px);
}

.rate-label {
  font-weight: 700;
  font-size: 1rem;
}

.rate-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.rate-again { border-color: var(--red); }
.rate-again .rate-label { color: var(--red); }
.rate-again:hover { background: var(--red-dim); }

.rate-hard { border-color: var(--orange); }
.rate-hard .rate-label { color: var(--orange); }
.rate-hard:hover { background: var(--orange-dim); }

.rate-good { border-color: var(--green); }
.rate-good .rate-label { color: var(--green); }
.rate-good:hover { background: var(--green-dim); }

.rate-easy { border-color: var(--blue); }
.rate-easy .rate-label { color: var(--blue); }
.rate-easy:hover { background: var(--blue-dim); }

/* === BROWSE VIEW === */
.browse-controls {
  display: flex;
  gap: 12px;
  margin: 20px 0;
}

.browse-controls input,
.browse-controls select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.browse-controls input {
  flex: 1;
}

.browse-controls input:focus,
.browse-controls select:focus {
  outline: none;
  border-color: var(--accent);
}

.word-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.word-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.2s;
}

.word-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}

.word-emoji {
  font-size: 1.5rem;
  width: 40px;
  text-align: center;
}

.word-info {
  flex: 1;
}

.word-spanish {
  font-weight: 600;
  font-size: 1.05rem;
}

.word-english {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.word-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mastery-indicator {
  display: flex;
  gap: 3px;
}

.mastery-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.mastery-dot.filled {
  background: var(--accent);
}

.mastery-dot.mastered {
  background: var(--green);
}

.word-due-tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--red-dim);
  color: var(--red);
}

.word-due-tag.upcoming {
  background: var(--orange-dim);
  color: var(--orange);
}

.word-due-tag.learned {
  background: var(--green-dim);
  color: var(--green);
}

/* === ADD WORD VIEW === */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

.form-group input,
.form-group textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-section {
  margin: 28px 0;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.form-section h3 {
  margin-bottom: 4px;
}

.form-hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.phrase-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.phrase-row input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.phrase-row input:focus {
  outline: none;
  border-color: var(--accent);
}

#add-note {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
}

#add-note:focus {
  outline: none;
  border-color: var(--accent);
}

/* === MODAL === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
}

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

.modal h2 {
  margin-bottom: 4px;
}

.modal-emoji {
  font-size: 3rem;
  margin-bottom: 8px;
}

.modal-word {
  font-size: 1.8rem;
  font-weight: 700;
}

.modal-translation {
  color: var(--accent);
  font-size: 1.2rem;
  margin-bottom: 16px;
}

.modal-section {
  margin-top: 20px;
}

.modal-section h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.modal-note-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  min-height: 70px;
}

.modal-note-input:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.modal-stat {
  text-align: center;
  padding: 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}

.modal-stat-val {
  font-size: 1.2rem;
  font-weight: 700;
}

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

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-danger:hover {
  background: var(--red);
  color: white;
}

/* === TOAST === */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  border: 1px solid var(--green);
  color: var(--text);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  transition: transform 0.3s ease;
  z-index: 300;
}

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

/* === RESPONSIVE === */
@media (max-width: 640px) {
  nav {
    flex-direction: column;
    gap: 12px;
  }

  .nav-links {
    width: 100%;
    overflow-x: auto;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .rating-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .browse-controls {
    flex-direction: column;
  }

  .phrase-row {
    flex-direction: column;
  }

  .mode-toggle {
    flex-direction: column;
  }

  .modal-stats {
    grid-template-columns: 1fr;
  }
}
