:root {
  --color-accent: #FBBF24;
  --color-accent-dark: #F59E0B;
  --color-accent-light: #FEF3C7;
  --color-success: #10B981;
  --color-success-light: #D1FAE5;
  --color-error: #EF4444;
  --color-error-light: #FEE2E2;
  --color-text: #0F172A;
  --color-text-secondary: #64748B;
  --color-text-tertiary: #94A3B8;
  --color-bg: #FAFAF9;
  --color-bg-white: #FFFFFF;
  --color-bg-secondary: #F1F0EE;
  --color-border: #E2E8F0;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 12px 0 rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 8px 30px 0 rgba(0, 0, 0, 0.08);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
  --radius: 8px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== NAV ===== */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(250, 250, 249, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-border);
  transition: box-shadow var(--transition);
}

.nav.scrolled {
  box-shadow: var(--shadow-sm);
}

.nav-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color var(--transition);
}

.nav-brand:hover { color: var(--color-accent-dark); }

.nav-logo {
  width: 26px;
  height: 26px;
  background: var(--color-accent);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--color-text);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-progress {
  font-size: 0.78rem;
  color: var(--color-text-tertiary);
  font-weight: 500;
}

.nav-progress strong {
  color: var(--color-accent-dark);
  font-weight: 700;
}

/* ===== MAIN LAYOUT ===== */
.main {
  max-width: 720px;
  margin: 0 auto;
  padding: 80px 24px 120px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ===== PROGRESS BAR ===== */
.progress-strip {
  width: 100%;
  height: 3px;
  background: var(--color-bg-secondary);
  border-radius: 2px;
  margin-bottom: 20px;
  overflow: hidden;
}

.progress-strip-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.progress-info {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  font-size: 0.82rem;
  color: var(--color-text-tertiary);
}

.progress-counter {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
}

.progress-category {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--color-accent-light);
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-accent-dark);
}

/* ===== FLASHCARD ===== */
.flashcard-wrapper {
  width: 100%;
  perspective: 1200px;
  margin-bottom: 24px;
}

.flashcard {
  width: 100%;
  min-height: 380px;
  position: relative;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.flashcard-front,
.flashcard-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-white);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  overflow-y: auto;
}

.flashcard-front {
  align-items: center;
  justify-content: center;
  text-align: center;
}

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

/* Front side */
.front-hint {
  font-size: 0.72rem;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  margin-bottom: 20px;
}

.front-root {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-text);
  margin-bottom: 12px;
  line-height: 1.2;
}

.front-meaning {
  font-size: 1.05rem;
  color: var(--color-text-secondary);
  line-height: 1.6;
  max-width: 420px;
}

.front-tap {
  position: absolute;
  bottom: 24px;
  font-size: 0.72rem;
  color: var(--color-text-tertiary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.front-tap kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--color-text-secondary);
}

/* Back side */
.back-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.back-root {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.back-origin {
  flex-shrink: 0;
  padding: 3px 10px;
  background: var(--color-accent);
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text);
}

.back-description {
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--color-text-secondary);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.back-examples-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-tertiary);
  margin-bottom: 10px;
}

.back-example {
  padding: 10px 0;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}

.back-example:last-child { border-bottom: none; }

.back-example-word {
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 2px;
}

.back-example-meaning {
  font-size: 0.8rem;
  color: var(--color-text-tertiary);
}

/* ===== CONTROLS ===== */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.btn {
  border: none;
  cursor: pointer;
  font-family: var(--font-family);
  font-weight: 600;
  transition: all var(--transition);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:active { transform: scale(0.97); }

.btn-nav {
  width: 48px;
  height: 48px;
  background: var(--color-bg-white);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: 1.1rem;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

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

.btn-nav:disabled {
  opacity: 0.3;
  cursor: default;
}

.btn-flip {
  height: 48px;
  padding: 0 28px;
  background: var(--color-text);
  color: var(--color-bg-white);
  font-size: 0.85rem;
}

.btn-flip:hover {
  background: #1E293B;
  box-shadow: var(--shadow-md);
}

.btn-master {
  height: 48px;
  padding: 0 20px;
  font-size: 0.82rem;
  background: var(--color-bg-white);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
}

.btn-master:hover {
  border-color: var(--color-success);
  color: var(--color-success);
  background: var(--color-success-light);
}

.btn-master.mastered {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}

.btn-master.mastered:hover {
  background: #059669;
  border-color: #059669;
  color: #fff;
}

/* ===== KEYBOARD HINTS ===== */
.keyboard-hints {
  margin-top: 32px;
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.keyboard-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--color-text-tertiary);
}

.keyboard-hint kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  background: var(--color-bg-white);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--color-text-secondary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

/* ===== QUIZ MODE ===== */
.quiz-section {
  width: 100%;
  margin-top: 24px;
  display: none;
}

.quiz-section.active { display: block; }

.quiz-card {
  background: var(--color-bg-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-card);
}

.quiz-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-accent-dark);
  margin-bottom: 12px;
}

.quiz-question {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 20px;
  line-height: 1.5;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-option {
  width: 100%;
  text-align: left;
  padding: 14px 18px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-family);
  font-size: 0.88rem;
  color: var(--color-text);
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.5;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--color-accent);
  background: var(--color-accent-light);
}

.quiz-option:disabled { cursor: default; }

.quiz-option.correct {
  border-color: var(--color-success);
  background: var(--color-success-light);
  color: #065F46;
  font-weight: 600;
}

.quiz-option.wrong {
  border-color: var(--color-error);
  background: var(--color-error-light);
  color: #991B1B;
}

/* ===== FEEDBACK TOAST ===== */
.feedback-toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  font-family: var(--font-family);
  z-index: 1000;
  animation: toastIn 0.3s ease forwards;
  box-shadow: var(--shadow-lg);
}

.feedback-toast.success {
  background: var(--color-success);
  color: #fff;
}

.feedback-toast.error {
  background: var(--color-error);
  color: #fff;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== MODE TOGGLE ===== */
.mode-toggle {
  display: flex;
  background: var(--color-bg-secondary);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
  margin-bottom: 24px;
}

.mode-btn {
  padding: 8px 18px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-family: var(--font-family);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text-tertiary);
  cursor: pointer;
  transition: all var(--transition);
}

.mode-btn.active {
  background: var(--color-bg-white);
  color: var(--color-text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.mode-btn:hover:not(.active) {
  color: var(--color-text-secondary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .nav-container { padding: 0 16px; }
  .main { padding: 72px 16px 100px; }

  .flashcard { min-height: 340px; }
  .flashcard-front,
  .flashcard-back { padding: 28px 24px; }

  .front-root { font-size: 1.6rem; }
  .front-meaning { font-size: 0.95rem; }
  .back-root { font-size: 1.15rem; }

  .controls { gap: 8px; }
  .btn-flip { padding: 0 20px; font-size: 0.8rem; }
  .btn-master { padding: 0 14px; font-size: 0.78rem; }

  .keyboard-hints { display: none; }

  .quiz-card { padding: 24px 20px; }
}
