.flashcard {
  background: var(--bg-card);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  display: grid;
  gap: 1.25rem;
  justify-items: center;
}

.flashcard__workspace {
  width: 100%;
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: nowrap;
}

.flashcard__question-column,
.flashcard__answer-column {
  flex: 1;
  min-width: clamp(240px, 32vw, 360px);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: flex-start;
}

.flashcard__answer-column {
  max-width: 420px;
}

.flashcard__card {
  position: relative;
  border-radius: 18px;
  background: var(--color-primary);
  color: var(--text-on-primary);
  text-align: center;
  padding: 1.2rem 1rem;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
  aspect-ratio: 4 / 2.5;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: default;
}

.flashcard__card[role="button"],
.flashcard__card--interactive {
  cursor: pointer;
}

.flashcard__card:disabled {
  cursor: default;
  opacity: 1;
  color: inherit;
}

.flashcard__card:focus-visible {
  outline: 3px solid var(--text-on-primary);
  outline-offset: 2px;
}

.flashcard__timer {
  position: absolute;
  top: 0;
  left: 0;
  height: 8px;
  width: 100%;
  background: rgba(255, 255, 255, 0.6);
  transform-origin: left;
  transition: width 0.1s linear, opacity 0.2s ease;
}

.flashcard__timer.inactive {
  opacity: 0.3;
}

.flashcard__problem {
  font-size: clamp(2.2rem, calc(var(--question-font-size) * 0.95), 4rem);
  font-weight: 600;
  line-height: 1.1;
  margin: 0;
}

.flashcard__answer-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 1rem;
  border-radius: 18px;
  border: 2px solid var(--border-light);
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  width: 100%;
  min-height: 100%;
}

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

.flashcard__form--hidden {
  display: none !important;
}

.flashcard__answer-card--choices .flashcard__form {
  display: none;
}

.flashcard__label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  text-align: left;
}

#answerInput {
  padding: 0.9rem 1rem;
  font-size: var(--answer-font-size);
  border-radius: 12px;
  border: 2px solid var(--border-light);
  text-align: center;
  width: 100%;
  min-height: 3rem;
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.flashcard__actions {
  display: flex;
  gap: 0.75rem;
  justify-content: stretch;
}

.flashcard__primary,
.flashcard__secondary {
  flex: 1;
  padding: 0.75rem;
  border-radius: 12px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.flashcard__primary {
  background: var(--color-accent);
  color: var(--text-on-primary);
  box-shadow: var(--shadow-md);
}

.flashcard__secondary {
  background: var(--color-warning);
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
}

.flashcard__microphone-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-transform: none;
  line-height: 1.15;
}

.flashcard__microphone-button .flashcard__microphone-icon {
  display: block;
  width: 1.75rem;
  height: 1.75rem;
  color: inherit;
}

.flashcard__microphone-button .flashcard__microphone-label {
  font-size: 0.85rem;
  font-weight: 600;
}

.flashcard__microphone-button[data-listen-state="active"] {
  background: var(--color-primary);
  box-shadow: var(--shadow-primary);
}

.flashcard__microphone-button[data-listen-state="processing"] {
  background: var(--text-secondary);
  box-shadow: var(--shadow-md);
  cursor: wait;
}

.flashcard__microphone-button[disabled] {
  cursor: not-allowed;
  opacity: 0.85;
}

.flashcard__listen-controls {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flashcard__listen-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.flashcard__listen-actions > button {
  flex: 1 1 45%;
}

.flashcard__listen-status {
  white-space: pre-line;
  font-size: 0.95rem;
  line-height: 1.35;
}

.flashcard__secondary--ghost {
  background: transparent;
  border: 2px dashed var(--color-warning);
}

.flashcard__card--correct {
  box-shadow: 0 18px 36px rgba(46, 196, 182, 0.35);
  background: radial-gradient(circle at top, #78f5c4 0%, #44d7b6 70%, #1fb89b 100%);
  transform: scale(1.01);
}

.flashcard__card--incorrect {
  box-shadow: 0 18px 36px rgba(239, 71, 111, 0.35);
  background: radial-gradient(circle at top, #ffb3c8 0%, #ff6f91 70%, #f94b79 100%);
}

.flashcard__card--loading {
  opacity: 0.85;
}

.flashcard__card--loading::after {
  content: "";
  position: absolute;
  width: 36px;
  height: 36px;
  border: 4px solid rgba(255, 255, 255, 0.8);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.flashcard__feedback {
  min-height: 1.25rem;
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
}

.flashcard__feedback--correct {
  color: var(--correct-color);
}

.flashcard__feedback--incorrect {
  color: var(--incorrect-color);
}

.flashcard__choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.flashcard__choices[hidden] {
  display: none;
}

.flashcard__choice {
  padding: 0.85rem;
  border-radius: 12px;
  border: 2px solid transparent;
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.flashcard__choice:hover:not(:disabled),
.flashcard__choice:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-primary);
  outline: none;
}

.flashcard__choice:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.flashcard__choice--correct {
  border-color: var(--correct-color);
  box-shadow: var(--shadow-md);
}

.flashcard__choice--incorrect {
  border-color: var(--incorrect-color);
  box-shadow: var(--shadow-md);
}

.flashcard__actions--single {
  flex-direction: column;
}

.flashcard__answer-card--choices .flashcard__actions {
  flex-direction: column;
}

@media (max-width: 768px) {
  .flashcard__workspace {
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
  }

  .flashcard__question-column,
  .flashcard__answer-column {
    min-width: min(100%, 340px);
  }

  .flashcard__actions {
    flex-direction: column;
  }

  .flashcard__problem {
    font-size: calc(var(--question-font-size) * 0.75);
  }
}

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