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

:root {
  --bg: #f8f4ed;
  --card: #fff;
  --text: #1a1a1a;
  --accent: #c45c26;
  --accent-hover: #a34a1e;
  --correct: #2d7d46;
  --wrong: #c62828;
  --muted: #6b6b6b;
}

body {
  font-family: 'Noto Sans Gujarati', 'Noto Sans Devanagari', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
}

header {
  text-align: center;
  margin-bottom: 1.5rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
}

.filters {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: rgba(0,0,0,0.03);
  border-radius: 8px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.filter-row:last-child {
  margin-bottom: 0;
}

.filter-label {
  font-size: 0.9rem;
  color: var(--muted);
  margin-right: 0.25rem;
}

.filter-row select {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  min-width: 120px;
}

.progress-info {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--muted);
}

.toggle-label input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: #ccc;
  border-radius: 24px;
  transition: background 0.2s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 2px;
  top: 2px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.2s;
}

.toggle-label input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-label input:checked + .toggle-slider::after {
  transform: translateX(20px);
}

.toggle-text {
  user-select: none;
}

.mode-tabs {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.tab {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.5rem 1rem;
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover {
  background: rgba(196, 92, 38, 0.1);
}

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

.progress {
  margin-bottom: 1rem;
}

#progress-text {
  font-size: 0.9rem;
  color: var(--muted);
  display: block;
  margin-bottom: 0.25rem;
}

.progress-bar {
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
}

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

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.question {
  font-size: 1.15rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  line-height: 1.7;
}

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

.option {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.85rem 1rem;
  text-align: left;
  border: 2px solid #ddd;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.option:hover:not(.disabled) {
  border-color: var(--accent);
  background: rgba(196, 92, 38, 0.05);
}

.option.correct {
  border-color: var(--correct);
  background: rgba(45, 125, 70, 0.1);
  cursor: default;
}

.option.wrong {
  border-color: var(--wrong);
  background: rgba(198, 40, 40, 0.08);
  cursor: default;
}

.option.disabled {
  opacity: 0.6;
  cursor: default;
}

.feedback {
  margin-top: 1rem;
  font-size: 0.95rem;
  min-height: 1.5em;
}

.feedback.correct-msg {
  color: var(--correct);
  font-weight: 600;
}

.feedback.wrong-msg {
  color: var(--wrong);
}

/* Quiz navigation (prev / skip / next) */
.quiz-nav {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1rem;
}

.quiz-skip {
  background: rgba(196, 92, 38, 0.08);
}

/* Submit button for type-in answers */
.submit-btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 0.75rem;
  padding: 0.65rem 1.25rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.submit-btn:hover {
  background: var(--accent-hover);
}

/* Option key prefix (A. B. C. D.) */
.opt-key {
  font-weight: 700;
  color: var(--accent);
  margin-right: 0.25rem;
}

/* Transliteration line (shown below original text) */
.transliteration,
.browse-translit {
  font-size: 0.88rem;
  color: #888;
  font-style: italic;
  margin-top: 0.15rem;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

/* Flashcards */
.flashcard {
  perspective: 1000px;
  margin-bottom: 1rem;
  cursor: pointer;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

/* Front is relative so it sizes the container; back is absolute and overlays */
.flashcard-front {
  position: relative;
  width: 100%;
  min-height: 160px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--card);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.flashcard-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--card);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  justify-content: center;
  transform: rotateY(180deg);
}

.fc-question,
.fc-answer {
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.7;
}

.transliteration {
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 0.5rem;
}

.fc-options {
  margin-top: 0.75rem;
  text-align: left;
}

.fc-opt {
  font-size: 0.95rem;
  padding: 0.25rem 0;
  color: var(--text);
  line-height: 1.5;
}

.fc-opt-key {
  font-weight: 600;
  color: var(--accent);
  margin-right: 0.25rem;
}

.flip-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 1rem;
  display: block;
}

.fc-nav {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1rem;
}

.nav-btn {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.6rem 1.25rem;
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn:hover {
  background: var(--accent);
  color: white;
}

/* Type-in input */
.type-in-wrap {
  display: flex;
  flex-direction: column;
}

.type-in-input {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.75rem 1rem;
  border: 2px solid #ddd;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

.type-in-input:focus {
  border-color: var(--accent);
}

.type-in-input.input-correct {
  border-color: var(--correct);
  background: rgba(45, 125, 70, 0.05);
}

.type-in-input.input-wrong {
  border-color: var(--wrong);
  background: rgba(198, 40, 40, 0.05);
}

.browse-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.browse-item {
  background: var(--card);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.browse-item .type {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.browse-item .q {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.browse-item .ans {
  font-size: 0.9rem;
  color: var(--correct);
  font-weight: 500;
}

@media (max-width: 480px) {
  .app { padding: 0.75rem; }
  .question { font-size: 1.05rem; }
  .option { padding: 0.75rem; }
}
