/* Sections after the hero: one word moving through Shunkan, Self Talk and
   Stories, the Agent request becoming materials, and the Anki export. */
:lang(zh-Hant) {
  font-family: "PingFang TC", "Noto Sans TC", "Helvetica Neue", system-ui, sans-serif;
}
.chapter h2,
.exercise-prompt,
.bubble,
.agent-guide .inline-link {
  word-break: auto-phrase;
}
.use-kicker {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 18px;
  font-size: 13px;
  font-weight: 550;
  color: var(--muted);
}
.use-kicker b {
  font-size: 19px;
  font-weight: 680;
  letter-spacing: -0.035em;
  color: var(--ink);
}
.stash-note {
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  margin: 2px 0 0;
}
mark,
.talk-transcript em {
  white-space: nowrap;
}
mark {
  color: inherit;
  font-weight: 650;
  background: linear-gradient(transparent 56%, #dde9b4 56%);
}

/* ---------- My Stash: where the word lands first ---------- */
.uses-intro {
  background: var(--paper);
  padding: clamp(72px, 9vw, 136px) 0 clamp(64px, 8vw, 120px);
}
.intro-layout {
  display: grid;
  grid-template-columns: 1fr minmax(300px, 400px);
  gap: clamp(30px, 7vw, 108px);
  align-items: center;
}
.stash-card {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 18px;
  padding: 16px 22px 8px;
  box-shadow: 0 22px 44px -34px rgba(25, 41, 31, 0.45);
}
.stash-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.stash-head b {
  font-size: 14px;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.source-word {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}
.source-word .word-slot {
  flex: none;
  width: 52px;
  height: 94px;
  object-fit: contain;
}
.source-word small,
.source-word strong {
  display: block;
}
.source-word small {
  color: #536458;
  font-size: 11px;
}
.source-word strong {
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.045em;
}
.source-word > span {
  margin-left: auto;
  font-size: 13px;
  color: #536458;
}
.stash-rest {
  list-style: none;
  margin: 0;
  padding: 0;
}
.stash-rest li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0 10px 68px;
  border-bottom: 1px solid #e5e9e2;
  color: #637268;
  font-size: 12px;
}
.stash-rest b {
  font-size: 19px;
  font-weight: 550;
  letter-spacing: -0.03em;
}
.stash-card .inline-link {
  font-size: 13px;
}

/* ---------- Shared layout of the three uses ---------- */
.use {
  position: relative;
  padding: clamp(84px, 10.5vw, 156px) 0;
}
.use-layout,
.anki-layout {
  display: grid;
  grid-template-columns: 0.72fr 1.28fr;
  gap: clamp(30px, 6vw, 96px);
  align-items: center;
}
.use h2,
.anki-section h2 {
  font-size: clamp(36px, 4vw, 60px);
}
.use-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(130px, 0.55fr) 1fr;
  gap: clamp(20px, 3vw, 44px);
  align-items: center;
  min-width: 0;
  border-radius: 22px;
  padding: clamp(26px, 3.4vw, 50px);
}
.use-media {
  position: relative;
  display: grid;
  place-items: center;
  margin: 0;
}
.use-media::before {
  content: "";
  position: absolute;
  width: 92%;
  aspect-ratio: 1;
  border-radius: 50%;
}
.use-media .word-slot {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(170px, 18vw, 250px);
  object-fit: contain;
}
.use-body {
  min-width: 0;
}
/* Only one copy of the word is solid at a time; the others wait as a trace. */
.word-slot[data-slot="ghost"] {
  opacity: 0.13;
  filter: grayscale(1);
}

/* ---------- Shunkan ---------- */
.use-shunkan {
  background: var(--soil);
  color: #f2f6ef;
}
.use-shunkan .use-kicker {
  color: #c4d3c1;
}
.use-shunkan .use-kicker b {
  color: #f2f6ef;
}
.use-shunkan .use-card {
  background: #23382a;
  border: 1px solid #3a5141;
  padding-top: clamp(44px, 4.6vw, 68px);
}
.use-shunkan .use-media::before {
  background: radial-gradient(circle, rgba(222, 239, 181, 0.13), transparent 68%);
}
.use-shunkan :focus-visible {
  outline-color: #dbefad;
}
.drill-timer {
  position: absolute;
  top: clamp(20px, 2vw, 28px);
  left: clamp(26px, 3.4vw, 50px);
  right: clamp(26px, 3.4vw, 50px);
  height: 3px;
  border-radius: 3px;
  background: rgba(222, 239, 181, 0.16);
  overflow: hidden;
}
.drill-timer i {
  display: block;
  height: 100%;
  background: #deefb5;
  transform: scaleX(0);
  transform-origin: left;
}
.use-shunkan.is-timing .drill-timer i {
  animation: drill-timer 2.8s linear forwards;
}
.use-shunkan.is-answered .drill-timer i {
  transform: scaleX(1);
  background: #8ea980;
}
@keyframes drill-timer {
  to { transform: scaleX(1); }
}
.exercise-word {
  display: inline-block;
  margin: 0;
  padding: 2px 11px 4px;
  border: 1px solid #6c816f;
  border-radius: 16px;
  color: #e3efc7;
  font-size: 16px;
}
.exercise-prompt {
  /* A phrase longer than the column may still break, rather than widen the card. */
  overflow-wrap: anywhere;
  font-weight: 530;
  font-size: clamp(22px, 2.2vw, 34px);
  line-height: 1.45;
  letter-spacing: -0.035em;
  margin: 12px 0 18px;
  transition: color 0.3s;
}
.use-shunkan.is-answered .exercise-prompt {
  color: #b8c8b5;
}
.english-example {
  font-size: clamp(21px, 2.1vw, 31px);
  line-height: 1.35;
  letter-spacing: -0.025em;
  margin: -4px 0 18px;
  color: #eff5ec;
}
/* Keep the answer's room so the card does not grow when it appears. */
.english-example[hidden] {
  display: block !important;
  visibility: hidden;
}
.english-example em {
  display: inline-block;
  font-style: normal;
  font-weight: 650;
  color: #e0efa8;
  transform-origin: left center;
}
.use-shunkan .bench-button:hover {
  background: #344b39;
}

/* ---------- Self Talk ---------- */
.use-self {
  background: var(--field);
}
.use-self .use-card {
  background: var(--paper);
  border: 1px solid #d3dbcf;
  box-shadow: 0 28px 60px -44px rgba(25, 41, 31, 0.5);
}
.use-self .use-media::before {
  background: #e5ece0;
}
.use-self .exercise-prompt {
  margin-top: 0;
}
.talk-meter {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 16px;
}
.talk-ring {
  position: relative;
  flex: none;
  width: 58px;
  height: 58px;
}
.talk-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  fill: none;
  stroke-width: 3;
}
.talk-ring circle {
  stroke: #d5ddd2;
}
.talk-ring .ring-fill {
  stroke: var(--soil);
  stroke-linecap: round;
  stroke-dasharray: 157.08;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}
.mic-button {
  position: absolute;
  inset: 7px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--soil);
  color: #f2f6ef;
}
.mic-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.mic-button:hover {
  background: #344b39;
}
.use-self.is-speaking .mic-button {
  animation: mic-pulse 1.6s ease-out infinite;
}
@keyframes mic-pulse {
  from { box-shadow: 0 0 0 0 rgba(146, 55, 33, 0.38); }
  to { box-shadow: 0 0 0 12px rgba(146, 55, 33, 0); }
}
.talk-time {
  min-width: 3ch;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.talk-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 1;
  max-width: 150px;
  height: 30px;
}
.talk-wave i {
  flex: 1;
  max-width: 4px;
  height: 100%;
  border-radius: 2px;
  background: #6d8a63;
  transform: scaleY(0.16);
}
.use-self.is-speaking .talk-wave i {
  animation: wave 1.1s ease-in-out infinite;
}
.talk-wave i:nth-child(3n) { animation-duration: 0.9s !important; }
.talk-wave i:nth-child(3n + 1) { animation-duration: 1.3s !important; }
.talk-wave i:nth-child(2) { animation-delay: -0.2s; }
.talk-wave i:nth-child(3) { animation-delay: -0.5s; }
.talk-wave i:nth-child(4) { animation-delay: -0.8s; }
.talk-wave i:nth-child(5) { animation-delay: -0.3s; }
.talk-wave i:nth-child(6) { animation-delay: -0.6s; }
.talk-wave i:nth-child(7) { animation-delay: -0.1s; }
.talk-wave i:nth-child(8) { animation-delay: -0.9s; }
.talk-wave i:nth-child(9) { animation-delay: -0.4s; }
.talk-wave i:nth-child(10) { animation-delay: -0.7s; }
.talk-wave i:nth-child(11) { animation-delay: -0.25s; }
.talk-wave i:nth-child(12) { animation-delay: -0.55s; }
.talk-wave i:nth-child(13) { animation-delay: -0.85s; }
.talk-wave i:nth-child(14) { animation-delay: -0.15s; }
.talk-wave i:nth-child(15) { animation-delay: -0.45s; }
.talk-wave i:nth-child(16) { animation-delay: -0.75s; }
@keyframes wave {
  0%, 100% { transform: scaleY(0.16); }
  50% { transform: scaleY(0.95); }
}
.talk-transcript {
  min-height: 3em;
  margin: 0;
  font-size: clamp(19px, 1.75vw, 25px);
  line-height: 1.5;
  letter-spacing: -0.02em;
}
.talk-transcript em {
  font-style: normal;
  font-weight: 650;
  background: linear-gradient(transparent 58%, #dde9b4 58%);
}
.talk-transcript .caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.16em;
  background: var(--ink);
  animation: caret 1s steps(1) infinite;
}
@keyframes caret {
  50% { opacity: 0; }
}

/* ---------- Stories ---------- */
.use-story {
  background: var(--clay);
}
.story-page {
  grid-template-columns: minmax(170px, 0.8fr) 1fr;
  background: #fffdf8;
  border: 1px solid #e4dacb;
  box-shadow: 0 32px 70px -46px rgba(70, 45, 20, 0.5);
}
.story-art::before {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 18px;
  background: #f2e8d8;
}
.story-art .word-slot {
  height: clamp(230px, 24vw, 340px);
  padding: 18px 0;
}
.story-page h3 {
  margin: 0 0 12px;
  font-family: "Iowan Old Style", Georgia, "Hiragino Mincho ProN", serif;
  font-size: clamp(20px, 1.7vw, 26px);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.story-text {
  margin: 0;
  font-family: "Iowan Old Style", Georgia, "Hiragino Mincho ProN", serif;
  font-size: clamp(18px, 1.55vw, 23px);
  line-height: 1.75;
  color: #2d2a24;
}
.story-page h3:lang(zh-Hant),
.story-text:lang(zh-Hant) {
  font-family: "Songti TC", "Noto Serif TC", "PingFang TC", serif;
}
.story-text > span {
  display: inline;
  transition: color 0.3s, opacity 0.6s;
}
.story-text mark {
  font-weight: 650;
  background: linear-gradient(#ebdb93, #ebdb93) no-repeat 0 88% / 100% 38%;
}
.use-story.is-armed .story-text mark {
  background-size: 0% 38%;
  transition: background-size 0.9s 0.7s cubic-bezier(0.3, 0.7, 0.3, 1);
}
.use-story.is-armed:not(.is-live) .story-text > span {
  opacity: 0;
}
.use-story.is-armed .story-text > span + span {
  transition-delay: 0.25s;
}
.use-story.is-armed.is-live .story-text mark {
  background-size: 100% 38%;
}
.story-text.is-reading > span:not(.reading) {
  color: #aaa293;
}
.listen-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
}
#story-listen {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--soil);
  color: #fff;
}
#story-listen:hover {
  background: #344b39;
}
#story-listen svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}
#story-listen .icon-pause,
#story-listen[aria-pressed="true"] .icon-play {
  display: none;
}
#story-listen[aria-pressed="true"] .icon-pause {
  display: block;
}
.listen-track {
  flex: 1;
  height: 3px;
  border-radius: 3px;
  background: #e6ddcf;
  overflow: hidden;
}
.listen-track i {
  display: block;
  height: 100%;
  background: var(--soil);
  transform: scaleX(0);
  transform-origin: left;
}

/* ---------- AI Agent: one request becomes five materials ---------- */
.agent-section {
  background: var(--paper);
}
.agent-stage {
  padding: clamp(76px, 9vw, 132px) 0;
}
.agent-side h2 {
  font-size: clamp(34px, 3.6vw, 56px);
}
.agent-requests {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 22px 0 16px;
}
.agent-requests button {
  min-height: 44px;
  padding: 8px 15px;
  border: 1px solid #a9b9a9;
  border-radius: 22px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}
.agent-requests button:hover {
  background: #e4ebe0;
}
.agent-requests button[aria-pressed="true"] {
  background: var(--soil);
  border-color: var(--soil);
  color: #f2f6ef;
}
.chat {
  position: relative;
  padding: 12px 16px 18px;
  border-radius: 18px;
  background: var(--soil);
  color: #eef4ea;
}
.chat-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #34493a;
  font-size: 12px;
  color: #b9c8b6;
}
.chat-bar i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9fd27e;
}
.bubble {
  width: fit-content;
  max-width: 94%;
  margin: 0;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.65;
}
.bubble.you {
  min-height: 2.65em;
  margin-left: auto;
  border-bottom-right-radius: 4px;
  background: #e8efe3;
  color: var(--ink);
}
.bubble.agent {
  margin-top: 10px;
  border-bottom-left-radius: 4px;
  background: #2c4333;
}
.caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 1px;
  vertical-align: -0.18em;
  background: currentColor;
  animation: caret 1s steps(1) infinite;
}
.bubble.you[data-typed="done"] .caret {
  display: none;
}
#agent-reply[data-state="hidden"] {
  visibility: hidden;
}
.thinking {
  display: none;
  gap: 5px;
  padding: 6px 2px;
}
.thinking i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b9c8b6;
  animation: think 1s ease-in-out infinite;
}
.thinking i:nth-child(2) { animation-delay: 0.15s; }
.thinking i:nth-child(3) { animation-delay: 0.3s; }
@keyframes think {
  0%, 100% { opacity: 0.3; transform: none; }
  50% { opacity: 1; transform: translateY(-3px); }
}
#agent-reply[data-state="thinking"] .thinking {
  display: inline-flex;
}
#agent-reply[data-state="thinking"] .reply-text {
  display: none;
}
.done {
  opacity: var(--k, 1);
  transform: translateY(calc((1 - var(--k, 1)) * 8px));
}
.done b {
  color: #e0efa8;
}
.materials {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mat {
  position: relative;
  min-width: 0;
  padding: 14px 18px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: #fff;
}
.mat-label {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 8px;
  font-size: 11px;
  color: var(--muted);
}
.mat-label svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.mat-label b {
  font-size: 14px;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.mat-words,
.mat-lines {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mat-words {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.mat-words li {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 4px 10px 5px;
  border-radius: 9px;
  background: #f1f4ee;
  font-size: 11px;
  color: var(--muted);
}
.mat-words li:first-child {
  background: #e4edcb;
}
.mat-words b {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.mat-lines {
  display: grid;
  gap: 5px;
}
.mat-lines b,
.mat-shunkan b {
  display: block;
  font-size: 15px;
  font-weight: 560;
  letter-spacing: -0.01em;
}
.mat-lines span,
.mat-shunkan span {
  display: block;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}
.mat-shunkan span {
  font-size: 12px;
}
.mat-shunkan span::after {
  content: " →";
}
.mat-story strong {
  display: block;
  font-family: "Iowan Old Style", Georgia, serif;
  font-size: 14px;
}
.mat-story p {
  margin: 2px 0 0;
  font-family: "Iowan Old Style", Georgia, "Hiragino Mincho ProN", serif;
  font-size: 14px;
  line-height: 1.6;
  color: #3a3830;
}
.mat-story :lang(zh-Hant) {
  font-family: "Songti TC", "Noto Serif TC", serif;
}
.mat-talk {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  font-size: 14px;
}
.mat-talk small {
  flex-basis: 100%;
  font-size: 11px;
  color: var(--muted);
}
.mat-talk span {
  padding: 4px 11px 5px;
  border-radius: 12px 12px 12px 3px;
  background: #f1f4ee;
}
.mat-talk span + span {
  border-radius: 12px 12px 3px 12px;
  background: #e4edcb;
}
.materials.is-swapping .mat {
  animation: mat-swap 0.42s ease-out both;
}
.materials.is-swapping .mat:nth-child(2) { animation-delay: 0.04s; }
.materials.is-swapping .mat:nth-child(3) { animation-delay: 0.08s; }
.materials.is-swapping .mat:nth-child(4) { animation-delay: 0.12s; }
.materials.is-swapping .mat:nth-child(5) { animation-delay: 0.16s; }
@keyframes mat-swap {
  from { filter: blur(3px); opacity: 0.2; }
}
.agent-guide .inline-link {
  margin-top: 8px;
}
/* Narrow screens only: the agent's closing reply, in the same chat window. */
.chat-end {
  display: none;
}
.chat-end b {
  color: #e0efa8;
}
.agent-wires path {
  fill: none;
  stroke: #87a083;
  stroke-width: 1.6;
}
.agent-wires circle {
  fill: var(--paper);
  stroke: #4e6a4a;
  stroke-width: 2;
}

/* Wide and tall enough: the request and the materials share one frame. */
@media (min-width: 900px) and (min-height: 680px) {
  .agent-grid {
    position: relative;
    display: grid;
    grid-template-columns: minmax(300px, 0.78fr) 1.22fr;
    grid-template-areas: "side mats" "guide mats";
    grid-template-rows: auto 1fr;
    column-gap: clamp(72px, 8vw, 132px);
  }
  .agent-side { grid-area: side; }
  .agent-guide { grid-area: guide; align-self: end; padding-top: 14px; }
  .materials {
    grid-area: mats;
    align-self: center;
    display: grid;
    gap: 10px;
  }
  .mat {
    display: grid;
    grid-template-columns: 104px 1fr;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    isolation: isolate;
    border: 1px dashed #c0cbbd;
    background: transparent;
  }
  /* An empty dashed slot until the agent fills it. */
  .mat::after {
    content: "";
    position: absolute;
    inset: -1px;
    z-index: -1;
    border: 1px solid var(--rule);
    border-radius: inherit;
    background: #fff;
    box-shadow: 0 16px 30px -28px rgba(25, 41, 31, 0.55);
    opacity: var(--k, 1);
    transform: scale(calc(0.97 + var(--k, 1) * 0.03));
  }
  .mat > * {
    opacity: var(--k, 1);
    transform: translateX(calc((1 - var(--k, 1)) * -22px));
  }
  .mat-label {
    flex-wrap: wrap;
    gap: 2px 7px;
    margin: 0;
  }
  .mat-label b {
    font-size: 15px;
  }
  .agent-wires {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
  }
}
@media (min-width: 900px) and (min-height: 680px) and (prefers-reduced-motion: no-preference) {
  .agent-track {
    height: 290vh;
  }
  .agent-stage {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    height: 100vh;
    padding: 0;
  }
}
/* Narrow or short: the materials follow the request down the page. */
@media not all and (min-width: 900px) and (min-height: 680px) {
  .agent-wires,
  #agent-done {
    display: none;
  }
  .materials {
    position: relative;
    display: grid;
    gap: 14px;
    margin-top: 34px;
    padding-left: 30px;
  }
  .materials::before {
    content: "";
    position: absolute;
    left: 10px;
    top: -34px;
    width: 2px;
    height: 61px;
    background: #87a083;
    transform: scaleY(var(--first, 1));
    transform-origin: top;
  }
  .mat {
    opacity: var(--k, 1);
    transform: translateY(calc((1 - var(--k, 1)) * 26px));
  }
  .mat::before {
    content: "";
    position: absolute;
    left: -20px;
    top: 27px;
    width: 2px;
    height: calc(100% + 14px);
    background: #87a083;
    transform: scaleY(var(--link, 1));
    transform-origin: top;
  }
  /* The last link runs on into the closing chat below the list. */
  .mat:last-child::before {
    height: calc(100% - 27px + 22px);
  }
  .mat::after {
    content: "";
    position: absolute;
    left: -25px;
    top: 22px;
    width: 8px;
    height: 8px;
    border: 2px solid #4e6a4a;
    border-radius: 50%;
    background: var(--paper);
  }
  .chat-end {
    display: block;
    margin: 22px 0 8px;
    opacity: var(--k, 1);
    transform: translateY(calc((1 - var(--k, 1)) * 14px));
  }
  .chat-end .bubble.agent {
    margin-top: 0;
  }
  .agent-guide {
    margin-top: 0;
  }
}

/* ---------- Anki export ---------- */
.anki-section {
  overflow: clip;
  background: var(--field);
  padding: clamp(84px, 10.5vw, 156px) 0;
}
.anki-sub {
  margin: 16px 0 4px;
  font-size: 15px;
  color: var(--muted);
}
.anki-stage {
  --card-w: 286px;
  --card-h: 426px;
  --side-x: calc(var(--card-w) * 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}
.export-panel {
  position: relative;
  z-index: 4;
  width: min(100%, 384px);
  padding: 14px 18px 16px;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 22px 44px -34px rgba(25, 41, 31, 0.45);
}

/* Adding a word: one field with its action inside, examples underneath. */
.add-form {
  position: relative;
  margin-top: 10px;
}
.add-field {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 4px 14px;
  border: 1px solid #b9c5b8;
  border-radius: 14px;
  background: #f6f8f3;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.add-field:focus-within {
  border-color: #296947;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(41, 105, 71, 0.14);
}
.add-field input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.add-field input::placeholder {
  color: #6b7b6f;
  font-size: 14px;
}
.add-field input:focus {
  outline: none;
}
.add-submit {
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 11px;
  background: var(--soil);
  color: #f2f6ef;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}
.add-submit:hover {
  background: #2e4a37;
}
.add-submit:disabled {
  cursor: progress;
  background: #536458;
}
.add-submit:focus-visible {
  outline-offset: 2px;
}
.add-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 5;
  overflow: hidden;
  padding: 4px;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 18px 36px -18px rgba(25, 41, 31, 0.45);
}
.add-suggest button {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.add-suggest button:hover,
.add-suggest button:focus-visible {
  background: #eef3ea;
  outline: none;
}
.add-suggest b {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.add-suggest span {
  overflow: hidden;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.add-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 9px;
}
.add-chips > span {
  margin-right: 2px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.add-chips button {
  min-height: 32px;
  padding: 3px 11px;
  border: 1px solid #c9d3c6;
  border-radius: 16px;
  background: transparent;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 550;
  letter-spacing: -0.01em;
}
.add-chips button:hover {
  border-color: #899c8b;
  background: #f1f5ed;
}
.add-chips button:disabled {
  cursor: progress;
  opacity: 0.55;
}
.add-status:empty,
.add-status[data-kind="done"] {
  position: absolute;
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  overflow: hidden;
  white-space: nowrap;
}
.add-status {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}
.add-status[data-kind="working"]::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 7px;
  border: 1.5px solid #9fb09f;
  border-top-color: var(--soil);
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(1turn); }
}
.add-status[data-kind="error"] {
  color: #8a3b2e;
}
.add-status a {
  color: inherit;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.export-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  border-top: 1px solid #e5e9e2;
}
.export-list li {
  display: grid;
  grid-template-columns: 24px minmax(0, auto) minmax(0, 1fr) 20px;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid #e5e9e2;
}
.export-list img {
  width: 24px;
  height: 32px;
  object-fit: contain;
}
.export-list img[hidden] {
  display: block !important;
  visibility: hidden;
}
.export-list b,
.export-list span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.export-list b {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.export-list span {
  font-size: 12px;
  color: var(--muted);
}
.tick {
  position: relative;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--soil);
  border-radius: 6px;
  background: var(--soil);
}
.tick::after {
  content: "";
  position: absolute;
  left: 5.5px;
  top: 1.5px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.export-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  margin-top: 12px;
  border-radius: 20px;
  background: var(--soil);
  color: #f2f6ef;
  font-size: 13px;
  font-weight: 600;
}
.export-drop {
  position: relative;
  z-index: 3;
  width: 60px;
  height: 84px;
}
.drop-wire {
  position: absolute;
  left: 50%;
  top: 0;
  width: 4px;
  height: 100%;
  margin-left: -2px;
  overflow: visible;
  transform-origin: top;
}
.drop-wire path {
  fill: none;
  stroke: #7f957f;
  stroke-width: 2;
  stroke-dasharray: 4 5;
  vector-effect: non-scaling-stroke;
}
.apkg-file {
  position: absolute;
  left: 50%;
  top: -10px;
  width: 40px;
  margin-left: -20px;
  opacity: 0;
}
.apkg-file svg {
  display: block;
  width: 40px;
  height: 50px;
}
.apkg-file path {
  fill: var(--paper);
  stroke: var(--soil);
  stroke-width: 2;
  stroke-linejoin: round;
}
.apkg-file .fold {
  fill: none;
}
.apkg-file b {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 9px;
  text-align: center;
  font-size: 9px;
  font-weight: 750;
  color: var(--soil);
}
.anki-hand {
  position: relative;
  width: 100%;
  height: calc(var(--card-h) + 40px);
}
.anki-slot {
  position: absolute;
  left: 50%;
  top: 0;
  width: var(--card-w);
  perspective: 1400px;
  transform: translateX(calc(-50% + var(--x, 0px))) translateY(var(--y, 0px)) rotate(var(--r, 0deg));
}
.anki-slot[data-slot="left"] {
  --x: calc(var(--side-x) * -1);
  --y: 22px;
  --r: -8deg;
}
.anki-slot[data-slot="right"],
.anki-slot[data-slot="out"] {
  --x: var(--side-x);
  --y: 22px;
  --r: 8deg;
}
.anki-slot[data-slot="out"]:empty {
  display: none;
}
.anki-slot[data-slot="main"] {
  z-index: 2;
}
.anki-card {
  position: relative;
  width: 100%;
  height: var(--card-h);
  border-radius: 20px;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
#anki-card {
  cursor: pointer;
}
.anki-card.flipped {
  transform: rotateY(180deg);
}
.anki-face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 20px;
  background: #1c1c1e;
  color: #f5f5f7;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.3);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.anki-back {
  transform: rotateY(180deg);
}
.anki-img {
  position: relative;
  flex-shrink: 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: radial-gradient(circle at 50% 62%, #3a3a40, #151517 74%);
}
.anki-img img {
  display: block;
  width: 100%;
  height: 100%;
  padding: 10px;
  object-fit: contain;
}
.anki-front .anki-img img,
.anki-slot:not([data-slot="main"]) .anki-img img {
  filter: blur(9px);
  opacity: 0.6;
  transform: scale(1.06);
}
.anki-content {
  position: relative;
  padding: 14px 18px 18px;
  text-align: center;
}
.anki-mode-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}
.anki-headline {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.15;
  color: #0a84ff;
  word-break: break-word;
}
.anki-reading {
  margin-top: 4px;
  font-family: Menlo, monospace;
  font-size: 13px;
  color: #9b9ba1;
}
.anki-reading:lang(zh-Hant) {
  font-family: "PingFang TC", "Noto Sans TC", sans-serif;
}
.anki-meaning {
  margin-top: 12px;
  font-size: 18px;
  line-height: 1.45;
  font-weight: 700;
}
.anki-masked {
  filter: blur(8px);
  opacity: 0.5;
  user-select: none;
}
.anki-flip-hint {
  display: inline-block;
  min-height: 34px;
  margin-top: 18px;
  padding: 6px 18px;
  border: 0;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.07);
  color: #a5a5ab;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
}
.anki-flip-hint:hover {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
}
.anki-example {
  position: relative;
  margin-top: 12px;
  padding: 11px 13px 11px 40px;
  border-radius: 12px;
  background: #222224;
  text-align: left;
}
.anki-example p {
  margin: 0;
}
#anki-example {
  font-size: 13px;
  line-height: 1.5;
  color: #fff;
}
#anki-example b {
  color: #7dc1ff;
  font-weight: 800;
}
#anki-example-jp {
  margin-top: 3px;
  font-size: 11.5px;
  line-height: 1.45;
  color: #a1a1a6;
}
.anki-speaker {
  position: absolute;
  left: 12px;
  top: 12px;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: #7dc1ff;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.anki-speaker .cone {
  fill: #7dc1ff;
  stroke: none;
}
.anki-card.flipped .anki-speaker .w1 {
  animation: speaker 1.4s ease-in-out infinite;
}
.anki-card.flipped .anki-speaker .w2 {
  animation: speaker 1.4s 0.25s ease-in-out infinite;
}
@keyframes speaker {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}
.anki-flip-back {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  color: #b6b6bc;
  font-size: 15px;
}
.anki-flip-back:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.anki-section :focus-visible {
  outline-color: #296947;
}
.anki-face :focus-visible {
  outline-color: #7dc1ff;
}

/* The export plays once each time the stage comes into view. */
.anki-stage.is-armed .tick {
  background: transparent;
  border-color: #a9b5a9;
}
.anki-stage.is-armed .tick::after {
  transform: rotate(45deg) scale(0);
}
.anki-stage.is-armed .drop-wire {
  transform: scaleY(0);
}
.anki-stage.is-armed .anki-slot {
  opacity: 0;
}
.anki-stage.is-playing .tick {
  animation: tick-box 0.28s var(--d) both;
}
.anki-stage.is-playing .tick::after {
  animation: tick-mark 0.28s var(--d) both;
}
.export-list li:nth-child(1) .tick, .export-list li:nth-child(1) .tick::after { --d: 0.25s; }
.export-list li:nth-child(2) .tick, .export-list li:nth-child(2) .tick::after { --d: 0.5s; }
.export-list li:nth-child(3) .tick, .export-list li:nth-child(3) .tick::after { --d: 0.75s; }
@keyframes tick-box {
  from { background: transparent; border-color: #a9b5a9; }
  to { background: var(--soil); border-color: var(--soil); }
}
@keyframes tick-mark {
  from { transform: rotate(45deg) scale(0); }
  to { transform: rotate(45deg) scale(1); }
}
.anki-stage.is-playing .export-button {
  animation: press 0.4s 1.05s both;
}
@keyframes press {
  50% { transform: scale(0.95); background: #3d6247; }
}
.anki-stage.is-playing .drop-wire {
  animation: wire-grow 0.6s 1.25s ease-out both;
}
@keyframes wire-grow {
  from { transform: scaleY(0); }
  to { transform: scaleY(1); }
}
.anki-stage.is-playing .apkg-file {
  animation: file-drop 0.95s 1.3s cubic-bezier(0.45, 0, 0.55, 1) both;
}
@keyframes file-drop {
  0% { opacity: 0; transform: translateY(-6px) scale(0.6); }
  18% { opacity: 1; transform: translateY(0) scale(1); }
  82% { opacity: 1; transform: translateY(70px) scale(1); }
  100% { opacity: 0; transform: translateY(92px) scale(0.5); }
}
.anki-stage.is-playing .anki-slot {
  animation: anki-deal 0.72s var(--deal) cubic-bezier(0.22, 1, 0.36, 1) both;
}
.anki-slot[data-slot="left"] { --deal: 2.15s; }
.anki-slot[data-slot="right"] { --deal: 2.3s; }
.anki-slot[data-slot="main"] { --deal: 2.45s; }
/* A card added from the field: the row drops in and is ticked, the .apkg
   falls, the old front card slides left, the left one moves right, the
   right one is pushed off, and the new card is dealt on top. */
.export-list li.is-new {
  animation: row-in 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.export-list li.is-leaving {
  animation: row-out 0.35s ease-in both;
}
@keyframes row-in {
  from { max-height: 0; padding-block: 0; opacity: 0; transform: translateY(-6px); }
  to { max-height: 52px; }
}
@keyframes row-out {
  to { max-height: 0; padding-block: 0; border-bottom-width: 0; opacity: 0; }
}
.export-list li.is-new,
.export-list li.is-leaving {
  overflow: hidden;
}
.anki-stage.is-adding li.is-new .tick {
  animation: tick-box 0.28s 0.4s both;
}
.anki-stage.is-adding li.is-new .tick::after {
  animation: tick-mark 0.28s 0.4s both;
}
.anki-stage.is-adding .export-button {
  animation: press 0.4s 0.75s both;
}
.anki-stage.is-adding .apkg-file {
  animation: file-drop 0.95s 0.95s cubic-bezier(0.45, 0, 0.55, 1) both;
}
.anki-stage.is-adding .anki-slot[data-slot="main"] {
  animation: anki-deal 0.72s 1.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.anki-stage.is-adding .anki-slot[data-slot="left"] {
  --fx: 0px;
  --fy: 0px;
  --fr: 0deg;
  z-index: 1;
  animation: anki-shift 0.6s 1.65s cubic-bezier(0.3, 0.7, 0.2, 1) both;
}
.anki-stage.is-adding .anki-slot[data-slot="right"] {
  --fx: calc(var(--side-x) * -1);
  --fy: 22px;
  --fr: -8deg;
  animation: anki-shift 0.6s 1.7s cubic-bezier(0.3, 0.7, 0.2, 1) both;
}
.anki-stage.is-adding .anki-slot[data-slot="out"] {
  animation: anki-out 0.55s 0.05s ease-in both;
}
@keyframes anki-shift {
  from { transform: translateX(calc(-50% + var(--fx))) translateY(var(--fy)) rotate(var(--fr)); }
}
@keyframes anki-out {
  to {
    opacity: 0;
    transform: translateX(calc(-50% + var(--x) + 48px)) translateY(calc(var(--y) + 70px)) rotate(calc(var(--r) + 9deg));
  }
}
@keyframes anki-deal {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-120px) rotate(0deg) scale(0.3);
  }
  60% {
    opacity: 1;
  }
  to {
    opacity: 1;
    transform: translateX(calc(-50% + var(--x, 0px))) translateY(var(--y, 0px)) rotate(var(--r, 0deg));
  }
}

/* ---------- Narrow screens ---------- */
@media (max-width: 900px) {
  .use-layout,
  .anki-layout,
  .intro-layout {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .intro-layout .stash-card {
    max-width: 440px;
  }
}
@media (max-width: 640px) {
  .use {
    padding: 72px 0 80px;
  }
  /* The word sits beside the first lines; the rest of the card runs full width. */
  .use-card,
  .story-page {
    grid-template-columns: 1fr clamp(88px, 28vw, 124px);
    align-items: start;
    column-gap: 12px;
    row-gap: 0;
    padding: 22px 18px 24px 22px;
  }
  .use-shunkan .use-card {
    padding-top: 40px;
  }
  .use-body {
    display: contents;
  }
  .use-body > * {
    grid-column: 1 / -1;
  }
  .use-body > button {
    justify-self: start;
  }
  .use-media {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
  .use-shunkan .exercise-word {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
  }
  .use-shunkan .exercise-prompt {
    grid-column: 1;
    grid-row: 2;
    margin-bottom: 0;
  }
  .use-shunkan .english-example {
    margin-top: 16px;
  }
  .use-self .exercise-prompt,
  .story-page h3 {
    grid-column: 1;
    grid-row: 1 / span 2;
    align-self: center;
    margin: 0;
  }
  .use-self .talk-meter {
    margin-top: 16px;
  }
  .story-text {
    margin-top: 14px;
  }
  .exercise-prompt br {
    display: none;
  }
  .use-media .word-slot {
    height: clamp(130px, 38vw, 180px);
  }
  .story-art .word-slot {
    height: clamp(150px, 44vw, 210px);
    padding: 10px 0;
  }
  .drill-timer {
    left: 22px;
    right: 18px;
  }
  .exercise-prompt {
    font-size: clamp(20px, 5.6vw, 26px);
  }
  .english-example {
    font-size: clamp(19px, 5.4vw, 24px);
  }
  .talk-meter {
    gap: 10px;
  }
  .talk-wave {
    max-width: 92px;
  }
  .talk-transcript {
    font-size: 18px;
  }
  .story-text {
    font-size: 17px;
  }
  .anki-section {
    padding: 72px 0 84px;
  }
  .anki-stage {
    --card-w: min(236px, 62vw);
    --card-h: 404px;
    --side-x: calc(var(--card-w) * 0.34);
  }
  .anki-headline {
    font-size: 26px;
  }
  .anki-content {
    padding: 12px 14px 16px;
  }
  .anki-example {
    padding-left: 36px;
  }
  .anki-speaker {
    left: 10px;
  }
}
@media (max-width: 760px) {
  .source-word .word-slot {
    order: 1;
  }
  .stash-rest li {
    padding-left: 0;
    padding-right: 68px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .talk-ring .ring-fill {
    transition: none;
  }
}
