/* Vocabulary flashcards: the reading pages' word popup as a flip-card deck.
   Deck rules are scoped to #vocabulary-dialog.is-flashcards, which
   vocabulary-flashcards.js adds, so the old popup styles stay as a no-JS fallback.
   The launch button exists only when that script adds it. */

/* "Open flashcards" button injected into each .vocabulary-section header:
   eyebrow and heading on the left, the button above the view switcher on the right. */
.vocabulary-header.has-flashcards-launch {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "kicker actions"
    "title actions";
  column-gap: 1.5rem;
}

.vocabulary-header.has-flashcards-launch > * {
  grid-column: 1 / -1;
}

.vocabulary-header.has-flashcards-launch > .vocabulary-kicker {
  grid-area: kicker;
  align-self: end;
}

.vocabulary-header.has-flashcards-launch > .vocabulary-header__topline {
  display: contents;
}

.vocabulary-header.has-flashcards-launch > .vocabulary-header__topline > h2 {
  grid-area: title;
  align-self: start;
  min-width: 0;
}

.vocabulary-header.has-flashcards-launch:not(:has(> .vocabulary-kicker)) > .vocabulary-header__topline > h2 {
  grid-row: 1 / span 2;
  align-self: center;
}

.vocabulary-header__actions {
  grid-area: actions;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  align-self: center;
  gap: 0.6rem;
}

.vocabulary-flashcards-launch-row {
  display: flex;
  margin-top: 0.85rem;
}

.vocabulary-flashcards-launch {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.75rem;
  padding: 0.55rem 1rem 0.55rem 0.85rem;
  border: 1px solid var(--vocabulary-gold, #c59a42);
  border-radius: 0.9rem;
  color: var(--vocabulary-gold-text, #78591e);
  background: color-mix(in srgb, var(--vocabulary-gold, #c59a42) 8%, var(--card, #fffdf8));
  font-family: var(--sans, inherit);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 160ms ease, transform 160ms ease;
}

.vocabulary-flashcards-launch:hover {
  background: color-mix(in srgb, var(--vocabulary-gold, #c59a42) 18%, var(--card, #fffdf8));
}

.vocabulary-flashcards-launch:active {
  transform: scale(0.98);
}

.vocabulary-flashcards-launch:focus-visible {
  outline: 3px solid var(--vocabulary-gold-text, #78591e);
  outline-offset: 3px;
}

.vocabulary-flashcards-launch__icon {
  flex: 0 0 auto;
  width: 1.2rem;
  height: 1.2rem;
}

.vocabulary-flashcards-launch__meta {
  color: var(--ink-soft, #66726c);
  font-weight: 600;
  font-size: 0.82rem;
}

.vocabulary-flashcards-launch__meta:empty {
  display: none;
}

.vocabulary-flashcards-launch__meta::before {
  content: "·";
  margin-right: 0.45rem;
  color: var(--vocabulary-gold, #c59a42);
}

@media screen {
  :root[data-theme="dark"] .vocabulary-flashcards-launch {
    border-color: color-mix(in srgb, var(--theme-gold) 55%, transparent);
    color: var(--theme-gold);
    background: color-mix(in srgb, var(--theme-gold) 10%, var(--theme-surface));
  }

  :root[data-theme="dark"] .vocabulary-flashcards-launch:hover {
    background: color-mix(in srgb, var(--theme-gold) 20%, var(--theme-surface));
  }

  :root[data-theme="dark"] .vocabulary-flashcards-launch:focus-visible {
    outline-color: var(--theme-gold);
  }

  :root[data-theme="dark"] .vocabulary-flashcards-launch__meta {
    color: var(--theme-muted);
  }
}

@media (max-width: 34rem) {
  .vocabulary-header.has-flashcards-launch {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "kicker"
      "title"
      "actions";
  }

  .vocabulary-header.has-flashcards-launch:not(:has(> .vocabulary-kicker)) > .vocabulary-header__topline > h2 {
    grid-row: auto;
  }

  .vocabulary-header__actions {
    align-items: stretch;
    margin-top: 0.4rem;
  }

  .vocabulary-flashcards-launch {
    justify-content: center;
    width: 100%;
    min-height: 3rem;
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  .vocabulary-flashcards-launch {
    transition: none;
  }

  .vocabulary-flashcards-launch:active {
    transform: none;
  }
}

@media print {
  .vocabulary-flashcards-launch-row {
    display: none !important;
  }
}

html:has(#vocabulary-dialog.is-flashcards[open]) {
  overflow: hidden;
}

#vocabulary-dialog.is-flashcards {
  --fc-accent: var(--water-deep, var(--accent-deep, #214a3b));
  --fc-paper: #fbf6ea;
  --fc-paper-edge: #efe5d1;
  --fc-ink: #1f302b;
  --fc-ink-soft: #55625b;
  --fc-faint: #69736c;
  --fc-line: rgba(31, 48, 43, 0.12);
  --fc-mark: rgba(186, 100, 75, 0.18);
  --fc-mark-line: #ba644b;
  --fc-chip: #fffcf5;
  --fc-chip-ink: #1f302b;
  --fc-on-backdrop: #fbf6ea;
  --fc-focus: #f2c46d;
  --fc-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 22px 44px -16px rgba(18, 30, 25, 0.55),
    0 3px 10px rgba(18, 30, 25, 0.16);
  --fc-texture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .36 0 0 0 0 .22 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --fc-radius: 20px;
  --fc-serif: "Hiragino Mincho ProN", "Yu Mincho", YuMincho, "Noto Serif JP", "Noto Serif CJK JP", var(--serif, serif);

  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: max(0.75rem, env(safe-area-inset-top)) 0.9rem max(0.9rem, env(safe-area-inset-bottom));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
  border-radius: 0;
  color: var(--fc-ink);
  background: transparent;
  box-shadow: none;
}

#vocabulary-dialog.is-flashcards[open] {
  display: flex;
}

#vocabulary-dialog.is-flashcards::backdrop {
  background: rgba(14, 22, 19, 0.62);
  -webkit-backdrop-filter: blur(7px) saturate(0.85);
  backdrop-filter: blur(7px) saturate(0.85);
}

#vocabulary-dialog.is-flashcards .vocabulary-dialog__content {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  width: min(100%, 25.5rem);
  margin: auto;
  padding: 0;
  background: transparent;
}

#vocabulary-dialog.is-flashcards .flashcards-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Top bar on the dimmed backdrop. */
#vocabulary-dialog.is-flashcards .flashcards__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 2.75rem;
  padding: 0 0.15rem;
}

#vocabulary-dialog.is-flashcards .vocabulary-dialog__kicker {
  margin: 0;
  color: var(--fc-on-backdrop);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

#vocabulary-dialog.is-flashcards .vocabulary-dialog__close {
  position: static;
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--fc-chip-ink);
  background: var(--fc-chip);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
}

#vocabulary-dialog.is-flashcards .vocabulary-dialog__close:hover {
  background: #fff;
}

/* Stage: live card plus two peeking cards. */
#vocabulary-dialog.is-flashcards .flashcards__stage {
  position: relative;
  display: grid;
  margin-bottom: 0.9rem;
  perspective: 1500px;
}

#vocabulary-dialog.is-flashcards .flashcards__stack {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#vocabulary-dialog.is-flashcards .flashcards__stack[hidden] {
  display: none;
}

#vocabulary-dialog.is-flashcards .flashcards__stack-card {
  position: absolute;
  inset: 0;
  border-radius: var(--fc-radius);
  background: var(--fc-paper-edge) var(--fc-texture);
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, 0.45);
}

#vocabulary-dialog.is-flashcards .flashcards__stack-card--near {
  transform: translate(6px, 9px) rotate(2.2deg) scale(0.975);
  filter: brightness(0.97);
}

#vocabulary-dialog.is-flashcards .flashcards__stack-card--far {
  transform: translate(-7px, 16px) rotate(-3deg) scale(0.95);
  filter: brightness(0.92);
}

#vocabulary-dialog.is-flashcards .flashcard {
  position: relative;
  grid-area: 1 / 1;
  z-index: 1;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

#vocabulary-dialog.is-flashcards .flashcard[hidden] {
  display: none;
}

#vocabulary-dialog.is-flashcards .flashcard.is-dragging {
  cursor: grabbing;
}

#vocabulary-dialog.is-flashcards .flashcard.is-lifting {
  animation: flashcard-lift 0.5s ease-out;
}

@keyframes flashcard-lift {
  50% { translate: 0 -8px; scale: 1.025; }
}

#vocabulary-dialog.is-flashcards .flashcard__inner {
  display: grid;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.3, 0.75, 0.2, 1);
}

#vocabulary-dialog.is-flashcards .flashcard.is-flipped .flashcard__inner {
  transform: rotateY(180deg);
}

#vocabulary-dialog.is-flashcards .flashcard.is-instant .flashcard__inner,
#vocabulary-dialog.is-flashcards .flashcard.is-instant .flashcard__face {
  transition: none;
}

#vocabulary-dialog.is-flashcards .flashcard__face {
  position: relative;
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  min-height: 25rem;
  padding: 1.15rem 1.15rem 1.1rem;
  overflow: hidden;
  border-radius: var(--fc-radius);
  color: var(--fc-ink);
  background: var(--fc-paper) var(--fc-texture);
  box-shadow: var(--fc-shadow);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

#vocabulary-dialog.is-flashcards .flashcard__face--back {
  transform: rotateY(180deg);
  padding-top: 1.6rem;
}

/* Front */
#vocabulary-dialog.is-flashcards .flashcard__known {
  position: absolute;
  top: 0.95rem;
  left: 0.95rem;
  z-index: 1;
  margin: 0;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  color: #fff;
  background: var(--fc-accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

#vocabulary-dialog.is-flashcards .flashcard__known[hidden] {
  display: none;
}

#vocabulary-dialog.is-flashcards .vocabulary-dialog__image-slot:empty {
  display: none;
}

#vocabulary-dialog.is-flashcards .vocabulary-dialog__image-slot {
  overflow: hidden;
  border-radius: 14px;
  background: #fffaf0;
  box-shadow: 0 0 0 1px rgba(31, 48, 43, 0.06);
}

#vocabulary-dialog.is-flashcards .vocabulary-dialog__image {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  aspect-ratio: 4 / 3;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  object-fit: cover;
  background: transparent;
  -webkit-mask-image: radial-gradient(130% 120% at 50% 40%, #000 62%, rgba(0, 0, 0, 0.55) 100%);
  mask-image: radial-gradient(130% 120% at 50% 40%, #000 62%, rgba(0, 0, 0, 0.55) 100%);
}

#vocabulary-dialog.is-flashcards .flashcard__word-wrap {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.1rem 0.5rem 0.4rem;
  text-align: center;
}

#vocabulary-dialog.is-flashcards .flashcard__furigana {
  min-height: 1.3em;
  margin: 0 0 0.15rem;
  color: var(--fc-ink-soft);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.hide-furigana #vocabulary-dialog.is-flashcards .flashcard__furigana {
  visibility: hidden;
}

#vocabulary-dialog.is-flashcards .flashcard__face--front h2 {
  margin: 0;
  padding: 0;
  color: var(--fc-ink);
  font-family: var(--fc-serif);
  font-size: clamp(2.35rem, 10vw, 3.15rem);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.04em;
  overflow-wrap: anywhere;
}

#vocabulary-dialog.is-flashcards .flashcard__hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 0.6rem 0 0;
  color: var(--fc-faint);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  transition: opacity 0.6s ease, visibility 0.6s;
}

#vocabulary-dialog.is-flashcards .flashcard.is-hint-seen .flashcard__hint {
  opacity: 0;
  visibility: hidden;
}

#vocabulary-dialog.is-flashcards .flashcard__hint-pointer { display: none; }
@media (hover: hover) and (pointer: fine) {
  #vocabulary-dialog.is-flashcards .flashcard__hint-touch { display: none; }
  #vocabulary-dialog.is-flashcards .flashcard__hint-pointer { display: inline; }
}

/* Back */
#vocabulary-dialog.is-flashcards .flashcard__accent {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 6px;
  background: var(--fc-accent);
}

#vocabulary-dialog.is-flashcards .flashcard__back-header {
  padding-right: 3.2rem;
}

#vocabulary-dialog.is-flashcards .flashcard__back-word {
  margin: 0;
  color: var(--fc-ink);
  font-family: var(--fc-serif);
  font-size: 1.85rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.03em;
}

#vocabulary-dialog.is-flashcards .vocabulary-dialog__reading {
  margin: 0.25rem 0 0;
  color: var(--fc-accent);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

#vocabulary-dialog.is-flashcards .vocabulary-dialog__meaning {
  margin: 1rem 0 0;
  padding: 1rem 0 0;
  border-top: 1px solid var(--fc-line);
  color: var(--fc-ink);
  font-size: 1.06rem;
  line-height: 1.55;
}

#vocabulary-dialog.is-flashcards .flashcard__sentence {
  margin: auto 0 0;
  padding: 0.85rem 0.95rem 0.9rem;
  border-radius: 12px;
  background: rgba(31, 48, 43, 0.045);
}

#vocabulary-dialog.is-flashcards .vocabulary-dialog__meaning + .flashcard__sentence {
  margin-top: 1.1rem;
}

#vocabulary-dialog.is-flashcards .flashcard__sentence[hidden] {
  display: none;
}

#vocabulary-dialog.is-flashcards .flashcard__sentence-label {
  margin: 0 0 0.3rem;
  color: var(--fc-ink-soft);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

#vocabulary-dialog.is-flashcards .flashcard__sentence-text {
  margin: 0;
  color: var(--fc-ink);
  font-size: 1rem;
  line-height: 2.05;
}

#vocabulary-dialog.is-flashcards .flashcard__sentence-text rt {
  color: var(--fc-ink-soft);
  font-size: 0.55em;
}

#vocabulary-dialog.is-flashcards .flashcard__mark {
  padding: 0.05em 0.1em;
  border-radius: 4px;
  color: inherit;
  background: var(--fc-mark);
  box-shadow: inset 0 -2px 0 var(--fc-mark-line);
  font-weight: 700;
}

/* The flip surface covers the card; the speaker sits above it. */
#vocabulary-dialog.is-flashcards .flashcard__flip {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--fc-radius);
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
  -webkit-tap-highlight-color: transparent;
}

#vocabulary-dialog.is-flashcards .flashcard__flip:focus-visible {
  outline: 3px solid var(--fc-focus);
  outline-offset: 4px;
}

#vocabulary-dialog.is-flashcards .flashcard__speaker {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  z-index: 3;
  display: flex;
}

#vocabulary-dialog.is-flashcards .flashcard__speaker:empty {
  display: none;
}

#vocabulary-dialog.is-flashcards .flashcard__speaker .vocabulary-speaker {
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid rgba(31, 48, 43, 0.14);
  color: var(--fc-ink);
  background: rgba(255, 252, 245, 0.92);
  box-shadow: 0 4px 12px rgba(18, 30, 25, 0.14);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

#vocabulary-dialog.is-flashcards .flashcard__speaker .vocabulary-speaker:hover,
#vocabulary-dialog.is-flashcards .flashcard__speaker .vocabulary-speaker.is-playing {
  color: #fff;
  border-color: var(--fc-accent);
  background: var(--fc-accent);
}

#vocabulary-dialog.is-flashcards .flashcard__speaker .vocabulary-speaker:focus-visible {
  outline: 3px solid var(--fc-focus);
  outline-offset: 2px;
}

/* A card flying off the deck. */
#vocabulary-dialog.is-flashcards .flashcard--ghost {
  position: absolute;
  z-index: 4;
  pointer-events: none;
}

/* End of pass */
#vocabulary-dialog.is-flashcards .flashcard--end {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 25rem;
  padding: 2rem 1.5rem;
  overflow: hidden;
  border-radius: var(--fc-radius);
  color: var(--fc-ink);
  background: var(--fc-paper) var(--fc-texture);
  box-shadow: var(--fc-shadow);
  text-align: center;
}

#vocabulary-dialog.is-flashcards .flashcard--end[hidden] {
  display: none;
}

#vocabulary-dialog.is-flashcards .flashcard-end__score {
  margin: 0;
  color: var(--fc-accent);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

#vocabulary-dialog.is-flashcards .flashcard-end__title {
  margin: 0.2rem 0 0;
  padding: 0;
  font-family: var(--fc-serif);
  font-size: clamp(2rem, 8vw, 2.6rem);
  font-weight: 600;
  letter-spacing: 0.04em;
}

#vocabulary-dialog.is-flashcards .flashcard-end__text {
  max-width: 18rem;
  margin: 0.3rem 0 1.4rem;
  color: var(--fc-ink-soft);
  line-height: 1.5;
}

/* Answer buttons and navigation */
#vocabulary-dialog.is-flashcards .flashcards__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.3s ease 0.15s, transform 0.3s ease 0.15s, visibility 0s linear 0.45s;
}

#vocabulary-dialog.is-flashcards .flashcards__actions.is-visible {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.3s ease 0.2s, transform 0.3s ease 0.2s, visibility 0s;
}

#vocabulary-dialog.is-flashcards .flashcards__button {
  min-height: 2.9rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid rgba(251, 246, 234, 0.55);
  border-radius: 999px;
  color: var(--fc-on-backdrop);
  background: rgba(251, 246, 234, 0.08);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

#vocabulary-dialog.is-flashcards .flashcards__button:hover {
  background: rgba(251, 246, 234, 0.16);
}

#vocabulary-dialog.is-flashcards .flashcards__button--primary {
  border-color: transparent;
  color: var(--fc-chip-ink);
  background: var(--fc-chip);
}

#vocabulary-dialog.is-flashcards .flashcards__button--primary:hover {
  background: #fff;
}

#vocabulary-dialog.is-flashcards .flashcard--end .flashcards__button--primary {
  color: #fff;
  background: var(--fc-accent);
}

#vocabulary-dialog.is-flashcards .flashcards__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0;
}

#vocabulary-dialog.is-flashcards .flashcards__nav[hidden] {
  display: none;
}

#vocabulary-dialog.is-flashcards .flashcards__arrow {
  display: grid;
  flex: 0 0 2.75rem;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(251, 246, 234, 0.5);
  border-radius: 50%;
  color: var(--fc-on-backdrop);
  background: rgba(251, 246, 234, 0.06);
  font: inherit;
  font-size: 1.15rem;
  cursor: pointer;
}

#vocabulary-dialog.is-flashcards .flashcards__arrow:disabled {
  opacity: 0.35;
  cursor: default;
}

#vocabulary-dialog.is-flashcards .flashcards__arrow:not(:disabled):hover {
  background: rgba(251, 246, 234, 0.16);
}

#vocabulary-dialog.is-flashcards :is(.flashcards__button, .flashcards__arrow, .vocabulary-dialog__close):focus-visible {
  outline: 3px solid var(--fc-focus);
  outline-offset: 3px;
}

#vocabulary-dialog.is-flashcards .flashcard--end .flashcards__button:focus-visible {
  outline-color: var(--fc-accent);
}

#vocabulary-dialog.is-flashcards .flashcards__dots {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#vocabulary-dialog.is-flashcards .flashcards__dot {
  width: 7px;
  height: 7px;
  border: 1.5px solid rgba(251, 246, 234, 0.6);
  border-radius: 999px;
  transition: width 0.25s ease, background-color 0.25s ease, border-color 0.25s ease;
}

#vocabulary-dialog.is-flashcards .flashcards__dot.is-known {
  border-color: var(--fc-on-backdrop);
  background: var(--fc-on-backdrop);
}

#vocabulary-dialog.is-flashcards .flashcards__dot.is-current {
  width: 20px;
  border-color: var(--fc-focus);
  background: var(--fc-focus);
}

#vocabulary-dialog.is-flashcards .vocabulary-audio-status:empty {
  display: none;
}

#vocabulary-dialog.is-flashcards .vocabulary-audio-status {
  margin: 0;
  color: var(--fc-on-backdrop);
  font-size: 0.85rem;
  text-align: center;
}

@media (min-width: 48rem) and (min-height: 50rem) {
  #vocabulary-dialog.is-flashcards .vocabulary-dialog__content {
    width: 27rem;
  }
}

@media (max-width: 30rem) {
  #vocabulary-dialog.is-flashcards .flashcard__face,
  #vocabulary-dialog.is-flashcards .flashcard--end {
    min-height: 22rem;
  }
}

@media (max-height: 44rem) {
  #vocabulary-dialog.is-flashcards .vocabulary-dialog__image {
    aspect-ratio: 16 / 10;
  }

  #vocabulary-dialog.is-flashcards .flashcard__face,
  #vocabulary-dialog.is-flashcards .flashcard--end {
    min-height: 0;
  }
}

/* Dark mode: ink-navy cards, off-white text, illustrations on a lighter inset. */
@media screen {
  :root[data-theme="dark"] #vocabulary-dialog.is-flashcards {
    --fc-paper: #1b2433;
    --fc-paper-edge: #253045;
    --fc-ink: #ece6da;
    --fc-ink-soft: #bcc3cd;
    --fc-faint: #a3abb6;
    --fc-line: rgba(236, 230, 218, 0.14);
    --fc-mark: rgba(240, 174, 156, 0.2);
    --fc-mark-line: #f0ae9c;
    --fc-chip: #ece6da;
    --fc-chip-ink: #141b26;
    --fc-on-backdrop: #ece6da;
    --fc-focus: #e3c077;
    --fc-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset,
      0 24px 50px -18px rgba(0, 0, 0, 0.85),
      0 3px 10px rgba(0, 0, 0, 0.4);
    --fc-texture: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .035 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  }

  :root[data-theme="dark"] #vocabulary-dialog.is-flashcards::backdrop {
    background: rgba(4, 6, 8, 0.78);
  }

  :root[data-theme="dark"] #vocabulary-dialog.is-flashcards .vocabulary-dialog__image-slot {
    padding: 6px;
    background: #efe6d3;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
  }

  :root[data-theme="dark"] #vocabulary-dialog.is-flashcards .vocabulary-dialog__image {
    border-radius: 10px;
  }

  :root[data-theme="dark"] #vocabulary-dialog.is-flashcards .flashcard__known,
  :root[data-theme="dark"] #vocabulary-dialog.is-flashcards .flashcard--end .flashcards__button--primary {
    color: #141b26;
  }

  :root[data-theme="dark"] #vocabulary-dialog.is-flashcards .flashcard__sentence {
    background: rgba(236, 230, 218, 0.06);
  }

  :root[data-theme="dark"] #vocabulary-dialog.is-flashcards .flashcard__speaker .vocabulary-speaker {
    border-color: rgba(20, 27, 38, 0.2);
    color: #141b26;
    background: rgba(236, 230, 218, 0.94);
  }

  :root[data-theme="dark"] #vocabulary-dialog.is-flashcards .flashcard__speaker .vocabulary-speaker:is(:hover, .is-playing) {
    color: #141b26;
    border-color: var(--fc-accent);
    background: var(--fc-accent);
  }

  :root[data-theme="dark"] #vocabulary-dialog.is-flashcards .vocabulary-dialog__close:hover,
  :root[data-theme="dark"] #vocabulary-dialog.is-flashcards .flashcards__button--primary:hover {
    background: #fff;
  }
}

/* Reduced motion: cross-fade instead of flipping; no tilt, spring or lift. */
@media (prefers-reduced-motion: reduce) {
  #vocabulary-dialog.is-flashcards .flashcard__inner,
  #vocabulary-dialog.is-flashcards .flashcard.is-flipped .flashcard__inner {
    transform: none;
    transition: none;
  }

  #vocabulary-dialog.is-flashcards .flashcard__face {
    transition: opacity 0.2s ease, visibility 0.2s;
  }

  #vocabulary-dialog.is-flashcards .flashcard__face--back {
    transform: none;
    opacity: 0;
    visibility: hidden;
  }

  #vocabulary-dialog.is-flashcards .flashcard.is-flipped .flashcard__face--back {
    opacity: 1;
    visibility: visible;
  }

  #vocabulary-dialog.is-flashcards .flashcard.is-flipped .flashcard__face--front {
    opacity: 0;
    visibility: hidden;
  }

  #vocabulary-dialog.is-flashcards .flashcard.is-lifting {
    animation: none;
  }

  #vocabulary-dialog.is-flashcards .flashcards__stack-card--near {
    transform: translate(0, 8px) scale(0.975);
  }

  #vocabulary-dialog.is-flashcards .flashcards__stack-card--far {
    transform: translate(0, 15px) scale(0.95);
  }

  #vocabulary-dialog.is-flashcards :is(.flashcards__actions, .flashcards__actions.is-visible, .flashcard__hint, .flashcards__dot) {
    transform: none;
    transition: none;
  }
}

@media print {
  #vocabulary-dialog.is-flashcards {
    display: none !important;
  }
}
