/* ==== Reviews: layout + responsive helpers ==== */

/* Grid layout + typography moved from global styles */
.review-wrap { grid-template-columns: 1fr; }

.details-wrap {
  grid-column: 1 / -1;
  display: contents;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 22px;
}

.details-wrap .sentences-card { margin: 0; }

#reading_input_bar { margin-top: 8px; }

.review-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.review-head__cluster {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.review-head__title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.review-head__labels {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.review-type-label {
  font-size: 0.85rem;
  padding: 4px 10px;
}

.review-wrap .inp-label {
  font-size: 150%;
  line-height: 1.2;
}

.review-wrap .attempt-input {
  font-size: 175%;
  line-height: 1.25;
  padding: 14px 20px;
  height: auto;
  text-align: center;
}

.review-wrap .attempt-input::placeholder,
.review-wrap .attempt-input::-webkit-input-placeholder,
.review-wrap .attempt-input::-moz-placeholder,
.review-wrap .attempt-input:-ms-input-placeholder {
  text-align: center;
}

/* Keep the card constrained by the parent grid */
.review-wrap > .card { min-width: 0; }

/* Guard rails: the big prompt and body must never force horizontal scroll */
.review-wrap .vocab-body { min-width: 0; }
.review-wrap #reviewPrompt { overflow-wrap: anywhere; word-break: break-word; }

/* Inputs: ensure they shrink gracefully inside rows */
.review-wrap .attempt-row { min-width: 0; }
.review-wrap .attempt-row .attempt-input { min-width: 0; width: 100%; }

/* Controls row: keep a single line across all breakpoints */
.review-wrap .lesson-controls--review {
  --rev-gap: 12px;
  display: flex !important;
  align-items: stretch;
  justify-content: flex-start;
  gap: var(--rev-gap);
  width: 100%;
  min-width: 0;
  flex-wrap: nowrap;
}

.review-cardstyle .review-wrap .lesson-controls--review {
  flex-direction: column;
}

.review-cardstyle #reviewPrimaryActions {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: var(--rev-gap);
}

.review-cardstyle #reviewPrimaryActions .reveal-actions,
.review-cardstyle #reviewPrimaryActions .grade-actions {
  display: grid;
  width: 100%;
  gap: var(--rev-gap);
}

.review-cardstyle #reviewPrimaryActions .reveal-actions {
  grid-template-columns: minmax(0, 1fr);
}

.review-cardstyle #reviewControls.has-audio #reviewPrimaryActions .reveal-actions {
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
}

.review-cardstyle #reviewPrimaryActions .grade-actions {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.review-cardstyle #reviewPrimaryActions button {
  width: 100%;
  min-width: 0;
}

.review-cardstyle #reviewSecondaryActions {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  gap: var(--rev-gap);
  width: 100%;
}

.review-wrap .lesson-controls--review .left-controls,
.review-wrap .lesson-controls--review .right-controls {
  display: contents;
}

/* Base control sizing + alignment */
.review-wrap .lesson-controls--review button,
.review-wrap .lesson-controls--review .audio-btn,
.review-wrap .lesson-controls--review .font-picker > #fontPickerBtn,
.review-wrap .lesson-controls--review #kanaCheatBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  text-align: center;
  box-sizing: border-box;
  min-height: 48px;
  flex: 0 0 auto;
}

/* Let the four primary actions fill the remaining width equally */
.review-wrap .lesson-controls--review #removeFromDeck,
.review-wrap .lesson-controls--review #openCustomMeaning,
.review-wrap .lesson-controls--review #toggleDetails,
.review-wrap .lesson-controls--review #nextBtn {
  flex: 1 1 0%;
  min-width: 0;
}

/* Audio + kana triggers stay compact */
.review-wrap .lesson-controls--review .audio-btn,
.review-wrap .lesson-controls--review #kanaCheatBtn {
  flex: 0 1 auto;
}

/* Hiragana/Katakana reviews: keep all visible controls the same width */
.review-wrap .lesson-controls--review.lesson-controls--syllabary .audio-btn,
.review-wrap .lesson-controls--review.lesson-controls--syllabary #kanaCheatBtn {
  flex: 1 1 0%;
  min-width: 0;
}

/* Keep any optional font-picker trigger compact as well */
.review-wrap .lesson-controls--review .font-picker {
  flex: 0 0 auto;
}

/* Slightly tighten gaps on mid widths to reduce overflow risk */
@media (max-width: 1200px) {
  .review-wrap .lesson-controls--review {
    --rev-gap: 10px;
  }
}

@media (max-width: 900px) {
  .review-wrap .lesson-controls--review {
    --rev-gap: 8px;
  }
}

/* Compact audio mode (≤850px): hide male button + female label */
@media (max-width: 850px) {
  .review-wrap #playVocabMaleBtn { display: none !important; }
  .review-wrap #playVocabFemaleBtn .audio-sex { display: none; }
}

/* Phone layout adjustments (≤640px) */
@media (max-width: 640px) {
  .review-wrap {
    padding: 0;
    gap: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  .review-wrap #readingHeader,
  .review-wrap #meaningHeader {
    display: none;
  }

  .review-wrap #reviewPrompt {
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .review-wrap > .card,
  .review-wrap .details-wrap > .card {
    border-radius: 0;
    flex: 1 1 auto;
  }

  .review-wrap .details-wrap {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    width: 100%;
    gap: 0;
  }

  .review-wrap .card-body.vocab-body {
    padding-left: 5px;
    padding-right: 5px;
  }

  .review-wrap .lesson-controls--review {
    --rev-gap: 3px;
  }

  .review-wrap .lesson-controls--review #kanaCheatBtn,
  .review-wrap .lesson-controls--review .audio-btn {
    padding-left: 8px;
    padding-right: 8px;
  }

  /* Allow button text to wrap if space becomes tight */
  .review-wrap .lesson-controls--review button,
  .review-wrap .lesson-controls--review .audio-btn {
    white-space: normal !important;
    max-width: 100%;
    min-width: 0;
    line-height: 1.15;
  }

  .review-wrap .lesson-controls--review button,
  .review-wrap .lesson-controls--review .audio-btn,
  .review-wrap .lesson-controls--review .font-picker > #fontPickerBtn,
  .review-wrap .lesson-controls--review #kanaCheatBtn {
    border-radius: 10px;
  }

  .review-wrap .lesson-controls--review .font-picker > #fontPickerBtn {
    white-space: nowrap !important;
  }
}

/* Sentences: match lessons-kana line spacing + furigana tone */
.review-wrap .sentences-body .jp-sentence { line-height: 1.5; }
.review-wrap .sentences-body .jp-sentence rt { color: var(--muted, #9aa0a6); }

/* Community Mnemonics header buttons should share height even when labels wrap */
#communityMnemonicsCard .card-head {
  align-items: stretch;
}

#communityMnemonicsCard .card-head .block-title {
  display: flex;
  align-items: center;
}

#communityMnemonicsCard .card-head .ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  height: auto;
}

/* ===== Example sentences styling (match vocab lessons) ===== */
html:not(.theme-dark) .review-wrap .sentences-head h2 {
  color: var(--teal);
}

html.theme-dark .review-wrap .sentences-head h2 {
  color: var(--teal);
}

.review-wrap #sentencesSection .sentences-tools .small {
  height: auto;
  white-space: normal;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
}

.review-wrap #sentencesSection .sentences-body {
  display: grid;
  gap: 12px;
}

.review-wrap #sentencesSection .sentence-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

.review-wrap #sentencesSection .sentence-texts {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.review-wrap #sentencesSection .sentence-actions {
  display: flex;
  align-items: center;
  justify-content: center;
}

.review-wrap #sentencesSection .sentence-actions .icon-btn {
  margin: 0;
}

.review-wrap #sentencesSection .jp-sentence {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.5;
  letter-spacing: 0.01em;
}

.review-wrap #sentencesSection .en-sentence {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.6;
}

@media (max-width: 640px) {
  .review-wrap .sentences-card {
    margin: 0;
    width: 100%;
  }

  .review-wrap .sentences-head h2 {
    font-size: 1.5rem;
  }

  .review-wrap #sentencesSection .sentences-tools .small {
    font-size: 1.08rem;
    padding: 10px 14px;
    border-radius: 13px;
  }

  .review-wrap #sentencesSection .sentences-body {
    padding: 5px;
    gap: 6px;
  }

  .review-wrap #sentencesSection .sentence-actions .icon-btn {
    width: 38px;
    height: 38px;
    font-size: 1.23rem;
  }

  .review-wrap #sentencesSection .sentence-actions .icon-btn.biggify {
    transform: scale(1.1);
  }

  .review-wrap #sentencesSection .jp-sentence,
  .review-wrap #sentencesSection .en-sentence {
    font-size: 1rem;
  }
}

/* Center labels on all review controls (inline-flex, no wrapping) */
.review-wrap #removeFromDeck,
.review-wrap #openCustomMeaning,
.review-wrap #toggleDetails,
.review-wrap #nextBtn,
.review-wrap .font-picker > #fontPickerBtn,
.review-wrap .audio-btn,
.review-wrap #kanaCheatBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  text-align: center;
}

/* Ensure all review controls use border-box so padding never increases row width */
.review-wrap .lesson-controls button,
.review-wrap .lesson-controls .font-picker {
  box-sizing: border-box;
}

#toggleDetails:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.review-wrap .lesson-controls--review .primary-actions button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.undo-toast {
  font-size: 0.95rem;
}

.undo-toast .undo-btn {
  border: none;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  background: var(--accent, #4a90e2);
  color: #fff;
}

.undo-toast .undo-btn:hover {
  filter: brightness(1.05);
}

