/* Transparent wrapper: Japanese keeps its original margins, widths and line breaks. */
.sentence-translation-unit {
  display: contents;
  --translation-tail-gap: 3px;
}
.current-sentence .sentence-translation-toggle {
  position: fixed;
  inset: auto;
  left: var(--translation-toggle-x, 0px);
  top: var(--translation-toggle-y, 0px);
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  width: 1rem;
  min-width: 1rem;
  height: var(--translation-tail-height, 1.8rem);
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  box-shadow: none;
  color: var(--accent, #315f59);
  font: 500 0.76rem/1 var(--font-ui, sans-serif);
  letter-spacing: 0;
  transform: none;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
}
/* Only Japanese hover reveals it: not playback, blank paragraph space or Chinese. */
.sentence-translation-unit:has(> .subtitle-sentence:hover) > .sentence-translation-toggle,
.sentence-translation-unit:has(:focus-visible) > .sentence-translation-toggle,
.current-sentence .sentence-translation-toggle:hover {
  opacity: 1;
  pointer-events: auto;
}
/* Bridge the tiny gap so moving from Japanese to the revealed control is stable. */
.current-sentence .sentence-translation-toggle::before {
  content: "";
  position: absolute;
  inset: var(--translation-bridge-inset, 0 0 0 -3px);
}
.current-sentence .sentence-translation-toggle::after {
  content: "";
  position: absolute;
  inset: calc(-1 * var(--translation-hit-padding, 0px));
}
/* Keep the active entrance identifiable; fleeting passes over other sentences
   must not compete with the translation being read. Keyboard focus stays instant. */
.current-sentence .sentence-translation-toggle[aria-expanded="true"] { opacity: .65; }
@media (hover: hover) and (pointer: fine) {
  .current-sentence:has(.is-translation-open) .sentence-translation-toggle[aria-expanded="false"] {
    visibility: hidden;
    transition: visibility 0s;
  }
  .current-sentence:has(.is-translation-open) .sentence-translation-unit:has(> .subtitle-sentence:hover) > .sentence-translation-toggle[aria-expanded="false"],
  .current-sentence:has(.is-translation-open) .sentence-translation-toggle[aria-expanded="false"]:hover {
    visibility: visible;
    transition-delay: 180ms;
  }
  .current-sentence:has(.is-translation-open) .sentence-translation-unit:has(:focus-visible) > .sentence-translation-toggle {
    visibility: visible;
    transition: none;
  }
}
.current-sentence .sentence-translation-toggle[aria-expanded="true"]:hover,
.current-sentence .sentence-translation-toggle[aria-expanded="true"]:focus-visible { opacity: 1; }
.current-sentence .sentence-translation-toggle:hover,
.current-sentence .sentence-translation-toggle[aria-expanded="true"] {
  background: color-mix(in srgb, var(--accent-soft, #e6eeea) 65%, transparent);
  /* An open entrance remains mouse-reachable even while its glyph is hidden. */
  pointer-events: auto;
}
.current-sentence .sentence-translation-toggle:focus-visible {
  outline: 2px solid var(--accent, #315f59);
  outline-offset: 3px;
}
.shadowing-panel { scroll-margin-top: 12px; }
.shadowing-panel > .section-heading { margin-bottom: 0.35rem; }
/* A stable, compact lane replaces stacked heading/body whitespace. Keeping the
   lane when text is hidden prevents opening and closing from moving Japanese. */
.translation-slot {
  box-sizing: border-box;
  width: 100%;
  max-width: 52rem;
  height: 4.2rem;
  flex: 0 0 4.2rem;
  margin: 0 auto;
  padding: 6px var(--space-2, 0.5rem) 10px;
  display: flex;
  align-items: flex-end;
  font-size: 0.94rem;
}
#current-sentence { padding-top: 0.25rem; }
.translation-display {
  box-sizing: border-box;
  width: 100%;
  max-width: 52rem;
  max-height: 100%;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  color: var(--muted-text, #626b7c);
  font: 400 0.94rem/1.55 var(--font-ui, sans-serif);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-align: left;
}
@media (max-width: 700px) { .translation-slot { padding-inline: var(--space-1, 0.25rem); } }
@media (max-width: 560px) { .translation-slot { padding-inline: 0; } }
.translation-display:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }
.translation-display[hidden],
.current-sentence .sentence-translation-toggle[hidden] { display: none; }
.current-sentence .sentence-translation-toggle[data-anchor-visible="false"] { visibility: hidden; pointer-events: none; }
.translation-feedback { margin: 0; color: var(--muted-text); font-size: 0.85rem; }
@media (hover: none), (pointer: coarse) {
  .current-sentence .sentence-translation-toggle,
  .current-sentence .sentence-translation-toggle[aria-expanded="true"] {
    opacity: 1;
    pointer-events: auto;
  }
  /* Invisible target padding is collision-checked by the controller. */
}
