.quiz-widget {
  margin: 1.25rem 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.5rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.06);
}

html[data-mode='light'] .quiz-widget {
  border-color: rgba(0, 0, 0, 0.12);
  background: rgba(0, 0, 0, 0.03);
}

.quiz-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.quiz-title {
  font-weight: 600;
  margin: 0;
  font-size: 1.05rem;
}

.quiz-progress {
  font-size: 0.9rem;
  opacity: 0.85;
  white-space: nowrap;
}

.quiz-card {
  perspective: 1200px;
}

.quiz-card-inner {
  position: relative;
  transform-style: preserve-3d;
  transition: transform 260ms ease;
  border-radius: 0.5rem;
}

.quiz-card.is-revealed .quiz-card-inner {
  transform: rotateY(180deg);
}

.quiz-face {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.5rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.12);
}

html[data-mode='light'] .quiz-face {
  border-color: rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.8);
}

.quiz-face-back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
}

.quiz-question {
  margin: 0 0 0.75rem 0;
  font-weight: 600;
}

.quiz-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
  flex-wrap: wrap;
}

.quiz-input {
  flex: 1 1 260px;
  min-width: 200px;
  padding: 0.55rem 0.7rem;
  border-radius: 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
}

html[data-mode='light'] .quiz-input {
  border-color: rgba(0, 0, 0, 0.16);
  background: rgba(255, 255, 255, 0.95);
}

.quiz-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-start;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.quiz-actions-back {
  margin-top: 0.9rem;
}

.quiz-actions-left {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.quiz-btn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.18);
  color: inherit;
  padding: 0.45rem 0.7rem;
  border-radius: 0.4rem;
  font-size: 0.92rem;
}

html[data-mode='light'] .quiz-btn {
  border-color: rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.9);
}

.quiz-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.quiz-feedback {
  margin-top: 0.5rem;
  font-size: 0.92rem;
}

.quiz-feedback.ok {
  color: #38d9a9;
}

.quiz-feedback.bad {
  color: #ff6b6b;
}

.quiz-answer {
  white-space: pre-wrap;
  margin: 0;
}

.quiz-explain {
  white-space: pre-wrap;
  margin: 0;
}

.quiz-solution-title {
  margin-top: 0.2rem;
  margin-bottom: 0.35rem;
  font-weight: 700;
  opacity: 0.9;
}

.quiz-hint {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  opacity: 0.8;
}

.quiz-widget:focus {
  outline: none;
}

.quiz-widget:focus-visible {
  outline: 2px solid rgba(45, 183, 245, 0.7);
  outline-offset: 3px;
  border-radius: 0.6rem;
}
