.cn-lesson {
  --lesson-ink: #1f2937;
  --lesson-muted: #94a3b8;
  --lesson-subtle: rgba(148, 163, 184, 0.14);
  --lesson-subtle-border: rgba(148, 163, 184, 0.2);
  --lesson-active: rgba(74, 222, 128, 0.16);
  --lesson-active-border: rgba(74, 222, 128, 0.28);
  --lesson-active-ink: #15803d;
  --lesson-bubble-bg: rgba(255, 255, 255, 0.97);
  --lesson-bubble-border: rgba(148, 163, 184, 0.18);
  --lesson-bubble-shadow: 0 20px 45px rgba(15, 23, 42, 0.16);
  --lesson-translation-ink: #475569;
  --lesson-token-bg-hover: rgba(248, 250, 252, 0.92);
  --lesson-ring: rgba(84, 99, 122, 0.18);
  margin: 1.25em 0 1.55em;
}

.cn-lesson__paragraph {
  position: relative;
  margin: 0 0 1.35em;
  color: var(--lesson-ink);
  line-height: 1.95;
}

.cn-lesson__paragraph:last-child {
  margin-bottom: 0;
}

.cn-lesson__sentence {
  position: relative;
  display: inline;
}

.cn-lesson__toggle,
.cn-lesson__audio,
.cn-lesson__token,
.cn-lesson__popover-audio {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.cn-lesson__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.45rem;
  margin-right: 0.42rem;
  padding: 0.05rem 0.34rem;
  vertical-align: baseline;
  border-radius: 999px;
  background: var(--lesson-subtle);
  color: var(--lesson-muted);
  font-size: 0.58em;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  box-shadow: inset 0 0 0 1px var(--lesson-subtle-border);
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.cn-lesson__toggle:hover {
  background: rgba(148, 163, 184, 0.2);
  color: #64748b;
}

.cn-lesson__toggle[aria-expanded="true"] {
  background: var(--lesson-active);
  color: var(--lesson-active-ink);
  box-shadow: inset 0 0 0 1px var(--lesson-active-border);
}

.cn-lesson__english {
  color: var(--lesson-ink);
}

.cn-lesson__english a {
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(51, 65, 85, 0.2);
}

.cn-lesson__english a:hover {
  border-bottom-color: rgba(51, 65, 85, 0.55);
}

.cn-lesson__translation {
  position: absolute;
  left: 0;
  top: calc(100% + 0.55rem);
  z-index: 20;
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  min-width: 14rem;
  max-width: min(30rem, calc(100vw - 2rem));
  padding: 0.52rem 0.62rem;
  border-radius: 14px;
  background: var(--lesson-bubble-bg);
  box-shadow: var(--lesson-bubble-shadow);
  box-shadow:
    var(--lesson-bubble-shadow),
    inset 0 0 0 1px var(--lesson-bubble-border);
  animation: cn-lesson-reveal 160ms ease;
}

.cn-lesson__translation::before {
  content: "";
  position: absolute;
  left: 1.1rem;
  width: 12px;
  height: 12px;
  background: inherit;
  transform: rotate(45deg);
}

.cn-lesson__translation[data-placement="bottom"]::before {
  top: -6px;
  box-shadow: inset -1px -1px 0 var(--lesson-bubble-border);
}

.cn-lesson__translation[data-placement="top"]::before {
  bottom: -6px;
  box-shadow: inset 1px 1px 0 var(--lesson-bubble-border);
}

.cn-lesson__translation[hidden] {
  display: none !important;
}

.cn-lesson__audio {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-top: 0.1rem;
  border-radius: 999px;
  background: rgba(241, 245, 249, 0.96);
  color: #64748b;
  box-shadow: inset 0 0 0 1px rgba(122, 141, 167, 0.22);
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.cn-lesson__audio:hover,
.cn-lesson__popover-audio:hover,
.cn-lesson__audio.is-playing,
.cn-lesson__popover-audio.is-playing {
  transform: translateY(-1px);
  background: #ffffff;
  color: #334155;
}

.cn-lesson__icon {
  width: 0.7rem;
  height: 0.7rem;
}

.cn-lesson__translation-text {
  width: 100%;
  color: var(--lesson-translation-ink);
  font-size: 0.84rem;
  line-height: 1.85;
  letter-spacing: 0.01em;
  font-family: "Noto Serif SC", "Songti SC", "STSong", "PingFang SC", "Microsoft YaHei", serif;
}

.cn-lesson__plain-text {
  display: inline;
}

.cn-lesson__token {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 0 0.08rem;
  border-radius: 0.35rem;
  background: transparent;
  color: inherit;
  transition: color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.cn-lesson__token:hover,
.cn-lesson__token.is-active {
  background: var(--lesson-token-bg-hover);
  box-shadow: 0 0 0 1px var(--lesson-ring);
  color: #0f172a;
}

.cn-lesson__popover {
  position: fixed;
  z-index: 1100;
  width: min(320px, calc(100vw - 1.5rem));
  pointer-events: auto;
}

.cn-lesson__popover-card {
  position: relative;
  padding: 0.95rem 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow:
    0 28px 60px rgba(15, 23, 42, 0.22),
    inset 0 0 0 1px rgba(122, 141, 167, 0.16);
  backdrop-filter: blur(18px);
}

.cn-lesson__popover[data-placement="top"] .cn-lesson__popover-card::after,
.cn-lesson__popover[data-placement="bottom"] .cn-lesson__popover-card::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  background: inherit;
  box-shadow: inset -1px -1px 0 rgba(122, 141, 167, 0.12);
  transform: rotate(45deg);
}

.cn-lesson__popover[data-placement="top"] .cn-lesson__popover-card::after {
  bottom: -7px;
}

.cn-lesson__popover[data-placement="bottom"] .cn-lesson__popover-card::after {
  top: -7px;
}

.cn-lesson__popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.cn-lesson__popover-word {
  color: #111827;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: "Noto Serif SC", "Songti SC", "STSong", "PingFang SC", "Microsoft YaHei", serif;
}

.cn-lesson__popover-audio {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.1);
  color: #334155;
}

.cn-lesson__popover-pinyin {
  margin-bottom: 0.5rem;
  color: #64748b;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cn-lesson__popover-gloss {
  color: #172033;
  font-size: 0.98rem;
  line-height: 1.7;
}

.cn-lesson__popover-note {
  margin-top: 0.45rem;
  color: #667085;
  font-size: 0.9rem;
  line-height: 1.6;
}

.cn-lesson__visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes cn-lesson-reveal {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  .cn-lesson__toggle {
    min-width: 1.3rem;
    margin-right: 0.32rem;
    font-size: 0.54em;
  }

  .cn-lesson__translation {
    min-width: 12rem;
    max-width: min(22rem, calc(100vw - 1.2rem));
    padding: 0.48rem 0.56rem;
  }

  .cn-lesson__translation-text {
    font-size: 0.8rem;
    line-height: 1.8;
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-user-color-scheme]) .cn-lesson {
    --lesson-ink: #e5ecf5;
    --lesson-muted: #94a3b8;
    --lesson-subtle: rgba(148, 163, 184, 0.12);
    --lesson-subtle-border: rgba(148, 163, 184, 0.16);
    --lesson-active: rgba(74, 222, 128, 0.18);
    --lesson-active-border: rgba(74, 222, 128, 0.26);
    --lesson-active-ink: #bbf7d0;
    --lesson-bubble-bg: rgba(17, 24, 39, 0.96);
    --lesson-bubble-border: rgba(148, 163, 184, 0.1);
    --lesson-bubble-shadow: 0 24px 58px rgba(3, 7, 18, 0.42);
    --lesson-translation-ink: #cbd5e1;
    --lesson-token-bg-hover: rgba(71, 85, 105, 0.32);
    --lesson-ring: rgba(148, 163, 184, 0.22);
  }

  :root:not([data-user-color-scheme]) .cn-lesson__audio,
  :root:not([data-user-color-scheme]) .cn-lesson__popover-audio {
    background: rgba(15, 23, 42, 0.7);
    color: #f8fafc;
  }

  :root:not([data-user-color-scheme]) .cn-lesson__popover-card {
    background: rgba(17, 24, 39, 0.96);
    box-shadow:
      0 28px 60px rgba(3, 7, 18, 0.45),
      inset 0 0 0 1px rgba(148, 163, 184, 0.1);
  }

  :root:not([data-user-color-scheme]) .cn-lesson__popover-word,
  :root:not([data-user-color-scheme]) .cn-lesson__popover-gloss {
    color: #f8fafc;
  }

  :root:not([data-user-color-scheme]) .cn-lesson__popover-pinyin,
  :root:not([data-user-color-scheme]) .cn-lesson__popover-note {
    color: #c2cedd;
  }
}

[data-user-color-scheme="dark"] .cn-lesson {
  --lesson-ink: #e5ecf5;
  --lesson-muted: #94a3b8;
  --lesson-subtle: rgba(148, 163, 184, 0.12);
  --lesson-subtle-border: rgba(148, 163, 184, 0.16);
  --lesson-active: rgba(74, 222, 128, 0.18);
  --lesson-active-border: rgba(74, 222, 128, 0.26);
  --lesson-active-ink: #bbf7d0;
  --lesson-bubble-bg: rgba(17, 24, 39, 0.96);
  --lesson-bubble-border: rgba(148, 163, 184, 0.1);
  --lesson-bubble-shadow: 0 24px 58px rgba(3, 7, 18, 0.42);
  --lesson-translation-ink: #cbd5e1;
  --lesson-token-bg-hover: rgba(71, 85, 105, 0.32);
  --lesson-ring: rgba(148, 163, 184, 0.22);
}

[data-user-color-scheme="dark"] .cn-lesson__audio,
[data-user-color-scheme="dark"] .cn-lesson__popover-audio {
  background: rgba(15, 23, 42, 0.7);
  color: #f8fafc;
}

[data-user-color-scheme="dark"] .cn-lesson__popover-card {
  background: rgba(17, 24, 39, 0.96);
  box-shadow:
    0 28px 60px rgba(3, 7, 18, 0.45),
    inset 0 0 0 1px rgba(148, 163, 184, 0.1);
}

[data-user-color-scheme="dark"] .cn-lesson__popover-word,
[data-user-color-scheme="dark"] .cn-lesson__popover-gloss {
  color: #f8fafc;
}

[data-user-color-scheme="dark"] .cn-lesson__popover-pinyin,
[data-user-color-scheme="dark"] .cn-lesson__popover-note {
  color: #c2cedd;
}
