:root {
  --flashcard-bg: #ffffff;
  --flashcard-border: #d1d5db;
  --flashcard-shadow: rgba(15, 23, 42, 0.12);
  --flashcard-text: #111827;
  --flashcard-muted: #6b7280;
  --flashcard-accent: #0ea5e9;
  --flashcard-accent-soft: rgba(14, 165, 233, 0.08);
  --flashcard-control-bg: #f9fafb;
  --flashcard-control-border: #d1d5db;
}

[data-mode="dark"] {
  --flashcard-bg: #020617;
  --flashcard-border: #1f2937;
  --flashcard-shadow: rgba(15, 23, 42, 0.7);
  --flashcard-text: #e5e7eb;
  --flashcard-muted: #9ca3af;
  --flashcard-accent: #38bdf8;
  --flashcard-accent-soft: rgba(56, 189, 248, 0.15);
  --flashcard-control-bg: #020617;
  --flashcard-control-border: #374151;
}

[data-mode="auto"] {}

@media (prefers-color-scheme: dark) {
  [data-mode="auto"] {
    --flashcard-bg: #020617;
    --flashcard-border: #1f2937;
    --flashcard-shadow: rgba(15, 23, 42, 0.7);
    --flashcard-text: #e5e7eb;
    --flashcard-muted: #9ca3af;
    --flashcard-accent: #38bdf8;
    --flashcard-accent-soft: rgba(56, 189, 248, 0.15);
    --flashcard-control-bg: #020617;
    --flashcard-control-border: #374151;
  }
}

.flashcards-root {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.flashcards-card-shell {
  display: flex;
  justify-content: center;
}

.flashcards-card {
  position: relative;
  width: min(640px, 100%);
  min-height: 160px;
  padding: 1.5rem 1.75rem;
  border-radius: 0.9rem;
  border: 1px solid var(--flashcard-border);
  background: radial-gradient(circle at top left, var(--flashcard-accent-soft), transparent 55%), var(--flashcard-bg);
  box-shadow: 0 18px 35px -22px var(--flashcard-shadow);
  color: var(--flashcard-text);
  overflow: hidden;
}

.flashcards-root[data-side="back"] .flashcards-card {
  background: radial-gradient(circle at top left, rgba(34, 197, 94, 0.12), transparent 55%), var(--flashcard-bg);
}

.flashcards-card-flip {
  animation: flashcards-flip 0.22s ease-out;
}

@keyframes flashcards-flip {
  0% {
    transform: translateY(0) rotateY(0deg);
    opacity: 1;
  }
  50% {
    transform: translateY(-4px) rotateY(7deg);
    opacity: 0.85;
  }
  100% {
    transform: translateY(0) rotateY(0deg);
    opacity: 1;
  }
}

.flashcards-face {
  transition: opacity 0.24s ease, transform 0.24s ease;
}

.flashcards-face.back {
  display: none;
}

.flashcards-root[data-side="back"] .flashcards-face.front {
  display: none;
}

.flashcards-root[data-side="back"] .flashcards-face.back {
  display: block;
}

.flashcards-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--flashcard-muted);
}

.flashcards-progress {
  font-weight: 600;
}

.flashcards-pill {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--flashcard-border);
  background-color: rgba(15, 23, 42, 0.02);
}

.flashcards-body {
  font-size: 0.98rem;
  line-height: 1.6;
}

.flashcards-body pre {
  margin: 0.5rem 0 0;
}

.flashcards-body img.flashcard-image {
  max-width: 100%;
  height: auto;
}

.flashcards-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--flashcard-muted);
}

.flashcards-controls {
  display: flex;
  gap: 0.5rem;
}

.flashcards-btn {
  border-radius: 999px;
  border: 1px solid var(--flashcard-control-border);
  background-color: var(--flashcard-control-bg);
  color: var(--flashcard-text);
  font-size: 0.8rem;
  padding: 0.4rem 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  transition: background-color 0.17s ease, transform 0.1s ease, box-shadow 0.1s ease, border-color 0.17s ease;
}

.flashcards-btn-primary {
  background-color: var(--flashcard-accent-soft);
  border-color: rgba(56, 189, 248, 0.4);
}

.flashcards-btn:hover {
  background-color: rgba(15, 23, 42, 0.03);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px -12px var(--flashcard-shadow);
}

.flashcards-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.flashcards-btn:disabled {
  opacity: 0.55;
  cursor: default;
  box-shadow: none;
}

.flashcards-hotkeys {
  display: none;
}

@media (min-width: 640px) {
  .flashcards-hotkeys {
    display: inline-flex;
    gap: 0.4rem;
    align-items: center;
  }

  .flashcards-hotkey-pill {
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.8);
    font-size: 0.7rem;
  }
}

@media (max-width: 640px) {
  .flashcards-card {
    padding: 1.15rem 1.25rem;
  }

  .flashcards-controls {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}
