/* 新闻小课 · original lime / cream / ink lesson UI */

:root {
  --ink: #1c2416;
  --ink-soft: #3f4b35;
  --muted: #66715b;
  --cream: #f3eedc;
  --cream-deep: #e7dfc4;
  --paper: #fffdf6;
  --lime: #c6e24a;
  --lime-hot: #d8f25a;
  --lime-deep: #8aae14;
  --leaf: #2b5c28;
  --terracotta: #c45a32;
  --line: color-mix(in srgb, var(--ink) 14%, transparent);
  --line-strong: color-mix(in srgb, var(--ink) 28%, transparent);
  --shadow: 0 18px 40px color-mix(in srgb, var(--ink) 10%, transparent);
  --font: ui-rounded, "Hiragino Sans GB", "PingFang SC", "Noto Sans SC",
    "Source Han Sans SC", "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  --radius: 18px;
  --radius-sm: 12px;
  --header-h: 4.15rem;
  --lesson-bar-h: 3.7rem;
  --pad: clamp(1rem, 3vw, 1.75rem);
  --focus: 0 0 0 3px var(--paper), 0 0 0 6px var(--ink);
  --script-size-en: 1.125rem;
  --script-size-zh: 0.95rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 0.5rem);
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--cream);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

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

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 100;
  background: var(--ink);
  color: var(--lime);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: 0.75rem;
  box-shadow: var(--focus);
}

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 10% -10%, color-mix(in srgb, var(--lime) 48%, transparent), transparent 60%),
    radial-gradient(700px 420px at 100% 0%, color-mix(in srgb, #f0c56a 35%, transparent), transparent 55%),
    linear-gradient(180deg, #f7f2e3 0%, var(--cream) 40%, #ece6cf 100%);
  pointer-events: none;
}

.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    -18deg,
    transparent 0 18px,
    color-mix(in srgb, var(--ink) 3.5%, transparent) 18px 19px
  );
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.4), transparent 70%);
  opacity: 0.6;
}

/* ——— header ——— */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--cream) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 2px solid var(--line);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  min-height: var(--header-h);
  padding: 0.55rem var(--pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand-mark {
  width: 2.35rem;
  height: 2.35rem;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--lime);
  color: var(--ink);
  font-weight: 800;
  border-radius: 10px;
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  letter-spacing: -0.06em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}

.brand-zh {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

.brand-en {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.channel-switch {
  display: inline-flex;
  align-items: stretch;
  flex: none;
  min-width: 0;
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 2px 2px 0 var(--ink);
}

.channel-switch {
  margin-right: auto;
}

.channel-link {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: 0.84rem;
  text-decoration: none;
  padding: 0.32rem 0.85rem;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.channel-link + .channel-link {
  border-left: 2px solid var(--ink);
}

.channel-link.is-on {
  background: var(--lime);
}

.channel-link:hover:not(.is-on) {
  background: color-mix(in srgb, var(--lime) 40%, var(--paper));
}

.channel-label-short {
  display: none;
}

body:not(.is-authed) .channel-switch {
  display: none;
}

/* ——— buttons ——— */

.btn,
.ctrl-btn,
.seg-btn,
.sent-action,
.icon-x {
  font-family: inherit;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  min-height: 44px;
  line-height: 1.2;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.btn:hover {
  background: #fff;
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--ink);
}

.btn:active {
  transform: translate(1px, 1px);
  box-shadow: 0 0 0 var(--ink);
}

.btn-ghost {
  box-shadow: none;
  background: transparent;
}

.btn-ghost:hover {
  background: color-mix(in srgb, var(--lime) 45%, var(--paper));
  box-shadow: 2px 2px 0 var(--ink);
}

.btn-primary {
  background: var(--lime);
  font-size: 1.05rem;
}

.btn-primary:hover {
  background: var(--lime-hot);
}

.btn-xl {
  padding: 0.85rem 1.5rem;
  font-size: 1.12rem;
  min-height: 52px;
  width: 100%;
  max-width: 22rem;
}

.btn-ico {
  display: grid;
  place-items: center;
}

.count-pill {
  display: inline-grid;
  place-items: center;
  min-width: 1.3rem;
  height: 1.3rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--lime);
  font-size: 0.72rem;
  font-weight: 800;
}

.count-pill.is-pop {
  animation: pill-pop 0.45s ease;
}

@keyframes pill-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* ——— home ——— */

.view {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.4rem var(--pad) 3rem;
}

.home-wrap {
  max-width: 1080px;
  margin: 0 auto;
}

.current-lessons {
  display: grid;
  gap: 1.1rem;
  padding-bottom: 10px; /* keep 8px card shadows from covering the streak */
}

.current-lessons .today-hero {
  text-decoration: none;
  color: inherit;
}

.today-hero {
  display: block;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 8px 8px 0 color-mix(in srgb, var(--ink) 85%, var(--lime));
}

.today-body {
  padding: 1.15rem 1.2rem 1.3rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
}

.today-topline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.today-topline-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.today-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 16px;
  border: 2px solid var(--ink);
  flex: none;
  background: color-mix(in srgb, var(--lime) 40%, var(--cream));
}

.today-hero .card-title {
  font-size: clamp(1.3rem, 2.8vw, 1.75rem);
}

.today-body .btn-xl {
  margin-top: 0.55rem;
  width: 100%;
  max-width: 22rem;
}

.today-progress {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.85rem;
  margin: 0.25rem 0 0.1rem;
}

.today-dots {
  display: flex;
  gap: 0.28rem;
}

.today-dot {
  font-size: 1.35rem;
  line-height: 1;
  color: color-mix(in srgb, var(--ink) 28%, transparent);
}

.today-dot.is-on {
  color: #d97706;
}

.today-count {
  margin: 0;
  font-weight: 750;
  font-size: 0.95rem;
}

.story-list-label {
  margin: 1.5rem 0 0.7rem;
  font-size: 0.95rem;
  font-weight: 800;
}

.story-item.is-next {
  background: color-mix(in srgb, var(--lime) 42%, var(--paper));
  box-shadow: 4px 4px 0 var(--ink);
}

.story-status {
  justify-self: end;
  font-size: 0.78rem;
  font-weight: 800;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  padding: 0.2rem 0.55rem;
  background: var(--paper);
  white-space: nowrap;
}

.story-status.is-next {
  background: var(--lime);
}

.story-status.is-done {
  background: color-mix(in srgb, var(--lime) 35%, var(--paper));
}

.archive {
  margin: 1.25rem 0 1.5rem;
}

.archive .story-list-label {
  margin-top: 0;
}

.archive-note {
  margin: -0.25rem 0 0.9rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
}

.archive-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}

a.archive-card {
  text-decoration: none;
}

.archive-card {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 4px 4px 0 color-mix(in srgb, var(--ink) 45%, transparent);
  padding: 0.85rem 0.9rem 0.95rem;
  gap: 0.8rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.archive-card:hover,
.archive-card:focus-visible {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--ink);
  outline: none;
}

.archive-thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 16px;
  border: 2px solid var(--ink);
  flex: none;
  background: color-mix(in srgb, var(--lime) 55%, var(--cream));
}

.archive-card.tone-2 .archive-thumb { background: color-mix(in srgb, #8ecae6 55%, var(--cream)); }
.archive-card.tone-3 .archive-thumb { background: color-mix(in srgb, #ffd6a5 70%, var(--cream)); }
.archive-card.tone-4 .archive-thumb { background: color-mix(in srgb, #cdb4db 55%, var(--cream)); }
.archive-card.tone-5 .archive-thumb { background: color-mix(in srgb, #b5e48c 60%, var(--cream)); }
.archive-card.tone-6 .archive-thumb { background: color-mix(in srgb, #f4a261 45%, var(--cream)); }

.archive-teaser {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
}

.archive-demo-mark {
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: 0.08em;
  border: 2px solid var(--ink);
  background: var(--paper);
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
}

.archive-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.18rem;
  min-width: 0;
  flex: 1;
}

.archive-body h3 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.archive-status {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  font-weight: 800;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  padding: 0.15rem 0.5rem;
  background: var(--paper);
}

@media (min-width: 640px) {
  .archive-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 980px) {
  .archive-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}


.kicker {
  margin: 0 0 0.85rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  color: var(--leaf);
  text-transform: uppercase;
}

.lesson-card {
  display: grid;
  grid-template-columns: 1fr;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 8px 8px 0 color-mix(in srgb, var(--ink) 85%, var(--lime));
}

.card-media {
  position: relative;
  background: #111;
  aspect-ratio: 16 / 9;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.duration-badge {
  position: absolute;
  right: 0.8rem;
  bottom: 0.8rem;
  background: var(--ink);
  color: var(--cream);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
}

.card-body {
  padding: 1.25rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}

.card-source {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.card-title {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.card-meta,
.card-level {
  margin: 0;
  color: var(--ink-soft);
  font-weight: 600;
}

.card-level {
  display: inline-flex;
  background: color-mix(in srgb, var(--lime) 40%, var(--paper));
  border: 1.5px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.85rem;
}

.home-streak {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin: 1.15rem 0 0;
  padding: 0.7rem 1.05rem;
  background: color-mix(in srgb, var(--lime) 34%, var(--paper));
  border: 2px solid color-mix(in srgb, var(--leaf) 28%, var(--line-strong));
  border-radius: 16px;
  font-weight: 750;
  color: var(--leaf);
  font-size: 0.98rem;
  line-height: 1.45;
  position: relative;
  z-index: 1;
  overflow: visible;
  overflow-wrap: anywhere;
}

.feature-list {
  margin: 0.6rem 0 0.8rem;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 1rem;
  width: 100%;
  font-weight: 650;
  font-size: 0.95rem;
}

.feature-list li {
  position: relative;
  padding-left: 1.15rem;
}

.feature-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.42em;
  width: 0.55em;
  height: 0.55em;
  background: var(--lime);
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  transform: rotate(8deg);
}

.stub-flag {
  margin: 0 0 0.4rem;
  font-size: 0.85rem;
  color: var(--terracotta);
  font-weight: 650;
}

.story-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0;
}

.story-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.35rem 0.85rem;
  align-items: center;
  width: 100%;
  text-decoration: none;
  color: inherit;
  background: color-mix(in srgb, var(--cream) 72%, var(--paper));
  border: 2px solid var(--ink);
  border-radius: 18px;
  padding: 0.8rem 0.9rem;
  box-shadow: 3px 3px 0 color-mix(in srgb, var(--ink) 35%, transparent);
}

.story-item:hover,
.story-item:focus-visible {
  background: color-mix(in srgb, var(--lime) 30%, var(--paper));
}

.story-item.is-done {
  background: color-mix(in srgb, var(--lime) 22%, var(--paper));
}

.story-index {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 2px solid var(--ink);
  display: grid;
  place-items: center;
  font-weight: 800;
  background: var(--paper);
}

.story-item.is-done .story-index {
  background: var(--lime);
}

.story-item-text {
  min-width: 0;
}

.story-item-text strong {
  display: block;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.story-item-text p {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  line-height: 1.4;
}

.story-star {
  font-size: 1.4rem;
  line-height: 1;
  color: color-mix(in srgb, var(--ink) 28%, transparent);
}

.story-item.is-done .story-star {
  color: #d97706;
}

.story-flag {
  grid-column: 2 / -1;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--terracotta);
}

.badge-medal.is-star {
  background: color-mix(in srgb, #fbbf24 70%, var(--lime));
}

@media (min-width: 840px) {
  .current-lessons {
    grid-template-columns: 1fr 1fr;
  }

  .current-lessons:has(.today-hero:nth-child(3)) {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .lesson-card {
    grid-template-columns: 1.15fr 1fr;
    min-height: 360px;
  }

  .card-media {
    aspect-ratio: auto;
    min-height: 100%;
  }

  .card-body,
  .today-body {
    padding: 1.3rem 1.4rem 1.4rem;
    justify-content: center;
  }

  .today-thumb {
    width: 80px;
    height: 80px;
  }
}

/* ——— lesson player ——— */

.lesson-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 19;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  margin: 0 0 0.85rem;
  padding: 0.2rem 0 0.5rem;
  background: color-mix(in srgb, var(--cream) 92%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 2px solid var(--line);
}

.btn-practice {
  margin-left: auto;
  min-height: 40px;
  padding: 0.3rem 0.9rem;
  font-size: 0.88rem;
  background: var(--lime);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
  min-height: 44px;
  padding: 0 0.4rem;
  border-radius: 10px;
}

.back-link:hover {
  background: color-mix(in srgb, var(--lime) 40%, transparent);
}

.lesson-bar-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.lesson-bar-title strong {
  font-size: 1.05rem;
}

.lesson-bar-title span {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.lesson-source {
  display: inline-flex;
  align-self: flex-start;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--leaf);
  background: color-mix(in srgb, var(--lime) 42%, var(--paper));
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 0.08rem 0.5rem;
  margin-bottom: 0.12rem;
}

.notice {
  background: color-mix(in srgb, var(--terracotta) 16%, var(--paper));
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.95rem;
  margin-bottom: 0.95rem;
  font-size: 0.92rem;
  font-weight: 600;
}

.notice.is-caution {
  background: color-mix(in srgb, var(--terracotta) 16%, var(--paper));
  color: var(--ink);
}

.story-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.65rem;
  margin: 0 0 0.75rem;
}

.story-nav .btn {
  min-height: 42px;
  padding: 0.4rem 0.95rem;
  font-size: 0.92rem;
}

.story-nav #nextStoryBtn,
.story-nav-end #nextStoryBtnEnd {
  margin-left: auto;
}

.story-nav-hint {
  margin: -0.35rem 0 0.85rem;
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--muted);
}

.story-nav-end {
  margin: 0;
  padding: 0.75rem 0.8rem 0.95rem;
  border-top: 2px solid var(--line);
  background: color-mix(in srgb, var(--cream) 55%, var(--paper));
}

.story-nav-end .story-nav-hint {
  flex: 1 0 100%;
  margin: 0.15rem 0 0;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  background: var(--paper);
}

.btn:disabled:hover,
.btn[aria-disabled="true"]:hover {
  background: var(--paper);
  box-shadow: none;
  transform: none;
}

.lesson-layout {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.lesson-layout audio {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.media-frame {
  display: none;
  background: #111;
  line-height: 0;
}

.lesson-layout.is-audio .media-frame,
.lesson-layout.is-audio #lessonVideo {
  display: none !important;
  width: 0;
  height: 0;
}

.lesson-layout.is-video .media-player {
  width: min(100%, calc(min(46vh, 520px) * 16 / 9));
  margin-inline: auto;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  box-shadow: 6px 6px 0 var(--ink);
  overflow: hidden;
}

.lesson-layout.is-video .media-frame {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-inline: auto;
  background: #111;
  overflow: hidden;
}

.lesson-layout.is-video #lessonVideo {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: cover;
  background: transparent;
  vertical-align: middle;
}

.lesson-layout.is-video .audio-player {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

.lesson-layout.is-video .audio-player .controls {
  border-top: 2px solid var(--line);
  border-radius: 0;
  background: color-mix(in srgb, var(--cream) 50%, var(--paper));
}

.audio-player {
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  box-shadow: 6px 6px 0 var(--ink);
  overflow: visible;
}

.audio-player .controls {
  border-top: 0;
  border-radius: 16px;
  background: color-mix(in srgb, var(--cream) 50%, var(--paper));
  padding: 0.35rem 0.5rem 0.4rem;
}

.now-playing {
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  box-shadow: 6px 6px 0 var(--ink);
  padding: 0.85rem 1rem 1rem;
}

.now-playing-kicker {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--leaf);
  line-height: 1.3;
}

.now-playing-off-hint,
.now-playing-empty {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--muted);
}

.now-playing-body .sent-en {
  margin: 0;
  font-size: var(--script-size-en);
  font-weight: 750;
  line-height: 1.55;
  letter-spacing: -0.01em;
}

.now-playing-body .sent-zh {
  margin: 0.25rem 0 0;
  font-size: var(--script-size-zh);
  color: var(--ink-soft);
  font-weight: 600;
  line-height: 1.5;
}

.now-playing[data-mode="en"] .sent-zh,
.now-playing[data-mode="off"] .now-playing-body,
#nowPlayingBody[hidden] {
  display: none;
}

.now-playing[data-size="sm"] {
  --script-size-en: 1.05rem;
  --script-size-zh: 0.9rem;
}
.now-playing[data-size="md"] {
  --script-size-en: 1.2rem;
  --script-size-zh: 1rem;
}
.now-playing[data-size="lg"] {
  --script-size-en: 1.35rem;
  --script-size-zh: 1.1rem;
}
.now-playing[data-size="xl"] {
  --script-size-en: 1.55rem;
  --script-size-zh: 1.22rem;
}

.script-kicker {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--leaf);
  line-height: 1.3;
  flex: 1 0 100%;
}

/* controls */

.controls {
  display: flex;
  align-items: center;
  gap: 0.25rem 0.35rem;
  flex-wrap: wrap;
  padding: 0.4rem 0.55rem 0.5rem;
  background: color-mix(in srgb, var(--cream) 72%, var(--paper));
  color: var(--ink);
  border-top: 2px solid var(--line);
}

#playBtn {
  background: var(--lime);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  margin-right: 0.15rem;
  width: 48px;
  height: 48px;
  border-radius: 14px;
}

.ctrl-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  padding: 0;
  flex: none;
}

.ctrl-btn svg {
  grid-area: 1 / 1;
}

#playBtn .ico-pause,
#muteBtn .ico-mute,
#fsBtn .ico-fs-exit {
  display: none;
}

#playBtn.is-playing .ico-play,
#muteBtn.is-muted .ico-vol,
#fsBtn.is-exit .ico-fs {
  display: none;
}

#playBtn.is-playing .ico-pause,
#muteBtn.is-muted .ico-mute,
#fsBtn.is-exit .ico-fs-exit {
  display: block;
}

.ctrl-btn:hover,
.ctrl-btn[aria-expanded="true"] {
  background: color-mix(in srgb, var(--lime) 22%, transparent);
}

.ctrl-text {
  width: auto;
  min-width: 44px;
  padding: 0 0.55rem;
  font-weight: 800;
  font-size: 0.88rem;
}

.time-readout {
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 0 0.2rem;
  white-space: nowrap;
}

.time-sep {
  opacity: 0.55;
  padding: 0 0.15rem;
}

.progress-wrap {
  flex: 1 1 140px;
  min-width: 100px;
}

.progress {
  position: relative;
  height: 44px;
  display: flex;
  align-items: center;
}

.progress::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 8px;
  background: color-mix(in srgb, var(--ink) 16%, transparent);
  border-radius: 99px;
  pointer-events: none;
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 8px;
  width: var(--p, 0%);
  background: var(--lime);
  border-radius: 99px;
  pointer-events: none;
  z-index: 1;
}

.progress input[type="range"] {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 44px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.progress input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  background: transparent;
  border-radius: 99px;
}

.progress input[type="range"]::-moz-range-track {
  height: 8px;
  background: transparent;
  border-radius: 99px;
}

.progress input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -5px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 1px 0 var(--ink);
}

.progress input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 50%;
}

.menu-wrap,
.volume-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.volume-slider {
  width: 0;
  opacity: 0;
  pointer-events: none;
  transition: width 0.16s ease, opacity 0.16s ease;
  appearance: none;
  background: transparent;
  height: 44px;
}

.volume-wrap:hover .volume-slider,
.volume-wrap:focus-within .volume-slider,
.volume-wrap.is-open .volume-slider {
  width: 84px;
  opacity: 1;
  pointer-events: auto;
  margin-inline-end: 0.25rem;
}

.volume-slider::-webkit-slider-runnable-track {
  height: 6px;
  background: color-mix(in srgb, var(--ink) 18%, transparent);
  border-radius: 99px;
}

.volume-slider::-moz-range-track {
  height: 6px;
  background: color-mix(in srgb, var(--ink) 18%, transparent);
  border-radius: 99px;
}

.volume-slider::-webkit-slider-thumb {
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -4px;
  background: var(--lime);
  border: 2px solid var(--ink);
  border-radius: 50%;
}

.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--lime);
  border: 2px solid var(--ink);
  border-radius: 50%;
}

/* Volume must not be hover-only on phones */
@media (max-width: 720px) {
  .audio-bar.controls {
    display: grid;
    grid-template-columns: auto auto auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "play prev next time speed fs"
      "progress progress progress progress vol vol";
    align-items: center;
    column-gap: 0.1rem;
    row-gap: 0;
    padding: 0.3rem 0.45rem 0.35rem;
  }

  .audio-bar #playBtn { grid-area: play; }
  .audio-bar #prevBtn { grid-area: prev; }
  .audio-bar #nextBtn { grid-area: next; }
  .audio-bar .time-readout { grid-area: time; }
  .audio-bar #speedWrap { grid-area: speed; }
  .audio-bar #fsBtn { grid-area: fs; justify-self: end; }
  .audio-bar .progress-wrap {
    grid-area: progress;
    flex: none;
    min-width: 0;
    width: 100%;
  }
  .audio-bar .volume-wrap {
    grid-area: vol;
    width: auto;
    justify-self: end;
  }

  .volume-slider,
  .volume-wrap .volume-slider {
    width: 72px;
    opacity: 1;
    pointer-events: auto;
    margin-inline-end: 0.15rem;
  }
}

.menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.4rem);
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 14px;
  min-width: 8.5rem;
  padding: 0.45rem;
  box-shadow: 4px 4px 0 var(--ink);
  z-index: 8;
}

.menu-label {
  margin: 0.15rem 0.4rem 0.35rem;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--muted);
}

.menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 750;
  padding: 0.5rem 0.65rem;
  min-height: 40px;
  border-radius: 9px;
  cursor: pointer;
  color: inherit;
}

.menu button:hover,
.menu button[aria-checked="true"] {
  background: var(--lime);
}

/* script / sentences */

.script-col {
  background: var(--paper);
  border: 2.5px solid var(--ink);
  border-radius: 22px;
  min-height: 16rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.script-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.7rem;
  align-items: center;
  padding: 0.7rem 0.8rem;
  border-bottom: 2px solid var(--line);
  background: color-mix(in srgb, var(--cream) 55%, var(--paper));
}

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  border: 2px solid var(--ink);
  border-radius: 12px;
  overflow: hidden;
  background: var(--paper);
}

.seg-btn {
  appearance: none;
  border: 0;
  border-right: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-weight: 750;
  font-size: 0.8rem;
  padding: 0.4rem 0.65rem;
  min-height: 38px;
}

.seg-btn:last-child {
  border-right: 0;
}

.seg-btn.is-on {
  background: var(--lime);
}

.script-list {
  overflow: auto;
  padding: 0.5rem 0.45rem calc(1.4rem + env(safe-area-inset-bottom, 0px));
  flex: 1;
  max-height: calc(100vh - var(--header-h) - var(--lesson-bar-h) - 20rem - env(safe-area-inset-bottom, 0px));
  min-height: 14rem;
  overscroll-behavior: contain;
  scroll-padding-top: 0.8rem;
  scroll-padding-bottom: 1.2rem;
}

.sentence {
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 0.7rem 0.75rem 0.75rem;
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.65rem;
  cursor: pointer;
  scroll-margin-top: 0.8rem;
  scroll-margin-bottom: 1.2rem;
}

.sentence:hover {
  background: color-mix(in srgb, var(--cream) 70%, var(--paper));
}

.sentence.is-current {
  background: color-mix(in srgb, var(--lime) 38%, var(--paper));
  border-color: var(--ink);
}

.sent-num {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.78rem;
  padding-top: 0.35rem;
}

.sentence.is-current .sent-num {
  color: var(--leaf);
}

.sent-body {
  min-width: 0;
}

.sent-en {
  margin: 0;
  font-size: var(--script-size-en);
  font-weight: 750;
  line-height: 1.55;
  letter-spacing: -0.01em;
}

.sent-zh {
  margin: 0.2rem 0 0;
  font-size: var(--script-size-zh);
  color: var(--ink-soft);
  font-weight: 600;
  line-height: 1.5;
}

.script-col[data-mode="en"] .sent-zh,
.script-col[data-mode="off"] .sent-en,
.script-col[data-mode="off"] .sent-zh {
  display: none;
}

.caption-off-hint {
  margin: 0;
  padding: 0.55rem 0.85rem 0.15rem;
  font-size: 0.85rem;
  font-weight: 650;
  color: var(--muted);
}

.script-col[data-size="sm"] {
  --script-size-en: 0.98rem;
  --script-size-zh: 0.85rem;
}
.script-col[data-size="md"] {
  --script-size-en: 1.125rem;
  --script-size-zh: 0.95rem;
}
.script-col[data-size="lg"] {
  --script-size-en: 1.35rem;
  --script-size-zh: 1.08rem;
}
.script-col[data-size="xl"] {
  --script-size-en: 1.58rem;
  --script-size-zh: 1.2rem;
}

.sent-actions {
  grid-column: 2;
  display: none;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.sentence:hover .sent-actions,
.sentence:focus-within .sent-actions {
  display: flex;
}

.sent-action {
  appearance: none;
  border: 2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-weight: 750;
  font-size: 0.8rem;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  min-height: 40px;
}

.sent-action:hover,
.sent-action.primary,
.sent-action.is-on {
  background: var(--lime);
}

/* clickable words */

.w {
  display: inline;
  margin: 0;
  padding: 0 0.08em;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  cursor: pointer;
  border-radius: 0.28em;
  line-height: inherit;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.w.has-def {
  box-shadow: inset 0 -0.22em 0 color-mix(in srgb, var(--lime) 85%, transparent);
}

.w:hover,
.w:focus-visible {
  background: var(--lime);
  color: var(--ink);
}

.w.is-spoken {
  background: var(--lime);
  color: var(--ink);
}

.punct {
  white-space: pre-wrap;
}

/* transcript fills the space under the compact player */

@media (min-width: 960px) {
  .view-lesson {
    padding-top: 0.65rem;
  }

  .script-list {
    max-height: calc(100vh - var(--header-h) - var(--lesson-bar-h) - 18rem - env(safe-area-inset-bottom, 0px));
    min-height: 20rem;
  }
}

@media (max-width: 959px) {
  .view-lesson {
    padding-inline: 0.7rem;
  }
}

@media (max-width: 520px) {
  .today-thumb,
  .archive-thumb {
    width: 64px;
    height: 64px;
    border-radius: 14px;
  }

  .story-nav .btn {
    flex: 1 1 auto;
    padding: 0.4rem 0.7rem;
    font-size: 0.86rem;
  }

  .story-nav #nextStoryBtn,
  .story-nav-end #nextStoryBtnEnd {
    margin-left: 0;
  }

  .now-playing {
    padding: 0.75rem 0.8rem 0.85rem;
  }
}

/* fullscreen listening workspace: compact player + highlighted transcript */

.lesson-layout:fullscreen,
.lesson-layout:-webkit-full-screen,
.lesson-layout.is-fullscreen {
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--cream);
  padding: 1.15rem 1.25rem 0;
  box-sizing: border-box;
}

.lesson-layout:fullscreen .audio-player,
.lesson-layout:-webkit-full-screen .audio-player,
.lesson-layout.is-fullscreen .audio-player,
.lesson-layout:fullscreen .now-playing,
.lesson-layout:-webkit-full-screen .now-playing,
.lesson-layout.is-fullscreen .now-playing,
.lesson-layout:fullscreen .media-player,
.lesson-layout:-webkit-full-screen .media-player,
.lesson-layout.is-fullscreen .media-player {
  flex: none;
  box-shadow: 4px 4px 0 var(--ink);
}

.lesson-layout.is-video:fullscreen .media-player,
.lesson-layout.is-video:-webkit-full-screen .media-player,
.lesson-layout.is-video.is-fullscreen .media-player {
  width: min(100%, calc(min(70vh, 100%) * 16 / 9));
  max-width: 100%;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 42%;
}

.lesson-layout.is-video:fullscreen .media-frame,
.lesson-layout.is-video:-webkit-full-screen .media-frame,
.lesson-layout.is-video.is-fullscreen .media-frame {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  aspect-ratio: auto;
  container-type: size;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
}

.lesson-layout.is-video:fullscreen #lessonVideo,
.lesson-layout.is-video:-webkit-full-screen #lessonVideo,
.lesson-layout.is-video.is-fullscreen #lessonVideo {
  position: static;
  inset: auto;
  width: min(100%, calc(100cqh * 16 / 9));
  height: min(100%, calc(100cqw * 9 / 16));
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: transparent;
}

.lesson-layout:fullscreen .story-nav,
.lesson-layout:-webkit-full-screen .story-nav,
.lesson-layout.is-fullscreen .story-nav {
  flex: none;
}

.lesson-layout:fullscreen .script-col,
.lesson-layout:-webkit-full-screen .script-col,
.lesson-layout.is-fullscreen .script-col {
  flex: 1;
  min-height: 0;
  margin-bottom: 0.85rem;
  box-shadow: 4px 4px 0 var(--ink);
}

.lesson-layout:fullscreen .script-list,
.lesson-layout:-webkit-full-screen .script-list,
.lesson-layout.is-fullscreen .script-list {
  flex: 1;
  max-height: none;
  min-height: 0;
}

.lesson-layout:fullscreen .sentence.is-current,
.lesson-layout:-webkit-full-screen .sentence.is-current,
.lesson-layout.is-fullscreen .sentence.is-current {
  box-shadow: 0 0 0 2px var(--ink);
}

.lesson-layout:fullscreen .controls,
.lesson-layout:-webkit-full-screen .controls,
.lesson-layout.is-fullscreen .controls {
  padding: 0.55rem 0.8rem calc(0.7rem + env(safe-area-inset-bottom, 0px));
}

.lesson-layout:fullscreen .time-readout,
.lesson-layout:-webkit-full-screen .time-readout,
.lesson-layout.is-fullscreen .time-readout,
.lesson-layout:fullscreen .ctrl-text,
.lesson-layout:-webkit-full-screen .ctrl-text,
.lesson-layout.is-fullscreen .ctrl-text {
  font-size: 1rem;
}

/* ——— dialogs ——— */

.dialog {
  border: 2.5px solid var(--ink);
  border-radius: 22px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 0;
  width: min(28rem, calc(100vw - 1.5rem));
}

.dialog::backdrop {
  background: color-mix(in srgb, var(--ink) 45%, transparent);
}

.dialog-head,
.drawer-head {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 0.45rem 0.5rem 0;
}

.drawer-head {
  justify-content: space-between;
  padding: 0.85rem 1rem 0.5rem 1.15rem;
  border-bottom: 2px solid var(--line);
}

.drawer-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.icon-x {
  appearance: none;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  border-radius: 12px;
  color: var(--ink);
}

.icon-x:hover {
  background: var(--cream);
}

.word-card-body {
  padding: 0 1.25rem 1.4rem;
}

.word-headword {
  margin: 0;
  font-size: 2rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.word-meta {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
  font-weight: 700;
}

.word-ipa {
  font-weight: 650;
  color: var(--leaf);
}

.word-zh {
  margin: 0.7rem 0 0;
  font-size: 1.25rem;
  font-weight: 800;
}

.word-note {
  margin: 0.35rem 0 0;
  color: var(--ink-soft);
}

.word-fallback {
  margin: 0.7rem 0 0;
  color: var(--ink-soft);
  font-weight: 600;
}

.orig {
  margin-top: 1rem;
  padding: 0.8rem 0.9rem;
  background: var(--cream);
  border-radius: 14px;
  border: 1.5px solid var(--line);
}

.orig-label {
  margin: 0 0 0.3rem;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.orig p {
  margin: 0;
}

.orig .en {
  font-weight: 750;
}

.orig .zh {
  margin-top: 0.2rem;
  color: var(--ink-soft);
}

.word-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.drawer {
  height: min(100%, 100dvh);
  margin: 0;
  max-height: unset;
}

.drawer[open] {
  display: flex;
  flex-direction: column;
}

@supports (width: 1px) {
  .drawer {
    margin-inline-start: auto;
    margin-block: 0;
    width: min(420px, 100vw);
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border-right: 0;
    border-top: 0;
    border-bottom: 0;
  }
}

.drawer-body {
  overflow: auto;
  padding: 0.6rem 0.8rem 1.5rem;
  flex: 1;
}

.wb-empty {
  padding: 1.4rem 0.6rem;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 600;
}

.wb-item {
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 0.85rem 0.9rem;
  margin: 0 0 0.65rem;
  background: var(--paper);
}

.wb-item h3 {
  margin: 0;
  font-size: 1.2rem;
}

.wb-item .meta {
  margin: 0.15rem 0 0;
  color: var(--leaf);
  font-weight: 700;
  font-size: 0.9rem;
}

.wb-item .ex {
  margin: 0.45rem 0 0;
  font-size: 0.92rem;
}

.wb-item .ex .zh {
  color: var(--muted);
}

.wb-item .row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
}

.btn-remove {
  flex: none;
  box-shadow: none;
  min-height: 40px;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

@media (max-width: 640px) {
  .drawer {
    margin: auto 0 0;
    width: 100vw;
    height: auto;
    max-height: 86vh;
    border-radius: 22px 22px 0 0;
    border: 2.5px solid var(--ink);
  }
}



/* ——— practice / badge / toast ——— */

.practice-dialog,
.badge-dialog {
  width: min(36rem, calc(100vw - 1.5rem));
  padding-bottom: 1.15rem;
}

.practice-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 0.7rem 0.35rem 1.2rem;
}

.practice-head h2,
.badge-body h2 {
  margin: 0;
  font-size: 1.25rem;
}

.practice-body,
.badge-body {
  padding: 0.4rem 1.2rem 0.4rem;
}

.practice-lead {
  margin: 0 0 1rem;
  font-weight: 650;
  color: var(--ink-soft);
}

.practice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.practice-progress {
  display: flex;
  gap: 0.4rem;
  margin: 0 0 0.85rem;
}

.practice-dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--paper);
}

.practice-dot.is-done {
  background: var(--lime);
}

.practice-dot.is-now {
  background: var(--lime-hot);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--lime) 45%, transparent);
}

.practice-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--leaf);
  text-transform: uppercase;
}

.practice-prompt {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  font-weight: 750;
  line-height: 1.55;
}

.practice-prompt .blank {
  display: inline-block;
  min-width: 4.5em;
  padding: 0 0.15em;
  border-bottom: 3px solid var(--ink);
  color: var(--leaf);
  font-weight: 800;
}

.practice-zh {
  margin: -0.35rem 0 0.9rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.choice {
  appearance: none;
  font-family: inherit;
  font-weight: 750;
  font-size: 1rem;
  min-height: 52px;
  padding: 0.55rem 0.7rem;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 3px 3px 0 color-mix(in srgb, var(--ink) 80%, transparent);
}

.choice:hover:not(:disabled) {
  background: color-mix(in srgb, var(--lime) 35%, var(--paper));
}

.choice.is-right {
  background: var(--lime);
}

.choice.is-wrong {
  border-color: var(--terracotta);
  background: color-mix(in srgb, var(--terracotta) 12%, var(--paper));
  animation: choice-shake 0.4s ease;
}

.choice:disabled {
  cursor: default;
}

@keyframes choice-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.listen-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.95rem;
}

.btn-listen {
  background: var(--lime);
  min-width: 8.5rem;
}

.practice-feedback {
  margin: 0.9rem 0 0;
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  border: 2px solid var(--ink);
  background: color-mix(in srgb, var(--lime) 28%, var(--paper));
  font-weight: 650;
}

.practice-feedback.is-try {
  background: color-mix(in srgb, var(--cream) 70%, var(--paper));
}

.badge-body {
  text-align: center;
  padding-bottom: 0.6rem;
}

.badge-medal {
  width: 7.2rem;
  height: 7.2rem;
  margin: 0.2rem auto 0.7rem;
  display: grid;
  place-items: center;
  background: var(--lime);
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: 6px 6px 0 var(--ink);
  font-size: 2.4rem;
  font-weight: 800;
  animation: badge-pop 0.7s ease;
}

@keyframes badge-pop {
  0% { transform: scale(0.6) rotate(-8deg); opacity: 0; }
  60% { transform: scale(1.08) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}

.badge-body h2 {
  font-size: 1.55rem;
}

.badge-sub,
.badge-streak {
  margin: 0.35rem 0 0;
  font-weight: 650;
  color: var(--ink-soft);
}

.badge-streak {
  margin-top: 0.7rem;
  color: var(--leaf);
  font-weight: 800;
  font-size: 1.05rem;
}

.badge-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.15rem;
}

.save-toast {
  position: fixed;
  top: calc(var(--header-h) + 0.65rem);
  right: 1rem;
  z-index: 80;
  background: var(--lime);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  font-weight: 750;
  box-shadow: 5px 5px 0 var(--ink);
  opacity: 0;
  pointer-events: none;
  max-width: min(22rem, calc(100vw - 2rem));
}

.save-toast.is-in {
  animation: toast-pop 2.4s ease forwards;
}

@keyframes toast-pop {
  0% { opacity: 0; transform: translateY(10px) scale(0.92); }
  12% { opacity: 1; transform: translateY(0) scale(1); }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-8px) scale(0.98); }
}

.load-error {
  position: fixed;
  inset: auto 1rem 1rem;
  background: var(--paper);
  border: 2px solid var(--terracotta);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
  z-index: 50;
  max-width: 28rem;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

body.is-error .load-error {
  display: block;
}

[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .btn,
  .volume-slider,
  .choice,
  .badge-medal,
  .save-toast,
  .count-pill {
    transition: none;
    animation: none;
  }

  .save-toast.is-in {
    opacity: 1;
    animation: none;
  }
}



/* page shell keeps a short login view from leaving a gap above the footer */
.page {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.page main {
  flex: 1 0 auto;
}

.site-footer {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0.7rem var(--pad) calc(1.25rem + env(safe-area-inset-bottom, 0px));
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.45;
  box-sizing: border-box;
}

.contact-wechat {
  margin: 0;
  user-select: text;
  -webkit-user-select: text;
  overflow-wrap: anywhere;
}

.auth-contact {
  margin: 1rem 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.45;
}

/* Login card already shows the WeChat id; skip the footer there to avoid a duplicate. */
body:has(#viewLogin:not([hidden])) .site-footer {
  display: none;
}

@media (max-width: 720px) {
  .site-footer,
  .auth-contact {
    font-size: 0.86rem;
  }
}

/* ——— auth + membership ——— */

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 0;
  flex: 0 1 auto;
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: nowrap;
  min-width: 0;
}

.account-meta {
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--muted);
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 720px) {
  :root {
    --header-h: 3.7rem;
  }

  .topbar-inner {
    gap: 0.45rem;
    padding: 0.35rem var(--pad);
  }

  .brand {
    gap: 0.45rem;
    flex: 0 1 auto;
  }

  .brand-mark {
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    box-shadow: 2px 2px 0 var(--ink);
  }

  .brand-zh {
    font-size: 1rem;
    white-space: nowrap;
  }

  .brand-en {
    display: none;
  }

  .channel-label-full {
    display: none;
  }

  .channel-label-short {
    display: inline;
  }

  .channel-switch .channel-link {
    padding: 0.22rem 0.5rem;
    min-height: 32px;
    font-size: 0.78rem;
  }

  .topbar-actions .btn {
    padding: 0.32rem 0.62rem;
    min-height: 40px;
    font-size: 0.86rem;
    white-space: nowrap;
  }

  .account-meta {
    max-width: 6.5rem;
  }
}

@media (max-width: 420px) {
  .brand-text {
    display: none;
  }
}

@media (max-width: 520px) {
  .account-meta {
    display: none;
  }

  .topbar-actions {
    gap: 0.3rem;
  }

  .account-chip {
    gap: 0.25rem;
  }

  .topbar-actions .btn {
    padding: 0.3rem 0.5rem;
    min-height: 38px;
  }
}

.auth-wrap,
.admin-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.4rem var(--pad) 3rem;
}

.admin-wrap {
  max-width: 920px;
}

.auth-card,
.admin-form {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 22px;
  box-shadow: 5px 5px 0 var(--ink);
  padding: 1.4rem 1.3rem 1.55rem;
}

.auth-card h1,
.admin-wrap h1 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.4rem, 3vw, 1.85rem);
}

.auth-lead,
.admin-lead {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.45;
}

.auth-card label,
.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.85rem;
  font-weight: 700;
}

.auth-card input,
.admin-form input[type="text"],
.admin-form input[type="password"],
.admin-form input[type="date"],
.admin-table input[type="date"] {
  font: inherit;
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  background: #fff;
  min-height: 44px;
}

.auth-error {
  margin: 0 0 0.8rem;
  color: #9a2a1f;
  font-weight: 700;
}

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.admin-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
}

.admin-table-wrap {
  margin-top: 1.4rem;
  overflow-x: auto;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 18px;
  box-shadow: 4px 4px 0 var(--ink);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.admin-table th {
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.admin-actions .btn {
  min-height: 38px;
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
}

@media (max-width: 720px) {
  .account-meta {
    max-width: 6.5rem;
  }
}
