.zd-reading-paragraph {
  position: relative;
}

.zd-reading-paragraph [data-zd-reading-content="true"],
.zd-reading-paragraph [data-zd-reading-content="true"] *,
.zd-reading-paragraph button:has([data-zd-reading-content="true"]) {
  -webkit-touch-callout: default;
  -webkit-user-select: text !important;
  user-select: text !important;
}

.zd-reading-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid rgba(120, 113, 108, 0.2);
}

.zd-reading-action {
  display: inline-flex;
  min-height: 2rem;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid rgba(15, 118, 110, 0.35);
  border-radius: 0.7rem;
  background: rgba(255, 255, 255, 0.92);
  color: #0f766e;
  padding: 0.38rem 0.7rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.zd-reading-action-icon,
.zd-reading-translation-close svg,
.zd-phrase-close svg,
.zd-word-close svg,
.zd-word-head-action svg {
  width: 0.95rem;
  height: 0.95rem;
  flex: 0 0 auto;
  stroke-width: 1.9;
}

.zd-reading-action:hover {
  border-color: rgba(15, 118, 110, 0.7);
  background: rgba(15, 118, 110, 0.08);
  transform: translateY(-1px);
}

.zd-reading-action:focus-visible,
.zd-word-token:focus-visible,
.zd-word-dialog button:focus-visible,
.zd-word-dialog a:focus-visible,
.zd-phrase-popup button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 2px;
}

.zd-reading-action[disabled] {
  cursor: wait;
  opacity: 0.62;
  transform: none;
}

.zd-reading-action.is-active {
  border-color: #0f766e;
  background: rgba(15, 118, 110, 0.1);
}

.zd-reading-translation {
  margin-top: 0.65rem;
  border: 1px solid rgba(15, 118, 110, 0.26);
  border-radius: 0.85rem;
  background: rgba(15, 118, 110, 0.065);
  padding: 0.85rem;
}

.zd-reading-translation[hidden] {
  display: none;
}

.zd-reading-translation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: #0f766e;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.zd-reading-translation-close {
  display: inline-flex;
  height: 1.6rem;
  width: 1.6rem;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: 0.5rem;
  background: white;
  color: #0f766e;
  font-size: 1rem;
}

.zd-reading-translation-body {
  margin-top: 0.55rem;
  color: #1f2933;
  font-size: 0.9rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

.zd-reading-error {
  width: 100%;
  margin-top: 0.2rem;
  color: #b91c1c;
  font-size: 0.75rem;
}

.zd-word-token {
  display: inline;
  border-radius: 0.28rem;
  cursor: text;
  padding: 0 0.06em;
  transition: background-color 120ms ease, box-shadow 120ms ease;
}

.zd-word-token:hover {
  background: rgba(15, 118, 110, 0.1);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.1);
}

.zd-word-token.is-loading {
  cursor: wait;
}

.zd-word-token.is-saved {
  background: rgba(255, 204, 0, 0.24);
  box-shadow: inset 0 -2px 0 rgba(180, 83, 9, 0.42);
}

.zd-word-token.is-saved-phrase {
  text-decoration-line: underline;
  text-decoration-color: #0f766e;
  text-decoration-thickness: 2px;
  text-decoration-skip-ink: auto;
  text-underline-offset: 4px;
}

.zd-word-tooltip {
  position: fixed;
  z-index: 140;
  box-sizing: border-box;
  max-width: min(17.5rem, calc(100vw - 1rem));
  overflow-wrap: anywhere;
  pointer-events: none;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: 0.65rem;
  background: #173f3b;
  color: white;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
  padding: 0.42rem 0.65rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.72rem;
  line-height: 1.35;
}

.zd-word-tooltip[hidden] {
  display: none;
}

.zd-phrase-popup {
  position: fixed;
  z-index: 150;
  width: min(24rem, calc(100vw - 1.25rem));
  max-height: min(32rem, calc(100vh - 1.25rem));
  overflow-y: auto;
  border: 1px solid rgba(15, 118, 110, 0.3);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 20px 55px rgba(15, 23, 42, 0.24);
  backdrop-filter: blur(10px);
  padding: 0.95rem;
}

.zd-phrase-popup[hidden],
.zd-phrase-loading[hidden],
.zd-phrase-error[hidden],
.zd-phrase-details[hidden],
.zd-phrase-explain[hidden],
.zd-phrase-save[hidden],
.zd-phrase-saved[hidden] {
  display: none;
}

.zd-phrase-popup-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.zd-phrase-kicker,
.zd-phrase-label {
  color: #0f766e;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.zd-phrase-title {
  display: -webkit-box;
  margin-top: 0.2rem;
  overflow: hidden;
  color: #1f2933;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.9rem;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow-wrap: anywhere;
}

.zd-phrase-close {
  display: inline-flex;
  width: 1.8rem;
  height: 1.8rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(120, 113, 108, 0.28);
  border-radius: 0.55rem;
  background: white;
  color: #5c6672;
  font-size: 1rem;
}

.zd-phrase-loading,
.zd-phrase-error {
  margin-top: 0.75rem;
  border-radius: 0.7rem;
  background: #f5f5f4;
  padding: 0.7rem;
  color: #5c6672;
  font-size: 0.76rem;
}

.zd-phrase-error {
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
}

.zd-phrase-details {
  margin-top: 0.8rem;
}

.zd-phrase-section + .zd-phrase-section {
  margin-top: 0.75rem;
}

.zd-phrase-value {
  margin-top: 0.22rem;
  color: #374151;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.zd-phrase-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(120, 113, 108, 0.18);
}

.zd-phrase-explain,
.zd-phrase-save {
  display: inline-flex;
  min-height: 2.15rem;
  align-items: center;
  justify-content: center;
  border: 1px solid #0f766e;
  border-radius: 0.68rem;
  background: #0f766e;
  color: white;
  padding: 0.48rem 0.75rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
}

.zd-phrase-explain[disabled],
.zd-phrase-save[disabled] {
  cursor: wait;
  opacity: 0.62;
}

.zd-phrase-saved {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #0f766e;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
}

.zd-phrase-saved svg {
  width: 0.9rem;
  height: 0.9rem;
  stroke-width: 2.2;
}

.zd-reading-audio-controls {
  position: fixed;
  right: 1.15rem;
  bottom: 5rem;
  z-index: 90;
}

.zd-reading-audio-controls[hidden] {
  display: none;
}

.zd-reading-audio-controls-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  border: 1px solid rgba(120, 113, 108, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(8px);
  padding: 0.45rem 0.6rem;
}

.zd-reading-audio-label {
  max-width: 13rem;
  overflow: hidden;
  padding: 0 0.25rem;
  color: #5c6672;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zd-reading-audio-btn {
  display: inline-flex;
  width: 1.9rem;
  height: 1.9rem;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(120, 113, 108, 0.28);
  border-radius: 999px;
  background: white;
  color: #5c6672;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
}

.zd-reading-audio-btn small {
  margin-left: -0.08rem;
  font-size: 0.48rem;
}

.zd-reading-audio-btn svg {
  width: 0.9rem;
  height: 0.9rem;
  flex: 0 0 auto;
  stroke-width: 2;
}

.zd-reading-audio-btn:hover,
.zd-reading-audio-btn:focus-visible {
  border-color: rgba(15, 118, 110, 0.5);
  background: rgba(15, 118, 110, 0.08);
  color: #0f766e;
}

.zd-reading-audio-stop {
  color: #b45309;
}

.zd-word-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.zd-word-modal[hidden] {
  display: none;
}

.zd-word-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(15, 23, 42, 0.46);
  backdrop-filter: blur(3px);
}

.zd-word-dialog {
  position: relative;
  width: min(34rem, 100%);
  max-height: min(42rem, calc(100vh - 2rem));
  overflow-y: auto;
  border: 1px solid rgba(120, 113, 108, 0.28);
  border-radius: 1.4rem;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
  padding: 1.25rem;
}

.zd-word-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.zd-word-dialog-head-main {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.zd-word-head-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

.zd-word-head-action {
  display: inline-flex;
  min-height: 2rem;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: 0.68rem;
  background: white;
  color: #0f766e;
  padding: 0.4rem 0.62rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.67rem;
  font-weight: 600;
}

.zd-word-head-action:hover {
  background: rgba(15, 118, 110, 0.07);
}

.zd-word-head-action[disabled] {
  cursor: wait;
  opacity: 0.62;
}

.zd-word-kicker {
  color: #0f766e;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.zd-word-title {
  margin-top: 0.2rem;
  color: #1f2933;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.55rem;
  font-weight: 600;
}

.zd-word-lemma {
  margin-top: 0.2rem;
  color: #6b7280;
  font-size: 0.8rem;
}

.zd-word-close {
  display: inline-flex;
  height: 2rem;
  width: 2rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(120, 113, 108, 0.28);
  border-radius: 0.65rem;
  background: #fff;
  color: #5c6672;
  font-size: 1.15rem;
}

.zd-word-loading,
.zd-word-modal-error {
  margin-top: 1rem;
  border-radius: 0.8rem;
  background: #f5f5f4;
  padding: 0.85rem;
  color: #5c6672;
  font-size: 0.85rem;
}

.zd-word-modal-status {
  margin-top: 0.75rem;
  border-radius: 0.72rem;
  background: rgba(15, 118, 110, 0.08);
  color: #0f766e;
  padding: 0.65rem 0.75rem;
  font-size: 0.78rem;
}

.zd-word-modal-status.is-error {
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
}

.zd-word-modal-error {
  background: rgba(220, 38, 38, 0.08);
  color: #b91c1c;
}

.zd-reading-error.is-subscription,
.zd-phrase-error.is-subscription,
.zd-word-modal-error.is-subscription,
.zd-word-modal-status.is-subscription {
  width: 100%;
  margin-top: 0.8rem;
  border: 1px solid #d7e5df;
  border-radius: 0.9rem;
  background: #f7faf7;
  color: #263f35;
  padding: 1rem;
  font-family: "Space Grotesk", Arial, sans-serif;
  text-align: start;
}

.zd-reading-subscription-copy strong {
  display: block;
  font-size: 1rem;
  line-height: 1.5;
}

.zd-reading-subscription-copy p {
  margin: 0.4rem 0 0.85rem;
  color: #53665e;
  font-size: 0.85rem;
  line-height: 1.6;
}

.zd-reading-subscription-link {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  border-radius: 0.6rem;
  background: #1a684b;
  color: #fff;
  padding: 0.55rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
}

.zd-reading-subscription-link:hover {
  background: #145b40;
  color: #fff;
}

.zd-reading-subscription-link:focus-visible {
  outline: 3px solid #d4a832;
  outline-offset: 3px;
}

.zd-word-head-actions[hidden] {
  display: none;
}

.zd-word-details {
  margin-top: 1rem;
}

.zd-word-section + .zd-word-section {
  margin-top: 0.9rem;
}

.zd-word-label {
  color: #6b7280;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.zd-word-value {
  margin-top: 0.25rem;
  color: #1f2933;
  font-size: 0.95rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.zd-word-examples {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  color: #374151;
  font-size: 0.87rem;
  line-height: 1.55;
}

.zd-word-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}

.zd-word-tag {
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.07);
  color: #0f766e;
  padding: 0.22rem 0.5rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.62rem;
}

.zd-word-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(120, 113, 108, 0.2);
}

.zd-word-save,
.zd-word-remove {
  display: inline-flex;
  min-height: 2.35rem;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  padding: 0.55rem 0.9rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
}

.zd-word-save {
  border: 1px solid #0f766e;
  background: #0f766e;
  color: white;
}

.zd-word-save[hidden],
.zd-word-remove[hidden] {
  display: none;
}

.zd-word-remove {
  border: 1px solid rgba(185, 28, 28, 0.36);
  background: rgba(220, 38, 38, 0.07);
  color: #b91c1c;
}

@media (max-width: 640px) {
  .zd-reading-toolbar {
    justify-content: stretch;
  }

  .zd-reading-action {
    flex: 1 1 9rem;
    min-height: 2.75rem;
  }

  .zd-reading-audio-controls {
    right: 0.75rem;
    bottom: calc(4.8rem + env(safe-area-inset-bottom));
    left: 0.75rem;
    text-align: center;
  }

  .zd-reading-audio-controls-inner {
    max-width: 100%;
  }

  .zd-reading-audio-label {
    min-width: 0;
    flex: 1 1 auto;
  }

  .zd-word-dialog-head-main {
    flex-direction: column;
  }

  .zd-word-head-actions {
    justify-content: flex-start;
  }

  .zd-word-dialog {
    max-height: calc(100dvh - 1.25rem);
    border-radius: 1rem;
    padding: 1rem;
  }

  .zd-word-modal {
    padding:
      max(0.625rem, env(safe-area-inset-top))
      max(0.625rem, env(safe-area-inset-right))
      max(0.625rem, env(safe-area-inset-bottom))
      max(0.625rem, env(safe-area-inset-left));
  }

  .zd-word-close,
  .zd-word-head-action,
  .zd-word-save,
  .zd-word-remove,
  .zd-phrase-close,
  .zd-phrase-explain,
  .zd-phrase-save {
    min-height: 2.75rem;
  }

  .zd-word-close,
  .zd-phrase-close {
    width: 2.75rem;
  }

  .zd-phrase-popup {
    max-height: calc(100dvh - 1.25rem);
  }
}

@media (hover: none) and (pointer: coarse) {
  .zd-word-token:hover:not(.is-saved) {
    background: transparent;
    box-shadow: none;
  }
}

/* Writing prompt typography must not override the learner’s translation size. */
.shreiben-task-columns .shreiben-markdown .zd-reading-translation-body { font-size: var(--zd-explanation-font-size, 18px) !important; line-height: 1.65; }
