/* ═══════════════════════════════════════════════
   LEARN MODE — Dedicated mobile learning experience
   All selectors scoped under .learn-mode-scroll
   to prevent conflicts with production CSS
   ═══════════════════════════════════════════════ */

/* ── Body-level rules ── */
body.learn-mode-active {
  overflow: hidden;
  position: fixed;
  inset: 0;
}
body.learn-mode-active .grid-container,
body.learn-mode-active .flashcard-container,
body.learn-mode-active .bottom-action-bar,
body.learn-mode-active #mobileLandingContainer,
body.learn-mode-active #mobile-grid-container,
body.learn-mode-active .container,
body.learn-mode-active .mf-bottom-bar,
body.learn-mode-active .mf-floating-audio,
body.learn-mode-active .mf-scroll-track,
body.learn-mode-active .mf-page-indicator,
body.learn-mode-active .mf-status-bar,
body.learn-mode-active .hero-top-bar,
body.learn-mode-active .app-branding-topleft {
  display: none !important;
}

/* ── Container ── */
#learn-mode-container {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--color-paper);
  scroll-snap-type: y proximity;
  scroll-behavior: smooth;
  touch-action: pan-y pinch-zoom;
  /* Hide system scrollbar — page dots carry orientation */
  scrollbar-width: none;            /* Firefox */
  -ms-overflow-style: none;         /* IE / legacy Edge */
}
#learn-mode-container::-webkit-scrollbar {
  display: none;                    /* WebKit (Safari, Chrome) */
}

/* Token aliases (--ink, --stone, --kanji-family, --side, etc.) live in tokens.css :root */
.learn-mode-scroll {
  font-family: var(--font-ui);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Kill inherited button transitions from production CSS ── */
/* Scoped: exclude quiz choices, audio, exit, and hanko to allow their animations */
.learn-mode-scroll button:not(.q-choice):not(.hero-audio):not(.lm-exit-btn):not(.quiz-begin-btn),
.learn-mode-scroll [role="button"] {
  transition: none !important;
  transform: none !important;
  box-shadow: none !important;
}

/* ── Critical ruby override — kills base.css opacity: 0.55 ── */
.learn-mode-scroll ruby rt {
  opacity: 1 !important;
  font-family: var(--furigana-family);
  color: var(--furigana-color);
  font-weight: var(--furigana-weight);
  letter-spacing: 0.05em;
  font-size: max(0.55em, 10px);
}

/* Paper grain — single surface only */
.learn-mode-scroll::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.02;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* ═══════════════════════════════════════════════
   PERSISTENT NAV
   ═══════════════════════════════════════════════ */
#learn-mode-container .learn-mode-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: calc(48px + var(--safe-top, 0px));
  padding-top: var(--safe-top, 0px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 56px;
  padding-right: 56px;
  transition: background 0.3s ease, box-shadow 0.3s ease;
  background: transparent;
}
#learn-mode-container .learn-mode-nav.solid {
  background: rgba(250, 247, 242, 0.72);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  box-shadow: 0 1px 3px rgba(60, 52, 40, 0.08),
              inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
/* ── Exit button — cream frosted chip (chip system) ── */
#learn-mode-container .lm-exit-btn {
  position: fixed;
  left: 14px;
  top: calc(4px + var(--safe-top, 0px));
  z-index: 201;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: rgba(250, 247, 242, 0.72) !important;
  border: 1px solid rgba(44, 44, 44, 0.08) !important;
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  box-shadow: 0 1px 3px rgba(60, 52, 40, 0.08),
              inset 0 1px 0 rgba(255, 255, 255, 0.5) !important;
  color: var(--color-ink, #2C2C2C);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.18s ease;
  outline: none;
}
#learn-mode-container .lm-exit-btn:hover {
  transform: none;
}
#learn-mode-container .lm-exit-btn:active {
  background: rgba(244, 240, 232, 0.88) !important;
  transform: none;
}
#learn-mode-container .lm-exit-btn svg {
  width: 20px; height: 20px;
}
#learn-mode-container .lm-nav-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#learn-mode-container .lm-nav-title .lm-nav-jp {
  font-family: 'Klee One', serif;
  font-size: 19px;
  font-weight: 400;
  color: var(--color-ink);
  letter-spacing: 0.04em;
}
#learn-mode-container .lm-nav-title .lm-nav-jp rt {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: max(0.55em, 9px);
  color: var(--color-furigana);
  font-weight: 500;
}
#learn-mode-container .lm-nav-title .lm-nav-en {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-stone);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 45vw;
}
#learn-mode-container .learn-mode-nav.solid .lm-nav-title {
  opacity: 1;
  transform: translateY(0);
}

/* ── Session fraction (N / M) inside nav — cream frosted chip ── */
#learn-mode-container .lm-nav-fraction {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(calc(-50% + 4px));
  height: 36px;
  padding: 0 12px;
  border-radius: 18px;
  background: rgba(250, 247, 242, 0.72);
  border: 1px solid rgba(44, 44, 44, 0.08);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  box-shadow: 0 1px 3px rgba(60, 52, 40, 0.08),
              inset 0 1px 0 rgba(255, 255, 255, 0.5);
  display: inline-flex;
  align-items: center;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-ink, #2C2C2C);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
#learn-mode-container .learn-mode-nav.solid .lm-nav-fraction {
  opacity: 1;
  transform: translateY(-50%);
}
#learn-mode-container .lm-nav-fraction:empty { display: none; }

/* ── Session progress hairline — top edge of viewport, under the notch ── */
#learn-mode-container .lm-session-progress {
  position: fixed;
  top: var(--safe-top, 0px);
  left: 0;
  right: 0;
  height: 2px;
  z-index: 202;
  background: rgba(44, 44, 44, 0.05);
  opacity: 0;
  transition: opacity 320ms ease;
  pointer-events: none;
}
#learn-mode-container .lm-session-progress-fill {
  height: 100%;
  width: 0;
  background: var(--color-accent, #3D5A80);
  opacity: 0.72;
  transition: width 500ms cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: left center;
}
/* Reveal when user leaves the hero (nav has gone solid) */
#learn-mode-container .learn-mode-nav.solid ~ .lm-session-progress {
  opacity: 1;
}
/* Single-word sessions: JS sets [hidden] to suppress the empty track */
#learn-mode-container .lm-session-progress[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  #learn-mode-container .lm-session-progress,
  #learn-mode-container .lm-session-progress-fill,
  #learn-mode-container .lm-nav-fraction {
    transition: none;
  }
}

/* ═══════════════════════════════════════════════
   CONTENT WRAPPER
   ═══════════════════════════════════════════════ */
.learn-mode-scroll .wrap {
  max-width: 440px;
  margin: 0 auto;
}

/* ═══════════════════════════════════════════════
   1. HERO (100vh, Emaki style)
   ═══════════════════════════════════════════════ */
.learn-mode-scroll .hero {
  position: relative;
  /* Strict viewport sizing so Save/Learn/Skip never spill below the fold.
     100svh as fallback, 100dvh adapts to mobile URL-bar show/hide. */
  height: 100svh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.learn-mode-scroll .hero-image {
  width: 100%;
  height: 60vh;
  position: relative;
  overflow: hidden;
  /* Elastic: image yields height when hero-word grows (e.g. 2-line English).
     hero-word + hero-fork stay at natural size (flex-shrink: 0 below). */
  flex-shrink: 1;
  min-height: 0;
  --hero-parallax-y: 0;
  -webkit-mask-image: linear-gradient(to bottom, black 0%, black 50%, rgba(0,0,0,0.5) 75%, rgba(0,0,0,0.15) 90%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 0%, black 50%, rgba(0,0,0,0.5) 75%, rgba(0,0,0,0.15) 90%, transparent 100%);
}
.learn-mode-scroll .hero-image img {
  position: absolute;
  top: -30px;
  left: 0;
  width: 100%;
  height: calc(100% + 30px);
  object-fit: cover;
  transform: translateY(calc(var(--hero-parallax-y) * 1px));
  will-change: transform;
  opacity: 1;
  transition: none;
}
/* Scroll-driven parallax — pure CSS, zero JS cost (Chrome 115+, Safari 18+) */
@supports (animation-timeline: scroll()) {
  .learn-mode-scroll .hero-image img {
    animation: heroParallax linear;
    animation-timeline: scroll(nearest block);
    animation-range: 0px 60vh;
    transform: none; /* override JS-driven default */
    will-change: auto;
  }
  @keyframes heroParallax {
    from { transform: translateY(0); }
    to { transform: translateY(calc(60vh * 0.25)); }
  }
}
/* Shimmer skeleton while hero image loads */
.learn-mode-scroll .hero-image::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(90deg, var(--color-paper-shimmer-lo) 25%, var(--color-paper-shimmer-hi) 50%, var(--color-paper-shimmer-lo) 75%);
  background-size: 200% 100%;
  animation: lmShimmer 1.8s ease-in-out infinite;
  transition: opacity 0.3s ease;
}
.learn-mode-scroll .hero-image.loaded::before {
  opacity: 0;
  pointer-events: none;
  animation: none;
}
@keyframes lmShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
/* Fade-in for images not yet pre-decoded */
.learn-mode-scroll .hero-image img.lm-hero-fade {
  opacity: 0;
  transition: opacity 0.3s ease;
}
.learn-mode-scroll .hero-image img.lm-hero-fade.loaded {
  opacity: 1;
}
/* Breath layer — ambient radial pulse over hero image */
.learn-mode-scroll .hero-image::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 30% 60%, rgba(201, 169, 110, 0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 40%, rgba(61, 90, 128, 0.04) 0%, transparent 55%);
  animation: lmBreath 8s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  opacity: 0;
}
@keyframes lmBreath {
  0%, 100% { opacity: 0; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}
.learn-mode-scroll .hero-word {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: -6vh;
  padding: 0 var(--side);
  padding-top: 1vh;
  /* Never shrink — text content + audio button always get natural height. */
  flex-shrink: 0;
  /* Warm paper halo for readability on bright/busy images */
  text-shadow: 0 1px 12px rgba(240, 237, 232, 0.9),
               0 0 40px rgba(240, 237, 232, 0.6);
}

/* ── Bilingual POS band — sits above the kanji ─────────────────
   ── 副詞 ADVERB ── styling, moss-tinted, stroke-marked.
   Matches the existing bilingual section labels (覚書 NOTES etc).
   Sits inside .hero-word so it inherits the paper halo. */
.learn-mode-scroll .hero-pos-band {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 14px;
  line-height: 1;
}
.learn-mode-scroll .hero-pos-stroke {
  display: inline-block;
  width: 24px;
  height: 1px;
  background: rgba(107, 127, 92, 0.42);
}
.learn-mode-scroll .hero-pos-jp {
  font-family: 'Noto Serif JP', serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-moss, #6B7F5C);
  letter-spacing: 0.1em;
}
.learn-mode-scroll .hero-pos-en {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-stone, #57534e);
  letter-spacing: 0.08em;
}
/* Long-word tiers: shrink band slightly so it doesn't dominate */
.learn-mode-scroll .hero-word[data-size="long"] .hero-pos-band {
  gap: 10px;
  margin-bottom: 10px;
}
.learn-mode-scroll .hero-word[data-size="long"] .hero-pos-stroke { width: 18px; }
.learn-mode-scroll .hero-word[data-size="long"] .hero-pos-jp { font-size: 13px; }
.learn-mode-scroll .hero-word[data-size="long"] .hero-pos-en { font-size: 11px; }
.learn-mode-scroll .hero-kanji {
  font-family: var(--kanji-family);
  font-size: clamp(3rem, 10vw + 1rem, 4.5rem);
  font-weight: 600;
  line-height: 1.15;
  color: var(--kanji-color);
  text-align: center;
  word-break: keep-all;
  letter-spacing: -0.02em;
}
/* Tighten ruby spacing to eliminate gaps between annotated and plain characters */
.learn-mode-scroll .hero-kanji ruby {
  margin-left: -0.08em;
}
/* Dynamic sizing tiers */
.learn-mode-scroll .hero-word[data-size="medium"] .hero-kanji {
  font-size: clamp(2.4rem, 8vw + 0.5rem, 3.5rem);
}
.learn-mode-scroll .hero-word[data-size="long"] .hero-kanji {
  font-size: clamp(1.8rem, 6vw + 0.5rem, 2.8rem);
}
.learn-mode-scroll .hero-kanji rt {
  font-family: var(--furigana-family);
  font-size: 0.30em;
  color: var(--furigana-color);
  font-weight: var(--furigana-weight);
  letter-spacing: 0.08em;
}
.learn-mode-scroll .hero-kana {
  font-family: var(--romaji-family);
  font-size: 1rem;
  font-style: italic;
  font-weight: var(--romaji-weight);
  color: var(--romaji-color);
  letter-spacing: 0.08em;
  margin-top: 0.6rem;
}
.learn-mode-scroll .hero-english {
  font-family: var(--english-family);
  font-size: 1.15rem;
  color: var(--english-color);
  font-weight: var(--english-weight);
  margin-top: 0.8rem;
  letter-spacing: 0.06em;
  max-width: 90%;
  word-break: break-word;
}
.learn-mode-scroll .hero-pos {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 400;
  color: var(--faint);
  letter-spacing: 0.06em;
  margin-top: 4px;
  text-transform: lowercase;
}
.learn-mode-scroll .hero-audio-row {
  /* Owns the vertical zone between hero-word and hero-fork.
     flex: 1 1 auto absorbs all free space; audio centers inside.
     min-height guarantees ≥16px breathing room above + below audio
     even when .hero-image has shrunk fully in tight URL-bar layouts. */
  flex: 1 1 auto;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.learn-mode-scroll .hero-audio {
  /* Centering + breathing room are owned by .hero-audio-row above. */
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 50%;
  /* Unified chip glass (cream frosted) */
  background: rgba(250, 247, 242, 0.72);
  border: 1px solid rgba(44, 44, 44, 0.08);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  box-shadow: 0 1px 3px rgba(60, 52, 40, 0.08),
              inset 0 1px 0 rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.2s ease, background 0.2s ease, opacity 0.3s ease;
}
.learn-mode-scroll .hero-audio:active {
  transform: scale(0.92);
  background: rgba(244, 240, 232, 0.88);
}
.learn-mode-scroll .hero-audio.playing {
  animation: lmAudioPulse 1s ease-in-out infinite;
}
@keyframes lmAudioPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.06); opacity: 0.85; }
}
.learn-mode-scroll .hero-audio svg {
  width: 18px !important; height: 18px !important; min-width: 18px; min-height: 18px;
  fill: var(--color-stone); stroke: none; overflow: visible;
}
.learn-mode-scroll .hero-audio.playing svg { fill: var(--color-gold); }

/* ═══════════════════════════════════════════════
   1b. VERB FORMS SECTION (B: single flow)
   ═══════════════════════════════════════════════ */
.learn-mode-scroll .lm-forms-pos {
  font-weight: 400;
  color: var(--faint);
  letter-spacing: 0.04em;
  margin-left: 6px;
  text-transform: none;
  font-size: 11px;
}
.learn-mode-scroll .lm-form-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  border-radius: 8px;
  transition: background 0.15s ease;
}
.learn-mode-scroll .lm-form-row:active {
  background: rgba(163, 90, 74, 0.04);
}
.learn-mode-scroll .lm-form-row.playing {
  background: rgba(201, 169, 110, 0.06);
}
/* Dict form is the anchor — slightly larger */
.learn-mode-scroll .lm-form-dict .lm-form-jp {
  font-size: 26px;
}
.learn-mode-scroll .lm-form-jp {
  font-family: var(--kanji-family);
  font-size: 22px;
  font-weight: 600;
  color: var(--jp-text);
  line-height: 1.4;
  letter-spacing: 0.02em;
  flex: 1;
  min-width: 0;
}
.learn-mode-scroll .lm-form-jp rt {
  font-family: var(--furigana-family);
  font-size: max(0.5em, 9px);
  color: var(--furigana-color);
  font-weight: var(--furigana-weight);
  letter-spacing: 0.05em;
}
.learn-mode-scroll .lm-form-romaji {
  font-family: var(--romaji-family);
  font-size: 13px;
  font-style: italic;
  font-weight: var(--romaji-weight);
  color: var(--romaji-color);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
/* Ghost speaker — no border, just the glyph */
.learn-mode-scroll .lm-form-speaker {
  width: 12px;
  height: 12px;
  min-width: 12px;
  flex-shrink: 0;
  fill: var(--faint);
  stroke: var(--faint);
  opacity: 0.35;
  transition: opacity 0.2s ease, fill 0.2s ease, stroke 0.2s ease;
  overflow: visible;
}
.learn-mode-scroll .lm-form-row:active .lm-form-speaker,
.learn-mode-scroll .lm-form-row.playing .lm-form-speaker {
  opacity: 0.8;
  fill: var(--gold);
  stroke: var(--gold);
}

/* ═══════════════════════════════════════════════
   COUNTER LIST (助数詞 — verb-form style, collapsible)
   ═══════════════════════════════════════════════ */
.learn-mode-scroll .lm-counter-section {
  margin-bottom: -24px;
}
.learn-mode-scroll .lm-counter-list {
  display: flex;
  flex-direction: column;
}
.learn-mode-scroll .lm-counter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 4px;
  border-radius: 8px;
}
.learn-mode-scroll .lm-counter-num {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  color: var(--faint);
  opacity: 0.5;
  min-width: 18px;
  text-align: right;
  flex-shrink: 0;
}
.learn-mode-scroll .lm-counter-jp {
  font-family: var(--kanji-family);
  font-size: 22px;
  font-weight: 600;
  color: var(--jp-text);
  line-height: 1.4;
  letter-spacing: 0.02em;
  flex: 1;
  min-width: 0;
}
.learn-mode-scroll .lm-counter-jp rt {
  font-family: var(--furigana-family);
  font-size: max(0.5em, 9px);
  color: var(--furigana-color);
  font-weight: var(--furigana-weight);
  letter-spacing: 0.05em;
}
.learn-mode-scroll .lm-counter-reading {
  font-family: var(--romaji-family);
  font-size: 13px;
  font-style: italic;
  font-weight: var(--romaji-weight);
  color: var(--romaji-color);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
/* Audio button — matches related word audio pattern */
.learn-mode-scroll .lm-counter-audio-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: 1px solid rgba(44, 44, 44, 0.08);
  border-radius: 50%;
  background: transparent;
  color: var(--faint);
  opacity: 0.5;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s ease, color 0.15s ease;
  padding: 0;
}
.learn-mode-scroll .lm-counter-audio-btn:active,
.learn-mode-scroll .lm-counter-audio-btn.playing {
  opacity: 1;
  color: var(--gold);
  border-color: rgba(201, 169, 110, 0.3);
}
/* Question row — subtle gold accent */
.learn-mode-scroll .lm-counter-question {
  border-top: 1px solid rgba(201, 169, 110, 0.15);
  margin-top: 4px;
  padding-top: 12px;
}
.learn-mode-scroll .lm-counter-question .lm-counter-num {
  color: var(--gold);
  opacity: 0.7;
  font-weight: 600;
}
.learn-mode-scroll .lm-counter-question .lm-counter-reading {
  color: var(--gold);
  opacity: 0.6;
}
/* Collapse/expand */
.learn-mode-scroll .lm-counter-more {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s ease-out, opacity 0.2s ease-out;
}
.learn-mode-scroll .lm-counter-more.expanded {
  max-height: 600px;
  opacity: 1;
}
.learn-mode-scroll .lm-counter-toggle {
  padding: 4px 4px 0;
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.learn-mode-scroll .lm-counter-toggle-text {
  font-family: var(--romaji-family);
  font-size: 12px;
  font-style: italic;
  color: var(--faint);
  opacity: 0.5;
  transition: opacity 0.15s ease;
}
.learn-mode-scroll .lm-counter-toggle:active .lm-counter-toggle-text {
  opacity: 0.8;
}

/* ═══════════════════════════════════════════════
   HANKO SEALS (shared)
   ═══════════════════════════════════════════════ */
.learn-mode-scroll .lm-hanko {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  padding: 6px;
  background: none;
  border: none;
  appearance: none;
  -webkit-appearance: none;
}
.learn-mode-scroll .lm-hanko-ring {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  background: transparent;
  position: relative;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
              background 0.3s ease, border-color 0.3s ease,
              box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s ease;
}
/* Secondary ink ring (hanko double-ring effect) */
.learn-mode-scroll .lm-hanko-ring::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid transparent;
  opacity: 0;
  transition: opacity 0.3s ease, inset 0.3s ease;
  pointer-events: none;
}
.learn-mode-scroll .lm-hanko-kanji {
  font-family: 'Klee One', serif;
  font-size: 20px;
  line-height: 1;
  user-select: none;
}
.learn-mode-scroll .lm-hanko-label {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--color-faint);
  opacity: 0.65;
  user-select: none;
  transition: opacity 0.3s ease, color 0.3s ease;
}

/* Known seal (green / 済) */
.lm-hanko--known {
  border-color: rgba(107, 127, 92, 0.45);
  background: rgba(107, 127, 92, 0.04);
}
.lm-hanko--known .lm-hanko-kanji {
  color: var(--color-moss);
  opacity: 0.75;
}
.lm-hanko--known::after {
  border-color: rgba(107, 127, 92, 0.12);
}

/* Learning seal (amber / 新) */
.lm-hanko--learning {
  border-color: rgba(160, 120, 80, 0.45);
  background: rgba(160, 120, 80, 0.04);
}
.lm-hanko--learning .lm-hanko-kanji {
  color: var(--color-amber);
  opacity: 0.75;
}
.lm-hanko--learning::after {
  border-color: rgba(160, 120, 80, 0.12);
}

/* Press */
.learn-mode-scroll .lm-hanko:active .lm-hanko-ring {
  transform: scale(0.85);
  transition-duration: 0.08s;
}

/* Ink bleed texture — real hanko stamps show irregular ink distribution */
.learn-mode-scroll .lm-hanko-ring::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)' opacity='0.12'/%3E%3C/svg%3E");
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: multiply;
  transition: opacity 0.3s ease;
}
.learn-mode-scroll .lm-hanko.animating .lm-hanko-ring::before {
  opacity: 1;
}
.learn-mode-scroll .lm-hanko.stamped .lm-hanko-ring::before {
  opacity: 0.7;
}

/* Stamp press animation */
@keyframes lmStampPress {
  0%   { transform: scale(1); }
  20%  { transform: scale(0.85); }
  55%  { transform: scale(1.06) rotate(2deg); }
  100% { transform: scale(1.0) rotate(2deg); }
}
@keyframes lmInkSpread {
  0%   { box-shadow: 0 0 0 0 transparent; }
  40%  { box-shadow: 0 0 0 2px var(--lm-ink-color); }
  100% { box-shadow: 0 0 0 1px var(--lm-ink-color); }
}
.learn-mode-scroll .lm-hanko.animating .lm-hanko-ring {
  animation: lmStampPress 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.learn-mode-scroll .lm-hanko.animating.mark-learned .lm-hanko-ring {
  --lm-ink-color: rgba(107, 127, 92, 0.12);
  animation: lmStampPress 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
             lmInkSpread 0.5s ease 0.1s forwards;
}
.learn-mode-scroll .lm-hanko.animating.mark-review .lm-hanko-ring {
  --lm-ink-color: rgba(160, 120, 80, 0.12);
  animation: lmStampPress 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
             lmInkSpread 0.5s ease 0.1s forwards;
}
/* Stamped */
.learn-mode-scroll .lm-hanko.stamped .lm-hanko-ring {
  transform: scale(1.0) rotate(2deg);
}
.learn-mode-scroll .lm-hanko.stamped .lm-hanko-kanji {
  opacity: 1;
}
.learn-mode-scroll .lm-hanko.stamped .lm-hanko-ring::after {
  opacity: 1;
  inset: -5px;
}
.learn-mode-scroll .lm-hanko.stamped.mark-learned .lm-hanko-ring {
  border-color: var(--color-moss);
  background: rgba(107, 127, 92, 0.08);
  box-shadow: 0 0 0 1px rgba(107, 127, 92, 0.12);
}
.learn-mode-scroll .lm-hanko.stamped.mark-learned .lm-hanko-label {
  color: var(--color-moss);
  opacity: 0.7;
}
.learn-mode-scroll .lm-hanko.stamped.mark-review .lm-hanko-ring {
  border-color: var(--color-amber);
  background: rgba(160, 120, 80, 0.06);
  box-shadow: 0 0 0 1px rgba(160, 120, 80, 0.12);
}
.learn-mode-scroll .lm-hanko.stamped.mark-review .lm-hanko-label {
  color: var(--color-amber);
  opacity: 0.7;
}

/* Dimmed (unchosen sibling) */
.learn-mode-scroll .lm-hanko.dimmed .lm-hanko-ring {
  opacity: 0.25;
  transform: scale(0.95);
}
.learn-mode-scroll .lm-hanko.dimmed .lm-hanko-label {
  opacity: 0.15;
}


/* Hero fork: side-by-side bordered pair */
.learn-mode-scroll .hero-fork {
  /* .hero-audio-row's flex: 1 absorbs free space, pinning fork at bottom. */
  margin-bottom: calc(2vh + var(--safe-bottom));
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--side);
  position: relative;
  gap: 10px;
  /* Never shrink — Save/Learn/Skip always at natural size. */
  flex-shrink: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.learn-mode-scroll .hero-fork.faded {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

/* Action buttons (Save / Learn / Skip) */
.learn-mode-scroll .hero-action-btn {
  flex: 1;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  min-height: 44px;
  appearance: none;
  -webkit-appearance: none;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  /* Unified chip glass (cream frosted) — per-button accent in border-color overrides below */
  background: rgba(250, 247, 242, 0.72);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  border: 1px solid rgba(44, 44, 44, 0.08);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(60, 52, 40, 0.08),
              inset 0 1px 0 rgba(255, 255, 255, 0.5);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.12s ease;
}
.learn-mode-scroll .hero-action-btn:active {
  transform: scale(0.96);
}

/* Save — amber */
.learn-mode-scroll .hero-action--save {
  color: var(--color-amber);
  border-color: rgba(201, 169, 110, 0.25);
}
.learn-mode-scroll .hero-action--save:active {
  background: rgba(201, 169, 110, 0.15);
  border-color: rgba(201, 169, 110, 0.5);
}

/* Learn — ink/accent */
.learn-mode-scroll .hero-action--learn {
  color: var(--ink);
  border-color: rgba(44, 44, 44, 0.12);
  gap: 4px;
}
.learn-mode-scroll .hero-action--learn:active {
  background: rgba(244, 240, 232, 0.88);
  border-color: rgba(61, 90, 128, 0.35);
}
.learn-mode-scroll .hero-action-chevron {
  stroke: var(--color-faint);
  opacity: 0.45;
}

/* Skip — moss green */
.learn-mode-scroll .hero-action--skip {
  color: rgba(107, 127, 92, 0.7);
  border-color: rgba(107, 127, 92, 0.2);
}
.learn-mode-scroll .hero-action--skip:active {
  background: rgba(107, 127, 92, 0.1);
  border-color: rgba(107, 127, 92, 0.45);
}

/* Pressed state (after tap, before card flies away) */
.learn-mode-scroll .hero-action-btn.pressed {
  transform: scale(0.95);
  transition: transform 0.15s ease, background 0.3s ease, border-color 0.3s ease;
}
.learn-mode-scroll .hero-action--save.pressed {
  background: rgba(201, 169, 110, 0.18);
  border-color: rgba(201, 169, 110, 0.5);
}
.learn-mode-scroll .hero-action--skip.pressed {
  background: rgba(107, 127, 92, 0.12);
  border-color: rgba(107, 127, 92, 0.45);
}
.learn-mode-scroll .hero-action-btn.dimmed {
  opacity: 0.3;
  transition: opacity 0.3s ease;
}

/* ═══════════════════════════════════════════════
   SECTION STYLING (shared)
   ═══════════════════════════════════════════════ */
.learn-mode-scroll .section {
  padding: 0 var(--side);
  margin-top: 48px;
  scroll-snap-align: start;
  scroll-margin-top: 56px;
  content-visibility: auto;
  contain-intrinsic-size: auto 300px;
}
.learn-mode-scroll .marking {
  content-visibility: auto;
  contain-intrinsic-size: auto 200px;
}
/* Initial hidden state + reveal animation live in the SECTION REVEAL
   block below (.lm-revealed). Reduced-motion override also lives there. */
.learn-mode-scroll .section-label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 20px;
}
.learn-mode-scroll .section-kanji {
  font-family: var(--kanji-family);
  font-size: 14px;
  font-weight: 400;
  color: var(--stone);
  letter-spacing: 0.04em;
}
.learn-mode-scroll .section-en {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
}
.learn-mode-scroll .section-label::before {
  content: '';
  display: block;
  width: 32px;
  height: 1px;
  background: linear-gradient(90deg, var(--gold), rgba(201, 169, 110, 0.3));
  margin-bottom: 20px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.15s;
}
.learn-mode-scroll .section.lm-revealed .section-label::before,
.learn-mode-scroll .marking.lm-revealed .section-label::before {
  transform: scaleX(1);
}

/* ═══════════════════════════════════════════════
   2. WORD STORY (Tanzaku bordered cards)
   ═══════════════════════════════════════════════ */
.learn-mode-scroll .story-card {
  background: var(--card);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  opacity: 0;
  transition: border-color 0.2s ease;
}
/* Reveal animation + stagger live in the SECTION REVEAL block below
   (.section.lm-revealed .story-card). Reduced-motion override is in the
   shared block at the bottom of this file. */
.learn-mode-scroll .story-card[data-type="watch_out"] {
  border-left: 2px solid var(--terracotta);
}
.learn-mode-scroll .story-card[data-type="quick_tip"],
.learn-mode-scroll .story-card[data-type="memory_hook"] {
  border-left: 2px solid var(--gold);
}
.learn-mode-scroll .story-card[data-type="culture_note"] {
  border-left: 2px solid var(--accent);
}
.learn-mode-scroll .story-card[data-type="grammar_hint"] {
  border-left: 2px solid var(--moss);
}
.learn-mode-scroll .story-type {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--terracotta);
  margin-bottom: 8px;
}
.learn-mode-scroll .story-card[data-type="quick_tip"] .story-type,
.learn-mode-scroll .story-card[data-type="memory_hook"] .story-type {
  color: var(--gold);
}
.learn-mode-scroll .story-card[data-type="culture_note"] .story-type {
  color: var(--accent);
}
.learn-mode-scroll .story-card[data-type="grammar_hint"] .story-type {
  color: var(--moss);
}
.learn-mode-scroll .story-body {
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink);
  letter-spacing: 0.01em;
}

/* ── 4-type inline text ── */
.learn-mode-scroll .jp {
  font-family: var(--kanji-family);
  color: var(--jp-text);
  font-weight: 600;
  font-size: 1.25em;
  letter-spacing: 0.02em;
}
.learn-mode-scroll .romaji {
  font-family: var(--romaji-family);
  font-style: italic;
  font-weight: var(--romaji-weight);
  color: var(--romaji-color);
  font-size: 0.92em;
  padding-right: 0.08em;
}
.learn-mode-scroll .en {
  font-family: var(--english-family);
  color: var(--english-color);
  font-weight: var(--english-weight);
}

/* ═══════════════════════════════════════════════
   3. SENTENCES (furigana always, tap to reveal)
   ═══════════════════════════════════════════════ */
.learn-mode-scroll #lmSentenceSection {
  counter-reset: sentence-counter;
}
.learn-mode-scroll .sentence-card {
  counter-increment: sentence-counter;
  position: relative;
  background: var(--card);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 16px 18px 16px 38px;
  margin-bottom: 10px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.2s ease, transform 0.08s ease, background 0.08s ease;
}
.learn-mode-scroll .sentence-card::before {
  content: counter(sentence-counter);
  position: absolute;
  left: 14px;
  top: 18px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--faint);
  opacity: 0.5;
}
.learn-mode-scroll .sentence-card:active:not(.expanded) {
  background: rgba(163, 90, 74, 0.04);
  transform: scale(0.985);
}
.learn-mode-scroll .sentence-card.expanded {
  border-color: rgba(163, 90, 74, 0.25);
}
.learn-mode-scroll .sentence-jp {
  font-family: var(--kanji-family);
  font-size: 20px;
  line-height: 1.9;
  color: var(--jp-text);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.learn-mode-scroll .sentence-jp rt {
  font-family: var(--furigana-family);
  font-size: max(0.55em, 10px);
  color: var(--furigana-color);
  font-weight: var(--furigana-weight);
  letter-spacing: 0.05em;
}
/* Span-based ruby for sentences (rubyToSpans in learn-mode.js buildSentences).
   Mobile WebKit's native ruby spreads the kanji base to fit a wider kana
   reading; positioning the reading absolutely keeps the compound tight. */
.learn-mode-scroll .sentence-jp .ruby-group,
.learn-mode-scroll .related-detail-jp .ruby-group {
  display: inline;
  position: relative;
}
.learn-mode-scroll .sentence-jp .ruby-rt,
.learn-mode-scroll .related-detail-jp .ruby-rt {
  display: block;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 100%;
  width: max-content;
  white-space: nowrap;
  font-family: var(--furigana-family);
  font-size: 0.55em;
  font-weight: var(--furigana-weight);
  line-height: 1;
  color: var(--furigana-color);
  text-align: center;
  text-align-last: justify;
  text-justify: inter-character;
  padding-bottom: 0.15em;
}
/* Reserve vertical room so the absolute-positioned readings don't clip
   against the sentence above. */
.learn-mode-scroll .sentence-jp:has(.ruby-group),
.learn-mode-scroll .related-detail-jp:has(.ruby-group) {
  padding-top: 0.8em;
}
.learn-mode-scroll .sentence-jp .target,
.learn-mode-scroll .sentence-romaji .target,
.learn-mode-scroll .sentence-en .target {
  text-decoration-line: underline;
  text-decoration-color: rgba(163, 90, 74, 0.25);
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
}
/* Kill default <mark> yellow — use terracotta underline instead */
.learn-mode-scroll mark,
.learn-mode-scroll .sentence-word-highlight {
  background: none;
  color: inherit;
  text-decoration-line: underline;
  text-decoration-color: rgba(163, 90, 74, 0.25);
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
}
.learn-mode-scroll .sentence-hidden {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.35s ease, opacity 0.3s ease, margin-top 0.3s ease;
  margin-top: 0;
}
.learn-mode-scroll .sentence-card.expanded .sentence-hidden {
  max-height: 400px;
  opacity: 1;
  margin-top: 10px;
}
/* Stagger-reveal: romaji slides in first, English follows */
.learn-mode-scroll .sentence-hidden .sentence-romaji,
.learn-mode-scroll .sentence-hidden .sentence-en {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.learn-mode-scroll .sentence-card.expanded .sentence-hidden .sentence-romaji {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 60ms;
}
.learn-mode-scroll .sentence-card.expanded .sentence-hidden .sentence-en {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 120ms;
}
.learn-mode-scroll .sentence-romaji {
  font-family: var(--romaji-family);
  font-size: 14px;
  font-style: italic;
  font-weight: var(--romaji-weight);
  color: var(--romaji-color);
  line-height: 1.5;
  letter-spacing: 0.01em;
}
.learn-mode-scroll .sentence-en {
  font-family: var(--english-family);
  font-size: 14px;
  color: var(--english-color);
  font-weight: var(--english-weight);
  line-height: 1.5;
  margin-top: 4px;
}
.learn-mode-scroll .sentence-hint {
  font-family: var(--font-ui);
  font-size: 0;
  color: transparent;
  margin-top: 6px;
  opacity: 0.35;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 14px;
}
.learn-mode-scroll .sentence-hint::after {
  content: '';
  width: 14px;
  height: 14px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2357534e' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center/contain no-repeat;
}
.learn-mode-scroll .sentence-card.expanded .sentence-hint {
  opacity: 0; height: 0; overflow: hidden;
}

/* ═══════════════════════════════════════════════
   4. RELATED WORDS
   ═══════════════════════════════════════════════ */
.learn-mode-scroll .related-group {
  margin-top: 24px;
}
.learn-mode-scroll .related-group:first-child {
  margin-top: 0;
}
.learn-mode-scroll .related-group-label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--stone);
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.learn-mode-scroll .related-group-kanji {
  font-family: var(--kanji-family);
  font-size: 13px;
  font-weight: 400;
  color: var(--gold);
  text-transform: none;
  letter-spacing: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--divider);
}
.learn-mode-scroll .related-item {
  padding: 10px 0;
}
.learn-mode-scroll .related-group:last-child .related-item:last-child {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(216, 210, 200, 0.4);
}
.learn-mode-scroll .related-item.has-detail {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.learn-mode-scroll .related-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
/* JP side is the primary anchor — never let it collapse and never wrap
   the kanji into vertical fragments. The English side wraps instead. */
.learn-mode-scroll .related-left {
  flex: 0 0 auto;
  min-width: 0;
  max-width: 55%;
}
.learn-mode-scroll .related-arrow {
  color: var(--faint);
  opacity: 0.4;
  transition: transform 0.2s ease, opacity 0.2s ease;
  flex-shrink: 0;
  margin-left: 8px;
  padding-top: 4px;
}
.learn-mode-scroll .related-item.expanded .related-arrow {
  transform: rotate(90deg);
  opacity: 0.7;
}
.learn-mode-scroll .related-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  /* min-width: 0 is the magic that lets the inner English text wrap inside
     a flex item instead of forcing the row to overflow. */
  min-width: 0;
  margin-left: auto;
}
.learn-mode-scroll .related-audio-btn {
  padding: 12px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--stone);
  opacity: 0.4;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
  line-height: 0;
}
.learn-mode-scroll .related-audio-btn:active {
  opacity: 0.8;
}
.learn-mode-scroll .related-detail {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s ease, opacity 0.3s ease, margin-top 0.3s ease;
  margin-top: 0;
}
.learn-mode-scroll .related-item.expanded .related-detail {
  max-height: 500px;
  opacity: 1;
  margin-top: 12px;
}
.learn-mode-scroll .related-detail-card {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--divider);
}
.learn-mode-scroll .related-detail-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
}
.learn-mode-scroll .related-detail-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.learn-mode-scroll .related-detail-text {
  padding: 14px 16px 16px;
}
.learn-mode-scroll .related-detail-jp {
  font-family: var(--kanji-family);
  font-size: 19px;
  line-height: 1.8;
  color: var(--jp-text);
}
.learn-mode-scroll .related-detail-jp rt {
  font-family: var(--furigana-family);
  font-size: max(0.55em, 10px);
  color: var(--furigana-color);
  font-weight: var(--furigana-weight);
}
.learn-mode-scroll .related-detail-romaji {
  font-family: var(--romaji-family);
  font-size: 13px;
  font-style: italic;
  color: var(--romaji-color);
  margin-top: 2px;
}
.learn-mode-scroll .related-detail-en {
  font-family: var(--english-family);
  font-size: 15px;
  font-weight: 500;
  color: var(--english-color);
  margin-top: 4px;
}
.learn-mode-scroll .related-item + .related-item {
  border-top: 1px solid rgba(216, 210, 200, 0.4);
}
.learn-mode-scroll .related-word {
  font-family: var(--kanji-family);
  font-size: 20px;
  color: var(--jp-text);
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.02em;
  /* Compounds like 蒸し暑い should wrap as a unit (or stay on one line);
     never split a 2-kanji word into vertical character fragments. */
  word-break: keep-all;
  overflow-wrap: normal;
  white-space: nowrap;
}
.learn-mode-scroll .related-word rt {
  font-family: var(--furigana-family);
  font-size: max(0.55em, 10px);
  color: var(--furigana-color);
  font-weight: var(--furigana-weight);
  letter-spacing: 0.05em;
}
.learn-mode-scroll .related-romaji {
  font-family: var(--romaji-family);
  font-size: 13px;
  font-style: italic;
  font-weight: var(--romaji-weight);
  color: var(--romaji-color);
  margin-top: 1px;
}
.learn-mode-scroll .related-english {
  font-family: var(--english-family);
  font-size: 15px;
  color: var(--english-color);
  font-weight: var(--english-weight);
  text-align: right;
  /* English wraps to multiple lines when long instead of stealing width
     from the JP side. line-height tuned for stacked wrapped lines. */
  line-height: 1.4;
  min-width: 0;
  flex: 1 1 auto;
  overflow-wrap: break-word;
}


/* ═══════════════════════════════════════════════
   6. MARKING (hanko seals)
   ═══════════════════════════════════════════════ */
.learn-mode-scroll .marking {
  padding: 40px var(--side) calc(120px + var(--safe-bottom));
  scroll-snap-align: start;
  scroll-margin-top: 64px;
  border-top: none;
  margin-top: 48px;
}
.learn-mode-scroll .marking-prompt {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--stone);
  text-align: center;
  margin: 0 0 24px;
}
.learn-mode-scroll .marking-bar {
  display: flex;
  justify-content: center;
  gap: 48px;
}
/* Marking-scoped seal amplification */
.learn-mode-scroll .marking .lm-hanko-ring {
  width: 68px;
  height: 68px;
}
.learn-mode-scroll .marking .lm-hanko--known {
  border-color: rgba(107, 127, 92, 0.65);
  background: rgba(107, 127, 92, 0.07);
}
.learn-mode-scroll .marking .lm-hanko--learning {
  border-color: rgba(160, 120, 80, 0.65);
  background: rgba(160, 120, 80, 0.07);
}
.learn-mode-scroll .marking .lm-hanko-kanji {
  font-size: 28px;
  opacity: 0.9;
}
.learn-mode-scroll .marking .lm-hanko--known .lm-hanko-kanji { transform: rotate(-1.5deg); }
.learn-mode-scroll .marking .lm-hanko--learning .lm-hanko-kanji { transform: rotate(1deg); }
.learn-mode-scroll .marking .lm-hanko-label {
  font-size: 13px;
  opacity: 0.8;
}
.learn-mode-scroll .marking .lm-hanko-ring::after {
  opacity: 0.4;
  inset: -4px;
}

/* ═══════════════════════════════════════════════
   PAGE INDICATOR (right-edge dots)
   ═══════════════════════════════════════════════ */
.lm-page-indicator {
  position: fixed;
  right: calc(14px + env(safe-area-inset-right, 0px));
  top: 50%;
  transform: translateY(-50%);
  z-index: 201;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
body.learn-mode-active .lm-page-indicator { opacity: 0.85; }
.lm-page-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(140, 133, 120, 0.45);
  box-shadow: none;
  transition: transform 0.25s ease, background 0.25s ease;
}
.lm-page-dot.active {
  background: var(--color-amber, #B8842A);
  transform: scale(2);
  box-shadow: 0 0 4px 1px rgba(184, 132, 42, 0.25);
}

/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */
@media (min-width: 480px) {
  .learn-mode-scroll { --side: 28px; }
}
@media (min-width: 768px) {
  .learn-mode-scroll { --side: 32px; }
  .learn-mode-scroll .wrap { max-width: 480px; }
}

/* ═══════════════════════════════════════════════
   SECTION REVEAL (IntersectionObserver)
   ═══════════════════════════════════════════════ */
@keyframes lmSectionReveal {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.learn-mode-scroll .section,
.learn-mode-scroll .marking {
  opacity: 0;
  transform: translateY(12px);
}
.learn-mode-scroll .section.lm-revealed,
.learn-mode-scroll .marking.lm-revealed {
  animation: lmSectionReveal 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
/* Stagger children within revealed sections */
.learn-mode-scroll .section.lm-revealed .story-card,
.learn-mode-scroll .section.lm-revealed .sentence-card,
.learn-mode-scroll .section.lm-revealed .related-group {
  opacity: 0;
  animation: lmSectionReveal 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.learn-mode-scroll .section.lm-revealed :nth-child(2) { animation-delay: 40ms; }
.learn-mode-scroll .section.lm-revealed :nth-child(3) { animation-delay: 80ms; }
.learn-mode-scroll .section.lm-revealed :nth-child(4) { animation-delay: 120ms; }

/* ═══════════════════════════════════════════════
   敷居 (shikii) — threshold entrance from landing
   Stagger reveal for hero content arriving via
   the shared-element transition from mobile landing.
   Applied by JS as .lm-from-landing, removed after ~450ms.
   ═══════════════════════════════════════════════ */

@keyframes lmThresholdIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

#learn-mode-container.lm-from-landing .learn-mode-nav {
  animation: lmThresholdIn 220ms ease-out both;
  animation-delay: 30ms;
}

#learn-mode-container.lm-from-landing .hero-word > * {
  opacity: 0;
}

#learn-mode-container.lm-from-landing .hero-kanji {
  animation: lmThresholdIn 220ms ease-out both;
  animation-delay: 50ms;
}

#learn-mode-container.lm-from-landing .hero-kana {
  animation: lmThresholdIn 220ms ease-out both;
  animation-delay: 90ms;
}

#learn-mode-container.lm-from-landing .hero-english {
  animation: lmThresholdIn 220ms ease-out both;
  animation-delay: 120ms;
}

#learn-mode-container.lm-from-landing .hero-audio {
  animation: lmThresholdIn 220ms ease-out both;
  animation-delay: 150ms;
}

#learn-mode-container.lm-from-landing .hero-fork {
  animation: lmThresholdIn 220ms ease-out both;
  animation-delay: 180ms;
}

/* ═══════════════════════════════════════════════
   CROSSFADE (word transitions)
   ═══════════════════════════════════════════════ */
#learn-mode-container.lm-crossfade-out {
  opacity: 0;
  filter: blur(3px);
  transition: opacity 0.18s ease, filter 0.18s ease;
}
#learn-mode-container.lm-crossfade-in {
  opacity: 0;
  filter: blur(3px);
}
#learn-mode-container.lm-crossfade-settle {
  opacity: 1;
  filter: blur(0);
  transition: opacity 0.22s ease, filter 0.22s ease;
}

/* Deck-exit departure — card leaves the current deck.
   Distinct from crossfade: lifts up + shrinks away.
   No opacity change — container background stays solid to prevent
   the grid from bleeding through during the transition. */
#learn-mode-container.lm-deck-exit-out {
  filter: blur(12px);
  transform: scale(0.92) translateY(-16px);
  transition: filter 0.32s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Deck-exit settle — blur dissolves to reveal new card.
   Later in file than lm-deck-exit-out so it overrides at same specificity. */
#learn-mode-container.lm-deck-exit-settle {
  filter: blur(0);
  transform: none;
  transition: filter 0.28s ease-out, transform 0.28s ease-out;
}

/* ═══════════════════════════════════════════════
   VIEW TRANSITIONS (word-to-word crossfade)
   ═══════════════════════════════════════════════ */
::view-transition-old(root) {
  animation: lmVTOut 0.2s ease forwards;
}
::view-transition-new(root) {
  animation: lmVTIn 0.25s ease forwards;
}
@keyframes lmVTOut {
  to { opacity: 0; filter: blur(2px); }
}
@keyframes lmVTIn {
  from { opacity: 0; filter: blur(2px); }
  to { opacity: 1; filter: blur(0); }
}

/* ═══════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  #learn-mode-container { scroll-behavior: auto; }
  .learn-mode-scroll .sentence-hidden,
  .learn-mode-scroll .sentence-hidden .sentence-romaji,
  .learn-mode-scroll .sentence-hidden .sentence-en,
  .learn-mode-scroll .related-expand { transition: none; }
  .learn-mode-scroll .q-dot.complete { animation: none; }
  /* Section reveals: show immediately */
  .learn-mode-scroll .section,
  .learn-mode-scroll .marking {
    opacity: 1;
    transform: none;
    animation: none !important;
  }
  .learn-mode-scroll .section .story-card,
  .learn-mode-scroll .section .sentence-card,
  .learn-mode-scroll .section .related-group {
    opacity: 1;
    animation: none !important;
  }
  /* Shimmer: static background, no animation */
  .learn-mode-scroll .hero-image::before { animation: none; }
  /* Parallax: disable */
  .learn-mode-scroll .hero-image img { transform: none !important; }
  /* Crossfade & deck exit: no blur/transform */
  #learn-mode-container.lm-crossfade-out,
  #learn-mode-container.lm-crossfade-in,
  #learn-mode-container.lm-crossfade-settle,
  #learn-mode-container.lm-deck-exit-out,
  #learn-mode-container.lm-deck-exit-settle {
    filter: none !important;
    transform: none !important;
  }
  /* Landing entrance: no stagger */
  #learn-mode-container.lm-from-landing .learn-mode-nav,
  #learn-mode-container.lm-from-landing .hero-word > * {
    animation: none !important;
    opacity: 1 !important;
  }
  /* Review mode: no transitions */
  .lm-review .hero-kanji,
  .lm-review .hero-kana,
  .lm-review .hero-english {
    transition: none !important;
  }
}

/* ═══════════════════════════════════════════════
   REVIEW MODE — Flippable hero, recall-test UX
   English-first, tap to reveal Japanese.
   Scoped under .lm-review on #learn-mode-container.
   ═══════════════════════════════════════════════ */

/* ── Default state: English visible, Japanese hidden ── */
.lm-review .hero-kanji {
  opacity: 0;
  height: 0;
  overflow: hidden;
  transition: opacity 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  pointer-events: none;
}
.lm-review .hero-kana {
  opacity: 0 !important;
  height: 0;
  overflow: hidden;
  transition: opacity 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  pointer-events: none;
}
.lm-review .hero-english {
  font-size: clamp(1.6rem, 5vw + 0.5rem, 2.2rem);
  font-weight: 600;
  color: var(--ink);
  order: -1;
  margin-top: 0;
  transition: opacity 0.35s cubic-bezier(0.32, 0.72, 0, 1),
              font-size 0.35s ease;
}

/* Hide audio on English face — no pronunciation hint before recall */
.lm-review .hero-audio-row {
  flex: 0 0 auto;
  min-height: 0;
  height: 0;
  overflow: hidden;
}
.lm-review.lm-flipped .hero-audio-row {
  flex: 1 1 auto;
  min-height: 80px;
  height: auto;
  overflow: visible;
}
.lm-review .hero-audio {
  opacity: 0;
  height: 0;
  padding: 0;
  margin-top: 0;
  overflow: hidden;
  pointer-events: none;
  transition: none;
}
.lm-review.lm-flipped .hero-audio {
  opacity: 1;
  height: 48px;
  margin-top: 1rem;
  overflow: visible;
  pointer-events: auto;
  transition: opacity 0.35s cubic-bezier(0.32, 0.72, 0, 1);
}

/* Tap hint */
.lm-review .hero-word,
.lm-review .hero-image {
  cursor: pointer;
}

/* Both faces: overlap image + vertically center text between image and buttons */
.lm-review .hero-word {
  flex: 1;
  justify-content: center;
  margin-top: -6vh;
}

/* ── Flipped state: Japanese revealed, English dimmed ── */
.lm-review.lm-flipped .hero-kanji {
  opacity: 1;
  height: auto;
  overflow: visible;
  pointer-events: auto;
}
.lm-review.lm-flipped .hero-kana {
  height: auto;
  overflow: visible;
}
.lm-review.lm-flipped .hero-english {
  opacity: 0.35;
  font-size: 1.15rem;
  font-weight: 500;
  order: 0;
}

/* ── Romaji: hidden until audio play, and only on Japanese face ── */
.lm-review .hero-kana.lm-romaji-revealed {
  opacity: 0 !important;
}
.lm-review.lm-flipped .hero-kana.lm-romaji-revealed {
  opacity: 1 !important;
  pointer-events: auto;
}

/* ── Review fork buttons ── */
.lm-review .hero-review-btn {
  flex: 1;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 16px;
  min-height: 44px;
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  border-radius: 8px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.lm-review .hero-review-text {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

/* "Keep in Review" — warm amber tint (新) */
.lm-review .hero-review-keep {
  background: rgba(160, 120, 80, 0.08);
  border: 1px solid rgba(160, 120, 80, 0.3);
}
.lm-review .hero-review-keep .hero-review-text {
  color: var(--color-amber);
}
.lm-review .hero-review-keep:active {
  background: rgba(160, 120, 80, 0.16);
  border-color: rgba(160, 120, 80, 0.5);
}

/* "I Know It" — moss green tint (済) */
.lm-review .hero-review-know {
  background: rgba(107, 127, 92, 0.06);
  border: 1px solid rgba(107, 127, 92, 0.25);
}
.lm-review .hero-review-know .hero-review-text {
  color: rgba(107, 127, 92, 0.7);
}
.lm-review .hero-review-know:active {
  background: rgba(107, 127, 92, 0.12);
  border-color: rgba(107, 127, 92, 0.45);
}

/* Stamp animation (reuse from marking) */
.lm-review .hero-review-btn.animating {
  animation: lmStampPress 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.lm-review .hero-review-btn.stamped {
  opacity: 0.5;
  pointer-events: none;
}
.lm-review .hero-review-btn.dimmed {
  opacity: 0.3;
  pointer-events: none;
}

/* ── Entrance animation override for review mode ── */
#learn-mode-container.lm-review.lm-from-landing .hero-kanji {
  animation: none;
  opacity: 0;
}
#learn-mode-container.lm-review.lm-from-landing .hero-kana {
  animation: none;
  opacity: 0;
}
#learn-mode-container.lm-review.lm-from-landing .hero-english {
  animation: lmThresholdIn 220ms ease-out both;
  animation-delay: 50ms;
}
#learn-mode-container.lm-review.lm-from-landing .hero-audio {
  animation: none;
  opacity: 0;
}

/* ═════════════════════════════════════════════════════════════════════
   LEARN MODE END — Session-complete overlay
   Visual language mirrors mobile landing (mh-*): warm paper ground,
   typographic greeting triplet, action cards with accent left borders.
   ═════════════════════════════════════════════════════════════════════ */

.lme-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background:
    radial-gradient(ellipse 90% 70% at 50% 40%, var(--seasonal-tint, rgba(201,169,110,0.04)) 0%, transparent 70%),
    var(--color-paper);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(14px + var(--safe-top, 0px)) 20px env(safe-area-inset-bottom, 24px);
  animation: lmeOverlayIn 320ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes lmeOverlayIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.lme-overlay.lme-exiting {
  animation: lmeOverlayOut 240ms ease-out both;
  pointer-events: none;
}

@keyframes lmeOverlayOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(4px); }
}

/* Washi texture — subtle, matches mobile-landing */
.lme-overlay::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.03;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-size: 300px 300px;
}


/* Home chip — top-left, mirrors lm-exit-btn placement */
.lme-overlay .lme-home {
  position: absolute;
  left: 14px;
  top: calc(14px + var(--safe-top, 0px));
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(168, 162, 158, 0.18);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--color-stone, #57534e);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.15s ease;
}
.lme-overlay .lme-home:active {
  background: rgba(168, 162, 158, 0.3);
}
.lme-overlay .lme-home:focus-visible {
  outline: 2px solid rgba(61, 90, 128, 0.45);
  outline-offset: 2px;
}

.lme-container {
  position: relative;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 28px);
  min-height: calc(100dvh - 28px);
}

/* Greeting — echoes mh-greeting spacing and hierarchy */
.lme-greeting {
  padding: 64px 0 20px;
}

.lme-greeting-en {
  font-family: var(--font-ui);
  font-size: 26px;
  font-weight: 500;
  color: var(--color-ink);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.lme-greeting-jp-line {
  margin-top: 8px;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.lme-greeting-jp {
  font-family: var(--font-jp);
  font-size: 16px;
  color: var(--color-faint);
  letter-spacing: 0.03em;
}

.lme-greeting-romaji {
  font-family: var(--font-ui);
  font-size: 13px;
  color: #948E85;
  letter-spacing: 0.04em;
}

/* Stats — quiet inline row above action cards */
.lme-stats {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 0 28px;
  flex-wrap: wrap;
}

.lme-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-ui);
}

.lme-stat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: translateY(-1px);
  flex-shrink: 0;
}

.lme-dot-known { background: var(--color-moss, #6B7F5C); }
.lme-dot-learning { background: var(--color-gold, #C9A96E); }
.lme-dot-unmarked { background: #D4CFC8; }

.lme-stat-num {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-ink);
  font-variant-numeric: tabular-nums;
}
.lme-stat-num.lme-stat-zero {
  color: #BDB6AB;
  font-weight: 500;
}

.lme-stat-label {
  font-size: 12px;
  color: var(--color-faint);
  letter-spacing: 0.01em;
}

/* Action cards — mirror mh-action-card pattern */
.lme-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lme-action-card {
  display: block;
  text-align: left;
  width: 100%;
  background: var(--color-card);
  border: none;
  border-left: 2px solid transparent;
  border-radius: var(--radius, 8px);
  padding: 18px 20px;
  box-shadow: var(--shadow-subtle, 0 1px 2px rgba(44, 44, 44, 0.03));
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, transform 0.15s ease;
  font-family: inherit;
}

.lme-action-card:active {
  background: #F5F2ED;
  transform: translateY(0);
}

.lme-action-card:focus-visible {
  outline: 2px solid rgba(61, 90, 128, 0.45);
  outline-offset: 2px;
}

/* Accent left borders — progression of emphasis */
.lme-card-continue { border-left-color: var(--color-accent, #3D5A80); }
.lme-card-review   { border-left-color: var(--color-gold, #C9A96E); }
.lme-card-quiz     { border-left-color: var(--color-moss, #6B7F5C); }

.lme-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.lme-card-title {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
  color: var(--color-ink);
  letter-spacing: -0.005em;
}

.lme-card-badge {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius, 8px);
  line-height: 1.4;
  white-space: nowrap;
}

.lme-card-continue .lme-card-badge {
  background: rgba(61, 90, 128, 0.10);
  color: var(--color-accent, #3D5A80);
}

.lme-card-review .lme-card-badge {
  background: rgba(201, 169, 110, 0.12);
  color: #7A6530;
}

.lme-card-quiz .lme-card-badge {
  background: rgba(107, 127, 92, 0.12);
  color: #4F6144;
}

.lme-card-jp {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.lme-card-jp-kana {
  font-family: var(--font-jp);
  font-size: 14px;
  color: var(--color-stone, #57534e);
  letter-spacing: 0.02em;
}

.lme-card-jp-roma {
  font-family: var(--font-ui);
  font-size: 11px;
  color: #948E85;
  letter-spacing: 0.04em;
}

.lme-card-guide {
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.55;
  color: var(--color-faint);
}

/* Finish — quiet ghost link, lives below the cards */
.lme-finish {
  align-self: center;
  margin: 32px auto 16px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  color: var(--color-faint);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease;
}

.lme-finish:active { color: var(--color-stone, #57534e); }
.lme-finish:focus-visible {
  outline: 2px solid rgba(61, 90, 128, 0.45);
  outline-offset: 2px;
  border-radius: var(--radius-full, 999px);
}

.lme-finish-label {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.lme-finish-jp {
  font-family: var(--font-jp);
  font-size: 12px;
  color: #A59E93;
  letter-spacing: 0.04em;
}

/* ═══════════════════════════════════════════════
   SESSION-END — summary list + gesture hint + action dock
   (extends the overlay declared above)
   ═══════════════════════════════════════════════ */

/* Compact greeting when list is below */
.lme-container > .lme-greeting {
  padding-top: 56px;
  padding-bottom: 14px;
}

/* Inline stats row — adds total on the right */
.lme-stats {
  padding-bottom: 18px;
  position: relative;
}
.lme-stat-total {
  margin-left: auto;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--color-faint);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

/* Gesture hint — quiet, fades after HINT_MAX_VIEWS */
.lme-hint {
  position: relative;
  margin: 0 -4px 18px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(247, 244, 238, 0.6);
  border: 1px solid rgba(168, 162, 158, 0.14);
  animation: lmeHintFadeIn 420ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 120ms;
}
@keyframes lmeHintFadeIn {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}
.lme-hint-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  text-align: center;
}
.lme-hint-line {
  font-family: var(--font-ui);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--color-stone, #57534e);
  letter-spacing: 0.01em;
}
.lme-hint-line--faint {
  font-size: 11.5px;
  color: var(--color-faint, #8b857a);
}
.lme-hint-arrow {
  font-family: var(--font-ui);
  color: var(--color-gold, #C9A96E);
  font-weight: 600;
  padding: 0 2px;
  letter-spacing: 0;
}
.lme-hint-sep {
  display: inline-block;
  padding: 0 7px;
  color: rgba(168, 162, 158, 0.55);
}
.lme-hint-dim { color: rgba(168, 162, 158, 0.7); }

/* Minimized state: show only the ? badge, hide body */
.lme-hint-badge {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid rgba(168, 162, 158, 0.3);
  border-radius: 50%;
  background: rgba(250, 250, 247, 0.7);
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 1;
  color: var(--color-faint);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, background 0.15s ease;
}
.lme-hint--minimized {
  padding: 0;
  background: transparent;
  border: none;
  min-height: 0;
  margin-bottom: 8px;
}
.lme-hint--minimized .lme-hint-body { display: none; }
.lme-hint--minimized .lme-hint-badge {
  position: static;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  margin-right: 2px;
  opacity: 1;
  pointer-events: auto;
}
.lme-hint--minimized.lme-hint--expanded {
  padding: 10px 14px;
  background: rgba(247, 244, 238, 0.6);
  border: 1px solid rgba(168, 162, 158, 0.14);
  border-radius: 10px;
  margin-bottom: 18px;
}
.lme-hint--minimized.lme-hint--expanded .lme-hint-body { display: flex; }
.lme-hint--minimized.lme-hint--expanded .lme-hint-badge {
  position: absolute;
  top: 8px;
  right: 10px;
}

/* ── Word list ──────────────────────────────────── */
.lme-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 -4px 12px;
}

.lme-row {
  position: relative;
  overflow: hidden;
  background: var(--color-card, #FAFAF7);
  border-radius: var(--radius, 8px);
  box-shadow: 0 1px 2px rgba(44, 44, 44, 0.03);
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
  animation: lmeRowIn 320ms cubic-bezier(0.16, 1, 0.3, 1) both;
  cursor: pointer;
}
@keyframes lmeRowIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Staggered entrance for the first ~12 rows */
.lme-list .lme-row:nth-child(1) { animation-delay: 0ms; }
.lme-list .lme-row:nth-child(2) { animation-delay: 24ms; }
.lme-list .lme-row:nth-child(3) { animation-delay: 48ms; }
.lme-list .lme-row:nth-child(4) { animation-delay: 72ms; }
.lme-list .lme-row:nth-child(5) { animation-delay: 96ms; }
.lme-list .lme-row:nth-child(6) { animation-delay: 120ms; }
.lme-list .lme-row:nth-child(7) { animation-delay: 140ms; }
.lme-list .lme-row:nth-child(8) { animation-delay: 160ms; }
.lme-list .lme-row:nth-child(9) { animation-delay: 180ms; }
.lme-list .lme-row:nth-child(10) { animation-delay: 200ms; }
.lme-list .lme-row:nth-child(n+11) { animation-delay: 220ms; }

.lme-row-accent {
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  transition: background 0.25s ease;
  pointer-events: none;
  z-index: 2;
}
.lme-row-accent--learning { background: var(--color-gold, #C9A96E); }
.lme-row-accent--known    { background: var(--color-moss, #6B7F5C); }
.lme-row-accent--new,
.lme-row-accent--unmarked { background: transparent; }

/* Swipe backgrounds */
.lme-row-bg {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  display: flex;
  align-items: center;
  padding: 0 20px;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 1;
}
.lme-row-bg--right {
  right: 0;
  justify-content: flex-end;
  background: linear-gradient(to left, rgba(107, 127, 92, 0.18), rgba(107, 127, 92, 0.04));
  color: #4F6144;
}
.lme-row-bg--left {
  left: 0;
  justify-content: flex-start;
  background: linear-gradient(to right, rgba(201, 169, 110, 0.2), rgba(201, 169, 110, 0.04));
  color: #7A6530;
}
.lme-row-bg--visible { opacity: 1; }
.lme-row-bg-icon {
  font-family: var(--font-jp);
  font-size: 22px;
  letter-spacing: 0.04em;
  font-weight: 500;
}

/* Inner content */
.lme-row-inner {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: var(--color-card, #FAFAF7);
  will-change: transform;
  transition: transform 0s;
}
.lme-snap-back { transition: transform 0.22s cubic-bezier(0.33, 1, 0.68, 1); }
.lme-swiping { /* no-op, reserved for future styling */ }

.lme-row-thumb {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #EAE6DF;
  position: relative;
}
.lme-row-thumb.no-image {
  background: linear-gradient(135deg, #EAE6DF 0%, #E0DACF 100%);
}
.lme-row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.lme-row-thumb img.loaded { opacity: 1; }

.lme-row-text {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.lme-row-jp {
  font-family: var(--font-jp);
  font-size: 17px;
  color: var(--color-ink);
  letter-spacing: 0.01em;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lme-row-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-ui);
  font-size: 12.5px;
  color: var(--color-faint);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.lme-row-roma {
  font-style: italic;
  color: var(--color-stone, #57534e);
  letter-spacing: 0.02em;
  font-size: 12px;
}
.lme-row-sep {
  color: rgba(168, 162, 158, 0.55);
}
.lme-row-en {
  color: var(--color-stone, #57534e);
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}

/* Kintsugi sweep on grade */
.lme-row-sweep::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  background: linear-gradient(100deg, transparent 30%, rgba(201, 169, 110, 0.22) 50%, transparent 70%);
  animation: lmeSweep 820ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.lme-row-sweep--known::after {
  background: linear-gradient(100deg, transparent 30%, rgba(107, 127, 92, 0.22) 50%, transparent 70%);
}
@keyframes lmeSweep {
  from { transform: translateX(-120%); }
  to   { transform: translateX(120%); }
}

.lme-row-audio .lme-row-thumb {
  box-shadow: 0 0 0 2px rgba(201, 169, 110, 0.55);
  transition: box-shadow 0.2s ease;
}

/* ── Action dock ─────────────────────────────────── */
.lme-dock {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.lme-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 16px 20px;
  border: none;
  border-radius: 14px;
  background: var(--color-card, #FAFAF7);
  box-shadow: 0 1px 2px rgba(44, 44, 44, 0.04);
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  text-align: left;
}
.lme-pill:active {
  transform: translateY(1px);
  box-shadow: 0 0 0 transparent;
}
.lme-pill:focus-visible {
  outline: 2px solid rgba(61, 90, 128, 0.45);
  outline-offset: 2px;
}
.lme-pill[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

.lme-pill--primary {
  background: var(--color-accent, #3D5A80);
  color: #FAFAF7;
  box-shadow: 0 2px 6px rgba(61, 90, 128, 0.18);
}
.lme-pill--primary .lme-pill-jp { color: rgba(250, 250, 247, 0.72); }
.lme-pill--primary .lme-pill-badge {
  background: rgba(250, 250, 247, 0.18);
  color: #FAFAF7;
}

.lme-pill--secondary {
  background: var(--color-card, #FAFAF7);
  color: var(--color-ink);
  border: 1px solid rgba(61, 90, 128, 0.18);
}
.lme-pill--secondary .lme-pill-badge {
  background: rgba(61, 90, 128, 0.10);
  color: var(--color-accent, #3D5A80);
}

.lme-pill--ghost {
  background: transparent;
  color: var(--color-ink);
  box-shadow: none;
  border: 1px solid rgba(168, 162, 158, 0.18);
}
.lme-pill--ghost:active { background: rgba(168, 162, 158, 0.08); }
.lme-pill--ghost .lme-pill-badge {
  background: rgba(168, 162, 158, 0.12);
  color: var(--color-stone, #57534e);
}

.lme-pill-body {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.lme-pill-title {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.lme-pill-jp {
  font-family: var(--font-jp);
  font-size: 12.5px;
  color: var(--color-faint);
  letter-spacing: 0.03em;
}
.lme-pill-badge {
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  line-height: 1.4;
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* Reduce-motion: drop animations and transitions */
@media (prefers-reduced-motion: reduce) {
  .lme-overlay,
  .lme-overlay.lme-exiting {
    animation: none;
  }
  .lme-action-card,
  .lme-pill { transition: none; }
  .lme-row,
  .lme-hint { animation: none; }
  .lme-row-sweep::after { animation: none; display: none; }
}

/* Small screens — tighten greeting padding */
@media (max-height: 640px) {
  .lme-greeting { padding: 44px 0 16px; }
  .lme-container > .lme-greeting { padding: 44px 0 10px; }
  .lme-stats { padding-bottom: 14px; }
  .lme-hint { margin-bottom: 12px; }
}

/* ── 奥付 Colophon — quiet provenance footer at the end of a Learn card ──
   Textbook source · semantic category · spoken-frequency rank. Deliberately
   understated (no card surface, no shadow): it reads like the printer's mark
   at the back of a book, not another content section. */
.learn-mode-scroll .lm-colophon {
  margin: 0 var(--side, 24px) calc(36px + var(--safe-bottom, 0px));
}

/* Reference label — left-justified and styled like the other section headers
   (QUICK TIP / EXAMPLES …) instead of a centred dotted rule, so it reads as part
   of the card rather than a bolted-on footer. */
.lm-colophon-rule {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 14px;
}
.lm-colophon-mark {
  font-family: var(--kanji-family);
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 0.04em;
}
.lm-colophon-mark > span {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
  margin-left: 3px;
}

/* Label / value rows */
.lm-colophon-rows { margin: 0; }
.lm-colophon-row {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 14px;
  padding: 9px 2px;
  align-items: baseline;
}
.lm-colophon-row + .lm-colophon-row {
  border-top: 1px solid rgba(87, 83, 78, 0.08);
}
.lm-colophon-label {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
}
.lm-colophon-val {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
}

/* Category: tier1 broad bucket (muted) above tier2 leaf (emphasized) */
.lm-colophon-cat-t1 {
  display: block;
  font-size: 11px;
  color: var(--faint);
  letter-spacing: 0.02em;
}
.lm-colophon-cat-t2 {
  display: block;
  color: var(--ink);
  font-weight: 500;
}

/* Frequency: band · precise rank · honest source note */
.lm-colophon-freq-band { color: var(--ink); font-weight: 500; }
.lm-colophon-freq-rank {
  margin-left: 8px;
  color: var(--stone);
  font-variant-numeric: tabular-nums;
}
.lm-colophon-freq-note {
  margin-left: 8px;
  font-size: 11px;
  color: var(--faint);
}
.lm-colophon-extra {
  margin-left: 5px;
  font-size: 11px;
  color: var(--faint);
}
/* One textbook source per line (a word can appear in several lessons) */
.lm-colophon-src-line { display: block; }
.lm-colophon-src-line + .lm-colophon-src-line { margin-top: 3px; }

/* ── Meaningful-hue layer: colour encodes textbook / category / frequency tier.
   Sits after the base rules above and intentionally overrides their grays. The
   gray base remains the fallback when a hook (data-tb / data-tier) is absent. */
/* Header stays gray (matches the section labels); only the data rows get hue. */
.lm-colophon-src-line[data-tb="genki1"] { color: var(--accent, #3D5A80); }      /* Genki 1 — indigo */
.lm-colophon-src-line[data-tb="genki2"] { color: var(--color-pill-genki2, #4A6B48); } /* Genki 2 — green */
.lm-colophon-src-line[data-tb="ippo"]   { color: var(--color-pill-ippo, #7A5030); }   /* Ippo — brown */
.lm-colophon-cat-t2 { color: #B0892E; } /* category — clear gold, kept distinct from Ippo's brown */
.lm-colophon-freq-band[data-tier="1"] { color: #3a6438; } /* Core — evergreen */
.lm-colophon-freq-band[data-tier="2"] { color: #5A7494; } /* Everyday — indigo */
.lm-colophon-freq-band[data-tier="3"] { color: #A88542; } /* Occasional — gold */
.lm-colophon-freq-band[data-tier="4"] { color: var(--faint, #8C8578); } /* Rare — faded */

/* ── Desktop story panels (Grid card-back / Focus+standard sidebar / Video overlay):
   the colophon fills the card's content width and left-aligns with the examples,
   separated from the content above by a hairline + padding — exactly like the
   divider between the other sections. Mobile keeps its var(--side) side margins
   (its own rule above) and inherits this top separator. ── */
.lm-colophon {
  margin: 0 0 6px;
  padding-top: 20px;
  border-top: 1px solid rgba(87, 83, 78, 0.10);
}

/* Video story overlay is a dark glass panel (rgba(15,15,20,.85)) — lighten the
   colophon ink + the section-divider hairline, brighten the hue accents. */
.video-story-panel .lm-colophon { border-top-color: rgba(255, 255, 255, 0.14); }
.video-story-panel .lm-colophon-mark { color: rgba(245, 240, 235, 0.5); }
.video-story-panel .lm-colophon-mark > span { color: rgba(245, 240, 235, 0.5); }
.video-story-panel .lm-colophon-label { color: rgba(245, 240, 235, 0.45); }
.video-story-panel .lm-colophon-val { color: rgba(245, 240, 235, 0.92); }
.video-story-panel .lm-colophon-row + .lm-colophon-row { border-top-color: rgba(255, 255, 255, 0.10); }
.video-story-panel .lm-colophon-cat-t1 { color: rgba(245, 240, 235, 0.45); }
.video-story-panel .lm-colophon-cat-t2 { color: #D4B87C; }
.video-story-panel .lm-colophon-src-line[data-tb="genki1"] { color: #9DB4D4; }
.video-story-panel .lm-colophon-src-line[data-tb="genki2"] { color: #8FB58C; }
.video-story-panel .lm-colophon-src-line[data-tb="ippo"]   { color: #CBA98A; }
.video-story-panel .lm-colophon-freq-band[data-tier="1"] { color: #7FB07C; }
.video-story-panel .lm-colophon-freq-band[data-tier="2"] { color: #9DB4D4; }
.video-story-panel .lm-colophon-freq-band[data-tier="3"] { color: #D4B87C; }
.video-story-panel .lm-colophon-freq-band[data-tier="4"] { color: rgba(245, 240, 235, 0.4); }
.video-story-panel .lm-colophon-freq-rank { color: rgba(245, 240, 235, 0.6); }
.video-story-panel .lm-colophon-freq-note { color: rgba(245, 240, 235, 0.4); }
